diff --git a/css/backoffice/base/_base.scss b/css/backoffice/base/_base.scss index 0e64928b6..c142e6b06 100644 --- a/css/backoffice/base/_base.scss +++ b/css/backoffice/base/_base.scss @@ -3,18 +3,18 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-scrollbar--scrollbar-width: 8px !default; +$ibo-scrollbar--scrollbar-width: $common-scrollbar--scrollbar-width !default; $ibo-scrollbar--scrollbar-height: $ibo-scrollbar--scrollbar-width !default; /* For horizontal scrollbars */ -$ibo-scrollbar--scrollbar-track-background-color: $ibo-color-transparent !default; -$ibo-scrollbar--scrollbar-track-border-radius: $ibo-border-radius-500 !default; -$ibo-scrollbar--scrollbar-thumb-background-color: $ibo-color-grey-300 !default; +$ibo-scrollbar--scrollbar-track-background-color: $common-scrollbar--scrollbar-track-background-color !default; +$ibo-scrollbar--scrollbar-track-border-radius: $common-scrollbar--scrollbar-track-border-radius !default; +$ibo-scrollbar--scrollbar-thumb-background-color: $common-scrollbar--scrollbar-thumb-background-color !default; $ibo-scrollbar--scrollbar-thumb-border: none !default; -$ibo-scrollbar--scrollbar-thumb-border-radius: $ibo-border-radius-500 !default; +$ibo-scrollbar--scrollbar-thumb-border-radius: $common-scrollbar--scrollbar-thumb-border-radius !default; -$ibo-svg-illustration--fill: $ibo-color-primary-500 !default; +$ibo-svg-illustration--fill: $common-svg-illustration--fill !default; -$ibo-content-block--background-color: $ibo-color-white-100 !default; -$ibo-content-block--border: 1px solid $ibo-color-grey-400 !default; +$ibo-content-block--background-color: $common-content-block--background-color !default; +$ibo-content-block--border: $common-content-block--border !default; /* CSS variables */ :root{ diff --git a/css/backoffice/base/_typography.scss b/css/backoffice/base/_typography.scss index c5d5159ed..3d23d535c 100644 --- a/css/backoffice/base/_typography.scss +++ b/css/backoffice/base/_typography.scss @@ -4,147 +4,3 @@ */ /* This is an overload of the default lib. stylesheet to use local fonts instead of the CDN */ -@font-face { - font-family: Raleway; - font-weight: 100; - font-style: normal; - font-display: swap; - src: local('Raleway Thin'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-100-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 100; - font-style: italic; - font-display: swap; - src: local('Raleway Thin'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-100-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 200; - font-style: normal; - font-display: swap; - src: local('Raleway ExtraLight'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-200-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 200; - font-style: italic; - font-display: swap; - src: local('Raleway ExtraLight'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-200-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 300; - font-style: normal; - font-display: swap; - src: local('Raleway Light'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-300-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 300; - font-style: italic; - font-display: swap; - src: local('Raleway Light'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-300-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 400; - font-style: normal; - font-display: swap; - src: local('Raleway'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-400-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 400; - font-style: italic; - font-display: swap; - src: local('Raleway'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-400-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 500; - font-style: normal; - font-display: swap; - src: local('Raleway Medium'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-500-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 500; - font-style: italic; - font-display: swap; - src: local('Raleway Medium'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-500-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 600; - font-style: normal; - font-display: swap; - src: local('Raleway SemiBold'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-600-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 600; - font-style: italic; - font-display: swap; - src: local('Raleway SemiBold'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-600-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 700; - font-style: normal; - font-display: swap; - src: local('Raleway'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-700-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 700; - font-style: italic; - font-display: swap; - src: local('Raleway'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-700-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 800; - font-style: normal; - font-display: swap; - src: local('Raleway ExtraBold'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-800-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 800; - font-style: italic; - font-display: swap; - src: local('Raleway ExtraBold'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-800-italic.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 900; - font-style: normal; - font-display: swap; - src: local('Raleway Black'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-900-normal.woff') format('woff'), -} -@font-face { - font-family: Raleway; - font-weight: 900; - font-style: italic; - font-display: swap; - src: local('Raleway Black'), - url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-900-italic.woff') format('woff'), -} diff --git a/css/backoffice/datamodel/_action.scss b/css/backoffice/datamodel/_action.scss index 0259dd4f1..a11b1df0e 100644 --- a/css/backoffice/datamodel/_action.scss +++ b/css/backoffice/datamodel/_action.scss @@ -14,8 +14,8 @@ $ibo-dm-class--Action--complementary-color: $ibo-color-white-100 !default; .ibo-dm-class--Action { --ibo-main-color: #{$ibo-dm-class--Action--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-class--Action--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-class--Action--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-class--Action--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-class--Action--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-class--Action--complementary-color}; } @@ -35,8 +35,8 @@ $ibo-dm-enum--Action-status-enabled--complementary-color: $ibo-lifecycle-active- .ibo-dm-enum--Action-status-enabled { --ibo-main-color: #{$ibo-dm-enum--Action-status-enabled--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--Action-status-enabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--Action-status-enabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--Action-status-enabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--Action-status-enabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-enum--Action-status-enabled--complementary-color}; } @@ -56,8 +56,8 @@ $ibo-dm-enum--Action-status-disabled--complementary-color: $ibo-lifecycle-frozen .ibo-dm-enum--Action-status-disabled { --ibo-main-color: #{$ibo-dm-enum--Action-status-disabled--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--Action-status-disabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--Action-status-disabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--Action-status-disabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--Action-status-disabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-enum--Action-status-disabled--complementary-color}; } @@ -78,8 +78,8 @@ $ibo-dm-enum--Action-status-test--complementary-color: $ibo-lifecycle-inactive-s .ibo-dm-enum--Action-status-test { --ibo-main-color: #{$ibo-dm-enum--Action-status-test--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--Action-status-test--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--Action-status-test--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--Action-status-test--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--Action-status-test--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-enum--Action-status-test--complementary-color}; } diff --git a/css/backoffice/datamodel/_user.scss b/css/backoffice/datamodel/_user.scss index ed17bbb3d..7bdad16ea 100644 --- a/css/backoffice/datamodel/_user.scss +++ b/css/backoffice/datamodel/_user.scss @@ -14,8 +14,8 @@ $ibo-dm-class--User--complementary-color: $ibo-color-white-100 !default; .ibo-dm-class--User { --ibo-main-color: #{$ibo-dm-class--User--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-class--User--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-class--User--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-class--User--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-class--User--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-class--User--complementary-color}; } .ibo-dm-class-alt--User { @@ -34,8 +34,8 @@ $ibo-dm-enum--User-status-enabled--complementary-color: $ibo-lifecycle-active-st .ibo-dm-enum--User-status-enabled { --ibo-main-color: #{$ibo-dm-enum--User-status-enabled--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-enabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-enabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--User-status-enabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--User-status-enabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-enum--User-status-enabled--complementary-color}; } .ibo-dm-enum-alt--User-status-enabled { @@ -54,8 +54,8 @@ $ibo-dm-enum--User-status-disabled--complementary-color: $ibo-lifecycle-inactive .ibo-dm-enum--User-status-disabled { --ibo-main-color: #{$ibo-dm-enum--User-status-disabled--main-color}; - --ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-disabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; - --ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-disabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; + --ibo-main-color--100: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--User-status-disabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)}; + --ibo-main-color--900: #{common-adjust-alpha(common-adjust-lightness($ibo-dm-enum--User-status-disabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)}; --ibo-complementary-color: #{$ibo-dm-enum--User-status-disabled--complementary-color}; } .ibo-dm-enum-alt--User-status-disabled { diff --git a/css/backoffice/main.scss b/css/backoffice/main.scss index 05819bfa8..35efcf72a 100644 --- a/css/backoffice/main.scss +++ b/css/backoffice/main.scss @@ -2,7 +2,7 @@ * @copyright Copyright (C) 2010-2024 Combodo SAS * @license http://opensource.org/licenses/AGPL-3.0 */ - +@import "../common/main"; @import "utils/all"; @import "vendors/all"; @import "base/all"; diff --git a/css/backoffice/utils/functions/_color.scss b/css/backoffice/utils/functions/_color.scss index 720900bb6..e71286841 100644 --- a/css/backoffice/utils/functions/_color.scss +++ b/css/backoffice/utils/functions/_color.scss @@ -7,28 +7,20 @@ * Adjust the lightness of $sColor to the absolute $fTargetLightness value. * It is different than lighten() / darken() that shift the current lightness by X% * + * @deprecated Use common-adjust-lightness() instead * @return Modified color value in HSLA format */ @function ibo-adjust-lightness($sColor, $fTargetLightness) { - $iHue: hue($sColor); - $fSaturation: saturation($sColor); - $fLightness: lightness($sColor); - $fAlpha: alpha($sColor); - - @return hsla($iHue, $fSaturation, $fTargetLightness, $fAlpha); + @return common-adjust-lightness($sColor, $fTargetLightness); } /** * Adjust the alpha chanel (opacity) of $sColor to the absolute $fTargetAlpha value. * It is different than opacify() / transparentize() that shift the current alpha value by X% * + * @deprecated Use common-adjust-alpha() instead * @return Modified color value in HSLA format */ @function ibo-adjust-alpha($sColor, $fTargetAlpha) { - $iHue: hue($sColor); - $fSaturation: saturation($sColor); - $fLightness: lightness($sColor); - $fAlpha: alpha($sColor); - - @return hsla($iHue, $fSaturation, $fLightness, $fTargetAlpha); + @return common-adjust-alpha($sColor, $fTargetAlpha); } \ No newline at end of file diff --git a/css/backoffice/utils/helpers/_class-icon.scss b/css/backoffice/utils/helpers/_class-icon.scss index 20d31b503..f572988bd 100644 --- a/css/backoffice/utils/helpers/_class-icon.scss +++ b/css/backoffice/utils/helpers/_class-icon.scss @@ -3,9 +3,9 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-class-icon--small--size: 32px !default; -$ibo-class-icon--medium--size: 48px !default; -$ibo-class-icon--large--size: 64px !default; +$ibo-class-icon--small--size: $common-class-icon--small--size !default; +$ibo-class-icon--medium--size: $common-class-icon--medium--size !default; +$ibo-class-icon--large--size: $common-class-icon--large--size !default; .ibo-class-icon{ &.ibo-is-small{ diff --git a/css/backoffice/utils/helpers/_color.scss b/css/backoffice/utils/helpers/_color.scss index 53a21723a..82e71ce52 100644 --- a/css/backoffice/utils/helpers/_color.scss +++ b/css/backoffice/utils/helpers/_color.scss @@ -3,24 +3,7 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-text-colors: ( - 'primary': $ibo-color-primary-800, - 'secondary': $ibo-color-secondary-800, - 'neutral': $ibo-color-secondary-800, - 'information': $ibo-color-information-800, - 'success': $ibo-color-success-800, - 'failure': $ibo-color-danger-800, - 'warning': $ibo-color-warning-800, - 'danger': $ibo-color-danger-800, - 'grey' : $ibo-color-grey-800, - 'blue-grey': $ibo-color-blue-grey-800, - 'blue': $ibo-color-blue-800, - 'cyan': $ibo-color-cyan-800, - 'green': $ibo-color-green-800, - 'orange': $ibo-color-orange-800, - 'red': $ibo-color-red-800, - 'pink': $ibo-color-pink-800, -) !default; +$ibo-text-colors: $common-text-colors !default; @each $sColor, $sColorValue in $ibo-text-colors { .ibo-text.ibo-is-#{$sColor} { diff --git a/css/backoffice/utils/helpers/_font-icon.scss b/css/backoffice/utils/helpers/_font-icon.scss index 3e90d2c75..a01274e51 100644 --- a/css/backoffice/utils/helpers/_font-icon.scss +++ b/css/backoffice/utils/helpers/_font-icon.scss @@ -8,36 +8,3 @@ /* To use it, simply "@extend %fa-regular-base" in a rule and put the desired icon "content: '\f054'" */ /******************************************************************************************************************************/ -%fa-regular-base{ - font-family: "Font Awesome 5 Free"; - font-weight: 400; - - -webkit-font-smoothing: antialiased; - display: inline-block; - font-style: normal; - font-variant: normal; - text-rendering: auto; - line-height: 1; -} -%fa-solid-base{ - font-family: "Font Awesome 5 Free"; - font-weight: 900; - - -webkit-font-smoothing: antialiased; - display: inline-block; - font-style: normal; - font-variant: normal; - text-rendering: auto; - line-height: 1; -} -%fc-regular-base{ - display: inline-block; - font-family: CombodoRegular; - font-style: normal; - font-variant: normal; - font-weight: normal; - text-rendering: auto; - line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} \ No newline at end of file diff --git a/css/backoffice/utils/helpers/_sticky-header.scss b/css/backoffice/utils/helpers/_sticky-header.scss index 322bf5a63..eeb57390c 100644 --- a/css/backoffice/utils/helpers/_sticky-header.scss +++ b/css/backoffice/utils/helpers/_sticky-header.scss @@ -10,12 +10,12 @@ /***********************************************************************/ /* SCSS variables */ -$ibo-sticky-sentinel--left: 0 !default; -$ibo-sticky-sentinel--right: 0 !default; -$ibo-sticky-sentinel--height: 0 !default; -$ibo-sticky-sentinel-top--top: 0 !default; +$ibo-sticky-sentinel--left: $common-sticky-sentinel--left !default; +$ibo-sticky-sentinel--right: $common-sticky-sentinel--right !default; +$ibo-sticky-sentinel--height: $common-sticky-sentinel--height !default; +$ibo-sticky-sentinel-top--top: $common-sticky-sentinel-top--top !default; $ibo-sticky-sentinel-top--height: $ibo-sticky-sentinel--height !default; -$ibo-sticky-sentinel-bottom--bottom: 0 !default; +$ibo-sticky-sentinel-bottom--bottom: $common-sticky-sentinel-bottom--bottom !default; $ibo-sticky-sentinel-bottom--height: $ibo-sticky-sentinel--height !default; /* Rules */ diff --git a/css/backoffice/utils/helpers/_text-decoration.scss b/css/backoffice/utils/helpers/_text-decoration.scss index 94312e4b5..c7814a65b 100644 --- a/css/backoffice/utils/helpers/_text-decoration.scss +++ b/css/backoffice/utils/helpers/_text-decoration.scss @@ -4,13 +4,13 @@ */ /* SCSS variables */ -$ibo-has-description--content: "?" !default; -$ibo-has-description--padding-left: $ibo-spacing-200 !default; -$ibo-has-description--color: $ibo-color-grey-600 !default; -$ibo-has-description--font-size: 0.7em !default; /* Font size is em on purpose as we want it to be proportional to its context */ +$ibo-has-description--content: $common-has-description--content !default; +$ibo-has-description--padding-left: $common-has-description--padding-left !default; +$ibo-has-description--color: $common-has-description--color !default; +$ibo-has-description--font-size: $common-has-description--font-size !default; /* Font size is em on purpose as we want it to be proportional to its context */ -$ibo-is-code--background-color: $ibo-color-white-200 !default; -$ibo-is-code--padding: 1.25rem 1.5rem !default; +$ibo-is-code--background-color: $common-is-code--background-color !default; +$ibo-is-code--padding: $common-is-code--padding !default; $ibo-hyperlink-color: $ibo-color-primary-700 !default; $ibo-hyperlink-text-decoration: none !default; @@ -19,8 +19,8 @@ $ibo-hyperlink-text-decoration--on-hover: $ibo-hyperlink-text-decoration !defaul $ibo-hyperlink-color--on-active: $ibo-color-primary-900 !default; $ibo-hyperlink-text-decoration--on-active: $ibo-hyperlink-text-decoration !default; -$ibo-figure--spacing-x: 2em !default; /* Mind that this matches Bulma rule for figure */ -$ibo-figure--spacing-y: 2em !default; +$ibo-figure--spacing-x: $common-figure--spacing-x !default; /* Mind that this matches Bulma rule for figure */ +$ibo-figure--spacing-y: $common-figure--spacing-y !default; /* CSS variables */ :root{ diff --git a/css/backoffice/utils/mixins/_highlight.scss b/css/backoffice/utils/mixins/_highlight.scss index 3e98c28c4..8c58725f6 100644 --- a/css/backoffice/utils/mixins/_highlight.scss +++ b/css/backoffice/utils/mixins/_highlight.scss @@ -3,8 +3,8 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-vertical-highlight--width: $ibo-size-100; -$ibo-vertical-highlight--height: 100%; +$ibo-vertical-highlight--width: $common-vertical-highlight--width; +$ibo-vertical-highlight--height: $common-vertical-highlight--height; @mixin ibo-vertical-highlight { display: block; diff --git a/css/backoffice/utils/mixins/_selectable.scss b/css/backoffice/utils/mixins/_selectable.scss index 533e688e4..327a91f3d 100644 --- a/css/backoffice/utils/mixins/_selectable.scss +++ b/css/backoffice/utils/mixins/_selectable.scss @@ -3,18 +3,19 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-selectable--background-color: transparent !default; +$ibo-selectable--background-color: $common-selectable--background-color !default; -$ibo-selectable--hover--color: $ibo-color-grey-100 !default; -$ibo-selectable--hover--background-color: $ibo-color-grey-600 !default; -$ibo-selectable--hover--background-opacity: 0.6 !default; +$ibo-selectable--hover--color: $common-selectable--hover--color !default; +$ibo-selectable--hover--background-color: $common-selectable--hover--background-color !default; +$ibo-selectable--hover--background-opacity: $common-selectable--hover--background-opacity !default; -$ibo-selected--color: $ibo-color-grey-100 !default; -$ibo-selected--background-color: $ibo-color-grey-900 !default; -$ibo-selected--background-opacity: 0.5 !default; +$ibo-selected--color: $common-selected--color !default; +$ibo-selected--background-color: $common-selected--background-color !default; +$ibo-selected--background-opacity: $common-selected--background-opacity !default; + +$ibo-selected--hover--background-color: $common-selected--hover--background-color !default; +$ibo-selected--hover--background-opacity: $common-selected--hover--background-opacity !default; -$ibo-selected--hover--background-color: $ibo-color-grey-700 !default; -$ibo-selected--hover--background-opacity: 0.5 !default; @mixin ibo-selectable { content: ' '; @extend %fa-solid-base; diff --git a/css/backoffice/utils/variables/_border-radius.scss b/css/backoffice/utils/variables/_border-radius.scss index 9b810ca24..72612b5ee 100644 --- a/css/backoffice/utils/variables/_border-radius.scss +++ b/css/backoffice/utils/variables/_border-radius.scss @@ -3,13 +3,13 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-border-radius-100: 1px !default; -$ibo-border-radius-300: 3px !default; -$ibo-border-radius-400: 4px !default; -$ibo-border-radius-500: 5px !default; -$ibo-border-radius-700: 10px !default; -$ibo-border-radius-900: 16px !default; -$ibo-border-radius-full: 100% !default; +$ibo-border-radius-100: $common-border-radius-100 !default; +$ibo-border-radius-300: $common-border-radius-300 !default; +$ibo-border-radius-400: $common-border-radius-400!default; +$ibo-border-radius-500: $common-border-radius-500 !default; +$ibo-border-radius-700: $common-border-radius-700 !default; +$ibo-border-radius-900: $common-border-radius-900 !default; +$ibo-border-radius-full: $common-border-radius-full !default; :root{ --ibo-border-radius-100: #{$ibo-border-radius-100}; diff --git a/css/backoffice/utils/variables/_depression.scss b/css/backoffice/utils/variables/_depression.scss index 308f1d69b..ffd0bedb6 100644 --- a/css/backoffice/utils/variables/_depression.scss +++ b/css/backoffice/utils/variables/_depression.scss @@ -3,7 +3,7 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-depression-100: inset 0 1px 1px 0 rgba(0, 0, 0, 0.15) !default; +$ibo-depression-100: $common-depression-100 !default; :root{ --ibo-depression-100: #{$ibo-depression-100}; diff --git a/css/backoffice/utils/variables/_elevation.scss b/css/backoffice/utils/variables/_elevation.scss index ad87108d6..7ca9c38e6 100644 --- a/css/backoffice/utils/variables/_elevation.scss +++ b/css/backoffice/utils/variables/_elevation.scss @@ -3,11 +3,11 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-elevation-100: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.12) !default; -$ibo-elevation-200: 0 2px 4px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.15) !default; -$ibo-elevation-300: 0 3px 6px rgba(0, 0, 0, 0.10), 0 10px 20px rgba(0, 0, 0, 0.15) !default; -$ibo-elevation-400: 0 5px 10px rgba(0, 0, 0, 0.05), 0 15px 25px rgba(0, 0, 0, 0.15) !default; -$ibo-elevation-500: 0 20px 40px rgba(0, 0, 0, 0.20) !default; +$ibo-elevation-100: $common-elevation-100 !default; +$ibo-elevation-200: $common-elevation-200 !default; +$ibo-elevation-300: $common-elevation-300 !default; +$ibo-elevation-400: $common-elevation-400 !default; +$ibo-elevation-500: $common-elevation-500 !default; :root{ --ibo-elevation-100: #{$ibo-elevation-100}; diff --git a/css/backoffice/utils/variables/_path.scss b/css/backoffice/utils/variables/_path.scss index 251b155d7..abb1ca22b 100644 --- a/css/backoffice/utils/variables/_path.scss +++ b/css/backoffice/utils/variables/_path.scss @@ -3,4 +3,3 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$approot-relative: '../../../../' !default; diff --git a/css/backoffice/utils/variables/_size.scss b/css/backoffice/utils/variables/_size.scss index 625f155d1..bebaa9654 100644 --- a/css/backoffice/utils/variables/_size.scss +++ b/css/backoffice/utils/variables/_size.scss @@ -3,25 +3,25 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -$ibo-size-0: 0 !default; -$ibo-size-50: 2px !default; -$ibo-size-100: 4px !default; -$ibo-size-150: 8px !default; -$ibo-size-200: 12px !default; -$ibo-size-250: 16px !default; -$ibo-size-300: 24px !default; -$ibo-size-350: 32px !default; -$ibo-size-400: 48px !default; -$ibo-size-450: 64px !default; -$ibo-size-500: 96px !default; -$ibo-size-550: 128px !default; -$ibo-size-600: 192px !default; -$ibo-size-650: 256px !default; -$ibo-size-700: 384px !default; -$ibo-size-750: 512px !default; -$ibo-size-800: 640px !default; -$ibo-size-850: 768px !default; -$ibo-size-900: 896px !default; +$ibo-size-0: $common-size-0 !default; +$ibo-size-50: $common-size-50 !default; +$ibo-size-100: $common-size-100 !default; +$ibo-size-150: $common-size-150 !default; +$ibo-size-200: $common-size-200 !default; +$ibo-size-250: $common-size-250 !default; +$ibo-size-300: $common-size-300 !default; +$ibo-size-350: $common-size-350 !default; +$ibo-size-400: $common-size-400 !default; +$ibo-size-450: $common-size-450 !default; +$ibo-size-500: $common-size-500 !default; +$ibo-size-550: $common-size-550 !default; +$ibo-size-600: $common-size-600 !default; +$ibo-size-650: $common-size-650 !default; +$ibo-size-700: $common-size-700 !default; +$ibo-size-750: $common-size-750 !default; +$ibo-size-800: $common-size-800 !default; +$ibo-size-850: $common-size-850 !default; +$ibo-size-900: $common-size-900 !default; :root{ --ibo-size-0: #{$ibo-size-0}; diff --git a/css/backoffice/utils/variables/_typography.scss b/css/backoffice/utils/variables/_typography.scss index 3a4a90516..268039178 100644 --- a/css/backoffice/utils/variables/_typography.scss +++ b/css/backoffice/utils/variables/_typography.scss @@ -4,37 +4,37 @@ */ /* Base size: html font-size 12px */ -$ibo-font-size-20: 0.67rem !default; /* 8px */ -$ibo-font-size-50: 0.83rem !default; /* 10px */ -$ibo-font-size-100: 1rem !default; /* 12px */ -$ibo-font-size-150: 1.17rem !default; /* 14px */ -$ibo-font-size-200: 1.33rem !default; /* 16px */ -$ibo-font-size-250: 1.5rem !default; /* 18px */ -$ibo-font-size-300: 1.67rem !default; /* 20px */ -$ibo-font-size-350: 1.83rem !default; /* 22px */ -$ibo-font-size-400: 2rem !default; /* 24px */ -$ibo-font-size-450: 2.5rem !default; /* 30px */ -$ibo-font-size-500: 3rem !default; /* 36px */ -$ibo-font-size-550: 4rem !default; /* 48px */ -$ibo-font-size-600: 5rem !default; /* 60px */ -$ibo-font-size-650: 6rem !default; /* 72px */ -$ibo-font-size-700: 7rem !default; /* 84px */ +$ibo-font-size-20: $common-font-size-20 !default; /* 8px */ +$ibo-font-size-50: $common-font-size-50 !default; /* 10px */ +$ibo-font-size-100: $common-font-size-100 !default; /* 12px */ +$ibo-font-size-150: $common-font-size-150 !default; /* 14px */ +$ibo-font-size-200: $common-font-size-200 !default; /* 16px */ +$ibo-font-size-250: $common-font-size-250 !default; /* 18px */ +$ibo-font-size-300: $common-font-size-300 !default; /* 20px */ +$ibo-font-size-350: $common-font-size-350 !default; /* 22px */ +$ibo-font-size-400: $common-font-size-400 !default; /* 24px */ +$ibo-font-size-450: $common-font-size-450 !default; /* 30px */ +$ibo-font-size-500: $common-font-size-500 !default; /* 36px */ +$ibo-font-size-550: $common-font-size-550 !default; /* 48px */ +$ibo-font-size-600: $common-font-size-600 !default; /* 60px */ +$ibo-font-size-650: $common-font-size-650 !default; /* 72px */ +$ibo-font-size-700: $common-font-size-700 !default; /* 84px */ /* Value Common weight name (https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) */ -$ibo-font-weight-100: 100 !default; /* 100 Thin (Harline) */ -$ibo-font-weight-200: 200 !default; /* 200 Extra Light (Ultra Light) */ -$ibo-font-weight-300: 300 !default; /* 300 Light */ -$ibo-font-weight-400: 400 !default; /* 400 Normal (Regular) */ -$ibo-font-weight-500: 500 !default; /* 500 Medium */ -$ibo-font-weight-600: 600 !default; /* 600 Semi Bold (Demi Bold) */ -$ibo-font-weight-700: 700 !default; /* 700 Bold */ -$ibo-font-weight-800: 800 !default; /* 800 Extra Bold (Ultra Bold) */ -$ibo-font-weight-900: 900 !default; /* 900 Black (Heavy) */ -$ibo-font-weight-950: 950 !default; /* 950 Extra Black (Ultra Black) */ +$ibo-font-weight-100: $common-font-weight-100 !default; /* 100 Thin (Harline) */ +$ibo-font-weight-200: $common-font-weight-200 !default; /* 200 Extra Light (Ultra Light) */ +$ibo-font-weight-300: $common-font-weight-300 !default; /* 300 Light */ +$ibo-font-weight-400: $common-font-weight-400 !default; /* 400 Normal (Regular) */ +$ibo-font-weight-500: $common-font-weight-500 !default; /* 500 Medium */ +$ibo-font-weight-600: $common-font-weight-600 !default; /* 600 Semi Bold (Demi Bold) */ +$ibo-font-weight-700: $common-font-weight-700 !default; /* 700 Bold */ +$ibo-font-weight-800: $common-font-weight-800 !default; /* 800 Extra Bold (Ultra Bold) */ +$ibo-font-weight-900: $common-font-weight-900 !default; /* 900 Black (Heavy) */ +$ibo-font-weight-950: $common-font-weight-950 !default; /* 950 Extra Black (Ultra Black) */ -$ibo-font-family-base: "Raleway" !default; -$ibo-font-family-fallbacks: "sans-serif", "system-ui" !default; -$ibo-font-family-monospace: monospace !default; +$ibo-font-family-base: $common-font-family-base !default; +$ibo-font-family-fallbacks: $common-font-family-fallbacks !default; +$ibo-font-family-monospace: $common-font-family-monospace !default; $ibo-font-family-code: $ibo-font-family-monospace !default; :root { diff --git a/css/backoffice/utils/variables/colors/_base-palette.scss b/css/backoffice/utils/variables/colors/_base-palette.scss index c6e7410a2..32621b544 100644 --- a/css/backoffice/utils/variables/colors/_base-palette.scss +++ b/css/backoffice/utils/variables/colors/_base-palette.scss @@ -4,102 +4,102 @@ */ /* Base color palettes */ -$ibo-color-white-100: hsla(0, 0%, 100%, 1) !default; -$ibo-color-white-200: hsla(0, 0%, 94.9%, 1) !default; -$ibo-color-transparent: hsla(0, 0%, 100%, 0) !default; +$ibo-color-white-100: $common-color-white-100 !default; +$ibo-color-white-200: $common-color-white-200 !default; +$ibo-color-transparent: $common-color-transparent !default; -$ibo-color-grey-50: hsla(240, 20%, 99%, 1) !default; -$ibo-color-grey-100: hsla(210, 16.7%, 97.6%, 1) !default; -$ibo-color-grey-200: hsla(207, 22.4%, 90.4%, 1) !default; -$ibo-color-grey-300: hsla(210, 23.5%, 86.7%, 1) !default; -$ibo-color-grey-400: hsla(208, 17.2%, 82.9%, 1) !default; -$ibo-color-grey-500: hsla(209, 23.7%, 74.3%, 1) !default; -$ibo-color-grey-600: hsla(215, 16.6%, 63.3%, 1) !default; -$ibo-color-grey-700: hsla(214, 11.3%, 48.6%, 1) !default; -$ibo-color-grey-800: hsla(215, 16.9%, 30.2%, 1) !default; -$ibo-color-grey-900: hsla(215, 22.4%, 16.7%, 1) !default; -$ibo-color-grey-950: hsla(215, 26.4%, 10.7%, 1) !default; +$ibo-color-grey-50: $common-color-grey-50 !default; +$ibo-color-grey-100: $common-color-grey-100 !default; +$ibo-color-grey-200: $common-color-grey-200 !default; +$ibo-color-grey-300: $common-color-grey-300 !default; +$ibo-color-grey-400: $common-color-grey-400 !default; +$ibo-color-grey-500: $common-color-grey-500 !default; +$ibo-color-grey-600: $common-color-grey-600 !default; +$ibo-color-grey-700: $common-color-grey-700 !default; +$ibo-color-grey-800: $common-color-grey-800 !default; +$ibo-color-grey-900: $common-color-grey-900 !default; +$ibo-color-grey-950: $common-color-grey-950 !default; -$ibo-color-blue-grey-50: hsla(210, 36%, 96%, 1) !default; -$ibo-color-blue-grey-100: hsla(198, 15.7%, 83.7%, 1) !default; -$ibo-color-blue-grey-200: hsla(200, 15.3%, 73.1%, 1) !default; -$ibo-color-blue-grey-300: hsla(200, 15.6%, 62.4%, 1) !default; -$ibo-color-blue-grey-400: hsla(200, 15.4%, 54.1%, 1) !default; -$ibo-color-blue-grey-500: hsla(200, 18.3%, 46.1%, 1) !default; -$ibo-color-blue-grey-600: hsla(199, 18.4%, 40.4%, 1) !default; -$ibo-color-blue-grey-700: hsla(199, 18.3%, 33.1%, 1) !default; -$ibo-color-blue-grey-800: hsla(200, 17.9%, 26.3%, 1) !default; -$ibo-color-blue-grey-900: hsla(200, 19.1%, 18.4%, 1) !default; -$ibo-color-blue-grey-950: hsla(200, 20.2%, 13.1%, 1) !default; +$ibo-color-blue-grey-50: $common-color-blue-grey-50 !default; +$ibo-color-blue-grey-100: $common-color-blue-grey-100 !default; +$ibo-color-blue-grey-200: $common-color-blue-grey-200 !default; +$ibo-color-blue-grey-300: $common-color-blue-grey-300 !default; +$ibo-color-blue-grey-400: $common-color-blue-grey-400 !default; +$ibo-color-blue-grey-500: $common-color-blue-grey-500 !default; +$ibo-color-blue-grey-600: $common-color-blue-grey-600 !default; +$ibo-color-blue-grey-700: $common-color-blue-grey-700 !default; +$ibo-color-blue-grey-800: $common-color-blue-grey-800 !default; +$ibo-color-blue-grey-900: $common-color-blue-grey-900 !default; +$ibo-color-blue-grey-950: $common-color-blue-grey-950 !default; -$ibo-color-blue-100: hsla(201, 100%, 96.1%, 1) !default; -$ibo-color-blue-200: hsla(202, 80.6%, 85.9%, 1) !default; -$ibo-color-blue-300: hsla(203, 82%, 76.1%, 1) !default; -$ibo-color-blue-400: hsla(205, 79.3%, 65.9%, 1) !default; -$ibo-color-blue-500: hsla(207, 72.6%, 57.1%, 1) !default; -$ibo-color-blue-600: hsla(209, 61.6%, 50%, 1) !default; -$ibo-color-blue-700: hsla(211, 60.7%, 42.9%, 1) !default; -$ibo-color-blue-800: hsla(213, 49.4%, 34.1%, 1) !default; -$ibo-color-blue-900: hsla(215, 41.3%, 28%, 1) !default; -$ibo-color-blue-950: hsla(215, 36.8%, 23%, 1) !default; +$ibo-color-blue-100: $common-color-blue-100 !default; +$ibo-color-blue-200: $common-color-blue-200 !default; +$ibo-color-blue-300: $common-color-blue-300 !default; +$ibo-color-blue-400: $common-color-blue-400 !default; +$ibo-color-blue-500: $common-color-blue-500 !default; +$ibo-color-blue-600: $common-color-blue-600 !default; +$ibo-color-blue-700: $common-color-blue-700 !default; +$ibo-color-blue-800: $common-color-blue-800 !default; +$ibo-color-blue-900: $common-color-blue-900 !default; +$ibo-color-blue-950: $common-color-blue-950 !default; -$ibo-color-cyan-100: hsla(186, 61.2%, 86.9%, 1) !default; -$ibo-color-cyan-200: hsla(187, 71.6%, 71%, 1) !default; -$ibo-color-cyan-300: hsla(187, 71.2%, 59.2%, 1) !default; -$ibo-color-cyan-400: hsla(187, 70.9%, 50.2%, 1) !default; -$ibo-color-cyan-500: hsla(187, 100%, 41.6%, 1) !default; -$ibo-color-cyan-600: hsla(187, 100%, 37.8%, 1) !default; -$ibo-color-cyan-700: hsla(186, 100%, 32.7%, 1) !default; -$ibo-color-cyan-800: hsla(185, 100%, 28%, 1) !default; -$ibo-color-cyan-900: hsla(182, 100%, 19.6%, 1) !default; -$ibo-color-cyan-950: hsla(180, 100%, 10.6%, 1) !default; +$ibo-color-cyan-100: $common-color-cyan-100 !default; +$ibo-color-cyan-200: $common-color-cyan-200 !default; +$ibo-color-cyan-300: $common-color-cyan-300 !default; +$ibo-color-cyan-400: $common-color-cyan-400 !default; +$ibo-color-cyan-500: $common-color-cyan-500 !default; +$ibo-color-cyan-600: $common-color-cyan-600 !default; +$ibo-color-cyan-700: $common-color-cyan-700 !default; +$ibo-color-cyan-800: $common-color-cyan-800 !default; +$ibo-color-cyan-900: $common-color-cyan-900 !default; +$ibo-color-cyan-950: $common-color-cyan-950 !default; -$ibo-color-green-100: hsla(88, 50.7%, 85.7%, 1) !default; -$ibo-color-green-200: hsla(88, 50%, 76.5%, 1) !default; -$ibo-color-green-300: hsla(88, 50%, 67.1%, 1) !default; -$ibo-color-green-400: hsla(88, 50.2%, 59.8%, 1) !default; -$ibo-color-green-500: hsla(88, 50.2%, 52.7%, 1) !default; -$ibo-color-green-600: hsla(89, 46.1%, 48%, 1) !default; -$ibo-color-green-700: hsla(92, 47.9%, 42.2%, 1) !default; -$ibo-color-green-800: hsla(95, 49.5%, 36.5%, 1) !default; -$ibo-color-green-900: hsla(103, 55.6%, 26.5%, 1) !default; -$ibo-color-green-950: hsla(108, 59.6%, 21.5%, 1) !default; +$ibo-color-green-100: $common-color-green-100 !default; +$ibo-color-green-200: $common-color-green-200 !default; +$ibo-color-green-300: $common-color-green-300 !default; +$ibo-color-green-400: $common-color-green-400 !default; +$ibo-color-green-500: $common-color-green-500 !default; +$ibo-color-green-600: $common-color-green-600 !default; +$ibo-color-green-700: $common-color-green-700 !default; +$ibo-color-green-800: $common-color-green-800 !default; +$ibo-color-green-900: $common-color-green-900 !default; +$ibo-color-green-950: $common-color-green-950 !default; -$ibo-color-orange-100: hsla(40, 100%, 97.1%, 1) !default; -$ibo-color-orange-200: hsla(39, 96.4%, 89%, 1) !default; -$ibo-color-orange-300: hsla(38, 93.2%, 76.9%, 1) !default; -$ibo-color-orange-400: hsla(33, 89.9%, 64.9%, 1) !default; -$ibo-color-orange-500: hsla(28, 82.9%, 51.8%, 1) !default; -$ibo-color-orange-600: hsla(24, 74.7%, 49.6%, 1) !default; -$ibo-color-orange-700: hsla(20, 70.7%, 44.1%, 1) !default; -$ibo-color-orange-800: hsla(16, 65.1%, 37.1%, 1) !default; -$ibo-color-orange-900: hsla(14, 60.8%, 30%, 1) !default; -$ibo-color-orange-950: hsla(14, 55.1%, 22%, 1) !default; +$ibo-color-orange-100: $common-color-orange-100 !default; +$ibo-color-orange-200: $common-color-orange-200 !default; +$ibo-color-orange-300: $common-color-orange-300 !default; +$ibo-color-orange-400: $common-color-orange-400 !default; +$ibo-color-orange-500: $common-color-orange-500 !default; +$ibo-color-orange-600: $common-color-orange-600 !default; +$ibo-color-orange-700: $common-color-orange-700 !default; +$ibo-color-orange-800: $common-color-orange-800 !default; +$ibo-color-orange-900: $common-color-orange-900 !default; +$ibo-color-orange-950: $common-color-orange-950 !default; -$ibo-color-red-100: hsla(0, 76.9%, 94.9%, 1) !default; -$ibo-color-red-200: hsla(0, 95.1%, 92%, 1) !default; -$ibo-color-red-300: hsla(0, 97.4%, 84.7%, 1) !default; -$ibo-color-red-400: hsla(0, 95.3%, 74.7%, 1) !default; -$ibo-color-red-500: hsla(0, 87.8%, 67.8%, 1) !default; -$ibo-color-red-600: hsla(0, 76.3%, 57.1%, 1) !default; -$ibo-color-red-700: hsla(0, 60.8%, 48%, 1) !default; -$ibo-color-red-800: hsla(0, 55.8%, 39%, 1) !default; -$ibo-color-red-900: hsla(0, 46.8%, 31%, 1) !default; -$ibo-color-red-950: hsla(0, 42.9%, 20%, 1) !default; +$ibo-color-red-100: $common-color-red-100 !default; +$ibo-color-red-200: $common-color-red-200 !default; +$ibo-color-red-300: $common-color-red-300 !default; +$ibo-color-red-400: $common-color-red-400 !default; +$ibo-color-red-500: $common-color-red-500 !default; +$ibo-color-red-600: $common-color-red-600 !default; +$ibo-color-red-700: $common-color-red-700 !default; +$ibo-color-red-800: $common-color-red-800 !default; +$ibo-color-red-900: $common-color-red-900 !default; +$ibo-color-red-950: $common-color-red-950 !default; -$ibo-color-pink-100: hsla(348, 100%, 98%, 1) !default; -$ibo-color-pink-200: hsla(343, 95%, 92%, 1) !default; -$ibo-color-pink-300: hsla(339, 90%, 85%, 1) !default; -$ibo-color-pink-400: hsla(336, 86%, 75%, 1) !default; -$ibo-color-pink-500: hsla(331, 79%, 66%, 1) !default; -$ibo-color-pink-600: hsla(329, 64%, 54%, 1) !default; -$ibo-color-pink-700: hsla(325, 57%, 46%, 1) !default; -$ibo-color-pink-800: hsla(322, 60%, 37%, 1) !default; -$ibo-color-pink-900: hsla(318, 51%, 29%, 1) !default; -$ibo-color-pink-950: hsla(318, 51%, 21%, 1) !default; +$ibo-color-pink-100: $common-color-pink-100 !default; +$ibo-color-pink-200: $common-color-pink-200 !default; +$ibo-color-pink-300: $common-color-pink-300 !default; +$ibo-color-pink-400: $common-color-pink-400 !default; +$ibo-color-pink-500: $common-color-pink-500 !default; +$ibo-color-pink-600: $common-color-pink-600 !default; +$ibo-color-pink-700: $common-color-pink-700 !default; +$ibo-color-pink-800: $common-color-pink-800 !default; +$ibo-color-pink-900: $common-color-pink-900 !default; +$ibo-color-pink-950: $common-color-pink-950 !default; -$ibo-colors: ('grey', 'blue-grey', 'blue', 'cyan', 'green', 'orange', 'red', 'pink', 'primary', 'secondary', 'information', 'success', 'warning', 'danger'); +$ibo-colors: $common-colors; /* CSS variables */ :root{ diff --git a/css/backoffice/utils/variables/colors/_base.scss b/css/backoffice/utils/variables/colors/_base.scss index 56ab1e2a8..1ef86d7e9 100644 --- a/css/backoffice/utils/variables/colors/_base.scss +++ b/css/backoffice/utils/variables/colors/_base.scss @@ -5,8 +5,8 @@ /* Base helpers for colors */ /* - These lightness vars are used to force a certain lightness on HSLA colors */ -$ibo-color-base-lightness-100: 93% !default; -$ibo-color-base-lightness-900: 15% !default; +$ibo-color-base-lightness-100: $common-color-base-lightness-100 !default; +$ibo-color-base-lightness-900: $common-color-base-lightness-900 !default; -$ibo-color-base-opacity-for-lightness-100: 1 !default; -$ibo-color-base-opacity-for-lightness-900: 1 !default; \ No newline at end of file +$ibo-color-base-opacity-for-lightness-100: $common-color-base-opacity-for-lightness-100 !default; +$ibo-color-base-opacity-for-lightness-900: $common-color-base-opacity-for-lightness-900 !default; \ No newline at end of file diff --git a/css/backoffice/utils/variables/colors/_skeleton-palette.scss b/css/backoffice/utils/variables/colors/_skeleton-palette.scss index 16e558b64..da44d3add 100644 --- a/css/backoffice/utils/variables/colors/_skeleton-palette.scss +++ b/css/backoffice/utils/variables/colors/_skeleton-palette.scss @@ -6,8 +6,8 @@ /* Skeleton palette */ /* - Colors used by skeletons svg to display placeholders */ -$ibo-skeleton-start-color: $ibo-color-grey-200 !default; -$ibo-skeleton-stop-color: $ibo-color-blue-grey-100 !default; +$ibo-skeleton-start-color: $common-skeleton-start-color !default; +$ibo-skeleton-stop-color: $common-skeleton-stop-color !default; /* CSS variables */ /* Skeleton CSS3 variables are not ibo prefixed as they are not iTop backoffice exclusives*/ diff --git a/css/backoffice/vendors/_highlightjs.scss b/css/backoffice/vendors/_highlightjs.scss index e2f16eeb9..0635a2f67 100644 --- a/css/backoffice/vendors/_highlightjs.scss +++ b/css/backoffice/vendors/_highlightjs.scss @@ -2,44 +2,115 @@ * @copyright Copyright (C) 2010-2024 Combodo SAS * @license http://opensource.org/licenses/AGPL-3.0 */ -@import "../../common/vendors/_highlightjs"; // Backoffice specific variables -$ibo-vendors-highlightjs--padding: 0.9rem !default; -$ibo-vendors-highlightjs--box-shadow: 0 0px 3px 2px inset rgba(0, 0, 0, 0.4) !default; -$ibo-vendors-highlightjs--border-radius: $ibo-border-radius-300 !default; -$ibo-vendors-highlightjs--code--padding-x: 5px !default; -$ibo-vendors-highlightjs--code--padding-y: 3px !default; +$ibo-vendors-highlightjs--padding: $common-vendors-highlightjs--padding !default; +$ibo-vendors-highlightjs--box-shadow: $common-vendors-highlightjs--box-shadow !default; +$ibo-vendors-highlightjs--border-radius: $common-vendors-highlightjs--border-radius !default; +$ibo-vendors-highlightjs--code--padding-x: $common-vendors-highlightjs--code--padding-x !default; +$ibo-vendors-highlightjs--code--padding-y: $common-vendors-highlightjs--code--padding-y !default; -$ibo-vendors-highlightjs--background-color: #282b2e !default; -$ibo-vendors-highlightjs--color: #e0e2e4 !default; -$ibo-vendors-highlightjs--keyword--color: #93c763 !default; -$ibo-vendors-highlightjs--number--color: #ffcd22 !default; -$ibo-vendors-highlightjs--attribute--color: #668bb0 !default; -$ibo-vendors-highlightjs--regexp--color: #d39745 !default; -$ibo-vendors-highlightjs--meta--color: #557182 !default; -$ibo-vendors-highlightjs--tag--color: #8cbbad !default; -$ibo-vendors-highlightjs--string--color: #ec7600 !default; -$ibo-vendors-highlightjs--comment--color: #818e96 !default; -$ibo-vendors-highlightjs--selector-class--color: #A082BD !default; -$ibo-vendors-highlightjs--code--color: white !default; +$ibo-vendors-highlightjs--background-color: $common-vendors-highlightjs--background-color !default; +$ibo-vendors-highlightjs--color: $common-vendors-highlightjs--color !default; +$ibo-vendors-highlightjs--keyword--color: $common-vendors-highlightjs--keyword--color !default; +$ibo-vendors-highlightjs--number--color: $common-vendors-highlightjs--number--color !default; +$ibo-vendors-highlightjs--attribute--color: $common-vendors-highlightjs--attribute--color !default; +$ibo-vendors-highlightjs--regexp--color: $common-vendors-highlightjs--regexp--color !default; +$ibo-vendors-highlightjs--meta--color: $common-vendors-highlightjs--meta--color !default; +$ibo-vendors-highlightjs--tag--color: $common-vendors-highlightjs--tag--color !default; +$ibo-vendors-highlightjs--string--color: $common-vendors-highlightjs--string--color !default; +$ibo-vendors-highlightjs--comment--color: $common-vendors-highlightjs--comment--color !default; +$ibo-vendors-highlightjs--selector-class--color: $common-vendors-highlightjs--selector-class--color !default; +$ibo-vendors-highlightjs--code--color: $common-vendors-highlightjs--code--color !default; -// Override common variables -$common-vendors-highlightjs--padding: $ibo-vendors-highlightjs--padding; -$common-vendors-highlightjs--box-shadow: $ibo-vendors-highlightjs--box-shadow; -$common-vendors-highlightjs--border-radius: $ibo-vendors-highlightjs--border-radius; -$common-vendors-highlightjs--code--padding-x: $ibo-vendors-highlightjs--code--padding-x; -$common-vendors-highlightjs--code--padding-y: $ibo-vendors-highlightjs--code--padding-y; +// Highlight.js stylesheets +/* Highlight JS */ +.common-hljs-container{ + padding: 0 !important; + border: none !important; +} -$common-vendors-highlightjs--background-color: $ibo-vendors-highlightjs--background-color; -$common-vendors-highlightjs--color: $ibo-vendors-highlightjs--color; -$common-vendors-highlightjs--keyword--color: $ibo-vendors-highlightjs--keyword--color; -$common-vendors-highlightjs--number--color: $ibo-vendors-highlightjs--number--color; -$common-vendors-highlightjs--attribute--color: $ibo-vendors-highlightjs--attribute--color; -$common-vendors-highlightjs--regexp--color: $ibo-vendors-highlightjs--regexp--color; -$common-vendors-highlightjs--meta--color: $ibo-vendors-highlightjs--meta--color; -$common-vendors-highlightjs--tag--color: $ibo-vendors-highlightjs--tag--color; -$common-vendors-highlightjs--string--color: $ibo-vendors-highlightjs--string--color; -$common-vendors-highlightjs--comment--color: $ibo-vendors-highlightjs--comment--color; -$common-vendors-highlightjs--selector-class--color: $ibo-vendors-highlightjs--selector-class--color; -$common-vendors-highlightjs--code--color: $ibo-vendors-highlightjs--code--color; \ No newline at end of file +pre code.hljs { + display: block; + overflow-x: auto; + padding: $ibo-vendors-highlightjs--padding !important; +} + +code.hljs { + padding: $ibo-vendors-highlightjs--code--padding-y $ibo-vendors-highlightjs--code--padding-x !important; +} +/** + * Obsidian style + * ported by Alexander Marenin (http://github.com/ioncreature) + */ +.hljs { + box-shadow: $ibo-vendors-highlightjs--box-shadow !important; + border-radius: $ibo-vendors-highlightjs--border-radius !important; + white-space: pre-wrap; + border: none !important; + color: $ibo-vendors-highlightjs--color !important; + background: $ibo-vendors-highlightjs--background-color !important; +} +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-selector-id { + color: $ibo-vendors-highlightjs--keyword--color !important; +} +.hljs-number { + color: $ibo-vendors-highlightjs--number--color !important; +} +.hljs-attribute { + color: $ibo-vendors-highlightjs--attribute--color +} +.hljs-regexp, +.hljs-link { + color: $ibo-vendors-highlightjs--regexp--color !important; +} +.hljs-meta { + color: $ibo-vendors-highlightjs--meta--color !important; +} +.hljs-tag, +.hljs-name, +.hljs-bullet, +.hljs-subst, +.hljs-emphasis, +.hljs-type, +.hljs-built_in, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: $ibo-vendors-highlightjs--tag--color !important; +} +.hljs-string, +.hljs-symbol { + color: $ibo-vendors-highlightjs--string--color !important; +} +.hljs-comment, +.hljs-quote, +.hljs-deletion { + color: $ibo-vendors-highlightjs--comment--color !important; +} +.hljs-selector-class { + color: $ibo-vendors-highlightjs--selector-class--color !important; +} +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-name, +.hljs-strong { + font-weight: bold +} +.hljs-code, +.hljs-title.class_, +.hljs-class .hljs-title, +.hljs-section { + color: $ibo-vendors-highlightjs--code--color !important; +} \ No newline at end of file diff --git a/css/common/README.md b/css/common/README.md new file mode 100644 index 000000000..313397bfd --- /dev/null +++ b/css/common/README.md @@ -0,0 +1,108 @@ +# Description +This is a brief description of how the common theme is structured using both BEM and SASS 7-1 systems and how to use them. + * [7-1 pattern](#7-1-pattern) + * [File structure](#file-structure) + * [Usage](#usage) + * [BEM methodology](#bem-methodology) + * [Principles](#principles) + * [Examples](#examples) + +# 7-1 pattern +## File structure +SCSS files are structured following the [7-1 pattern](https://sass-guidelin.es/#the-7-1-pattern). \ +@rveitch made a great summary with the following, which can also be found [here](https://gist.github.com/rveitch/84cea9650092119527bc). + +_Note: Folders with an * are customizations we made to the original 7-1 pattern to best fit our needs_ + +``` +css/common/ +| +|– utils/ +| |– variables/ # Sass Variables used in Functions, Mixins, Helpers, ... +| | |- colors/ +| | | |- _base.scss +| | | |- _base-palette.scss # Base colors used everywhere +| | | |- _lifecycle-palette.scss # Colors used for lifecycle of an object (e.g. representing states such as new, frozen, done, ...), based on the base colors +| | | |- _semantic-palette.scss # Colors used for semantic meaning (e.g. red for errors, green for success, ...), based on the base colors +| | | ... +| | | +| | |- _depression.scss +| | |- _elevation.scss +| | |- _size.scss # Base sizes used everywhere (spacings, ...) +| | |- _spacing.scss +| | |- _typography.scss # Typography sizes, weights, families, ... +| | ... +| | +| |– functions/ # Sass Functions +| | |- _color.scss # Color manipulation functions +| | +| |– mixins/ # Sass Mixins +| |– helpers/ # Class & placeholders helpers +| +|– vendors/ # Third-party libs, should be either: +| # - Overload of the lib SCSS variables (BEST way, but possible only if the lib exposes them. e.g. Bulma) +| # - Overload of the lib necessary CSS classes only (not great as it duplicates some rules in the browser, which add weight and computation. e.g. dataTables) +| # - Duplicate the lib CSS completly to insert SCSS variables (not great as it will be outdated when updating the lib itself. e.g. jQuery UI) +| |– _bulma-variables-overload.scss # Bulma CSS framework +| |– _jquery-ui.scss # jQuery UI +| ... # Etc… +| +|– base/ +| |– _reset.scss # Reset/normalize +| |– _typography.scss # Typography fonts imports +| ... # Etc… +| +|- _shame.scss # Shame file, should contain all the ugly hacks (https://sass-guidelin.es/#shame-file) +`– main.scss # Main Sass file +``` + +## Usage +To avoid common errors, files should be imported in the final file in the following order. Again those are just following the SASS guidelines: +- Utils + - Variables + - Functions + - Mixins + - Helpers +- Vendors +- Base +- Shame file + +# BEM methodology +## Principles +[BEM is a methodology](https://getbem.com/) that helps you to create reusable components and code sharing in front‑end development. \ +The main idea is to use discriminant classes instead of nested basic selectors for 2 main reasons: + * It's easier to understand the purpose of a specific class when seeing it in the HTML markup of the SCSS file + * It's easier to override a specific class when needed as you don't need to use a selector at least as precise/complex as the one you want to override + +In our implementation, we start with the code of the UI block, followed by the sub-element, then the property or modifier. Separation is made of `--` instead of `__`. + +## Examples +### Classes and CSS properties example +```scss +// SCSS variables: +// - For CSS properties: CSS class, followed by CSS property +$common-button--padding-y: 6px !default; +$common-button--padding-x: 9px !default; +$common-button--border: 0 !default; +$common-button--border-radius: $common-border-radius-400 !default; +$common-button--box-shadow-bottom: 0px 2px 0px !default; +$common-button--box-shadow-top: inset 0px 2px 0px !default; + +$common-button--label--margin-left: $common-spacing-200 !default; + +``` + +### States example +```scss +// SCSS variables: +// Same rule as before, but with a `--is-` or `--on--` suffix +$common-quick-create--input--padding: $common-spacing-0 default; +$common-quick-create--input--padding-x--is-opened: $common-spacing-300 !default; +$common-quick-create--input--padding-y--is-opened: $common-spacing-300 !default; + +$common-quick-create--input--width: $common-size-0 !default; +$common-quick-create--input--width--is-opened: 245px !default; + +$common-quick-create--input--background-color: $common-color-white-100 !default; +$common-quick-create--input--background-color--on-hover: $common-color-grey-200 !default; +``` \ No newline at end of file diff --git a/css/common/_shame.scss b/css/common/_shame.scss new file mode 100644 index 000000000..7f5644072 --- /dev/null +++ b/css/common/_shame.scss @@ -0,0 +1,40 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +// ========================================================================== +// $Shame +// @see http://csswizardry.com/2013/04/shame-css/ +// Thanks https://github.com/heroheman/shepherd/blob/master/sass/_shame.scss +// ========================================================================== +// +// ========================================================================== +// because hacks happen. +// +// be very specific about what each piece of code is doing, and +// how to better fix it later +// ========================================================================== +// +// Try: $ git blame _shame.scss +// +// Rules: +// --------------- +// 1. If it’s a hack, it goes in _shame.scss. +// 2. Document all hacks fully: +// 3. What part of the codebase does it relate to? +// 4. Why was this needed? +// 5. How does this fix it? +// 6. How might you fix it properly, given more time? +// 7. Do not blame the developer; if they explained why they had to do it then their reasons are probably (hopefully) valid. +// 8. Try and clean _shame.scss up when you have some down time. + +// Example: +// --------------- +// Nav specificity fix. +// +// Someone used an ID in the header code (`#header a{}`) which trumps the +// nav selectors (`.site-nav a{}`). Use !important to override it until I +// have time to refactor the header stuff. +// +// .site-nav a { color:#BADA55!important; } diff --git a/css/common/base/_all.scss b/css/common/base/_all.scss new file mode 100644 index 000000000..ac0b49163 --- /dev/null +++ b/css/common/base/_all.scss @@ -0,0 +1,7 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "base"; +@import "typography"; \ No newline at end of file diff --git a/css/common/base/_base.scss b/css/common/base/_base.scss new file mode 100644 index 000000000..0ba5a8b4c --- /dev/null +++ b/css/common/base/_base.scss @@ -0,0 +1,17 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-scrollbar--scrollbar-width: 8px !default; +$common-scrollbar--scrollbar-height: $common-scrollbar--scrollbar-width !default; /* For horizontal scrollbars */ +$common-scrollbar--scrollbar-track-background-color: $common-color-transparent !default; +$common-scrollbar--scrollbar-track-border-radius: $common-border-radius-500 !default; +$common-scrollbar--scrollbar-thumb-background-color: $common-color-grey-300 !default; +$common-scrollbar--scrollbar-thumb-border: none !default; +$common-scrollbar--scrollbar-thumb-border-radius: $common-border-radius-500 !default; + +$common-svg-illustration--fill: $common-color-primary-500 !default; + +$common-content-block--background-color: $common-color-white-100 !default; +$common-content-block--border: 1px solid $common-color-grey-400 !default; diff --git a/css/common/base/_typography.scss b/css/common/base/_typography.scss new file mode 100644 index 000000000..c5d5159ed --- /dev/null +++ b/css/common/base/_typography.scss @@ -0,0 +1,150 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* This is an overload of the default lib. stylesheet to use local fonts instead of the CDN */ +@font-face { + font-family: Raleway; + font-weight: 100; + font-style: normal; + font-display: swap; + src: local('Raleway Thin'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-100-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 100; + font-style: italic; + font-display: swap; + src: local('Raleway Thin'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-100-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 200; + font-style: normal; + font-display: swap; + src: local('Raleway ExtraLight'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-200-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 200; + font-style: italic; + font-display: swap; + src: local('Raleway ExtraLight'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-200-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 300; + font-style: normal; + font-display: swap; + src: local('Raleway Light'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-300-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 300; + font-style: italic; + font-display: swap; + src: local('Raleway Light'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-300-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 400; + font-style: normal; + font-display: swap; + src: local('Raleway'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-400-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 400; + font-style: italic; + font-display: swap; + src: local('Raleway'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-400-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 500; + font-style: normal; + font-display: swap; + src: local('Raleway Medium'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-500-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 500; + font-style: italic; + font-display: swap; + src: local('Raleway Medium'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-500-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 600; + font-style: normal; + font-display: swap; + src: local('Raleway SemiBold'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-600-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 600; + font-style: italic; + font-display: swap; + src: local('Raleway SemiBold'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-600-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 700; + font-style: normal; + font-display: swap; + src: local('Raleway'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-700-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 700; + font-style: italic; + font-display: swap; + src: local('Raleway'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-700-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 800; + font-style: normal; + font-display: swap; + src: local('Raleway ExtraBold'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-800-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 800; + font-style: italic; + font-display: swap; + src: local('Raleway ExtraBold'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-800-italic.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 900; + font-style: normal; + font-display: swap; + src: local('Raleway Black'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-900-normal.woff') format('woff'), +} +@font-face { + font-family: Raleway; + font-weight: 900; + font-style: italic; + font-display: swap; + src: local('Raleway Black'), + url($approot-relative + 'node_modules/@fontsource/raleway/files/raleway-all-900-italic.woff') format('woff'), +} diff --git a/css/common/main.scss b/css/common/main.scss new file mode 100644 index 000000000..0bb2767a4 --- /dev/null +++ b/css/common/main.scss @@ -0,0 +1,4 @@ +@import "utils/all"; +@import "vendors/all"; +@import "base/all"; +@import "shame"; diff --git a/css/common/utils/_all.scss b/css/common/utils/_all.scss new file mode 100644 index 000000000..969240a12 --- /dev/null +++ b/css/common/utils/_all.scss @@ -0,0 +1,9 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "variables/all"; +@import "functions/all"; +@import "mixins/all"; +@import "helpers/all"; \ No newline at end of file diff --git a/css/common/utils/functions/_all.scss b/css/common/utils/functions/_all.scss new file mode 100644 index 000000000..4eb534c5d --- /dev/null +++ b/css/common/utils/functions/_all.scss @@ -0,0 +1,6 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "color"; \ No newline at end of file diff --git a/css/common/utils/functions/_color.scss b/css/common/utils/functions/_color.scss new file mode 100644 index 000000000..0fe1784c3 --- /dev/null +++ b/css/common/utils/functions/_color.scss @@ -0,0 +1,34 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/** + * Adjust the lightness of $sColor to the absolute $fTargetLightness value. + * It is different than lighten() / darken() that shift the current lightness by X% + * + * @return Modified color value in HSLA format + */ +@function common-adjust-lightness($sColor, $fTargetLightness) { + $iHue: hue($sColor); + $fSaturation: saturation($sColor); + $fLightness: lightness($sColor); + $fAlpha: alpha($sColor); + + @return hsla($iHue, $fSaturation, $fTargetLightness, $fAlpha); +} + +/** + * Adjust the alpha chanel (opacity) of $sColor to the absolute $fTargetAlpha value. + * It is different than opacify() / transparentize() that shift the current alpha value by X% + * + * @return Modified color value in HSLA format + */ +@function common-adjust-alpha($sColor, $fTargetAlpha) { + $iHue: hue($sColor); + $fSaturation: saturation($sColor); + $fLightness: lightness($sColor); + $fAlpha: alpha($sColor); + + @return hsla($iHue, $fSaturation, $fLightness, $fTargetAlpha); +} \ No newline at end of file diff --git a/css/common/utils/helpers/_all.scss b/css/common/utils/helpers/_all.scss new file mode 100644 index 000000000..cdd9914d9 --- /dev/null +++ b/css/common/utils/helpers/_all.scss @@ -0,0 +1,15 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "border-radius"; +@import "color"; +@import "class-icon"; +@import "depression"; +@import "elevation"; +@import "font-icon"; +@import "sticky-header"; +@import "text-decoration"; +@import "text-position"; +@import "typography"; diff --git a/css/common/utils/helpers/_border-radius.scss b/css/common/utils/helpers/_border-radius.scss new file mode 100644 index 000000000..0d4325913 --- /dev/null +++ b/css/common/utils/helpers/_border-radius.scss @@ -0,0 +1,26 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +%common-border-radius-100{ + border-radius: $common-border-radius-100; +} +%common-border-radius-300{ + border-radius: $common-border-radius-300; +} +%common-border-radius-400{ + border-radius: $common-border-radius-400; +} +%common-border-radius-500{ + border-radius: $common-border-radius-500; +} +%common-border-radius-700{ + border-radius: $common-border-radius-700; +} +%common-border-radius-900{ + border-radius: $common-border-radius-900; +} +%common-border-radius-full{ + border-radius: $common-border-radius-full; +} \ No newline at end of file diff --git a/css/common/utils/helpers/_class-icon.scss b/css/common/utils/helpers/_class-icon.scss new file mode 100644 index 000000000..ccad38f3e --- /dev/null +++ b/css/common/utils/helpers/_class-icon.scss @@ -0,0 +1,8 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-class-icon--small--size: 32px !default; +$common-class-icon--medium--size: 48px !default; +$common-class-icon--large--size: 64px !default; \ No newline at end of file diff --git a/css/common/utils/helpers/_color.scss b/css/common/utils/helpers/_color.scss new file mode 100644 index 000000000..4b51bec46 --- /dev/null +++ b/css/common/utils/helpers/_color.scss @@ -0,0 +1,23 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-text-colors: ( + 'primary': $common-color-primary-800, + 'secondary': $common-color-secondary-800, + 'neutral': $common-color-secondary-800, + 'information': $common-color-information-800, + 'success': $common-color-success-800, + 'failure': $common-color-danger-800, + 'warning': $common-color-warning-800, + 'danger': $common-color-danger-800, + 'grey' : $common-color-grey-800, + 'blue-grey': $common-color-blue-grey-800, + 'blue': $common-color-blue-800, + 'cyan': $common-color-cyan-800, + 'green': $common-color-green-800, + 'orange': $common-color-orange-800, + 'red': $common-color-red-800, + 'pink': $common-color-pink-800, +) !default; diff --git a/css/common/utils/helpers/_depression.scss b/css/common/utils/helpers/_depression.scss new file mode 100644 index 000000000..f8a878102 --- /dev/null +++ b/css/common/utils/helpers/_depression.scss @@ -0,0 +1,8 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +%common-depression-100{ + box-shadow: $common-depression-100; +} \ No newline at end of file diff --git a/css/common/utils/helpers/_elevation.scss b/css/common/utils/helpers/_elevation.scss new file mode 100644 index 000000000..6394ad7fc --- /dev/null +++ b/css/common/utils/helpers/_elevation.scss @@ -0,0 +1,20 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +%common-elevation-100{ + box-shadow: $common-elevation-100; +} +%common-elevation-200{ + box-shadow: $common-elevation-200; +} +%common-elevation-300{ + box-shadow: $common-elevation-300; +} +%common-elevation-400{ + box-shadow: $common-elevation-400; +} +%common-elevation-500{ + box-shadow: $common-elevation-500; +} \ No newline at end of file diff --git a/css/common/utils/helpers/_font-icon.scss b/css/common/utils/helpers/_font-icon.scss new file mode 100644 index 000000000..3e90d2c75 --- /dev/null +++ b/css/common/utils/helpers/_font-icon.scss @@ -0,0 +1,43 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/******************************************************************************************************************************/ +/* NOTE: Those helpers allow to easily use an icon from libs. like FontAwesome or FontCombodo within a CSS rule (eg. ::after) */ +/* To use it, simply "@extend %fa-regular-base" in a rule and put the desired icon "content: '\f054'" */ +/******************************************************************************************************************************/ + +%fa-regular-base{ + font-family: "Font Awesome 5 Free"; + font-weight: 400; + + -webkit-font-smoothing: antialiased; + display: inline-block; + font-style: normal; + font-variant: normal; + text-rendering: auto; + line-height: 1; +} +%fa-solid-base{ + font-family: "Font Awesome 5 Free"; + font-weight: 900; + + -webkit-font-smoothing: antialiased; + display: inline-block; + font-style: normal; + font-variant: normal; + text-rendering: auto; + line-height: 1; +} +%fc-regular-base{ + display: inline-block; + font-family: CombodoRegular; + font-style: normal; + font-variant: normal; + font-weight: normal; + text-rendering: auto; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} \ No newline at end of file diff --git a/css/common/utils/helpers/_sticky-header.scss b/css/common/utils/helpers/_sticky-header.scss new file mode 100644 index 000000000..ec49acf30 --- /dev/null +++ b/css/common/utils/helpers/_sticky-header.scss @@ -0,0 +1,19 @@ +/*! + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/***********************************************************************/ +/* Sticky headers */ +/* */ +/* Used as a trigger to make an element stick to another during scroll */ +/***********************************************************************/ + +/* SCSS variables */ +$common-sticky-sentinel--left: 0 !default; +$common-sticky-sentinel--right: 0 !default; +$common-sticky-sentinel--height: 0 !default; +$common-sticky-sentinel-top--top: 0 !default; +$common-sticky-sentinel-top--height: $common-sticky-sentinel--height !default; +$common-sticky-sentinel-bottom--bottom: 0 !default; +$common-sticky-sentinel-bottom--height: $common-sticky-sentinel--height !default; diff --git a/css/common/utils/helpers/_text-decoration.scss b/css/common/utils/helpers/_text-decoration.scss new file mode 100644 index 000000000..5e67d9c7b --- /dev/null +++ b/css/common/utils/helpers/_text-decoration.scss @@ -0,0 +1,23 @@ +/*! + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* SCSS variables */ +$common-has-description--content: "?" !default; +$common-has-description--padding-left: $common-spacing-200 !default; +$common-has-description--color: $common-color-grey-600 !default; +$common-has-description--font-size: 0.7em !default; /* Font size is em on purpose as we want it to be proportional to its context */ + +$common-is-code--background-color: $common-color-white-200 !default; +$common-is-code--padding: 1.25rem 1.5rem !default; + +$common-hyperlink-color: $common-color-primary-700 !default; +$common-hyperlink-text-decoration: none !default; +$common-hyperlink-color--on-hover: $common-color-primary-800 !default; +$common-hyperlink-text-decoration--on-hover: $common-hyperlink-text-decoration !default; +$common-hyperlink-color--on-active: $common-color-primary-900 !default; +$common-hyperlink-text-decoration--on-active: $common-hyperlink-text-decoration !default; + +$common-figure--spacing-x: 2em !default; /* Mind that this matches Bulma rule for figure */ +$common-figure--spacing-y: 2em !default; diff --git a/css/common/utils/helpers/_text-position.scss b/css/common/utils/helpers/_text-position.scss new file mode 100644 index 000000000..412a6ee73 --- /dev/null +++ b/css/common/utils/helpers/_text-position.scss @@ -0,0 +1,34 @@ +/*! + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/****************************/ +/* Disposition / alignement */ +/****************************/ +.common-is-fullwidth { + width: 100%; +} + +%common-fully-centered-content { + display: flex; + justify-content: center; + align-items: center; +} + +%common-vertically-centered-content { + display: flex; + align-items: center; +} + +/* Typically to align icons and text as it is a good practice to align them on the baseline and not the "middle" */ +%common-baseline-centered-content { + display: flex; + align-items: baseline; +} + +/* Note: This might not be named correctly. The intention is to make an element occupy the full height of its parent and to be centered in it */ +%common-full-height-content { + display: flex; + align-items: stretch; +} \ No newline at end of file diff --git a/css/common/utils/helpers/_typography.scss b/css/common/utils/helpers/_typography.scss new file mode 100644 index 000000000..9c965f859 --- /dev/null +++ b/css/common/utils/helpers/_typography.scss @@ -0,0 +1,745 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* + * SCSS helpers for font sizes (use in SCSS files) + * + * Use them to only redefine the font size instead of the global font defnition, this way if the container's font changes + * the other properties will be propagated (weight, style) + * + * Usage: @extend %common-font-size-XXX; + */ +%common-font-size-50 { + font-size: $common-font-size-50; +} +%common-font-size-100 { + font-size: $common-font-size-100; +} +%common-font-size-150 { + font-size: $common-font-size-150; +} +%common-font-size-200 { + font-size: $common-font-size-200; +} +%common-font-size-250 { + font-size: $common-font-size-250; +} +%common-font-size-300 { + font-size: $common-font-size-300; +} +%common-font-size-350 { + font-size: $common-font-size-350; +} +%common-font-size-400 { + font-size: $common-font-size-400; +} +%common-font-size-450 { + font-size: $common-font-size-450; +} +%common-font-size-500 { + font-size: $common-font-size-500; +} +%common-font-size-550 { + font-size: $common-font-size-550; +} + +/* + * SCSS helpers for font weights (use in SCSS files) + * + * Use them to only redefine the font weight instead of the global font defnition, this way if the container's font changes + * the other properties will be propagated (size, style) + * + * Usage: @extend %common-font-weight-XXX; + */ +%common-font-weight-100 { + font-weight: $common-font-weight-100; +} +%common-font-weight-200 { + font-weight: $common-font-weight-200; +} +%common-font-weight-300 { + font-weight: $common-font-weight-300; +} +%common-font-weight-400 { + font-weight: $common-font-weight-400; +} +%common-font-weight-500 { + font-weight: $common-font-weight-500; +} +%common-font-weight-600 { + font-weight: $common-font-weight-600; +} +%common-font-weight-700 { + font-weight: $common-font-weight-700; +} +%common-font-weight-800 { + font-weight: $common-font-weight-800; +} +%common-font-weight-900 { + font-weight: $common-font-weight-900; +} +%common-font-weight-950 { + font-weight: $common-font-weight-950; +} + +/* + * SCSS helpers for global font definition (use in SCSS files) + * + * Use this only when you want to completely redefine the font, otherwise use the other helpers above + * + * Usage: @extend %common-font-XXX-YYY; + */ +%common-font-ral-nor-50 { + font-size: $common-font-size-50; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-100 { + font-size: $common-font-size-100; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-150 { + font-size: $common-font-size-150; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-200 { + font-size: $common-font-size-200; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-250 { + font-size: $common-font-size-250; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-300 { + font-size: $common-font-size-300; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-350 { + font-size: $common-font-size-350; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-400 { + font-size: $common-font-size-400; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-450 { + font-size: $common-font-size-450; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-500 { + font-size: $common-font-size-500; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-nor-550 { + font-size: $common-font-size-550; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-50 { + font-size: $common-font-size-50; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-100 { + font-size: $common-font-size-100; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-150 { + font-size: $common-font-size-150; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-200 { + font-size: $common-font-size-200; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-250 { + font-size: $common-font-size-250; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-300 { + font-size: $common-font-size-300; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-350 { + font-size: $common-font-size-350; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-400 { + font-size: $common-font-size-400; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-450 { + font-size: $common-font-size-450; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-500 { + font-size: $common-font-size-500; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-med-550 { + font-size: $common-font-size-550; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-500; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-50 { + font-size: $common-font-size-50; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-100 { + font-size: $common-font-size-100; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-150 { + font-size: $common-font-size-150; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-200 { + font-size: $common-font-size-200; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-250 { + font-size: $common-font-size-250; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-300 { + font-size: $common-font-size-300; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-350 { + font-size: $common-font-size-350; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-400 { + font-size: $common-font-size-400; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-450 { + font-size: $common-font-size-450; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-500 { + font-size: $common-font-size-500; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-bol-550 { + font-size: $common-font-size-550; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-700; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-50 { + font-size: $common-font-size-50; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-100 { + font-size: $common-font-size-100; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-150 { + font-size: $common-font-size-150; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-200 { + font-size: $common-font-size-200; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-250 { + font-size: $common-font-size-250; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-300 { + font-size: $common-font-size-300; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-350 { + font-size: $common-font-size-350; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-400 { + font-size: $common-font-size-400; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-450 { + font-size: $common-font-size-450; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-500 { + font-size: $common-font-size-500; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-sembol-550 { + font-size: $common-font-size-550; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-600; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-50 { + font-size: $common-font-size-50; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-100 { + font-size: $common-font-size-100; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-150 { + font-size: $common-font-size-150; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-200 { + font-size: $common-font-size-200; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-250 { + font-size: $common-font-size-250; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-300 { + font-size: $common-font-size-300; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-350 { + font-size: $common-font-size-350; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-400 { + font-size: $common-font-size-400; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-450 { + font-size: $common-font-size-450; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} +%common-font-ral-ita-500 { + font-size: $common-font-size-500; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} + +%common-font-ral-ita-550 { + font-size: $common-font-size-550; + font-family: $common-font-family-base, $common-font-family-fallbacks; + font-weight: $common-font-weight-400; + font-style: italic; + -webkit-font-feature-settings: "lnum"; + -moz-font-feature-settings: "lnum"; + font-feature-settings: "lnum"; +} + +%common-font-code-50 { + font-size: $common-font-size-50; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-100 { + font-size: $common-font-size-100; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-150 { + font-size: $common-font-size-150; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-200 { + font-size: $common-font-size-200; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-250 { + font-size: $common-font-size-250; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-300 { + font-size: $common-font-size-300; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-350 { + font-size: $common-font-size-350; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-400 { + font-size: $common-font-size-400; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-450 { + font-size: $common-font-size-450; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-500 { + font-size: $common-font-size-500; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +%common-font-code-550 { + font-size: $common-font-size-550; + font-family: $common-font-family-code; + font-weight: $common-font-weight-400; +} + +/* + * CSS classes for font sizes (use in HTML markup, JS scripts) + * + * Use them to only redefine the font size instead of the global font defnition, this way if the container's font changes + * the other properties will be propagated (weight, style) + * + * Usage: .common-font-size-XXX; + */ +$common-font-sizes: ( + 'common-font-size-50', + 'common-font-size-100', + 'common-font-size-150', + 'common-font-size-200', + 'common-font-size-250', + 'common-font-size-300', + 'common-font-size-350', + 'common-font-size-400', + 'common-font-size-450', + 'common-font-size-500', + 'common-font-size-550' +); +@each $sFontSize in $common-font-sizes { + .#{$sFontSize} { + @extend %#{$sFontSize}; + } +} + +/* + * CSS classes for font weights (use in HTML markup, JS scripts) + * + * Use them to only redefine the font weight instead of the global font defnition, this way if the container's font changes + * the other properties will be propagated (size, style) + * + * Usage: .common-font-weight-XXX; + */ +$common-font-weights: ( + 'common-font-weight-100', + 'common-font-weight-200', + 'common-font-weight-300', + 'common-font-weight-400', + 'common-font-weight-500', + 'common-font-weight-600', + 'common-font-weight-700', + 'common-font-weight-800', + 'common-font-weight-900', + 'common-font-weight-950' +); +@each $sFontWeight in $common-font-weights { + .#{$sFontWeight} { + @extend %#{$sFontWeight}; + } +} + +/* + * CSS classes for global font wrappers (use in HTML markup, JS scripts) + * + * Use this only when you want to completely redefine the font, otherwise use the other helpers + * + * Usage: .common-font-XXX-YYY; + */ +$common-fonts-all: ( + 'common-font-ral-nor-50', + 'common-font-ral-nor-100', + 'common-font-ral-nor-150', + 'common-font-ral-nor-200', + 'common-font-ral-nor-250', + 'common-font-ral-nor-300', + 'common-font-ral-nor-350', + 'common-font-ral-nor-400', + 'common-font-ral-nor-450', + 'common-font-ral-nor-500', + 'common-font-ral-nor-550', + 'common-font-ral-med-50', + 'common-font-ral-med-100', + 'common-font-ral-med-150', + 'common-font-ral-med-200', + 'common-font-ral-med-250', + 'common-font-ral-med-300', + 'common-font-ral-med-350', + 'common-font-ral-med-400', + 'common-font-ral-med-450', + 'common-font-ral-med-500', + 'common-font-ral-med-550', + 'common-font-ral-bol-50', + 'common-font-ral-bol-100', + 'common-font-ral-bol-150', + 'common-font-ral-bol-200', + 'common-font-ral-bol-250', + 'common-font-ral-bol-300', + 'common-font-ral-bol-350', + 'common-font-ral-bol-400', + 'common-font-ral-bol-450', + 'common-font-ral-bol-500', + 'common-font-ral-bol-550', + 'common-font-ral-sembol-50', + 'common-font-ral-sembol-100', + 'common-font-ral-sembol-150', + 'common-font-ral-sembol-200', + 'common-font-ral-sembol-250', + 'common-font-ral-sembol-300', + 'common-font-ral-sembol-350', + 'common-font-ral-sembol-400', + 'common-font-ral-sembol-450', + 'common-font-ral-sembol-500', + 'common-font-ral-sembol-550', + 'common-font-ral-ita-50', + 'common-font-ral-ita-100', + 'common-font-ral-ita-150', + 'common-font-ral-ita-200', + 'common-font-ral-ita-250', + 'common-font-ral-ita-300', + 'common-font-ral-ita-350', + 'common-font-ral-ita-400', + 'common-font-ral-ita-450', + 'common-font-ral-ita-500', + 'common-font-ral-ita-550', + 'common-font-code-50', + 'common-font-code-100', + 'common-font-code-150', + 'common-font-code-200', + 'common-font-code-250', + 'common-font-code-300', + 'common-font-code-350', + 'common-font-code-400', + 'common-font-code-450', + 'common-font-code-500', + 'common-font-code-550' +); +@each $sFont in $common-fonts-all { + .#{$sFont} { + @extend %#{$sFont}; + } +} \ No newline at end of file diff --git a/css/common/utils/mixins/_all.scss b/css/common/utils/mixins/_all.scss new file mode 100644 index 000000000..f87007f3b --- /dev/null +++ b/css/common/utils/mixins/_all.scss @@ -0,0 +1,7 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "highlight"; +@import "selectable"; \ No newline at end of file diff --git a/css/common/utils/mixins/_highlight.scss b/css/common/utils/mixins/_highlight.scss new file mode 100644 index 000000000..66a065221 --- /dev/null +++ b/css/common/utils/mixins/_highlight.scss @@ -0,0 +1,17 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-vertical-highlight--width: $common-size-100; +$common-vertical-highlight--height: 100%; + +@mixin common-vertical-highlight { + display: block; + position: absolute; + top: 0; + left: 0; + content: ""; + width: $common-vertical-highlight--width; + height: $common-vertical-highlight--height; +} \ No newline at end of file diff --git a/css/common/utils/mixins/_selectable.scss b/css/common/utils/mixins/_selectable.scss new file mode 100644 index 000000000..6bd2a5e5a --- /dev/null +++ b/css/common/utils/mixins/_selectable.scss @@ -0,0 +1,40 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SARL + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-selectable--background-color: transparent !default; + +$common-selectable--hover--color: $common-color-grey-100 !default; +$common-selectable--hover--background-color: $common-color-grey-600 !default; +$common-selectable--hover--background-opacity: 0.6 !default; + +$common-selected--color: $common-color-grey-100 !default; +$common-selected--background-color: $common-color-grey-900 !default; +$common-selected--background-opacity: 0.5 !default; + +$common-selected--hover--background-color: $common-color-grey-700 !default; +$common-selected--hover--background-opacity: 0.5 !default; +@mixin common-selectable { + content: ' '; + @extend %fa-solid-base; + background-color: $common-selectable--background-color; + cursor: pointer; +} +@mixin common-selectable-hover { + @extend %fa-regular-base; + content: '\f058'; + color: $common-selectable--hover--color; + background-color: transparentize($common-selectable--hover--background-color, $common-selectable--hover--background-opacity); +} + +@mixin common-selected { + @extend %fa-solid-base; + content: '\f058'; + color: $common-selected--color; + background-color: transparentize($common-selected--background-color, $common-selected--background-opacity); +} + +@mixin common-selected-hover { + background-color: transparentize($common-selected--hover--background-color, $common-selected--hover--background-opacity); +} \ No newline at end of file diff --git a/css/common/utils/variables/_all.scss b/css/common/utils/variables/_all.scss new file mode 100644 index 000000000..2f0be82f6 --- /dev/null +++ b/css/common/utils/variables/_all.scss @@ -0,0 +1,15 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "colors/all"; +@import "border-radius"; +@import "depression"; +@import "elevation"; +@import "path"; +@import "size"; +@import "spacing"; +@import "typography"; +// Important: Keep this partial last as it includes variables from the previous partials +@import "base"; diff --git a/css/common/utils/variables/_base.scss b/css/common/utils/variables/_base.scss new file mode 100644 index 000000000..b306db378 --- /dev/null +++ b/css/common/utils/variables/_base.scss @@ -0,0 +1,9 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +// These are the base variables used throughout the backoffice, if you don't know what to use, these are probably good :) + +$common-base-variable--text-color: $common-color-grey-900 !default; +$common-base-variable--border-radius: $common-border-radius-300 !default;; \ No newline at end of file diff --git a/css/common/utils/variables/_border-radius.scss b/css/common/utils/variables/_border-radius.scss new file mode 100644 index 000000000..823f8d765 --- /dev/null +++ b/css/common/utils/variables/_border-radius.scss @@ -0,0 +1,12 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-border-radius-100: 1px !default; +$common-border-radius-300: 3px !default; +$common-border-radius-400: 4px !default; +$common-border-radius-500: 5px !default; +$common-border-radius-700: 10px !default; +$common-border-radius-900: 16px !default; +$common-border-radius-full: 100% !default; \ No newline at end of file diff --git a/css/common/utils/variables/_depression.scss b/css/common/utils/variables/_depression.scss new file mode 100644 index 000000000..ee1d270fa --- /dev/null +++ b/css/common/utils/variables/_depression.scss @@ -0,0 +1,6 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-depression-100: inset 0 1px 1px 0 rgba(0, 0, 0, 0.15) !default; \ No newline at end of file diff --git a/css/common/utils/variables/_elevation.scss b/css/common/utils/variables/_elevation.scss new file mode 100644 index 000000000..d9d86ae14 --- /dev/null +++ b/css/common/utils/variables/_elevation.scss @@ -0,0 +1,10 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-elevation-100: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.12) !default; +$common-elevation-200: 0 2px 4px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.15) !default; +$common-elevation-300: 0 3px 6px rgba(0, 0, 0, 0.10), 0 10px 20px rgba(0, 0, 0, 0.15) !default; +$common-elevation-400: 0 5px 10px rgba(0, 0, 0, 0.05), 0 15px 25px rgba(0, 0, 0, 0.15) !default; +$common-elevation-500: 0 20px 40px rgba(0, 0, 0, 0.20) !default; diff --git a/css/common/utils/variables/_path.scss b/css/common/utils/variables/_path.scss new file mode 100644 index 000000000..251b155d7 --- /dev/null +++ b/css/common/utils/variables/_path.scss @@ -0,0 +1,6 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$approot-relative: '../../../../' !default; diff --git a/css/common/utils/variables/_size.scss b/css/common/utils/variables/_size.scss new file mode 100644 index 000000000..12cfb9827 --- /dev/null +++ b/css/common/utils/variables/_size.scss @@ -0,0 +1,24 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-size-0: 0 !default; +$common-size-50: 2px !default; +$common-size-100: 4px !default; +$common-size-150: 8px !default; +$common-size-200: 12px !default; +$common-size-250: 16px !default; +$common-size-300: 24px !default; +$common-size-350: 32px !default; +$common-size-400: 48px !default; +$common-size-450: 64px !default; +$common-size-500: 96px !default; +$common-size-550: 128px !default; +$common-size-600: 192px !default; +$common-size-650: 256px !default; +$common-size-700: 384px !default; +$common-size-750: 512px !default; +$common-size-800: 640px !default; +$common-size-850: 768px !default; +$common-size-900: 896px !default; diff --git a/css/common/utils/variables/_spacing.scss b/css/common/utils/variables/_spacing.scss new file mode 100644 index 000000000..4d22d7bb1 --- /dev/null +++ b/css/common/utils/variables/_spacing.scss @@ -0,0 +1,16 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +$common-spacing-0: $common-size-0 !default; +$common-spacing-100: $common-size-50 !default; +$common-spacing-200: $common-size-100 !default; +$common-spacing-300: $common-size-150 !default; +$common-spacing-400: $common-size-200 !default; +$common-spacing-500: $common-size-250 !default; +$common-spacing-600: $common-size-300 !default; +$common-spacing-700: $common-size-350 !default; +$common-spacing-800: $common-size-400 !default; +$common-spacing-900: $common-size-450 !default; +$common-spacing-950: $common-size-500 !default; diff --git a/css/common/utils/variables/_typography.scss b/css/common/utils/variables/_typography.scss new file mode 100644 index 000000000..6b284f5d2 --- /dev/null +++ b/css/common/utils/variables/_typography.scss @@ -0,0 +1,38 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* Base size: html font-size 12px */ +$common-font-size-20: 0.67rem !default; /* 8px */ +$common-font-size-50: 0.83rem !default; /* 10px */ +$common-font-size-100: 1rem !default; /* 12px */ +$common-font-size-150: 1.17rem !default; /* 14px */ +$common-font-size-200: 1.33rem !default; /* 16px */ +$common-font-size-250: 1.5rem !default; /* 18px */ +$common-font-size-300: 1.67rem !default; /* 20px */ +$common-font-size-350: 1.83rem !default; /* 22px */ +$common-font-size-400: 2rem !default; /* 24px */ +$common-font-size-450: 2.5rem !default; /* 30px */ +$common-font-size-500: 3rem !default; /* 36px */ +$common-font-size-550: 4rem !default; /* 48px */ +$common-font-size-600: 5rem !default; /* 60px */ +$common-font-size-650: 6rem !default; /* 72px */ +$common-font-size-700: 7rem !default; /* 84px */ + +/* Value Common weight name (https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) */ +$common-font-weight-100: 100 !default; /* 100 Thin (Harline) */ +$common-font-weight-200: 200 !default; /* 200 Extra Light (Ultra Light) */ +$common-font-weight-300: 300 !default; /* 300 Light */ +$common-font-weight-400: 400 !default; /* 400 Normal (Regular) */ +$common-font-weight-500: 500 !default; /* 500 Medium */ +$common-font-weight-600: 600 !default; /* 600 Semi Bold (Demi Bold) */ +$common-font-weight-700: 700 !default; /* 700 Bold */ +$common-font-weight-800: 800 !default; /* 800 Extra Bold (Ultra Bold) */ +$common-font-weight-900: 900 !default; /* 900 Black (Heavy) */ +$common-font-weight-950: 950 !default; /* 950 Extra Black (Ultra Black) */ + +$common-font-family-base: "Raleway" !default; +$common-font-family-fallbacks: "sans-serif", "system-ui" !default; +$common-font-family-monospace: monospace !default; +$common-font-family-code: $common-font-family-monospace !default; diff --git a/css/common/utils/variables/colors/_all.scss b/css/common/utils/variables/colors/_all.scss new file mode 100644 index 000000000..e6441601e --- /dev/null +++ b/css/common/utils/variables/colors/_all.scss @@ -0,0 +1,10 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +@import "base"; +@import "base-palette"; +@import "semantic-palette"; +@import "lifecycle-palette"; +@import "skeleton-palette"; \ No newline at end of file diff --git a/css/common/utils/variables/colors/_base-palette.scss b/css/common/utils/variables/colors/_base-palette.scss new file mode 100644 index 000000000..16e73d134 --- /dev/null +++ b/css/common/utils/variables/colors/_base-palette.scss @@ -0,0 +1,102 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* Base color palettes */ +$common-color-white-100: hsla(0, 0%, 100%, 1) !default; +$common-color-white-200: hsla(0, 0%, 94.9%, 1) !default; +$common-color-transparent: hsla(0, 0%, 100%, 0) !default; + +$common-color-grey-50: hsla(240, 20%, 99%, 1) !default; +$common-color-grey-100: hsla(210, 16.7%, 97.6%, 1) !default; +$common-color-grey-200: hsla(207, 22.4%, 90.4%, 1) !default; +$common-color-grey-300: hsla(210, 23.5%, 86.7%, 1) !default; +$common-color-grey-400: hsla(208, 17.2%, 82.9%, 1) !default; +$common-color-grey-500: hsla(209, 23.7%, 74.3%, 1) !default; +$common-color-grey-600: hsla(215, 16.6%, 63.3%, 1) !default; +$common-color-grey-700: hsla(214, 11.3%, 48.6%, 1) !default; +$common-color-grey-800: hsla(215, 16.9%, 30.2%, 1) !default; +$common-color-grey-900: hsla(215, 22.4%, 16.7%, 1) !default; +$common-color-grey-950: hsla(215, 26.4%, 10.7%, 1) !default; + +$common-color-blue-grey-50: hsla(210, 36%, 96%, 1) !default; +$common-color-blue-grey-100: hsla(198, 15.7%, 83.7%, 1) !default; +$common-color-blue-grey-200: hsla(200, 15.3%, 73.1%, 1) !default; +$common-color-blue-grey-300: hsla(200, 15.6%, 62.4%, 1) !default; +$common-color-blue-grey-400: hsla(200, 15.4%, 54.1%, 1) !default; +$common-color-blue-grey-500: hsla(200, 18.3%, 46.1%, 1) !default; +$common-color-blue-grey-600: hsla(199, 18.4%, 40.4%, 1) !default; +$common-color-blue-grey-700: hsla(199, 18.3%, 33.1%, 1) !default; +$common-color-blue-grey-800: hsla(200, 17.9%, 26.3%, 1) !default; +$common-color-blue-grey-900: hsla(200, 19.1%, 18.4%, 1) !default; +$common-color-blue-grey-950: hsla(200, 20.2%, 13.1%, 1) !default; + +$common-color-blue-100: hsla(201, 100%, 96.1%, 1) !default; +$common-color-blue-200: hsla(202, 80.6%, 85.9%, 1) !default; +$common-color-blue-300: hsla(203, 82%, 76.1%, 1) !default; +$common-color-blue-400: hsla(205, 79.3%, 65.9%, 1) !default; +$common-color-blue-500: hsla(207, 72.6%, 57.1%, 1) !default; +$common-color-blue-600: hsla(209, 61.6%, 50%, 1) !default; +$common-color-blue-700: hsla(211, 60.7%, 42.9%, 1) !default; +$common-color-blue-800: hsla(213, 49.4%, 34.1%, 1) !default; +$common-color-blue-900: hsla(215, 41.3%, 28%, 1) !default; +$common-color-blue-950: hsla(215, 36.8%, 23%, 1) !default; + +$common-color-cyan-100: hsla(186, 61.2%, 86.9%, 1) !default; +$common-color-cyan-200: hsla(187, 71.6%, 71%, 1) !default; +$common-color-cyan-300: hsla(187, 71.2%, 59.2%, 1) !default; +$common-color-cyan-400: hsla(187, 70.9%, 50.2%, 1) !default; +$common-color-cyan-500: hsla(187, 100%, 41.6%, 1) !default; +$common-color-cyan-600: hsla(187, 100%, 37.8%, 1) !default; +$common-color-cyan-700: hsla(186, 100%, 32.7%, 1) !default; +$common-color-cyan-800: hsla(185, 100%, 28%, 1) !default; +$common-color-cyan-900: hsla(182, 100%, 19.6%, 1) !default; +$common-color-cyan-950: hsla(180, 100%, 10.6%, 1) !default; + +$common-color-green-100: hsla(88, 50.7%, 85.7%, 1) !default; +$common-color-green-200: hsla(88, 50%, 76.5%, 1) !default; +$common-color-green-300: hsla(88, 50%, 67.1%, 1) !default; +$common-color-green-400: hsla(88, 50.2%, 59.8%, 1) !default; +$common-color-green-500: hsla(88, 50.2%, 52.7%, 1) !default; +$common-color-green-600: hsla(89, 46.1%, 48%, 1) !default; +$common-color-green-700: hsla(92, 47.9%, 42.2%, 1) !default; +$common-color-green-800: hsla(95, 49.5%, 36.5%, 1) !default; +$common-color-green-900: hsla(103, 55.6%, 26.5%, 1) !default; +$common-color-green-950: hsla(108, 59.6%, 21.5%, 1) !default; + + +$common-color-orange-100: hsla(40, 100%, 97.1%, 1) !default; +$common-color-orange-200: hsla(39, 96.4%, 89%, 1) !default; +$common-color-orange-300: hsla(38, 93.2%, 76.9%, 1) !default; +$common-color-orange-400: hsla(33, 89.9%, 64.9%, 1) !default; +$common-color-orange-500: hsla(28, 82.9%, 51.8%, 1) !default; +$common-color-orange-600: hsla(24, 74.7%, 49.6%, 1) !default; +$common-color-orange-700: hsla(20, 70.7%, 44.1%, 1) !default; +$common-color-orange-800: hsla(16, 65.1%, 37.1%, 1) !default; +$common-color-orange-900: hsla(14, 60.8%, 30%, 1) !default; +$common-color-orange-950: hsla(14, 55.1%, 22%, 1) !default; + +$common-color-red-100: hsla(0, 76.9%, 94.9%, 1) !default; +$common-color-red-200: hsla(0, 95.1%, 92%, 1) !default; +$common-color-red-300: hsla(0, 97.4%, 84.7%, 1) !default; +$common-color-red-400: hsla(0, 95.3%, 74.7%, 1) !default; +$common-color-red-500: hsla(0, 87.8%, 67.8%, 1) !default; +$common-color-red-600: hsla(0, 76.3%, 57.1%, 1) !default; +$common-color-red-700: hsla(0, 60.8%, 48%, 1) !default; +$common-color-red-800: hsla(0, 55.8%, 39%, 1) !default; +$common-color-red-900: hsla(0, 46.8%, 31%, 1) !default; +$common-color-red-950: hsla(0, 42.9%, 20%, 1) !default; + +$common-color-pink-100: hsla(348, 100%, 98%, 1) !default; +$common-color-pink-200: hsla(343, 95%, 92%, 1) !default; +$common-color-pink-300: hsla(339, 90%, 85%, 1) !default; +$common-color-pink-400: hsla(336, 86%, 75%, 1) !default; +$common-color-pink-500: hsla(331, 79%, 66%, 1) !default; +$common-color-pink-600: hsla(329, 64%, 54%, 1) !default; +$common-color-pink-700: hsla(325, 57%, 46%, 1) !default; +$common-color-pink-800: hsla(322, 60%, 37%, 1) !default; +$common-color-pink-900: hsla(318, 51%, 29%, 1) !default; +$common-color-pink-950: hsla(318, 51%, 21%, 1) !default; + +$common-colors: ('grey', 'blue-grey', 'blue', 'cyan', 'green', 'orange', 'red', 'pink', 'primary', 'secondary', 'information', 'success', 'warning', 'danger'); \ No newline at end of file diff --git a/css/common/utils/variables/colors/_base.scss b/css/common/utils/variables/colors/_base.scss new file mode 100644 index 000000000..3eab9bca3 --- /dev/null +++ b/css/common/utils/variables/colors/_base.scss @@ -0,0 +1,12 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* Base helpers for colors */ +/* - These lightness vars are used to force a certain lightness on HSLA colors */ +$common-color-base-lightness-100: 93% !default; +$common-color-base-lightness-900: 15% !default; + +$common-color-base-opacity-for-lightness-100: 1 !default; +$common-color-base-opacity-for-lightness-900: 1 !default; \ No newline at end of file diff --git a/css/common/utils/variables/colors/_lifecycle-palette.scss b/css/common/utils/variables/colors/_lifecycle-palette.scss new file mode 100644 index 000000000..7a17ac539 --- /dev/null +++ b/css/common/utils/variables/colors/_lifecycle-palette.scss @@ -0,0 +1,61 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* Lifecycle palette */ +/* - For workflow */ +$common-lifecycle-new-state-primary-color: $common-color-blue-800 !default; +$common-lifecycle-new-state-secondary-color: $common-color-white-100 !default; +$common-lifecycle-neutral-state-primary-color: $common-color-blue-800 !default; +$common-lifecycle-neutral-state-secondary-color: $common-color-white-100 !default; +$common-lifecycle-waiting-state-primary-color: $common-color-orange-400 !default; +$common-lifecycle-waiting-state-secondary-color: $common-color-white-100 !default; +$common-lifecycle-success-state-primary-color: $common-color-green-700 !default; +$common-lifecycle-success-state-secondary-color: $common-color-white-100 !default; +$common-lifecycle-failure-state-primary-color: $common-color-pink-700 !default; +$common-lifecycle-failure-state-secondary-color: $common-color-white-100 !default; +$common-lifecycle-frozen-state-primary-color: $common-color-grey-200 !default; +$common-lifecycle-frozen-state-secondary-color: $common-color-grey-700 !default; + +/* - For basic lifecycle */ +$common-lifecycle-active-state-primary-color: $common-color-green-700 !default; +$common-lifecycle-active-state-secondary-color: $common-color-white-100 !default; +$common-lifecycle-inactive-state-primary-color: $common-color-orange-400 !default; +$common-lifecycle-inactive-state-secondary-color: $common-color-white-100 !default; + +$common-lifecycle-states-colors: ( + 'new': ( + 'primary-color': $common-lifecycle-new-state-primary-color, + 'secondary-color': $common-lifecycle-new-state-secondary-color, + ), + 'neutral': ( + 'primary-color': $common-lifecycle-neutral-state-primary-color, + 'secondary-color': $common-lifecycle-neutral-state-secondary-color, + ), + 'waiting': ( + 'primary-color': $common-lifecycle-waiting-state-primary-color, + 'secondary-color': $common-lifecycle-waiting-state-secondary-color, + ), + 'success': ( + 'primary-color': $common-lifecycle-success-state-primary-color, + 'secondary-color': $common-lifecycle-success-state-secondary-color, + ), + 'failure': ( + 'primary-color': $common-lifecycle-failure-state-primary-color, + 'secondary-color': $common-lifecycle-failure-state-secondary-color, + ), + 'frozen': ( + 'primary-color': $common-lifecycle-frozen-state-primary-color, + 'secondary-color': $common-lifecycle-frozen-state-secondary-color, + ), + + 'active': ( + 'primary-color': $common-lifecycle-active-state-primary-color, + 'secondary-color': $common-lifecycle-active-state-secondary-color, + ), + 'inactive': ( + 'primary-color': $common-lifecycle-inactive-state-primary-color, + 'secondary-color': $common-lifecycle-inactive-state-secondary-color, + ), +); \ No newline at end of file diff --git a/css/common/utils/variables/colors/_semantic-palette.scss b/css/common/utils/variables/colors/_semantic-palette.scss new file mode 100644 index 000000000..030ea787e --- /dev/null +++ b/css/common/utils/variables/colors/_semantic-palette.scss @@ -0,0 +1,100 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* Semantic palettes */ +/* - Primary color of the brand */ +$common-color-primary-100: $common-color-blue-100 !default; +$common-color-primary-200: $common-color-blue-200 !default; +$common-color-primary-300: $common-color-blue-300 !default; +$common-color-primary-400: $common-color-blue-400 !default; +$common-color-primary-500: $common-color-blue-500 !default; +$common-color-primary-600: $common-color-blue-600 !default; +$common-color-primary-700: $common-color-blue-700 !default; +$common-color-primary-800: $common-color-blue-800 !default; +$common-color-primary-900: $common-color-blue-900 !default; +$common-color-primary-950: $common-color-blue-950 !default; + +/* - Secondary color of the brand */ +$common-color-secondary-100: $common-color-grey-100 !default; +$common-color-secondary-200: $common-color-grey-200 !default; +$common-color-secondary-300: $common-color-grey-300 !default; +$common-color-secondary-400: $common-color-grey-400 !default; +$common-color-secondary-500: $common-color-grey-500 !default; +$common-color-secondary-600: $common-color-grey-600 !default; +$common-color-secondary-700: $common-color-grey-700 !default; +$common-color-secondary-800: $common-color-grey-800 !default; +$common-color-secondary-900: $common-color-grey-900 !default; +$common-color-secondary-950: $common-color-grey-950 !default; + +/* - Information: messages / actions that should neither seem as success, warning or failure */ +$common-color-information-100: $common-color-blue-100 !default; +$common-color-information-200: $common-color-blue-200 !default; +$common-color-information-300: $common-color-blue-300 !default; +$common-color-information-400: $common-color-blue-400 !default; +$common-color-information-500: $common-color-blue-500 !default; +$common-color-information-600: $common-color-blue-600 !default; +$common-color-information-700: $common-color-blue-700 !default; +$common-color-information-800: $common-color-blue-800 !default; +$common-color-information-900: $common-color-blue-900 !default; +$common-color-information-950: $common-color-blue-950 !default; + +/* Success: messages of success, safe actions, ... */ +$common-color-success-100: $common-color-green-100 !default; +$common-color-success-200: $common-color-green-200 !default; +$common-color-success-300: $common-color-green-300 !default; +$common-color-success-400: $common-color-green-400 !default; +$common-color-success-500: $common-color-green-500 !default; +$common-color-success-600: $common-color-green-600 !default; +$common-color-success-700: $common-color-green-700 !default; +$common-color-success-800: $common-color-green-800 !default; +$common-color-success-900: $common-color-green-900 !default; +$common-color-success-950: $common-color-green-950 !default; + +/* Warning: messages of warning, actions that would be done carefully, ... */ +$common-color-warning-100: $common-color-orange-100 !default; +$common-color-warning-200: $common-color-orange-200 !default; +$common-color-warning-300: $common-color-orange-300 !default; +$common-color-warning-400: $common-color-orange-400 !default; +$common-color-warning-500: $common-color-orange-500 !default; +$common-color-warning-600: $common-color-orange-600 !default; +$common-color-warning-700: $common-color-orange-700 !default; +$common-color-warning-800: $common-color-orange-800 !default; +$common-color-warning-900: $common-color-orange-900 !default; +$common-color-warning-950: $common-color-orange-950 !default; + +/* Danger: messages of failure, error, ... */ +$common-color-error-100: $common-color-red-100 !default; +$common-color-error-200: $common-color-red-200 !default; +$common-color-error-300: $common-color-red-300 !default; +$common-color-error-400: $common-color-red-400 !default; +$common-color-error-500: $common-color-red-500 !default; +$common-color-error-600: $common-color-red-600 !default; +$common-color-error-700: $common-color-red-700 !default; +$common-color-error-800: $common-color-red-800 !default; +$common-color-error-900: $common-color-red-900 !default; +$common-color-error-950: $common-color-red-950 !default; + +/* Danger: messages of danger, actions that cannot be undone, ... */ +$common-color-danger-100: $common-color-red-100 !default; +$common-color-danger-200: $common-color-red-200 !default; +$common-color-danger-300: $common-color-red-300 !default; +$common-color-danger-400: $common-color-red-400 !default; +$common-color-danger-500: $common-color-red-500 !default; +$common-color-danger-600: $common-color-red-600 !default; +$common-color-danger-700: $common-color-red-700 !default; +$common-color-danger-800: $common-color-red-800 !default; +$common-color-danger-900: $common-color-red-900 !default; +$common-color-danger-950: $common-color-red-950 !default; + +$common-semantic-colors: ('primary', 'secondary', 'information', 'success', 'warning', 'danger'); + +$common-caselog-highlight-color-1: $common-color-green-700 !default; +$common-caselog-highlight-color-2: $common-color-pink-700 !default; +$common-caselog-highlight-color-3: $common-color-orange-400 !default; +$common-caselog-highlight-color-4: $common-color-blue-600 !default; +$common-caselog-highlight-color-5: $common-color-cyan-200 !default; +$common-caselog-highlight-color-6: $common-color-green-200 !default; +$common-caselog-highlight-color-7: $common-color-pink-300 !default; +$common-caselog-highlight-colors: ($common-caselog-highlight-color-1, $common-caselog-highlight-color-2, $common-caselog-highlight-color-3, $common-caselog-highlight-color-4, $common-caselog-highlight-color-5, $common-caselog-highlight-color-6, $common-caselog-highlight-color-7) !default; diff --git a/css/common/utils/variables/colors/_skeleton-palette.scss b/css/common/utils/variables/colors/_skeleton-palette.scss new file mode 100644 index 000000000..3aedc2c90 --- /dev/null +++ b/css/common/utils/variables/colors/_skeleton-palette.scss @@ -0,0 +1,17 @@ +/* + * @copyright Copyright (C) 2010-2024 Combodo SAS + * @license http://opensource.org/licenses/AGPL-3.0 + */ + +/* Skeleton palette */ +/* - Colors used by skeletons svg to display placeholders */ + +$common-skeleton-start-color: $common-color-grey-200 !default; +$common-skeleton-stop-color: $common-color-blue-grey-100 !default; + +/* CSS variables */ +/* Skeleton CSS3 variables are not common prefixed as they are not iTop backoffice exclusives*/ +:root { + --skeleton-start-color: #{$common-skeleton-start-color}; + --skeleton-stop-color: #{$common-skeleton-stop-color}; +} \ No newline at end of file diff --git a/css/common/vendors/_all.scss b/css/common/vendors/_all.scss new file mode 100644 index 000000000..e41eddb40 --- /dev/null +++ b/css/common/vendors/_all.scss @@ -0,0 +1 @@ +@import "highlightjs"; \ No newline at end of file diff --git a/css/common/vendors/_highlightjs.scss b/css/common/vendors/_highlightjs.scss index d23dce08b..e033673f5 100644 --- a/css/common/vendors/_highlightjs.scss +++ b/css/common/vendors/_highlightjs.scss @@ -5,9 +5,9 @@ $common-vendors-highlightjs--padding: 0.9rem !default; $common-vendors-highlightjs--box-shadow: 0 0px 3px 2px inset rgba(0, 0, 0, 0.4) !default; -$common-vendors-highlightjs--border-radius: 4px !default; -$common-vendors-highlightjs--code--padding-x: 5px !default; -$common-vendors-highlightjs--code--padding-y: 3px !default; +$common-vendors-highlightjs--border-radius: $common-border-radius-300 !default; +$common-vendors-highlightjs--code--padding-x: $common-spacing-200 !default; +$common-vendors-highlightjs--code--padding-y: $common-spacing-200 !default; $common-vendors-highlightjs--background-color: #282b2e !default; $common-vendors-highlightjs--color: #e0e2e4 !default; @@ -22,99 +22,3 @@ $common-vendors-highlightjs--comment--color: #818e96 !default; $common-vendors-highlightjs--selector-class--color: #A082BD !default; $common-vendors-highlightjs--code--color: white !default; - -// Highlight.js stylesheets -/* Highlight JS */ -.hljs { - -} - -.common-hljs-container{ - padding: 0 !important; - border: none !important; -} - -pre code.hljs { - display: block; - overflow-x: auto; - padding: $common-vendors-highlightjs--padding !important; -} - -code.hljs { - padding: $common-vendors-highlightjs--code--padding-y $common-vendors-highlightjs--code--padding-x !important; -} -/** - * Obsidian style - * ported by Alexander Marenin (http://github.com/ioncreature) - */ -.hljs { - box-shadow: $common-vendors-highlightjs--box-shadow !important; - border-radius: $common-vendors-highlightjs--border-radius !important; - white-space: pre-wrap; - border: none !important; - color: $common-vendors-highlightjs--color !important; - background: $common-vendors-highlightjs--background-color !important; -} -.hljs-keyword, -.hljs-selector-tag, -.hljs-literal, -.hljs-selector-id { - color: $common-vendors-highlightjs--keyword--color !important; -} -.hljs-number { - color: $common-vendors-highlightjs--number--color !important; -} -.hljs-attribute { - color: $common-vendors-highlightjs--attribute--color -} -.hljs-regexp, -.hljs-link { - color: $common-vendors-highlightjs--regexp--color !important; -} -.hljs-meta { - color: $common-vendors-highlightjs--meta--color !important; -} -.hljs-tag, -.hljs-name, -.hljs-bullet, -.hljs-subst, -.hljs-emphasis, -.hljs-type, -.hljs-built_in, -.hljs-selector-attr, -.hljs-selector-pseudo, -.hljs-addition, -.hljs-variable, -.hljs-template-tag, -.hljs-template-variable { - color: $common-vendors-highlightjs--tag--color !important; -} -.hljs-string, -.hljs-symbol { - color: $common-vendors-highlightjs--string--color !important; -} -.hljs-comment, -.hljs-quote, -.hljs-deletion { - color: $common-vendors-highlightjs--comment--color !important; -} -.hljs-selector-class { - color: $common-vendors-highlightjs--selector-class--color !important; -} -.hljs-keyword, -.hljs-selector-tag, -.hljs-literal, -.hljs-doctag, -.hljs-title, -.hljs-section, -.hljs-type, -.hljs-name, -.hljs-strong { - font-weight: bold -} -.hljs-code, -.hljs-title.class_, -.hljs-class .hljs-title, -.hljs-section { - color: $common-vendors-highlightjs--code--color !important; -} \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index fdc8c5f17..0d0b9ad76 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -71,7 +71,7 @@ }, "node_modules/ckeditor5-itop-build": { "version": "3.2.0", - "resolved": "git+ssh://git@github.com/Combodo/ckeditor5-itop-build.git#afb3e73d4636520a46e2c05d6630bbed9c4f6cc5" + "resolved": "git+ssh://git@github.com/Combodo/ckeditor5-itop-build.git#7366299c6c4b659736b958c5e9496e98c22a3c36" }, "node_modules/clipboard": { "version": "2.0.11", diff --git a/node_modules/ckeditor5-itop-build/README.md b/node_modules/ckeditor5-itop-build/README.md index 279e95266..c0d45bef2 100644 --- a/node_modules/ckeditor5-itop-build/README.md +++ b/node_modules/ckeditor5-itop-build/README.md @@ -32,5 +32,5 @@ In order to update iTop CKEditor's build you need to push your changes to github Then run the following command in iTop's root directory: ``` - npm install https://github.com/Combodo/ckeditor5-itop-build.git + npm install https://github.com/Combodo/ckeditor5-itop-build.git --omit=dev ``` \ No newline at end of file diff --git a/node_modules/ckeditor5-itop-build/build/ckeditor.js b/node_modules/ckeditor5-itop-build/build/ckeditor.js index cbcbcf699..92414c6b9 100644 --- a/node_modules/ckeditor5-itop-build/build/ckeditor.js +++ b/node_modules/ckeditor5-itop-build/build/ckeditor.js @@ -3,5 +3,5 @@ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md. */ -function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ClassicEditor=t():e.ClassicEditor=t()}(self,(()=>(()=>{var e,t,i={659:(e,t,i)=>{const n=i(156),o={};for(const e of Object.keys(n))o[n[e]]=e;const s={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=s;for(const e of Object.keys(s)){if(!("channels"in s[e]))throw new Error("missing channels property: "+e);if(!("labels"in s[e]))throw new Error("missing channel labels property: "+e);if(s[e].labels.length!==s[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=s[e];delete s[e].channels,delete s[e].labels,Object.defineProperty(s[e],"channels",{value:t}),Object.defineProperty(s[e],"labels",{value:i})}s.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(t,i,n),s=Math.max(t,i,n),r=s-o;let a,l;s===o?a=0:t===s?a=(i-n)/r:i===s?a=2+(n-t)/r:n===s&&(a=4+(t-i)/r),a=Math.min(60*a,360),a<0&&(a+=360);const c=(o+s)/2;return l=s===o?0:c<=.5?r/(s+o):r/(2-s-o),[a,100*l,100*c]},s.rgb.hsv=function(e){let t,i,n,o,s;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),d=c-Math.min(r,a,l),h=function(e){return(c-e)/6/d+.5};return 0===d?(o=0,s=0):(s=d/c,t=h(r),i=h(a),n=h(l),r===c?o=n-i:a===c?o=1/3+t-n:l===c&&(o=2/3+i-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*s,100*c]},s.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const o=s.rgb.hsl(e)[0],r=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[o,100*r,100*n]},s.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-i,1-n);return[100*((1-t-o)/(1-o)||0),100*((1-i-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},s.rgb.keyword=function(e){const t=o[e];if(t)return t;let i,s=1/0;for(const t of Object.keys(n)){const o=n[t],l=(a=o,((r=e)[0]-a[0])**2+(r[1]-a[1])**2+(r[2]-a[2])**2);l.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;return[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},s.rgb.lab=function(e){const t=s.rgb.xyz(e);let i=t[0],n=t[1],o=t[2];i/=95.047,n/=100,o/=108.883,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;return[116*n-16,500*(i-n),200*(n-o)]},s.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let o,s,r;if(0===i)return r=255*n,[r,r,r];o=n<.5?n*(1+i):n+i-n*i;const a=2*n-o,l=[0,0,0];for(let e=0;e<3;e++)s=t+1/3*-(e-1),s<0&&s++,s>1&&s--,r=6*s<1?a+6*(o-a)*s:2*s<1?o:3*s<2?a+(o-a)*(2/3-s)*6:a,l[e]=255*r;return l},s.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,o=i;const s=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,o*=s<=1?s:2-s;return[t,100*(0===n?2*o/(s+o):2*i/(n+i)),100*((n+i)/2)]},s.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const o=Math.floor(t)%6,s=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*s),l=255*n*(1-i*(1-s));switch(n*=255,o){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},s.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,o=Math.max(n,.01);let s,r;r=(2-i)*n;const a=(2-i)*o;return s=i*o,s/=a<=1?a:2-a,s=s||0,r/=2,[t,100*s,100*r]},s.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const o=i+n;let s;o>1&&(i/=o,n/=o);const r=Math.floor(6*t),a=1-n;s=6*t-r,1&r&&(s=1-s);const l=i+s*(a-i);let c,d,h;switch(r){default:case 6:case 0:c=a,d=l,h=i;break;case 1:c=l,d=a,h=i;break;case 2:c=i,d=a,h=l;break;case 3:c=i,d=l,h=a;break;case 4:c=l,d=i,h=a;break;case 5:c=a,d=i,h=l}return[255*c,255*d,255*h]},s.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,i*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},s.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let o,s,r;return o=3.2406*t+-1.5372*i+-.4986*n,s=-.9689*t+1.8758*i+.0415*n,r=.0557*t+-.204*i+1.057*n,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),r=Math.min(Math.max(0,r),1),[255*o,255*s,255*r]},s.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},s.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const o=i**3,s=t**3,r=n**3;return i=o>.008856?o:(i-16/116)/7.787,t=s>.008856?s:(t-16/116)/7.787,n=r>.008856?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},s.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let o;o=360*Math.atan2(n,i)/2/Math.PI,o<0&&(o+=360);return[t,Math.sqrt(i*i+n*n),o]},s.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},s.rgb.ansi16=function(e,t=null){const[i,n,o]=e;let r=null===t?s.rgb.hsv(e)[2]:t;if(r=Math.round(r/50),0===r)return 30;let a=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===r&&(a+=60),a},s.hsv.ansi16=function(e){return s.rgb.ansi16(s.hsv.rgb(e),e[2])},s.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t===i&&i===n)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},s.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},s.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},s.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},s.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map((e=>e+e)).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},s.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,i),n),s=Math.min(Math.min(t,i),n),r=o-s;let a,l;return a=r<1?s/(1-r):0,l=r<=0?0:o===t?(i-n)/r%6:o===i?2+(n-t)/r:4+(t-i)/r,l/=6,l%=1,[360*l,100*r,100*a]},s.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let o=0;return n<1&&(o=(i-.5*n)/(1-n)),[e[0],100*n,100*o]},s.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},s.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const o=[0,0,0],s=t%1*6,r=s%1,a=1-r;let l=0;switch(Math.floor(s)){case 0:o[0]=1,o[1]=r,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=r;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=r,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-i)*n,[255*(i*o[0]+l),255*(i*o[1]+l),255*(i*o[2]+l)]},s.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},s.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},s.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},s.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},s.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},s.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},s.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},s.gray.hsl=function(e){return[0,0,e[0]]},s.gray.hsv=s.gray.hsl,s.gray.hwb=function(e){return[0,100,e[0]]},s.gray.cmyk=function(e){return[0,0,0,e[0]]},s.gray.lab=function(e){return[e[0],0,0]},s.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},s.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},734:(e,t,i)=>{const n=i(659),o=i(507),s={};Object.keys(n).forEach((e=>{s[e]={},Object.defineProperty(s[e],"channels",{value:n[e].channels}),Object.defineProperty(s[e],"labels",{value:n[e].labels});const t=o(e);Object.keys(t).forEach((i=>{const n=t[i];s[e][i]=function(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)}))})),e.exports=s},507:(e,t,i)=>{const n=i(659);function o(e){const t=function(){const e={},t=Object.keys(n);for(let i=t.length,n=0;n{"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var s=n[e]={exports:{}};return i[e](s,s.exports,o),s.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(i,n){if(1&n&&(i=this(i)),8&n)return i;if("object"==typeof i&&i){if(4&n&&i.__esModule)return i;if(16&n&&"function"==typeof i.then)return i}var s=Object.create(null);o.r(s);var r={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&i;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>r[e]=()=>i[e]));return r.default=()=>i,o.d(s,r),s},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{"use strict";let e;o.d(s,{default:()=>NP});try{e={window,document}}catch(t){e={window:{},document:{}}}const t=e;const i=function(){try{return navigator.userAgent.toLowerCase()}catch(e){return""}}(),n={isMac:a(i),isWindows:function(e){return e.indexOf("windows")>-1}(i),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(i),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(i),isiOS:function(e){return!!e.match(/iphone|ipad/i)||a(e)&&navigator.maxTouchPoints>0}(i),isAndroid:function(e){return e.indexOf("android")>-1}(i),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(i),get isMediaForcedColors(){return!!t.window.matchMedia&&t.window.matchMedia("(forced-colors: active)").matches},get isMotionReduced(){return!!t.window.matchMedia&&t.window.matchMedia("(prefers-reduced-motion)").matches},features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}},r=n;function a(e){return e.indexOf("macintosh")>-1}function l(e,t,i,n){i=i||function(e,t){return e===t};const o=Array.isArray(e)?e:Array.prototype.slice.call(e),s=Array.isArray(t)?t:Array.prototype.slice.call(t),r=function(e,t,i){const n=c(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=d(e,n),s=d(t,n),r=c(o,s,i),a=e.length-r,l=t.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(o,s,i),a=n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:o}=e;if(-1===i)return Array(t).fill("equal");let s=[];i>0&&(s=s.concat(Array(i).fill("equal")));o-i>0&&(s=s.concat(Array(o-i).fill("insert")));n-i>0&&(s=s.concat(Array(n-i).fill("delete")));o0&&i.push({index:n,type:"insert",values:e.slice(n,s)});o-n>0&&i.push({index:n+(s-n),type:"delete",howMany:o-n});return i}(s,r);return a}function c(e,t,i){for(let n=0;n200||o>200||n+o>300)return h.fastDiff(e,t,i,!0);let s,r;if(oc?-1:1;d[n+h]&&(d[n]=d[n+h].slice(0)),d[n]||(d[n]=[]),d[n].push(o>c?s:r);let m=Math.max(o,c),g=m-n;for(;gc;g--)u[g]=m(g);u[c]=m(c),f++}while(u[c]!==l);return d[c].slice(1)}h.fastDiff=l;const u=function(){return function e(){e.called=!0}};class m{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=u(),this.off=u()}}const g=new Array(256).fill("").map(((e,t)=>("0"+t.toString(16)).slice(-2)));function f(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0;return"e"+g[255&e]+g[e>>8&255]+g[e>>16&255]+g[e>>24&255]+g[255&t]+g[t>>8&255]+g[t>>16&255]+g[t>>24&255]+g[255&i]+g[i>>8&255]+g[i>>16&255]+g[i>>24&255]+g[255&n]+g[n>>8&255]+g[n>>16&255]+g[n>>24&255]}const p={get(e="normal"){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function b(e,t){const i=p.get(t.priority);for(let n=0;n{if("object"==typeof t&&null!==t){if(i.has(t))return`[object ${t.constructor.name}]`;i.add(t)}return t},o=t?` ${JSON.stringify(t,n)}`:"",s=y(e);return e+o+s}(e,i)),this.name="CKEditorError",this.context=t,this.data=i}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new _(e.message,t);throw i.stack=e.stack,i}}function v(e,t){console.warn(...k(e,t))}function y(e){return`\nRead more: ${w}#error-${e}`}function k(e,t){const i=y(e);return t?[e,t,i]:[e,i]}const C="41.4.2",A=new Date(2024,4,17);if(globalThis.CKEDITOR_VERSION)throw new _("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION=C;const x=Symbol("listeningTo"),E=Symbol("emitterId"),T=Symbol("delegations"),S=P(Object);function P(e){if(!e)return S;return class extends e{on(e,t,i){this.listenTo(this,e,t,i)}once(e,t,i){let n=!1;this.listenTo(this,e,((e,...i)=>{n||(n=!0,e.off(),t.call(this,e,...i))}),i)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,i,n={}){let o,s;this[x]||(this[x]={});const r=this[x];V(e)||I(e);const a=V(e);(o=r[a])||(o=r[a]={emitter:e,callbacks:{}}),(s=o.callbacks[t])||(s=o.callbacks[t]=[]),s.push(i),function(e,t,i,n,o){t._addEventListener?t._addEventListener(i,n,o):e._addEventListener.call(t,i,n,o)}(this,e,t,i,n)}stopListening(e,t,i){const n=this[x];let o=e&&V(e);const s=n&&o?n[o]:void 0,r=s&&t?s.callbacks[t]:void 0;if(!(!n||e&&!s||t&&!r))if(i){F(this,e,t,i);-1!==r.indexOf(i)&&(1===r.length?delete s.callbacks[t]:F(this,e,t,i))}else if(r){for(;i=r.pop();)F(this,e,t,i);delete s.callbacks[t]}else if(s){for(t in s.callbacks)this.stopListening(e,t);delete n[o]}else{for(o in n)this.stopListening(n[o].emitter);delete this[x]}}fire(e,...t){try{const i=e instanceof m?e:new m(this,e),n=i.name;let o=B(this,n);if(i.path.push(this),o){const e=[i,...t];o=Array.from(o);for(let t=0;t{this[T]||(this[T]=new Map),e.forEach((e=>{const n=this[T].get(e);n?n.set(t,i):this[T].set(e,new Map([[t,i]]))}))}}}stopDelegating(e,t){if(this[T])if(e)if(t){const i=this[T].get(e);i&&i.delete(t)}else this[T].delete(e);else this[T].clear()}_addEventListener(e,t,i){!function(e,t){const i=R(e);if(i[t])return;let n=t,o=null;const s=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},s.push(i[n]),o&&i[n].childEvents.push(o),o=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of s)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(o)}}(this,e);const n=O(this,e),o={callback:t,priority:p.get(i.priority)};for(const e of n)b(e,o)}_removeEventListener(e,t){const i=O(this,e);for(const e of i)for(let i=0;i-1?B(e,t.substr(0,t.lastIndexOf(":"))):null}function M(e,t,i){for(let[n,o]of e){o?"function"==typeof o&&(o=o(t.name)):o=t.name;const e=new m(t.source,o);e.path=[...t.path],n.fire(e,...i)}}function F(e,t,i,n){t._removeEventListener?t._removeEventListener(i,n):e._removeEventListener.call(t,i,n)}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{P[e]=S.prototype[e]}));const N=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},D=Symbol("observableProperties"),L=Symbol("boundObservables"),z=Symbol("boundProperties"),H=Symbol("decoratedMethods"),W=Symbol("decoratedOriginal"),j=U(P());function U(e){if(!e)return j;return class extends e{set(e,t){if(N(e))return void Object.keys(e).forEach((t=>{this.set(t,e[t])}),this);q(this);const i=this[D];if(e in this&&!i.has(e))throw new _("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i.get(e),set(t){const n=i.get(e);let o=this.fire(`set:${e}`,e,t,n);void 0===o&&(o=t),n===o&&i.has(e)||(i.set(e,o),this.fire(`change:${e}`,e,o,n))}}),this[e]=t}bind(...e){if(!e.length||!Z(e))throw new _("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new _("observable-bind-duplicate-properties",this);q(this);const t=this[z];e.forEach((e=>{if(t.has(e))throw new _("observable-bind-rebind",this)}));const i=new Map;return e.forEach((e=>{const n={property:e,to:[]};t.set(e,n),i.set(e,n)})),{to:G,toMany:K,_observable:this,_bindProperties:e,_to:[],_bindings:i}}unbind(...e){if(!this[D])return;const t=this[z],i=this[L];if(e.length){if(!Z(e))throw new _("observable-unbind-wrong-properties",this);e.forEach((e=>{const n=t.get(e);n&&(n.to.forEach((([e,t])=>{const o=i.get(e),s=o[t];s.delete(n),s.size||delete o[t],Object.keys(o).length||(i.delete(e),this.stopListening(e,"change"))})),t.delete(e))}))}else i.forEach(((e,t)=>{this.stopListening(t,"change")})),i.clear(),t.clear()}decorate(e){q(this);const t=this[e];if(!t)throw new _("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,((e,i)=>{e.return=t.apply(this,i)})),this[e]=function(...t){return this.fire(e,t)},this[e][W]=t,this[H]||(this[H]=[]),this[H].push(e)}stopListening(e,t,i){if(!e&&this[H]){for(const e of this[H])this[e]=this[e][W];delete this[H]}super.stopListening(e,t,i)}}}function q(e){e[D]||(Object.defineProperty(e,D,{value:new Map}),Object.defineProperty(e,L,{value:new Map}),Object.defineProperty(e,z,{value:new Map}))}function G(...e){const t=function(...e){if(!e.length)throw new _("observable-bind-to-parse-error",null);const t={to:[]};let i;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new _("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}})),t}(...e),i=Array.from(this._bindings.keys()),n=i.length;if(!t.callback&&t.to.length>1)throw new _("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new _("observable-bind-to-extra-callback",this);var o;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==n)throw new _("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)})),this._to=t.to,t.callback&&(this._bindings.get(i[0]).callback=t.callback),o=this._observable,this._to.forEach((e=>{const t=o[L];let i;t.get(e.observable)||o.listenTo(e.observable,"change",((n,s)=>{i=t.get(e.observable)[s],i&&i.forEach((e=>{J(o,e.property)}))}))})),function(e){let t;e._bindings.forEach(((i,n)=>{e._to.forEach((o=>{t=o.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([o.observable,t]),function(e,t,i,n){const o=e[L],s=o.get(i),r=s||{};r[n]||(r[n]=new Set);r[n].add(t),s||o.set(i,r)}(e._observable,i,o.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{J(this._observable,e)}))}function K(e,t,i){if(this._bindings.size>1)throw new _("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const i=e.map((e=>[e,t]));return Array.prototype.concat.apply([],i)}(e,t),i)}function Z(e){return e.every((e=>"string"==typeof e))}function J(e,t){const i=e[z].get(t);let n;i.callback?n=i.callback.apply(e,i.to.map((e=>e[0][e[1]]))):(n=i.to[0],n=n[0][n[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=n:e.set(t,n)}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{U[e]=j.prototype[e]}));class Y{constructor(){this._replacedElements=[]}replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach((({element:e,newElement:t})=>{e.style.display="",t&&t.remove()})),this._replacedElements=[]}}function Q(e){let t=0;for(const i of e)t++;return t}function X(e,t){const i=Math.min(e.length,t.length);for(let n=0;n-1};const Oe=function(e,t){var i=this.__data__,n=Se(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function Be(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var jt={};jt["[object Float32Array]"]=jt["[object Float64Array]"]=jt["[object Int8Array]"]=jt["[object Int16Array]"]=jt["[object Int32Array]"]=jt["[object Uint8Array]"]=jt["[object Uint8ClampedArray]"]=jt["[object Uint16Array]"]=jt["[object Uint32Array]"]=!0,jt["[object Arguments]"]=jt["[object Array]"]=jt["[object ArrayBuffer]"]=jt["[object Boolean]"]=jt["[object DataView]"]=jt["[object Date]"]=jt["[object Error]"]=jt["[object Function]"]=jt["[object Map]"]=jt["[object Number]"]=jt["[object Object]"]=jt["[object RegExp]"]=jt["[object Set]"]=jt["[object String]"]=jt["[object WeakMap]"]=!1;const Ut=function(e){return fe(e)&&Wt(e.length)&&!!jt[me(e)]};const qt=function(e){return function(t){return e(t)}};var Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Kt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Zt=Kt&&Kt.exports===Gt&&te.process;const Jt=function(){try{var e=Kt&&Kt.require&&Kt.require("util").types;return e||Zt&&Zt.binding&&Zt.binding("util")}catch(e){}}();var Yt=Jt&&Jt.isTypedArray;const Qt=Yt?qt(Yt):Ut;var Xt=Object.prototype.hasOwnProperty;const ei=function(e,t){var i=ge(e),n=!i&&Mt(e),o=!i&&!n&&zt(e),s=!i&&!n&&!o&&Qt(e),r=i||n||o||s,a=r?It(e.length,String):[],l=a.length;for(var c in e)!t&&!Xt.call(e,c)||r&&("length"==c||o&&("offset"==c||"parent"==c)||s&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||$t(c,l))||a.push(c);return a};var ti=Object.prototype;const ii=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ti)};const ni=we(Object.keys,Object);var oi=Object.prototype.hasOwnProperty;const si=function(e){if(!ii(e))return ni(e);var t=[];for(var i in Object(e))oi.call(e,i)&&"constructor"!=i&&t.push(i);return t};const ri=function(e){return null!=e&&Wt(e.length)&&!ze(e)};const ai=function(e){return ri(e)?ei(e):si(e)};const li=function(e,t){return e&&Pt(t,ai(t),e)};const ci=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t};var di=Object.prototype.hasOwnProperty;const hi=function(e){if(!N(e))return ci(e);var t=ii(e),i=[];for(var n in e)("constructor"!=n||!t&&di.call(e,n))&&i.push(n);return i};const ui=function(e){return ri(e)?ei(e,!0):hi(e)};const mi=function(e,t){return e&&Pt(t,ui(t),e)};var gi="object"==typeof exports&&exports&&!exports.nodeType&&exports,fi=gi&&"object"==typeof module&&module&&!module.nodeType&&module,pi=fi&&fi.exports===gi?ne.Buffer:void 0,bi=pi?pi.allocUnsafe:void 0;const wi=function(e,t){if(t)return e.slice();var i=e.length,n=bi?bi(i):new e.constructor(i);return e.copy(n),n};const _i=function(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i{this._setToTarget(e,n,t[n],i)}))}}function An(e){return yn(e,xn)}function xn(e){return kn(e)||"function"==typeof e?e:void 0}function En(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}function Tn(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const Sn=Pn(P());function Pn(e){if(!e)return Sn;return class extends e{listenTo(e,t,i,n={}){if(En(e)||Tn(e)){const o={capture:!!n.useCapture,passive:!!n.usePassive},s=this._getProxyEmitter(e,o)||new In(e,o);this.listenTo(s,t,i,n)}else super.listenTo(e,t,i,n)}stopListening(e,t,i){if(En(e)||Tn(e)){const n=this._getAllProxyEmitters(e);for(const e of n)this.stopListening(e,t,i)}else super.stopListening(e,t,i)}_getProxyEmitter(e,t){return function(e,t){const i=e[x];return i&&i[t]?i[t].emitter:null}(this,Vn(e,t))}_getAllProxyEmitters(e){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map((t=>this._getProxyEmitter(e,t))).filter((e=>!!e))}}}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{Pn[e]=Sn.prototype[e]}));class In extends(P()){constructor(e,t){super(),I(this,Vn(e,t)),this._domNode=e,this._options=t}attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t}detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()}_addEventListener(e,t,i){this.attach(e),P().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){P().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=t=>{this.fire(e,t)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function Vn(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=f())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}function Rn(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}function On(e){return"[object Text]"==Object.prototype.toString.call(e)}function Bn(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Mn(e){return e&&e.parentNode?e.offsetParent===t.document.body?null:e.offsetParent:null}const Fn=["top","right","bottom","left","width","height"];class Nn{constructor(e){const t=Bn(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),zn(e)||t)if(t){const t=Nn.getDomRangeRects(e);Dn(this,Nn.getBoundingRect(t))}else Dn(this,e.getBoundingClientRect());else if(Tn(e)){const{innerWidth:t,innerHeight:i}=e;Dn(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else Dn(this,e)}clone(){return new Nn(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};if(t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0)return null;{const e=new Nn(t);return e._source=this._source,e}}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(Ln(e))return t;let i,n=e,o=e.parentNode||e.commonAncestorContainer;for(;o&&!Ln(o);){const e="visible"===((s=o)instanceof HTMLElement?s.ownerDocument.defaultView.getComputedStyle(s).overflow:"visible");n instanceof HTMLElement&&"absolute"===Hn(n)&&(i=n);const r=Hn(o);if(e||i&&("relative"===r&&e||"relative"!==r)){n=o,o=o.parentNode;continue}const a=new Nn(o),l=t.getIntersection(a);if(!l)return null;l.getArea(){for(const t of e){const e=$n._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}}))}}$n._observerInstance=null,$n._elementCallbacks=null;const Wn=$n;function jn(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function Un(e){return t=>t+e}function qn(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Gn(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function Kn(e){return e&&e.nodeType===Node.COMMENT_NODE}function Zn(e){try{t.document.createAttribute(e)}catch(e){return!1}return!0}function Jn(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}function Yn({element:e,target:i,positions:n,limiter:o,fitInViewport:s,viewportOffsetConfig:r}){ze(i)&&(i=i()),ze(o)&&(o=o());const a=Mn(e),l=function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const i=new Nn(t.window);return i.top+=e.top,i.height-=e.top,i.bottom-=e.bottom,i.height-=e.bottom,i}(r),c=new Nn(e),d=Qn(i,l);let h;if(!d||!l.getIntersection(d))return null;const u={targetRect:d,elementRect:c,positionedElementAncestor:a,viewportRect:l};if(o||s){if(o){const e=Qn(o,l);e&&(u.limiterRect=e)}h=function(e,t){const{elementRect:i}=t,n=i.getArea(),o=e.map((e=>new Xn(e,t))).filter((e=>!!e.name));let s=0,r=null;for(const e of o){const{limiterIntersectionArea:t,viewportIntersectionArea:i}=e;if(t===n)return e;const o=i**2+t**2;o>s&&(s=o,r=e)}return r}(n,u)}else h=new Xn(n[0],u);return h}function Qn(e,t){const i=new Nn(e).getVisible();return i?i.getIntersection(t):null}class Xn{constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:n,top:o,name:s,config:r}=i;this.name=s,this.config=r,this._positioningFunctionCoordinates={left:n,top:o},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;return e?e.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=this._rect.toAbsoluteRect()),this._cachedAbsoluteRect}}function eo(e){const t=e.parentNode;t&&t.removeChild(e)}function to({window:e,rect:t,alignToTop:i,forceScroll:n,viewportOffset:o}){const s=t.clone().moveBy(0,o.bottom),r=t.clone().moveBy(0,-o.top),a=new Nn(e).excludeScrollbarsAndBorders(),l=i&&n,c=[r,s].every((e=>a.contains(e)));let{scrollX:d,scrollY:h}=e;const u=d,m=h;l?h-=a.top-t.top+o.top:c||(oo(r,a)?h-=a.top-t.top+o.top:no(s,a)&&(h+=i?t.top-a.top-o.top:t.bottom-a.bottom+o.bottom)),c||(so(t,a)?d-=a.left-t.left+o.left:ro(t,a)&&(d+=t.right-a.right+o.right)),d==u&&h===m||e.scrollTo(d,h)}function io({parent:e,getRect:t,alignToTop:i,forceScroll:n,ancestorOffset:o=0,limiterElement:s}){const r=ao(e),a=i&&n;let l,c,d;const h=s||r.document.body;for(;e!=h;)c=t(),l=new Nn(e).excludeScrollbarsAndBorders(),d=l.contains(c),a?e.scrollTop-=l.top-c.top+o:d||(oo(c,l)?e.scrollTop-=l.top-c.top+o:no(c,l)&&(e.scrollTop+=i?c.top-l.top-o:c.bottom-l.bottom+o)),d||(so(c,l)?e.scrollLeft-=l.left-c.left+o:ro(c,l)&&(e.scrollLeft+=c.right-l.right+o)),e=e.parentNode}function no(e,t){return e.bottom>t.bottom}function oo(e,t){return e.topt.right}function ao(e){return Bn(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function lo(e){if(Bn(e)){let t=e.commonAncestorContainer;return On(t)&&(t=t.parentNode),t}return e.parentNode}function co(e,t){const i=ao(e),n=new Nn(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new Nn(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const ho={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},uo={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},mo={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},go=function(){const e={pageup:33,pagedown:34,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){e[String.fromCharCode(t).toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return Object.assign(e,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),e}(),fo=Object.fromEntries(Object.entries(go).map((([e,t])=>{let i;return i=t in mo?mo[t]:e.charAt(0).toUpperCase()+e.slice(1),[t,i]})));function po(e){let t;if("string"==typeof e){if(t=go[e.toLowerCase()],!t)throw new _("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?go.alt:0)+(e.ctrlKey?go.ctrl:0)+(e.shiftKey?go.shift:0)+(e.metaKey?go.cmd:0);return t}function bo(e){return"string"==typeof e&&(e=function(e){return e.split("+").map((e=>e.trim()))}(e)),e.map((e=>"string"==typeof e?function(e){if(e.endsWith("!"))return po(e.slice(0,-1));const t=po(e);return(r.isMac||r.isiOS)&&t==go.ctrl?go.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function wo(e){let t=bo(e);return Object.entries(r.isMac||r.isiOS?ho:uo).reduce(((e,[i,n])=>(t&go[i]&&(t&=~go[i],e+=n),e)),"")+(t?fo[t]:"")}function _o(e,t){const i="ltr"===t;switch(e){case go.arrowleft:return i?"left":"right";case go.arrowright:return i?"right":"left";case go.arrowup:return"up";case go.arrowdown:return"down"}}function vo(e){return Array.isArray(e)?e:[e]}const yo=function(e,t,i){(void 0!==i&&!Te(e[t],i)||void 0===i&&!(t in e))&&Et(e,t,i)};const ko=function(e){return function(t,i,n){for(var o=-1,s=Object(t),r=n(t),a=r.length;a--;){var l=r[e?a:++o];if(!1===i(s[l],l,s))break}return t}}();const Co=function(e){return fe(e)&&ri(e)};const Ao=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};const xo=function(e){return Pt(e,ui(e))};const Eo=function(e,t,i,n,o,s,r){var a=Ao(e,i),l=Ao(t,i),c=r.get(l);if(c)yo(e,i,c);else{var d=s?s(a,l,i+"",e,t,r):void 0,h=void 0===d;if(h){var u=ge(l),m=!u&&zt(l),g=!u&&!m&&Qt(l);d=l,u||m||g?ge(a)?d=a:Co(a)?d=_i(a):m?(h=!1,d=wi(l,!0)):g?(h=!1,d=sn(l,!0)):d=[]:xe(l)||Mt(l)?(d=a,Mt(a)?d=xo(a):N(a)&&!ze(a)||(d=cn(l))):h=!1}h&&(r.set(l,d),o(d,l,n,s,r),r.delete(l)),yo(e,i,d)}};const To=function e(t,i,n,o,s){t!==i&&ko(i,(function(r,a){if(s||(s=new Ct),N(r))Eo(t,i,a,n,e,o,s);else{var l=o?o(Ao(t,a),r,a+"",t,i,s):void 0;void 0===l&&(l=r),yo(t,a,l)}}),ui)};const So=function(e){return e};const Po=function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)};var Io=Math.max;const Vo=function(e,t,i){return t=Io(void 0===t?e.length-1:t,0),function(){for(var n=arguments,o=-1,s=Io(n.length-t,0),r=Array(s);++o0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}};const Fo=Mo(Oo);const No=function(e,t){return Fo(Vo(e,t,So),e+"")};const Do=function(e,t,i){if(!N(i))return!1;var n=typeof t;return!!("number"==n?ri(i)&&$t(t,i.length):"string"==n&&t in i)&&Te(i[t],e)};const Lo=function(e){return No((function(t,i){var n=-1,o=i.length,s=o>1?i[o-1]:void 0,r=o>2?i[2]:void 0;for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,r&&Do(i[0],i[1],r)&&(s=o<3?void 0:s,o=1),t=Object(t);++n1===e?0:1),d=l[a];if("string"==typeof d)return d;return d[Number(c(n))]}t.window.CKEDITOR_TRANSLATIONS||(t.window.CKEDITOR_TRANSLATIONS={});const $o=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig"];function Wo(e){return $o.includes(e)?"rtl":"ltr"}class jo{constructor({uiLanguage:e="en",contentLanguage:t,translations:i}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=Wo(this.uiLanguage),this.contentLanguageDirection=Wo(this.contentLanguage),this.translations=function(e){return Array.isArray(e)?e.reduce(((e,t)=>zo(e,t))):e}(i),this.t=(e,t)=>this._t(e,t)}get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=vo(t),"string"==typeof e&&(e={string:e});const i=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,i)=>ithis._items.length||t<0)throw new _("collection-add-item-invalid-index",this);let i=0;for(const n of e){const e=this._getItemIdBeforeAdding(n),o=t+i;this._items.splice(o,0,n),this._itemMap.set(e,n),this.fire("add",n,o),i++}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if("string"==typeof e)t=this._itemMap.get(e);else{if("number"!=typeof e)throw new _("collection-get-invalid-arg",this);t=this._items[e]}return t||null}has(e){if("string"==typeof e)return this._itemMap.has(e);{const t=e[this._idProperty];return t&&this._itemMap.has(t)}}getIndex(e){let t;return t="string"==typeof e?this._itemMap.get(e):e,t?this._items.indexOf(t):-1}remove(e){const[t,i]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:i}),t}map(e,t){return this._items.map(e,t)}forEach(e,t){this._items.forEach(e,t)}find(e,t){return this._items.find(e,t)}filter(e,t){return this._items.filter(e,t)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const e=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:e,index:0})}bindTo(e){if(this._bindToCollection)throw new _("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:e=>{this._setUpBindToBinding((t=>new e(t)))},using:e=>{"function"==typeof e?this._setUpBindToBinding(e):this._setUpBindToBinding((t=>t[e]))}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(i,n,o)=>{const s=t._bindToCollection==this,r=t._bindToInternalToExternalMap.get(n);if(s&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(o);let s=o;for(const e of this._skippedIndexesFromExternal)o>e&&s--;for(const e of t._skippedIndexesFromExternal)s>=e&&s++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,s);for(let e=0;e{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(it&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],"string"!=typeof i)throw new _("collection-add-invalid-id",this);if(this.get(i))throw new _("collection-add-item-already-exists",this)}else e[t]=i=f();return i}_remove(e){let t,i,n,o=!1;const s=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),o=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],o=!n,n&&(i=n[s])):(n=e,i=n[s],t=this._items.indexOf(n),o=-1==t||!this._itemMap.get(i)),o)throw new _("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function qo(e){const t=e.next();return t.done?null:t.value}class Go extends(Pn(U())){constructor(){super(),this._elements=new Set,this._nextEventLoopTimeout=null,this.set("isFocused",!1),this.set("focusedElement",null)}add(e){if(this._elements.has(e))throw new _("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",(()=>this._focus(e)),{useCapture:!0}),this.listenTo(e,"blur",(()=>this._blur()),{useCapture:!0}),this._elements.add(e)}remove(e){e===this.focusedElement&&this._blur(),this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e))}destroy(){this.stopListening()}_focus(e){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=e,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0)}}class Ko{constructor(){this._listener=new(Pn())}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+po(t),t)}))}set(e,t,i={}){const n=bo(e),o=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,((e,i)=>{t(i,(()=>{i.preventDefault(),i.stopPropagation(),e.stop()})),e.return=!0}),{priority:o})}press(e){return!!this._listener.fire("_keydown:"+po(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}function Zo(e){return ee(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function Jo(e,t){let i;function n(...o){n.cancel(),i=setTimeout((()=>e(...o)),t)}return n.cancel=()=>{clearTimeout(i)},n}function Yo(e,t){return!!(i=e.charAt(t-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var i}function Qo(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}const Xo=function(){const e=/\p{Regional_Indicator}{2}/u.source,t="(?:"+[/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,/\p{Emoji}\u{FE0F}?\u{20E3}/u,/\p{Emoji}\u{FE0F}/u,/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u].map((e=>e.source)).join("|")+")";return new RegExp(`${e}|${t}(?:‍${t})*`,"ug")}();function es(e,t){const i=String(e).matchAll(Xo);return Array.from(i).some((e=>e.index{this._renderViewIntoCollectionParent(t,i)})),this.on("remove",((e,t)=>{t.element&&this._parentElement&&t.element.remove()})),this._parentElement=null}destroy(){this.map((e=>e.destroy()))}setParent(e){this._parentElement=e;for(const e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!e.every((e=>"string"==typeof e)))throw new _("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const n of e)i.delegate(n).to(t);this.on("add",((i,n)=>{for(const i of e)n.delegate(i).to(t)})),this.on("remove",((i,n)=>{for(const i of e)n.stopDelegating(i,t)}))}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}remove(e){return super.remove(e)}}class is extends(P()){constructor(e){super(),Object.assign(this,us(hs(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new _("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const i of t.children)ws(i)?yield i:_s(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new os({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,o)=>new ss({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:o})}}static extend(e,t){if(e._isRendered)throw new _("template-extend-render",[this,e]);ps(e,us(hs(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new _("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),rs(this.text)?this._bindToObservable({schema:this.text,updater:ls(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const n in this.attributes){const o=t.getAttribute(n),s=this.attributes[n];i&&(i.attributes[n]=o);const r=ys(s)?s[0].ns:null;if(rs(s)){const a=ys(s)?s[0].value:s;i&&ks(n)&&a.unshift(o),this._bindToObservable({schema:a,updater:cs(t,n,r),data:e})}else if("style"==n&&"string"!=typeof s[0])this._renderStyleAttribute(s[0],e);else{i&&o&&ks(n)&&s.unshift(o);const e=s.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(gs,"");bs(e)||t.setAttributeNS(r,n,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const o=e[n];rs(o)?this._bindToObservable({schema:[o],updater:ds(i,n),data:t}):i.style[n]=o}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let o=0;for(const s of this.children)if(vs(s)){if(!n){s.setParent(t);for(const e of s)i.appendChild(e.element)}}else if(ws(s))n||(s.isRendered||s.render(),i.appendChild(s.element));else if(En(s))i.appendChild(s);else if(n){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),s._renderNode({intoFragment:!1,node:i.childNodes[o++],isApplying:!0,revertData:t})}else i.appendChild(s.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map((i=>{const[n,o]=t.split("@");return i.activateDomEventListener(n,o,e)}));e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;as(e,t,i);const o=e.filter((e=>!bs(e))).filter((e=>e.observable)).map((n=>n.activateAttributeListener(e,t,i)));n&&n.bindings.push(o)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)return void(e.textContent=t.text);const i=e;for(const e in t.attributes){const n=t.attributes[e];null===n?i.removeAttribute(e):i.setAttribute(e,n)}for(let e=0;eas(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,n),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,n)}}}class os extends ns{constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,i){const n=(e,i)=>{t&&!i.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,e,n),()=>{this.emitter.stopListening(i.node,e,n)}}}class ss extends ns{constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!bs(super.getValue(e))&&(this.valueIfTrue||!0)}}function rs(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(rs):e instanceof ns)}function as(e,t,{node:i}){const n=function(e,t){return e.map((e=>e instanceof ns?e.getValue(t):e))}(e,i);let o;o=1==e.length&&e[0]instanceof ss?n[0]:n.reduce(gs,""),bs(o)?t.remove():t.set(o)}function ls(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function cs(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function ds(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function hs(e){return yn(e,(e=>{if(e&&(e instanceof ns||_s(e)||ws(e)||vs(e)))return e}))}function us(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=vo(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)ms(e,t);return e}(e.on),delete e.on),!e.text){e.attributes&&function(e){for(const t in e)e[t].value&&(e[t].value=vo(e[t].value)),ms(e,t)}(e.attributes);const t=[];if(e.children)if(vs(e.children))t.push(e.children);else for(const i of e.children)_s(i)||ws(i)||En(i)?t.push(i):t.push(new is(i));e.children=t}return e}function ms(e,t){e[t]=vo(e[t])}function gs(e,t){return bs(t)?e:bs(e)?t:`${e} ${t}`}function fs(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function ps(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),fs(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),fs(e.eventListeners,t.eventListeners)),t.text&&e.text.push(...t.text),t.children&&t.children.length){if(e.children.length!=t.children.length)throw new _("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)ps(e.children[i++],n)}}function bs(e){return!e&&0!==e}function ws(e){return e instanceof Cs}function _s(e){return e instanceof is}function vs(e){return e instanceof ts}function ys(e){return N(e[0])&&e[0].ns}function ks(e){return"class"==e||"style"==e}class Cs extends(Pn(U())){constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Uo,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,i)=>{i.locale=e,i.t=e&&e.t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=is.bind(this,this)}createCollection(e){const t=new ts(e);return this._viewCollections.add(t),t}registerChild(e){ee(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){ee(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new is(e)}extendTemplate(e){is.extend(this.template,e)}render(){if(this.isRendered)throw new _("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map((e=>e.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}}function As({emitter:e,activator:t,callback:i,contextElements:n}){e.listenTo(document,"mousedown",((e,o)=>{if(!t())return;const s="function"==typeof o.composedPath?o.composedPath():[],r="function"==typeof n?n():n;for(const e of r)if(e.contains(o.target)||s.includes(e))return;i()}))}function xs(e){return class extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...e){super(...e),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}function Es({view:e}){e.listenTo(e.element,"submit",((t,i)=>{i.preventDefault(),e.fire("submit")}),{useCapture:!0})}function Ts({keystrokeHandler:e,focusTracker:t,gridItems:i,numberOfColumns:n,uiLanguageDirection:o}){const s="number"==typeof n?()=>n:n;function r(e){return n=>{const o=i.find((e=>e.element===t.focusedElement)),s=i.getIndex(o),r=e(s,i);i.get(r).focus(),n.stopPropagation(),n.preventDefault()}}function a(e,t){return e===t-1?0:e+1}function l(e,t){return 0===e?t-1:e-1}e.set("arrowright",r(((e,t)=>"rtl"===o?l(e,t.length):a(e,t.length)))),e.set("arrowleft",r(((e,t)=>"rtl"===o?a(e,t.length):l(e,t.length)))),e.set("arrowup",r(((e,t)=>{let i=e-s();return i<0&&(i=e+s()*Math.floor(t.length/s()),i>t.length-1&&(i-=s())),i}))),e.set("arrowdown",r(((e,t)=>{let i=e+s();return i>t.length-1&&(i=e%s()),i})))}class Ss extends(U()){constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Ps,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Ps),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function Ps(e){e.return=!1,e.stop()}class Is extends(U()){constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.listenTo(e,"change:isReadOnly",(()=>{this.refresh()})),this.on("set:isEnabled",(t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())}),{priority:"highest"}),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Vs,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Vs),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function Vs(e){e.return=!1,e.stop()}class Rs extends Is{constructor(){super(...arguments),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){b(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",(()=>this._checkEnabled())),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find((({command:e})=>e.isEnabled));return e&&e.command}}class Os extends(P()){constructor(e,t=[],i=[]){super(),this._plugins=new Map,this._context=e,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new _("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const n=this,o=this._context;!function e(t,i=new Set){t.forEach((t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!n._availablePlugins.has(t.pluginName)&&n._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),h(e);const s=[...function e(t,i=new Set){return t.map((e=>a(e)?e:n._availablePlugins.get(e))).reduce(((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(h(n.requires,n),e(n.requires,i).forEach((e=>t.add(e)))),t.add(n))),new Set)}(e.filter((e=>!c(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new _("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new _("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new _("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const o=n._availablePlugins.get(t);if(!o)throw new _("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const s=e.indexOf(o);if(-1===s){if(n._contextPlugins.has(o))return;throw new _("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(o.requires&&o.requires.length)throw new _("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(s,1,i),n._availablePlugins.set(t,i)}}(s,i);const r=function(e){return e.map((e=>{let t=n._contextPlugins.get(e);return t=t||new e(o),n._add(e,t),t}))}(s);return u(r,"init").then((()=>u(r,"afterInit"))).then((()=>r));function a(e){return"function"==typeof e}function l(e){return a(e)&&!!e.isContextPlugin}function c(e,t){return t.some((t=>t===e||(d(e)===t||d(t)===e)))}function d(e){return a(e)?e.pluginName||e.name:e}function h(e,i=null){e.map((e=>a(e)?e:n._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(a(e))return;if(t)throw new _("plugincollection-soft-required",o,{missingPlugin:e,requiredBy:d(t)});throw new _("plugincollection-plugin-not-found",o,{plugin:e})}(e,i),function(e,t){if(!l(t))return;if(l(e))return;throw new _("plugincollection-context-required",o,{plugin:d(e),requiredBy:d(t)})}(e,i),function(e,i){if(!i)return;if(!c(e,t))return;throw new _("plugincollection-required",o,{plugin:d(e),requiredBy:d(i)})}(e,i)}))}function u(e,t){return e.reduce(((e,i)=>i[t]?n._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new _("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Bs{constructor(e){this._contextOwner=null;const{translations:t,...i}=e||{};this.config=new Cn(i,this.constructor.defaultConfig);const n=this.constructor.builtinPlugins;this.config.define("plugins",n),this.plugins=new Os(this,n);const o=this.config.get("language")||{};this.locale=new jo({uiLanguage:"string"==typeof o?o:o.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new Uo}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new _("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new _("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,(e=>e.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new _("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const i=new this(e);t(i.initPlugins().then((()=>i)))}))}}class Ms extends(U()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}const Fs=new WeakMap;let Ns=!1;function Ds({view:e,element:t,text:i,isDirectHost:n=!0,keepOnFocus:o=!1}){const s=e.document;function r(i){Fs.get(s).set(t,{text:i,isDirectHost:n,keepOnFocus:o,hostElement:n?t:null}),e.change((e=>$s(s,e)))}Fs.has(s)||(Fs.set(s,new Map),s.registerPostFixer((e=>$s(s,e))),s.on("change:isComposing",(()=>{e.change((e=>$s(s,e)))}),{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",((e,t,i)=>{r(i)})),t.placeholder?r(t.placeholder):i&&r(i),i&&function(){Ns||v("enableplaceholder-deprecated-text-option");Ns=!0}()}function Ls(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}function zs(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function Hs(e,t){if(!e.isAttached())return!1;const i=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(i)return!1;const n=e.document,o=n.selection.anchor;return(!n.isComposing||!o||o.parent!==e)&&(!!t||(!n.isFocused||!!o&&o.parent!==e))}function $s(e,t){const i=Fs.get(e),n=[];let o=!1;for(const[e,s]of i)s.isDirectHost&&(n.push(e),Ws(t,e,s)&&(o=!0));for(const[e,s]of i){if(s.isDirectHost)continue;const i=js(e);i&&(n.includes(i)||(s.hostElement=i,Ws(t,e,s)&&(o=!0)))}return o}function Ws(e,t,i){const{text:n,isDirectHost:o,hostElement:s}=i;let r=!1;s.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,s),r=!0);return(o||1==t.childCount)&&Hs(s,i.keepOnFocus)?Ls(e,s)&&(r=!0):zs(e,s)&&(r=!0),r}function js(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class Us{is(){throw new Error("is() method is abstract")}}const qs=function(e){return vn(e,4)};class Gs extends(P(Us)){constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new _("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=X(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]e.data.length)throw new _("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new _("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}Zs.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class Js{constructor(...e){this._patterns=[],this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=Ys(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=Ys(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}}function Ys(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=new Set(t.getAttributeKeys());xe(e)?(void 0!==e.style&&v("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&v("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class"));return Qs(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)||t.classes&&(i.classes=function(e,t){return Qs(e,t.getClassNames(),(()=>{}))}(t.classes,e),!i.classes)||t.styles&&(i.styles=function(e,t){return Qs(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles)?null:i}function Qs(e,t,i){const n=function(e){if(Array.isArray(e))return e.map((e=>xe(e)?(void 0!==e.key&&void 0!==e.value||v("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(xe(e))return Object.entries(e);return[[e,!0]]}(e),o=Array.from(t),s=[];if(n.forEach((([e,t])=>{o.forEach((n=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,n)&&function(e,t,i){if(!0===e)return!0;const n=i(t);return e===n||e instanceof RegExp&&!!String(n).match(e)}(t,n,i)&&s.push(n)}))})),n.length&&!(s.lengtho?0:o+t),(i=i>o?o:i)<0&&(i+=o),o=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(o);++nt===e));return Array.isArray(t)}set(e,t){if(N(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=Sr(e);kr(this._styles,t),delete this._styles[e],this._cleanEmptyObjectsOnPath(t)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map((e=>e.join(":"))).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!N(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){if(this.isEmpty)return[];if(e)return this._styleProcessor.getStyleNames(this._styles);return this.getStylesEntries().map((([e])=>e))}clear(){this._styles={}}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=Cr(this._styles,i);if(!n)return;!Object.keys(n).length&&this.remove(i)}}class Tr{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(N(t))Pr(i,Sr(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:o,value:s}=n(t);Pr(i,o,s)}else Pr(i,e,t)}getNormalized(e,t){if(!e)return zo({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return Cr(t,i);const n=i(e,t);if(n)return n}return Cr(t,Sr(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);if(void 0===i)return[];if(this._reducers.has(e)){return this._reducers.get(e)(i)}return[[e,i]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const i=this.getNormalized(t,e);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...t,...Object.keys(e)]);return Array.from(i)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function Sr(e){return e.replace("-",".")}function Pr(e,t,i){let n=i;N(i)&&(n=zo({},Cr(e,t),i)),xr(e,t,n)}class Ir extends Gs{constructor(e,t,i,n){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=Zo(e);for(const[e,i]of t)null===i?t.delete(e):"string"!=typeof i&&t.set(e,String(i));return t}(i),this._children=[],n&&this._insertChild(0,n),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");Vr(this._classes,e),this._attrs.delete("class")}this._styles=new Er(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if("class"==e)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==e){const e=this._styles.toString();return""==e?void 0:e}return this._attrs.get(e)}hasAttribute(e){return"class"==e?this._classes.size>0:"style"==e?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(e){if(!(e instanceof Ir))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e){return this._styles.getStyleNames(e)}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new Js(...e);let i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new Ks(e,t)];ee(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Ks(e,t):t instanceof Zs?new Ks(e,t.data):t))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of vo(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of vo(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),"string"!=typeof e?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of vo(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function Vr(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}Ir.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Rr extends Ir{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Or}}function Or(){const e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const t of e)if(!t.is("uiElement"))return null;return this.childCount}Rr.prototype.is=function(e,t){return t?t===this.name&&("containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Br extends(U(Rr)){constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",(t=>t&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}destroy(){this.stopListening()}}Br.prototype.is=function(e,t){return t?t===this.name&&("editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};const Mr=Symbol("rootName");class Fr extends Br{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(Mr)}set rootName(e){this._setCustomProperty(Mr,e)}set _name(e){this.name=e}}Fr.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Nr{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new _("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new _("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Dr._createAt(e.startPosition):this._position=Dr._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i instanceof Ks){if(e.isAtEnd)return this._position=Dr._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof Ir){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Dr(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n instanceof Ks){if(this.singleCharacters)return e=new Dr(n,0),this._position=e,this._next();let i,o=n.data.length;return n==this._boundaryEndParent?(o=this.boundaries.end.offset,i=new Zs(n,0,o),e=Dr._createAfter(i)):(i=new Zs(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,o)}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{n=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset}const o=new Zs(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Dr._createAfter(i),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i instanceof Ks){if(e.isAtStart)return this._position=Dr._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof Ir)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Dr(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof Ks){if(this.singleCharacters)return e=new Dr(n,n.data.length),this._position=e,this._previous();let i,o=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new Zs(n,t,n.data.length-t),o=i.data.length,e=Dr._createBefore(i)}else i=new Zs(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,o)}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const o=new Zs(i,e.offset,n);return this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Dr._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,o){return t instanceof Zs&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Dr._createAfter(t.textNode):(n=Dr._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Dr._createBefore(t.textNode):(n=Dr._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}}class Dr extends Us{constructor(e,t){super(),this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return 0===this.offset}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof Br);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Dr._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Nr(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const n=X(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]0?new this(i,n):new this(n,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(Dr._createBefore(e),t)}}function zr(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}Lr.prototype.is=function(e){return"range"===e||"view:range"===e};class Hr extends(P(Us)){constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Q(this.getRanges());if(t!=Q(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(n);else if(t instanceof Hr||t instanceof $r)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Lr)this._setRanges([t],n&&n.backward),this._setFakeOptions(n);else if(t instanceof Dr)this._setRanges([new Lr(t)]),this._setFakeOptions(n);else if(t instanceof Gs){const e=!!n&&!!n.backward;let o;if(void 0===i)throw new _("view-selection-setto-required-second-parameter",this);o="in"==i?Lr._createIn(t):"on"==i?Lr._createOn(t):new Lr(Dr._createAt(t,i)),this._setRanges([o],e),this._setFakeOptions(n)}else{if(!ee(t))throw new _("view-selection-setto-not-selectable",this);this._setRanges(t,n&&n.backward),this._setFakeOptions(n)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new _("view-selection-setfocus-no-ranges",this);const i=Dr._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new Lr(i,n),!0):this._addRange(new Lr(n,i)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof Lr))throw new _("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new _("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Lr(e.start,e.end))}}Hr.prototype.is=function(e){return"selection"===e||"view:selection"===e};class $r extends(P(Us)){constructor(...e){super(),this._selection=new Hr,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}}$r.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class Wr extends m{constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const jr=Symbol("bubbling contexts");function Ur(e){return class extends e{fire(e,...t){try{const i=e instanceof m?e:new m(this,e),n=Zr(this);if(!n.size)return;if(qr(i,"capturing",this),Gr(n,"$capture",i,...t))return i.return;const o=i.startRange||this.selection.getFirstRange(),s=o?o.getContainedElement():null,r=!!s&&Boolean(Kr(n,s));let a=s||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),o=i.getPath();return n.length>o.length?t:i}(o);if(qr(i,"atTarget",a),!r){if(Gr(n,"$text",i,...t))return i.return;qr(i,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(Gr(n,"$root",i,...t))return i.return}else if(a.is("element")&&Gr(n,a.name,i,...t))return i.return;if(Gr(n,a,i,...t))return i.return;a=a.parent,qr(i,"bubbling",a)}return qr(i,"bubbling",this),Gr(n,"$document",i,...t),i.return}catch(e){_.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const n=vo(i.context||"$document"),o=Zr(this);for(const s of n){let n=o.get(s);n||(n=new(P()),o.set(s,n)),this.listenTo(n,e,t,i)}}_removeEventListener(e,t){const i=Zr(this);for(const n of i.values())this.stopListening(n,e,t)}}}{const e=Ur(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{Ur[t]=e.prototype[t]}))}function qr(e,t,i){e instanceof Wr&&(e._eventPhase=t,e._currentTarget=i)}function Gr(e,t,i,...n){const o="string"==typeof t?e.get(t):Kr(e,t);return!!o&&(o.fire(i,...n),i.stop.called)}function Kr(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function Zr(e){return e[jr]||(e[jr]=new Map),e[jr]}class Jr extends(Ur(U())){constructor(e){super(),this._postFixers=new Set,this.selection=new $r,this.roots=new Uo({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}}class Yr extends Ir{constructor(e,t,i,n){super(e,t,i,n),this._priority=10,this._id=null,this._clonesGroup=null,this.getFillerOffset=Xr}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new _("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}}Yr.DEFAULT_PRIORITY=10;const Qr=Yr;function Xr(){if(ea(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(ea(e)>1)return null;e=e.parent}return!e||ea(e)>1?null:this.childCount}function ea(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}Yr.prototype.is=function(e,t){return t?t===this.name&&("attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e):"attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class ta extends Ir{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ia}_insertChild(e,t){if(t&&(t instanceof Gs||Array.from(t).length>0))throw new _("view-emptyelement-cannot-add",[this,t]);return 0}}function ia(){return null}ta.prototype.is=function(e,t){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class na extends Ir{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=sa}_insertChild(e,t){if(t&&(t instanceof Gs||Array.from(t).length>0))throw new _("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}}function oa(e){e.document.on("arrowKey",((t,i)=>function(e,t,i){if(t.keyCode==go.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,o=e.focusOffset,s=i.domPositionToView(t,o);if(null===s)return;let r=!1;const a=s.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,e.domConverter)),{priority:"low"})}function sa(){return null}na.prototype.is=function(e,t){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class ra extends Ir{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=aa}_insertChild(e,t){if(t&&(t instanceof Gs||Array.from(t).length>0))throw new _("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function aa(){return null}ra.prototype.is=function(e,t){return t?t===this.name&&("rawElement"===e||"view:rawElement"===e||"element"===e||"view:element"===e):"rawElement"===e||"view:rawElement"===e||e===this.name||e==="view:"+this.name||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class la extends(P(Us)){constructor(e,t){super(),this._children=[],this._customProperties=new Map,this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new Ks(e,t)];ee(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Ks(e,t):t instanceof Zs?new Ks(e,t.data):t))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e}),[]);let n=null,o=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(o,e,t);n||(n=i.start),o=i.end}return n?new Lr(n,o):new Lr(e)}remove(e){const t=e instanceof Lr?e:Lr._createOn(e);if(wa(t,this.document),t.isCollapsed)return new la(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),o=i.parent,s=n.offset-i.offset,r=o._removeChildren(i.offset,s);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new la(this.document,r)}clear(e,t){wa(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let o;if(i.is("element")&&t.isSimilar(i))o=Lr._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(o=Lr._createIn(e))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,o=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-o}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof Qr))throw new _("view-writer-wrap-invalid-attribute",this.document);if(wa(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(n=n.getLastMatchingPosition((e=>e.item.is("uiElement")))),n=this._wrapPosition(n,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new Lr(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof Qr))throw new _("view-writer-unwrap-invalid-attribute",this.document);if(wa(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),o=i.parent,s=this._unwrapChildren(o,i.offset,n.offset,t),r=this.mergeAttributes(s.start);r.isEqual(s.start)||s.end.offset--;const a=this.mergeAttributes(s.end);return new Lr(r,a)}rename(e,t){const i=new Rr(this.document,e,t.getAttributes());return this.insert(Dr._createAfter(t),i),this.move(Lr._createIn(t),Dr._createAt(i,0)),this.remove(Lr._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Dr._createAt(e,t)}createPositionAfter(e){return Dr._createAfter(e)}createPositionBefore(e){return Dr._createBefore(e)}createRange(e,t){return new Lr(e,t)}createRangeOn(e){return Lr._createOn(e)}createRangeIn(e){return Lr._createIn(e)}createSelection(...e){return new Hr(...e)}createSlot(e="children"){if(!this._slotFactory)throw new _("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,o;if(n=i?da(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new _("view-writer-invalid-position-container",this.document);o=i?this._breakAttributes(e,!0):e.parent.is("$text")?ma(e):e;const s=n._insertChild(o.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=o.getShiftedBy(s),a=this.mergeAttributes(o);a.isEqual(o)||r.offset--;const l=this.mergeAttributes(r);return new Lr(a,l)}_wrapChildren(e,t,i,n){let o=t;const s=[];for(;o!1,e.parent._insertChild(e.offset,i);const n=new Lr(e,e.getShiftedBy(1));this.wrap(n,t);const o=new Dr(i.parent,i.index);i._remove();const s=o.nodeBefore,r=o.nodeAfter;return s instanceof Ks&&r instanceof Ks?ga(s,r):ua(o)}_wrapAttributeElement(e,t){if(!_a(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!_a(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(wa(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Lr(i,i)}const o=this._breakAttributes(n,t),s=o.parent.childCount,r=this._breakAttributes(i,t);return o.offset+=o.parent.childCount-s,new Lr(r,o)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new _("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new _("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new _("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&ba(n.parent))return e.clone();if(ba(n))return e.clone();if(n.is("$text"))return this._breakAttributes(ma(e),t);if(i==n.childCount){const e=new Dr(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Dr(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,o=n._clone();n.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const s=n.childCount-i,r=n._removeChildren(i,s);o._appendChild(r);const a=new Dr(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function da(e){let t=e.parent;for(;!ba(t);){if(!t)return;t=t.parent}return t}function ha(e,t){return e.priorityt.priority)&&e.getIdentity()i instanceof e)))throw new _("view-writer-insert-invalid-node-type",t);i.is("$text")||pa(i.getChildren(),t)}}function ba(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function wa(e,t){const i=da(e.start),n=da(e.end);if(!i||!n||i!==n)throw new _("view-writer-invalid-range-container",t)}function _a(e,t){return null===e.id&&null===t.id}const va=e=>e.createTextNode(" "),ya=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},ka=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},Ca=7,Aa="⁠".repeat(Ca);function xa(e){return"string"==typeof e?e.substr(0,Ca)===Aa:On(e)&&e.data.substr(0,Ca)===Aa}function Ea(e){return e.data.length==Ca&&xa(e)}function Ta(e){const t="string"==typeof e?e:e.data;return xa(e)?t.slice(Ca):t}function Sa(e,t){if(t.keyCode==go.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;xa(t)&&i<=Ca&&e.collapse(t,0)}}}class Pa extends(U()){constructor(e,t){super(),this.domDocuments=new Set,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this._inlineFiller=null,this._fakeSelectionContainer=null,this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),r.isBlink&&!r.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||this.render()}))}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e){throw new _("view-renderer-unknown-type",this)}this.markedChildren.add(t)}}}render(){if(this.isComposing&&!r.isAndroid)return;let e=null;const t=!(r.isBlink&&!r.isAndroid)||!this.isSelecting;for(const e of this.markedChildren)this._updateChildrenMappings(e);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=Dr._createBefore(e.parent)));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;xa(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Ia(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),o=this._diffNodeLists(i,n),s=this._findUpdateActions(o,i,n,Va);if(-1!==s.indexOf("update")){const t={equal:0,insert:0,delete:0};for(const o of s)if("update"===o){const o=t.equal+t.insert,s=t.equal+t.delete,r=e.getChild(o);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,i[s]),eo(n[o]),t.equal++}else t[o]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?Dr._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&On(t.parent)&&xa(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!xa(e))throw new _("view-renderer-filler-was-lost",this);Ea(e)?e.remove():e.data=e.data.substr(Ca),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;const n=e.nodeBefore,o=e.nodeAfter;return!(n instanceof Ks||o instanceof Ks)&&(!!(i!==t.getFillerOffset()||n&&n.is("element","br"))&&(!r.isAndroid||!n&&!o))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(n=Aa+n),Ba(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map((e=>e.name)),n=e.getAttributeKeys();for(const i of n)this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e);for(const n of i)e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(r.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&On(e)&&On(t)){i.normalize();break}e=t}}const n=t.inlineFillerPosition,o=i.childNodes,s=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&Ia(i.ownerDocument,s,n.offset);const a=this._diffNodeLists(o,s),l=this._findUpdateActions(a,o,s,Ra);let c=0;const d=new Set;for(const e of l)"delete"===e?(d.add(o[c]),eo(o[c])):"equal"!==e&&"update"!==e||c++;c=0;for(const e of l)"insert"===e?(Gn(i,c,s[c]),c++):"update"===e?(Ba(o[c],s[c].data),c++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(s[c])),c++);for(const e of d)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;const n=i[i.length-1];n==t&&i.pop();return i}(e,this._fakeSelectionContainer),h(e,t,Oa.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let o=[],s=[],r=[];const a={equal:0,insert:0,delete:0};for(const l of e)"insert"===l?r.push(i[a.equal+a.insert]):"delete"===l?s.push(t[a.equal+a.delete]):(o=o.concat(h(s,r,n).map((e=>"equal"===e?"update":e))),o.push("equal"),s=[],r=[]),a[l]++;return o.concat(h(s,r,n).map((e=>"equal"===e?"update":e)))}_markDescendantTextToSync(e){if(e)if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}_updateSelection(){if(r.isBlink&&!r.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e&&(this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&r.isAndroid||this._updateDomSelection(e))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),o=t.createRange();n.removeAllRanges(),o.selectNodeContents(i),n.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,n.parent,n.offset),r.isGecko&&function(e,t){let i=e.parent,n=e.offset;On(i)&&Ea(i)&&(n=qn(i)+1,i=i.parentNode);if(i.nodeType!=Node.ELEMENT_NODE||n!=i.childNodes.length-1)return;const o=i.childNodes[n];o&&"BR"==o.tagName&&t.addRange(t.getRangeAt(0))}(n,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Ia(e,t,i){const n=t instanceof Array?t:t.childNodes,o=n[i];if(On(o))return o.data=Aa+o.data,o;{const o=e.createTextNode(Aa);return Array.isArray(t)?n.splice(i,0,o):Gn(t,i,o),o}}function Va(e,t){return En(e)&&En(t)&&!On(e)&&!On(t)&&!Kn(e)&&!Kn(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Ra(e,t){return En(e)&&En(t)&&On(e)&&On(t)}function Oa(e,t,i){return t===i||(On(t)&&On(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}function Ba(e,t){const i=e.data;if(i==t)return;const n=l(i,t);for(const t of n)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const Ma=ka(t.document),Fa=va(t.document),Na=ya(t.document),Da="data-ck-unsafe-attribute-",La="data-ck-unsafe-element";class za{constructor(e,{blockFillerMode:i,renderingMode:n="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new Js,this._inlineObjectElementMatcher=new Js,this._elementsWithTemporaryCustomProperties=new Set,this.document=e,this.renderingMode=n,this.blockFillerMode=i||("editing"===n?"br":"nbsp"),this.preElements=["pre"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?t.document:t.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Hr(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of Array.from(e.children))this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||("source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),o=i.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);const s=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=s.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(ja(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{const i=e;if(this.mapViewToDom(i)){if(!i.getCustomProperty("editingPipeline:doNotReuseOnce"))return this.mapViewToDom(i);this._elementsWithTemporaryCustomProperties.add(i)}let n;if(i.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,i);else{if(i.is("uiElement"))return n="$comment"===i.name?this._domDocument.createComment(i.getCustomProperty("$rawContent")):i.render(this._domDocument,this),t.bind&&this.bindElements(n,i),n;this._shouldRenameElement(i.name)?(ja(i.name),n=this._createReplacementDomElement(i.name)):n=i.hasAttribute("xmlns")?this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(n,this),t.bind&&this.bindElements(n,i);for(const e of i.getAttributeKeys())this.setDomElementAttribute(n,e,i.getAttribute(e),i)}if(!1!==t.withChildren)for(const e of this.viewChildrenToDom(i,t))n instanceof HTMLTemplateElement?n.content.appendChild(e):n.appendChild(e);return n}}setDomElementAttribute(e,t,i,n){const o=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);o||v("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),Zn(t)?(e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(Da+t)&&o&&e.removeAttribute(Da+t),e.setAttribute(o?t:Da+t,i)):v("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=La&&(e.removeAttribute(t),e.removeAttribute(Da+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let n=0;for(const o of e.getChildren()){i===n&&(yield this._getBlockFiller());const e=o.is("element")&&!!o.getCustomProperty("dataPipeline:transparentRendering")&&!qo(o.getAttributes());e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(o,t):(e&&v("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,t)),n++}i===n&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return xa(i)&&(n+=Ca),{parent:i,offset:n}}{let i,n,o;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;o=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!n)return null;i=n.parentNode,o=n.nextSibling}if(On(o)&&xa(o))return{parent:o,offset:Ca};return{parent:i,offset:n?qn(n)+1:0}}}domToView(e,t={}){const i=[],n=this._domToView(e,t,i),o=n.next().value;return o?(n.next(),this._processDomInlineNodes(null,i,t),o.is("$text")&&0==o.data.length?null:o):null}*domChildrenToView(e,t={},i=[]){let n=[];n=e instanceof HTMLTemplateElement?[...e.content.childNodes]:[...e.childNodes];for(let o=0;o{const{scrollLeft:t,scrollTop:i}=e;o.push([t,i])})),i.focus(),$a(i,(e=>{const[t,i]=o.shift();e.scrollLeft=t,e.scrollTop=i})),t.window.scrollTo(e,n)}}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(Ma):!("BR"!==e.tagName||!Wa(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(Na)||function(e,t){const i=e.isEqualNode(Fa);return i&&Wa(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements))}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch(e){return!1}const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=function(e){const t=[];let i=e;for(;i&&i.nodeType!=Node.DOCUMENT_NODE;)t.unshift(i),i=i.parentNode;return t}(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return va(this._domDocument);case"markedNbsp":return ya(this._domDocument);case"br":return ka(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(On(e)&&xa(e)&&t0?t[e-1]:null,l=e+1this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_getTouchingInlineViewNode(e,t){const i=new Nr({startPosition:t?Dr._createAfter(e):Dr._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element","br"))return null;if(this._isInlineObjectElement(e.item))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("$textProxy"))return e.item}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if(Kn(e))return new na(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Ir(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(La,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function Ha(e,t){return e.getAncestors().some((e=>e.is("element")&&t.includes(e.name)))}function $a(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function Wa(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function ja(e){"script"===e&&v("domconverter-unsafe-script-element-detected"),"style"===e&&v("domconverter-unsafe-style-element-detected")}class Ua extends(Pn()){constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}const qa=Lo((function(e,t){Pt(t,ui(t),e)}));class Ga{constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,qa(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class Ka extends Ua{constructor(){super(...arguments),this.useCapture=!1}observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach((t=>{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new Ga(this.view,t,i))}}class Za extends Ka{constructor(){super(...arguments),this.domEventType=["keydown","keyup"]}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return po(this)}};this.fire(e.type,e,t)}}const Ja=function(){return ne.Date.now()};var Ya=/\s/;const Qa=function(e){for(var t=e.length;t--&&Ya.test(e.charAt(t)););return t};var Xa=/^\s+/;const el=function(e){return e?e.slice(0,Qa(e)+1).replace(Xa,""):e};var tl=/^[-+]0x[0-9a-f]+$/i,il=/^0b[01]+$/i,nl=/^0o[0-7]+$/i,ol=parseInt;const sl=function(e){if("number"==typeof e)return e;if(Xs(e))return NaN;if(N(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=N(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=el(e);var i=il.test(e);return i||nl.test(e)?ol(e.slice(2),i?2:8):tl.test(e)?NaN:+e};var rl=Math.max,al=Math.min;const ll=function(e,t,i){var n,o,s,r,a,l,c=0,d=!1,h=!1,u=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var i=n,s=o;return n=o=void 0,c=t,r=e.apply(s,i)}function g(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=s}function f(){var e=Ja();if(g(e))return p(e);a=setTimeout(f,function(e){var i=t-(e-l);return h?al(i,s-(e-c)):i}(e))}function p(e){return a=void 0,u&&n?m(e):(n=o=void 0,r)}function b(){var e=Ja(),i=g(e);if(n=arguments,o=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(f,t),d?m(e):r}(l);if(h)return clearTimeout(a),a=setTimeout(f,t),m(l)}return void 0===a&&(a=setTimeout(f,t)),r}return t=sl(t)||0,N(i)&&(d=!!i.leading,s=(h="maxWait"in i)?rl(sl(i.maxWait)||0,t):s,u="trailing"in i?!!i.trailing:u),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=o=a=void 0},b.flush=function(){return void 0===a?r:p(Ja())},b};class cl extends Ua{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=ll((e=>{this.document.fire("selectionChangeDone",e)}),200)}observe(){const e=this.document;e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)}),{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new Hr(t.getRanges(),{backward:t.isBackward,fake:!1});e!=go.arrowleft&&e!=go.arrowup||i.setTo(i.getFirstPosition()),e!=go.arrowright&&e!=go.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}const dl=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const hl=function(e){return this.__data__.has(e)};function ul(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new vt;++ta))return!1;var c=s.get(e),d=s.get(t);if(c&&d)return c==t&&d==e;var h=-1,u=!0,m=2&i?new ml:void 0;for(s.set(e,t),s.set(t,e);++h{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{this.flush(),e.change((()=>{}))}),50)})),t.on("blur",((i,n)=>{const o=t.selection.editableElement;null!==o&&o!==n.target||(t.isFocused=!1,this._isFocusChanging=!1,e.change((()=>{})))}))}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class Bl extends Ua{constructor(e){super(e),this.mutationObserver=e.getObserver(Vl),this.focusObserver=e.getObserver(Ol),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=ll((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=ll((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,i)=>{this.document.isComposing&&!r.isAndroid||(this._handleSelectionChange(i,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(i);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.selection.isEqual(n)||!this.domConverter.isDomSelectionCorrect(i))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.selection.isSimilar(n))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:n,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class Ml extends Ka{constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",(()=>{t.isComposing=!0}),{priority:"low"}),t.on("compositionend",(()=>{t.isComposing=!1}),{priority:"low"})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class Fl{constructor(e,t={}){this._files=t.cacheFiles?Nl(e):null,this._native=e}get files(){return this._files||(this._files=Nl(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function Nl(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}class Dl extends Ka{constructor(){super(...arguments),this.domEventType="beforeinput"}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,n=i.document;let o=null,s=null,a=[];if(e.dataTransfer&&(o=new Fl(e.dataTransfer)),null!==e.data?s=e.data:o&&(s=o.getData("text/plain")),n.selection.isFake)a=Array.from(n.selection.getRanges());else if(t.length)a=t.map((e=>{const t=i.domConverter.domPositionToView(e.startContainer,e.startOffset),n=i.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?i.createRange(t,n):n?i.createRange(n):void 0})).filter((e=>!!e));else if(r.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();a=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(r.isAndroid&&"insertCompositionText"==e.inputType&&s&&s.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(a[0].end)]});else if("insertText"==e.inputType&&s&&s.includes("\n")){const t=s.split(/\n{1,2}/g);let i=a;for(let s=0;s{if(this.isEnabled&&((i=t.keyCode)==go.arrowright||i==go.arrowleft||i==go.arrowup||i==go.arrowdown)){const i=new Wr(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i}))}observe(){}stopObserving(){}}class zl extends Ua{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=go.tab||i.ctrlKey)return;const n=new Wr(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()}))}observe(){}stopObserving(){}}const Hl=function(e){return vn(e,5)};class $l extends(U()){constructor(e){super(),this.domRoots=new Map,this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this.document=new Jr(e),this.domConverter=new za(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Pa(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new ca(this.document),this.addObserver(Vl),this.addObserver(Ol),this.addObserver(Bl),this.addObserver(Za),this.addObserver(cl),this.addObserver(Ml),this.addObserver(Ll),this.addObserver(Dl),this.addObserver(zl),this.document.on("arrowKey",Sa,{priority:"low"}),oa(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})),r.isiOS&&this.listenTo(this.document,"blur",((e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}))}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:o}of Array.from(e.attributes))n[t]=o,"class"===t?this._writer.addClass(o.split(" "),i):this._writer.setAttribute(t,o,i);this._initialDomRootAttributes.set(e,n);const o=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),i.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),i.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),i.on("change:isReadOnly",(()=>this.change(o))),i.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const e of this._observers.values())e.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:n=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const s=Hl({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const r={target:this.domConverter.viewRangeToDom(o),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",r,s),function({target:e,viewportOffset:t=0,ancestorOffset:i=0,alignToTop:n,forceScroll:o}){const s=ao(e);let r=s,a=null;for(t=function(e){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:e}(t);r;){let l;l=lo(r==s?e:a),io({parent:l,getRect:()=>co(e,r),alignToTop:n,ancestorOffset:i,forceScroll:o});const c=co(e,r);if(to({window:r,rect:c,viewportOffset:t,alignToTop:n,forceScroll:o}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}(r)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new _("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(e){_.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Ol).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Dr._createAt(e,t)}createPositionAfter(e){return Dr._createAfter(e)}createPositionBefore(e){return Dr._createBefore(e)}createRange(e,t){return new Lr(e,t)}createRangeOn(e){return Lr._createOn(e)}createRangeIn(e){return Lr._createIn(e)}createSelection(...e){return new Hr(...e)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}class Wl{is(){throw new Error("is() method is abstract")}}class jl extends Wl{constructor(e){super(),this.parent=null,this._attrs=Zo(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new _("model-node-not-found-in-parent",this);return e}get startOffset(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildStartOffset(this)))throw new _("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=X(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n](e[t[0]]=t[1],e)),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=Zo(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}jl.prototype.is=function(e){return"node"===e||"model:node"===e};class Ul{constructor(e){this._nodes=[],e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce(((e,t)=>e+t.offsetSize),0)}getNode(e){return this._nodes[e]||null}getNodeIndex(e){const t=this._nodes.indexOf(e);return-1==t?null:t}getNodeStartOffset(e){const t=this.getNodeIndex(e);return null===t?null:this._nodes.slice(0,t).reduce(((e,t)=>e+t.offsetSize),0)}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new _("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&e1e4)return e.slice(0,i).concat(t).concat(e.slice(i+n,e.length));{const o=Array.from(e);return o.splice(i,n,...t),o}}(this._nodes,Array.from(t),e,0)}_removeNodes(e,t=1){return this._nodes.splice(e,t)}toJSON(){return this._nodes.map((e=>e.toJSON()))}}class ql extends jl{constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new ql(this.data,this.getAttributes())}static fromJSON(e){return new ql(e.data,e.attributes)}}ql.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class Gl extends Wl{constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new _("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new _("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}Gl.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class Kl extends jl{constructor(e,t,i){super(t),this._children=new Ul,this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):void 0;return new Kl(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new ql(e)];ee(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new ql(e):e instanceof Gl?new ql(e.data,e.getAttributes()):e))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(Kl.fromJSON(i)):t.push(ql.fromJSON(i))}return new Kl(e.name,e.attributes,t)}}Kl.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e};class Zl{constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new _("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new _("model-tree-walker-unknown-direction",e,{direction:t});this.direction=t,this.boundaries=e.boundaries||null,e.startPosition?this._position=e.startPosition.clone():this._position=Yl._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,n,o;do{n=this.position,o=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,this._visitedParent=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const n=Ql(t,i),o=n||Xl(t,i,n);if(o instanceof Kl){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=o;return this._position=t,Jl("elementStart",o,e,t,1)}if(o instanceof ql){let n;if(this.singleCharacters)n=1;else{let e=o.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),n=t.offset-e}const o=t.offset-s.startOffset,r=new Gl(s,o-n,n);return t.offset-=n,this._position=t,Jl("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,Jl("elementStart",i,e,t,1)}}function Jl(e,t,i,n,o){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}class Yl extends Wl{constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new _("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new _("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t1)return!1;if(1===t)return tc(e,this,i);if(-1===t)return tc(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?ic(this.path,t):ic(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==X(this.getParentPath(),e.getParentPath())}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=Yl._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?Yl._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=Yl._createAt(this);if(this.root!=e.root)return i;if("same"==X(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==X(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=Yl._createAt(this);if(this.root!=e.root)return i;if("same"==X(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[n]+o!==i.maxOffset)return!1;o=1,n--,i=i.parent}return!0}(e,i+1))}function ic(e,t){for(;tt+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new nc(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new nc(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new Zl(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Zl(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new Zl(e);yield t.position;for(const e of t)yield e.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new nc(this.start,this.end)]}getTransformedByOperations(e){const t=[new nc(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,n):new this(n,i)}static _createIn(e){return new this(Yl._createAt(e,0),Yl._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(Yl._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new _("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const i=e.indexOf(t),n=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(n.start);t++)n.start=Yl._createAt(e[t].start);for(let t=i+1;t{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new _("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=Yl._createAt(n,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new nc(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Lr(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let n=0;for(let i=0;i1?t[0]+":"+t[1]:t[0]}class ac extends(P()){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=this._createConversionApi(i,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,n);const o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(nc._createFromPositionAndShift(e.position,e.length),n):"reinsert"===e.type?this._convertReinsert(nc._createFromPositionAndShift(e.position,e.length),n):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,n):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,n);n.mapper.flushDeferredBindings();for(const e of n.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,n),this._convertMarkerAdd(e,i,n)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,n);n.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const o=this._createConversionApi(i,void 0,n);this._convertInsert(e,o);for(const[e,i]of t)this._convertMarkerAdd(e,i,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const o=e.getFirstPosition().root;if(!n.mapper.toViewElement(o))return;const s=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,s),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of s)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!lc(e.getFirstPosition(),t,n.mapper))continue;const o={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,o,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,n)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const i of Array.from(e.getWalker({shallow:!0})).map(cc))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const s of e){const e={item:s.item,range:nc._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(cc))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n=`addMarker:${e}`;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const o of t.getItems()){if(!i.consumable.test(o,n))continue;const s={item:o,range:nc._createOn(o),markerName:e,markerRange:t};this.fire(n,s,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){const i=t.item.is("element")?t.item.name:"$text";return`${e}:${i}`}(e,t),o=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,s=this._firedEventsMap.get(i),r=s.get(o);if(r){if(r.has(n))return;r.add(n)}else s.set(o,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:nc._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new sc,writer:e,options:i,convertItem:e=>this._convertInsert(nc._createOn(e),n),convertChildren:e=>this._convertInsert(nc._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}}function lc(e,t,i){const n=t.getRange(),o=Array.from(e.getAncestors());o.shift(),o.reverse();return!o.some((e=>{if(n.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}}))}function cc(e){return{item:e.item,range:nc._createFromPositionAndShift(e.previousPosition,e.length)}}class dc extends(P(Wl)){constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new nc(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?new nc(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?new nc(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof 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],!!n&&!!n.backward);else if(t instanceof Yl)this._setRanges([new nc(t)]);else if(t instanceof jl){const e=!!n&&!!n.backward;let o;if("in"==i)o=nc._createIn(t);else if("on"==i)o=nc._createOn(t);else{if(void 0===i)throw new _("model-selection-setto-required-second-parameter",[this,t]);o=new nc(Yl._createAt(t,i))}this._setRanges([o],e)}else{if(!ee(t))throw new _("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,n&&!!n.backward)}}_setRanges(e,t=!1){const i=Array.from(e),n=i.some((t=>{if(!(t instanceof nc))throw new _("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new _("model-selection-setfocus-no-ranges",[this,e]);const i=Yl._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new nc(i,n)),this._lastRangeBackward=!0):(this._pushRange(new nc(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=mc(t.start,e);fc(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&uc(n,e,t)&&(yield n)}const n=mc(t.end,e);pc(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=Yl._createAt(e,0),i=Yl._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new nc(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function hc(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function uc(e,t,i){return hc(e,t)&&gc(e,i)}function mc(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const s=n.find((e=>!o&&(o=i.isLimit(e),!o&&hc(e,t))));return n.forEach((e=>t.add(e))),s}function gc(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);if(!i)return!0;return!t.containsRange(nc._createOn(i),!0)}function fc(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(Yl._createAt(e,e.maxOffset))&&gc(e,t))}function pc(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(Yl._createAt(e,0))&&gc(e,t))}dc.prototype.is=function(e){return"selection"===e||"model:selection"===e};class bc extends(P(nc)){constructor(e,t){super(e,t),wc.call(this)}detach(){this.stopListening()}toRange(){return new nc(this.start,this.end)}static fromRange(e){return new bc(e.start,e.end)}}function wc(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&_c.call(this,i)}),{priority:"low"})}function _c(e){const t=this.getTransformedByOperation(e),i=nc._createFromRanges(t),n=!i.isEqual(this),o=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let s=null;if(n){"$graveyard"==i.root.rootName&&(s="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:s})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:s})}bc.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const vc="selection:";class yc extends(P(Wl)){constructor(e){super(),this._selection=new kc(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return vc+e}static _isStoreAttributeKey(e){return e.startsWith(vc)}}yc.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class kc extends dc{constructor(e){super(),this.markers=new Uo({idProperty:"name"}),this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{this._validateSelectionRanges(this.getRanges())})),this.listenTo(this._model.markers,"update",((e,t,i,n)=>{this._updateMarker(t,n)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(vc)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const o=Array.from(this.markers),s=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!s?(this.markers.add(e),n=!0):!i&&s&&(this.markers.remove(e),n=!0)}else s&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=Zo(this._getSurroundingAttributes()),i=Zo(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";if("low"==n&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,i),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e){this._setAttribute(i,n,!1)&&t.add(i)}return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(vc)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Cc(n,t)),i||(i=Cc(o,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=Cc(e,t)}if(!i){let e=o;for(;e&&!i;)e=e.nextSibling,i=Cc(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=Cc(n.item,t);break}if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Cc(e,t){if(!e)return null;if(e instanceof Gl||e instanceof ql)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,o]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,o]);return i}class Ac{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class xc extends Ac{elementToElement(e){return this.add(function(e){const t=Vc(e.model),i=Rc(e.view,"container");t.attributes.length&&(t.children=!0);return n=>{n.on(`insert:${t.name}`,Sc(i,Nc(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",Fc(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Vc(e.model),i=Rc(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new _("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var o,s;n.on(`insert:${t.name}`,(o=i,s=Nc(t),(e,t,i)=>{if(!s(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,o)=>{const s=n.createContainerElement("$slot");let r=null;if("children"===o)r=Array.from(e.getChildren());else{if("function"!=typeof o)throw new _("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:o});r=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(s,r),s}}(t.item,n,i));const r=o(t.item,i,t);if(i.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),o=new Set(n);if(o.size!=n.length)throw new _("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(o.size!=e.childCount)throw new _("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),s(t.item,i.consumable);const a=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,r),i.writer.insert(a,r),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let o=null,s=null;for([o,s]of t)Dc(e,s,i,n),i.writer.move(i.writer.createRangeIn(o),i.writer.createPositionBefore(o)),i.writer.remove(o);function r(e,t){const i=t.modelPosition.nodeAfter,n=s.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(o,n))}i.mapper.off("modelToViewPosition",r)}(r,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",Fc(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=Hl(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Rc(e.view[i],"attribute");else e.view=Rc(e.view,"attribute");const n=Oc(e);return t=>{t.on(i,Tc(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Hl(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Bc(e.view[i]);else e.view=Bc(e.view);const n=Oc(e);return t=>{var o;t.on(i,(o=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=o(t.attributeOldValue,i,t),s=o(t.attributeNewValue,i,t);if(!n&&!s)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new _("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n)if("class"==n.key){const e="string"==typeof n.value?n.value.split(/\s+/):n.value;for(const t of e)a.removeClass(t,r)}else if("style"==n.key)if("string"==typeof n.value){const e=new Er(a.document.stylesProcessor);e.setTo(n.value);for(const[t]of e.getStylesEntries())a.removeStyle(t,r)}else{const e=Object.keys(n.value);for(const t of e)a.removeStyle(t,r)}else a.removeAttribute(n.key,r);if(null!==t.attributeNewValue&&s)if("class"==s.key){const e="string"==typeof s.value?s.value.split(/\s+/):s.value;for(const t of e)a.addClass(t,r)}else if("style"==s.key)if("string"==typeof s.value){const e=new Er(a.document.stylesProcessor);e.setTo(s.value);for(const[t,i]of e.getStylesEntries())a.setStyle(t,i,r)}else{const e=Object.keys(s.value);for(const t of e)a.setStyle(t,s.value[t],r)}else a.setAttribute(s.key,s.value,r)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=Rc(e.view,"ui");return i=>{i.on(`addMarker:${e.model}`,Pc(t),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,((e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on(`addMarker:${e.model}`,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof dc||t.item instanceof yc||t.item.is("$textProxy")))return;const o=Mc(i,t,n);if(!o)return;if(!n.consumable.consume(t.item,e.name))return;const s=n.writer,r=Ec(s,o),a=s.document.selection;if(t.item instanceof dc||t.item instanceof yc)s.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=s.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof Kl))return;const o=Mc(e,i,n);if(!o)return;if(!n.consumable.test(i.item,t.name))return;const s=n.mapper.toViewElement(i.item);if(s&&s.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of nc._createIn(i.item))n.consumable.consume(e.item,t.name);s.getCustomProperty("addHighlight")(s,o,n.writer),n.mapper.bindElementToMarker(s,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const o=Mc(e,i,n);if(!o)return;const s=Ec(n.writer,o),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)if(n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement"))n.writer.unwrap(n.writer.createRangeOn(e),s);else{e.getCustomProperty("removeHighlight")(e,o.id,n.writer)}n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){e=Hl(e);const t=e.model;let i=e.view;i||(i=i=>({group:t,name:i.substr(e.model.length+1)}));return n=>{var o;n.on(`addMarker:${t}`,(o=i,(e,t,i)=>{const n=o(t.markerName,i);if(!n)return;const s=t.markerRange;i.consumable.consume(s,e.name)&&(Ic(s,!1,i,t,n),Ic(s,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const o=e(i.markerName,n);if(!o)return;const s=n.mapper.markerNameToElements(i.markerName);if(s){for(const e of s)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${o.group}-start-before`,e),r(`data-${o.group}-start-after`,e),r(`data-${o.group}-end-before`,e),r(`data-${o.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(o.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Ec(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function Tc(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const o=e(i.attributeOldValue,n,i),s=e(i.attributeNewValue,n,i);if(!o&&!s)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof dc||i.item instanceof yc)r.wrap(a.getFirstRange(),s);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&o&&(e=r.unwrap(e,o)),null!==i.attributeNewValue&&s&&r.wrap(e,s)}}}function Sc(e,t=zc){return(i,n,o)=>{if(!t(n.item,o.consumable,{preflight:!0}))return;const s=e(n.item,o,n);if(!s)return;t(n.item,o.consumable);const r=o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(n.item,s),o.writer.insert(r,s),o.convertAttributes(n.item),Dc(s,n.item.getChildren(),o,{reconversion:n.reconversion})}}function Pc(e){return(t,i,n)=>{i.isOpening=!0;const o=e(i,n);i.isOpening=!1;const s=e(i,n);if(!o||!s)return;const r=i.markerRange;if(r.isCollapsed&&!n.consumable.consume(r,t.name))return;for(const e of r)if(!n.consumable.consume(e.item,t.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(r.start),o),n.mapper.bindElementToMarker(o,i.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),s),n.mapper.bindElementToMarker(s,i.markerName)),t.stop()}}function Ic(e,t,i,n,o){const s=t?e.start:e.end,r=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(r||a){let e,s;t&&r||!t&&!a?(e=r,s=!0):(e=a,s=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,o,s){const r=`data-${s.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(s.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,o.markerName)}(l,t,s,i,n,o)}!function(e,t,i,n,o){const s=`${o.group}-${t?"start":"end"}`,r=o.name?{name:o.name}:null,a=i.writer.createUIElement(s,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(s),t,i,n,o)}function Vc(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?vo(e.attributes):[],children:!!e.children}}function Rc(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){"string"==typeof e&&(e={name:e});let n;const o=t.writer,s=Object.assign({},e.attributes);if("container"==i)n=o.createContainerElement(e.name,s);else if("attribute"==i){const t={priority:e.priority||Qr.DEFAULT_PRIORITY};n=o.createAttributeElement(e.name,s,t)}else n=o.createUIElement(e.name,s);if(e.styles){const t=Object.keys(e.styles);for(const i of t)o.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,n);else for(const e of t)o.addClass(e,n)}return n}(e,n,t)}function Oc(e){return e.model.values?(t,i,n)=>{const o=e.view[t];return o?o(t,i,n):null}:e.view}function Bc(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Mc(e,t,i){const n="function"==typeof e?e(t,i):e;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function Fc(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)){if(!i.reconvertedElements.has(o)){i.reconvertedElements.add(o);const e=Yl._createBefore(o);let t=n.length;for(let i=n.length-1;i>=0;i--){const o=n[i],s=("attribute"==o.type?o.range.start:o.position).compareWith(e);if("before"==s||"remove"==o.type&&"same"==s)break;t=i}n.splice(t,0,{type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function Nc(e){return(t,i,n={})=>{const o=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&o.push(`attribute:${i}`);return!!o.every((e=>i.test(t,e)))&&(n.preflight||o.forEach((e=>i.consume(t,e))),!0)}}function Dc(e,t,i,n){for(const o of t)Lc(e.root,o,i,n)||i.convertItem(o)}function Lc(e,t,i,n){const{writer:o,mapper:s}=i;if(!n.reconversion)return!1;const r=s.toViewElement(t);return!(!r||r.root==e)&&(!!i.canReuseView(r)&&(o.move(o.createRangeOn(r),s.toViewPosition(Yl._createBefore(t))),!0))}function zc(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function Hc(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function $c(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function Wc(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class jc extends Ac{elementToElement(e){return this.add(Uc(e))}elementToAttribute(e){return this.add(function(e){e=Hl(e),Kc(e);const t=Zc(e,!1),i=qc(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Hl(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key,i=void 0===e.view.value?/[\s\S]*/:e.view.value;let n;if("class"==t||"style"==t){const e="class"==t?"classes":"styles";n={[e]:i}}else n={attributes:{[t]:i}};e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));Kc(e,t);const i=Zc(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return Uc({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){e=Hl(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=Gc(Jc(t,"start")),n=Gc(Jc(t,"end"));return o=>{o.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),o.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});const s=p.low,r=p.highest,a=p.get(e.converterPriority)/r;o.on("element",function(e){return(t,i,n)=>{const o=`data-${e.view}`;function s(t,o){for(const s of o){const o=e.model(s,n),r=n.writer.createElement("$marker",{"data-name":o});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:o+"-end-after"})||n.consumable.test(i.viewItem,{attributes:o+"-start-after"})||n.consumable.test(i.viewItem,{attributes:o+"-end-before"})||n.consumable.test(i.viewItem,{attributes:o+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:o+"-end-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-end-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:s+a})}}(e))}}function Uc(e){const t=Gc(e=Hl(e)),i=qc(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function qc(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Gc(e){const t=new Js(e.view);return(i,n,o)=>{const s=t.match(n.viewItem);if(!s)return;const r=s.match;if(r.name=!0,!o.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,o);a&&o.safeInsert(a,n.modelCursor)&&(o.consumable.consume(n.viewItem,r),o.convertChildren(n.viewItem,a),o.updateConversionResult(a,n))}}function Kc(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:o}}function Zc(e,t){const i=new Js(e.view);return(n,o,s)=>{if(!o.modelRange&&t)return;const r=i.match(o.viewItem);if(!r)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!qc(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,o.viewItem)?delete r.match.name:r.match.name=!0,!s.consumable.test(o.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(o.viewItem,s):e.model.value;if(null===l)return;o.modelRange||Object.assign(o,s.convertChildren(o.viewItem,o.modelCursor));const c=function(e,t,i,n){let o=!1;for(const s of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(s,t.key)&&(o=!0,s.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,s));return o}(o.modelRange,{key:a,value:l},t,s);c&&(s.consumable.test(o.viewItem,{name:!0})&&(r.match.name=!0),s.consumable.consume(o.viewItem,r.match))}}function Jc(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),o=e.model(n,i);return i.writer.createElement("$marker",{"data-name":o})}}}function Yc(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.selection,n=t.schema,o=[];let s=!1;for(const e of i.getRanges()){const t=Qc(e,n);t&&!t.isEqual(e)?(o.push(t),s=!0):o.push(e)}s&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n!i.has(t)))}(o),{backward:i.isBackward});return!1}(t,e)))}function Qc(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?nc._createOn(e):null}if(!n.isCollapsed)return n;const o=n.start;if(i.isEqual(o))return null;return new nc(o)}(e,t):function(e,t){const{start:i,end:n}=e,o=t.checkChild(i,"$text"),s=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(o&&s)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),o=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||o}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),o=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),s=e?e.start:i,r=o?o.end:n;return new nc(s,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,o=l&&(!e||!ed(i.nodeAfter,t)),s=c&&(!e||!ed(n.nodeBefore,t));let d=i,h=n;return o&&(d=Yl._createBefore(Xc(r,t))),s&&(h=Yl._createAfter(Xc(a,t))),new nc(d,h)}return null}(e,t)}function Xc(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function ed(e,t){return e&&t.isSelectable(e)}class td extends(U()){constructor(e,t){super(),this.model=e,this.view=new $l(t),this.mapper=new oc,this.downcastDispatcher=new ac({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.selection,o=this.model.markers;var s,a,l;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(i,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(i.differ,o,e),this.downcastDispatcher.convertSelection(n,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const o=n.newSelection,s=[];for(const e of o.getRanges())s.push(t.toModelRange(e));const r=e.createSelection(s,{backward:o.isBackward});r.isEqual(e.document.selection)||e.change((e=>{e.setSelection(r)}))}}(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",(s=this.mapper,a=this.model.schema,l=this.view,(e,t)=>{if(!l.document.isComposing||r.isAndroid)for(let e=0;e{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),s=i.mapper.toViewPosition(o,{isPhantom:!0}),r=i.writer.createRange(n,s),a=i.writer.remove(r.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",((e,t,i)=>{const n=i.writer,o=n.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)})),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=[];for(const e of n.getRanges())o.push(i.mapper.toViewRange(e));i.writer.setSelection(o,{backward:n.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=i.writer,s=n.getFirstPosition(),r=i.mapper.toViewPosition(s),a=o.breakAttributes(r);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new Fr(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new _("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(i)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}class id{constructor(){this._consumables=new Map}add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new od(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const n=e.getClassNames();for(const e of n)t.classes.push(e);const o=e.getStyleNames();for(const e of o)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new id),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,id.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=id.createFrom(i,t);return t}}const nd=["attributes","classes","styles"];class od{constructor(e){this.element=e,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(e){e.name&&(this._canConsumeName=!0);for(const t of nd)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of nd)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of nd)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of nd)t in e&&this._revert(t,e[t])}_add(e,t){const i=vo(t),n=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new _("viewconsumable-invalid-attribute",this);if(n.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!0)}}_test(e,t){const i=vo(t),n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=n.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=vo(t),n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(n.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=vo(t),n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){!1===n.get(t)&&n.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class sd extends(U()){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new rd(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new rd(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new _("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},t)],this._clearCache()}extend(e,t){if(!this._sourceDefinitions[e])throw new _("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!!t&&!(!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!!t&&!(!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!!t&&!(!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof Yl){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof Kl))throw new _("schema-check-merge-no-element-before",this);if(!(i instanceof Kl))throw new _("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[i,n])=>{if(!n)return;const o=e(i,n);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,n])=>{const o=e(i,n);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;if(e instanceof Yl)t=e.parent;else{t=(e instanceof nc?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new ql("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new nc(e);let i,n;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new Zl({boundaries:nc._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new Zl({boundaries:nc._createIn(o),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return nc._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new nc(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const n=i.model;for(const[o,s]of Object.entries(t))n.schema.checkAttribute(e,o)&&i.setAttribute(o,s,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))_d(this,i,t);else{const e=nc._createIn(i).getPositions();for(const i of e){_d(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const n={};for(const[o,s]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[o]=s))}return n}createContext(e){return new rd(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=ad(t[n],n);for(const t of i)ld(e,t);for(const t of i)cd(e,t);for(const t of i)dd(e,t);for(const t of i)hd(e,t),ud(e,t);for(const t of i)md(e,t),gd(e,t),fd(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const n=t.getItem(i);if(e.allowIn.includes(n.name)){if(0==i)return!0;{const e=this.getDefinition(n);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(nc._createIn(o),t)),this.checkAttribute(o,t)||(i.isEqual(n)||(yield new nc(i,n)),i=Yl._createAfter(o)),n=Yl._createAfter(o);i.isEqual(n)||(yield new nc(i,n))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return"before"==t||"after"==t?new nc(Yl._createAt(i,t)):nc._createOn(i);const n=qo(e.getSelectedBlocks());if(!n)return new nc(e.focus);if(n.isEmpty)return new nc(Yl._createAt(n,0));const o=Yl._createAfter(n);return e.focus.isTouching(o)?new nc(o):new nc(Yl._createBefore(n))}}class rd{constructor(e){if(e instanceof rd)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(wd)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new rd([e]);return t._items=[...this._items,...t._items],t}getItem(e){return this._items[e]}*getNames(){yield*this._items.map((e=>e.name))}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function ad(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const n of e)t[n]=!!i[n]}}(e,i),pd(e,i,"allowIn"),pd(e,i,"allowContentOf"),pd(e,i,"allowWhere"),pd(e,i,"allowAttributes"),pd(e,i,"allowAttributesOf"),pd(e,i,"allowChildren"),pd(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function ld(e,t){const i=e[t];for(const n of i.allowChildren){const i=e[n];i&&i.allowIn.push(t)}i.allowChildren.length=0}function cd(e,t){for(const i of e[t].allowContentOf)if(e[i]){bd(e,i).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function dd(e,t){for(const i of e[t].allowWhere){const n=e[i];if(n){const i=n.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function hd(e,t){for(const i of e[t].allowAttributesOf){const n=e[i];if(n){const i=n.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function ud(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const n=e[t];if(n){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const t of e)t in i||(i[t]=n[t])}}delete i.inheritTypesFrom}function md(e,t){const i=e[t],n=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(n))}function gd(e,t){const i=e[t];for(const n of i.allowIn){e[n].allowChildren.push(t)}}function fd(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function pd(e,t,i){for(const n of e){const e=n[i];"string"==typeof e?t[i].push(e):Array.isArray(e)&&t[i].push(...e)}}function bd(e,t){const i=e[t];return(n=e,Object.keys(n).map((e=>n[e]))).filter((e=>e.allowIn.includes(i.name)));var n}function wd(e){return"string"==typeof e||e.is("documentFragment")?{name:"string"==typeof e?e:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:e.is("element")?e.name:"$text",*getAttributeKeys(){yield*e.getAttributeKeys()},getAttribute:t=>e.getAttribute(t)}}function _d(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class vd extends(P()){constructor(e){super(),this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new rd(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const o=t.createElement(n.name,e);i&&t.insert(o,i),i=Yl._createAt(o,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=id.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const i=new Set,n=new Map,o=nc._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),o=t.createPositionBefore(e);n.has(i)?n.get(i).end=o.clone():n.set(i,new nc(o.clone())),t.remove(e)}return n}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof nc))throw new _("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:Yl._createAt(t,0);const n=new nc(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof nc&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?n.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let o=i.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return $c(t,e,i)?{position:Wc(t,n)}:null;const s=this.conversionApi.writer.split(t,o),r=[];for(const e of s.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=s.range.end.parent;return this._cursorParents.set(e,a),{position:s.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&!this._emptyElementsToKeep.has(t)&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}}class yd{getHtml(e){const i=t.document.implementation.createHTMLDocument("").createElement("div");return i.appendChild(e),i.innerHTML}}class kd{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new za(e,{renderingMode:"data"}),this.htmlWriter=new yd}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}class Cd extends(P()){constructor(e,t){super(),this.model=e,this.mapper=new oc,this.downcastDispatcher=new ac({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new vd({schema:e.schema}),this.viewDocument=new Jr(t),this.stylesProcessor=t,this.htmlProcessor=new kd(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new ca(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:o})=>{let s=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(s,"$text")){if(!$c(s,"$text",i))return;if(0==t.viewItem.data.trim().length)return;const e=s.nodeBefore;s=Wc(s,o),e&&e.is("element","$marker")&&(o.move(o.createRangeOn(e),s),s=o.createPositionAfter(e))}n.consume(t.viewItem);const r=o.createText(t.viewItem.data);o.insert(r,s),t.modelRange=o.createRange(s,s.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),U().prototype.decorate.call(this,"init"),U().prototype.decorate.call(this,"set"),U().prototype.decorate.call(this,"get"),U().prototype.decorate.call(this,"toView"),U().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},Hc)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new _("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||v("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const o=nc._createIn(e),s=new la(i);this.mapper.bindElements(e,s);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=nc._createIn(e);for(const e of i.model.markers){const i=e.getRange(),o=i.isCollapsed,s=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&s)t.push([e.name,i]);else{const o=n.getIntersection(i);o&&t.push([e.name,o])}}return t.sort((([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,r,n,t),s}init(e){if(this.model.document.version)throw new _("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new _("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new _("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}}))}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change((i=>this.upcastDispatcher.convert(e,i,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}class Ad{constructor(e,t){this._helpers=new Map,this._downcast=vo(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=vo(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new _("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new _("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of xd(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of xd(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of xd(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new _("conversion-group-exists",this);const n=i?new xc(t):new jc(t);this._helpers.set(e,n)}}function*xd(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*Ed(i,n,o)}else yield*Ed(e.model,e.view,e.upcastAlso)}function*Ed(e,t,i){if(yield{model:e,view:t},i)for(const t of vo(i))yield{model:e,view:t}}class Td{constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}function Sd(e,t){const i=Vd(t),n=i.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;Od(e);const s=e.index;return o._insertChild(s,i),Rd(o,s+i.length),Rd(o,s),new nc(e,e.getShiftedBy(n))}function Pd(e){if(!e.isFlat)throw new _("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Od(e.start),Od(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Rd(t,e.start.index),i}function Id(e,t){if(!e.isFlat)throw new _("operation-utils-move-range-not-flat",this);const i=Pd(e);return Sd(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Vd(e){const t=[];!function e(i){if("string"==typeof i)t.push(new ql(i));else if(i instanceof Gl)t.push(new ql(i.data,i.getAttributes()));else if(i instanceof jl)t.push(i);else if(ee(i))for(const t of i)e(t);else{}}(e);for(let e=1;ee.maxOffset)throw new _("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new Fd(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new Yl(e,[0]);return new Md(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Sd(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const t of e.nodes)t.name?i.push(Kl.fromJSON(t)):i.push(ql.fromJSON(t));const n=new Fd(Yl.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class Nd extends Td{constructor(e,t,i,n,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new Yl(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new nc(this.splitPosition,e)}get affectedSelectable(){const e=[nc._createFromPositionAndShift(this.splitPosition,0),nc._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(nc._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new Nd(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new Yl(e,[0]);return new Dd(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof Ld){const i=e.newRange;if(!i)return;if(t instanceof Md){const n=nc._createFromPositionAndShift(t.sourcePosition,t.howMany),o=n.containsPosition(i.start)||n.start.isEqual(i.start),s=n.containsPosition(i.end)||n.end.isEqual(i.end);!o&&!s||n.containsRange(i)||this._setRelation(e,t,{side:o?"left":"right",path:o?i.start.path.slice():i.end.path.slice()})}else if(t instanceof Dd){const n=i.start.isEqual(t.targetPosition),o=i.start.isEqual(t.deletionPosition),s=i.end.isEqual(t.deletionPosition),r=i.end.isEqual(t.sourcePosition);(n||o||s||r)&&this._setRelation(e,t,{wasInLeftElement:n,wasStartBeforeMergedElement:o,wasEndBeforeMergedElement:s,wasInRightElement:r})}}}getContext(e,t,i){return{aIsStrong:i,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const i=this.originalOperations.get(t),n=this._history.getUndoneOperation(i);if(!n)return null;const o=this.originalOperations.get(e),s=this._relations.get(o);return s&&s.get(n)||null}_setRelation(e,t,i){const n=this.originalOperations.get(e),o=this.originalOperations.get(t);let s=this._relations.get(n);s||(s=new Map,this._relations.set(n,s)),s.set(o,i)}}function eh(e,t){for(const i of e)i.baseVersion=t++}function th(e,t){for(let i=0;i{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map((t=>new Hd(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&i.aIsStrong&&n.push(new Hd(o,t.key,t.newValue,e.newValue,0)),0==n.length?[new $d(0)]:n}return[e]})),Zd(Hd,Fd,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new Hd(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=ih(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Zd(Hd,Dd,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(nc._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new Hd(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Zd(Hd,Md,((e,t)=>{const i=function(e,t){const i=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,o=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(o=e.getDifference(i),n=e.getIntersection(i)):o=[e];const s=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),o=e._getTransformedByInsertion(i,t.howMany,n);s.push(...o)}n&&s.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return s}(e.range,t);return i.map((t=>new Hd(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Zd(Hd,Nd,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new nc(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),Zd(Fd,Hd,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=ih(e,t.key,t.newValue);n&&i.push(n)}return i})),Zd(Fd,Fd,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Zd(Fd,Md,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Zd(Fd,Nd,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Zd(Fd,Dd,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Zd(Ld,Fd,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Zd(Ld,Ld,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new $d(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Zd(Ld,Dd,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Zd(Ld,Md,((e,t,i)=>{if(e.oldRange&&(e.oldRange=nc._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=nc._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=n.end,e.newRange.start.path=i.abRelation.path,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=n.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=nc._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Zd(Ld,Nd,((e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=Yl._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=Yl._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=Yl._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=Yl._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Zd(Dd,Fd,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),Zd(Dd,Dd,((e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new Yl(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new $d(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName;if(o&&!n||!(n&&!o)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Md(i,e.howMany,n,0)]}return[new $d(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Zd(Dd,Md,((e,t,i)=>{const n=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new $d(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(e.sourcePosition)&&"mergeSourceAffected"==i.abRelation?e.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness="toNone",e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&"mergeTargetWasBefore"==i.abRelation?(e.targetPosition.stickiness="toPrevious",e.howMany+=t.howMany):(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany)),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.sourcePosition.stickiness="toPrevious",e.targetPosition.stickiness="toNext",e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),Zd(Dd,Nd,((e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const n=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||o||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),Zd(Md,Fd,((e,t)=>{const i=nc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),Zd(Md,Md,((e,t,i)=>{const n=nc._createFromPositionAndShift(e.sourcePosition,e.howMany),o=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);let s,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),s=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),nh(e,t)&&nh(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(o,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),oh([n],s);if(o.containsPosition(e.targetPosition)&&o.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),oh([n],s);const l=X(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),oh([n],s);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],d=n.getDifference(o);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==X(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const h=n.getIntersection(o);return null!==h&&r&&(h.start=h.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),h.end=h.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(h):1==c.length?o.start.isBefore(n.start)||o.start.isEqual(n.start)?c.unshift(h):c.push(h):c.splice(1,0,h)),0===c.length?[new $d(e.baseVersion)]:oh(c,s)})),Zd(Md,Nd,((e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const o=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new nc(t.splitPosition,o.end);e=e._getTransformedBySplitOperation(t);return oh([new nc(o.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const s=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&s.push(nc._createFromPositionAndShift(t.insertionPosition,1))}return oh(s,n)})),Zd(Md,Dd,((e,t,i)=>{const n=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new $d(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Md(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const s=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),r=new Md(n,1,s,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new Yl(r.targetPosition.root,a);o=o._getTransformedByMove(n,s,1);const c=new Md(o,t.howMany,l,0);return i.push(r),i.push(c),i}const o=nc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=o.start,e.howMany=o.end.offset-o.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),Zd(Wd,Fd,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Zd(Wd,Dd,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Zd(Wd,Md,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Zd(Wd,Wd,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new $d(0)];e.oldName=t.newName}return[e]})),Zd(Wd,Nd,((e,t)=>{if("same"==X(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new Wd(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),Zd(jd,jd,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new $d(0)];e.oldValue=t.newValue}return[e]})),Zd(Ud,Ud,((e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new $d(0)]:[e])),Zd(Nd,Fd,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new Yl(t.graveyardPosition.root,i),o=Nd.getInsertionPosition(new Yl(t.graveyardPosition.root,i)),s=new Nd(n,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Nd.getInsertionPosition(e.splitPosition),e.graveyardPosition=s.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[s,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Nd.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Zd(Nd,Md,((e,t,i)=>{const n=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&o){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),o=n.path.slice();o.push(0);const s=new Yl(n.root,o);return[new Md(i,e.howMany,s,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Nd.getInsertionPosition(e.splitPosition),[e];if(o&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new $d(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new $d(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName;if(o&&!n||!(n&&!o)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Md(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Md(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new $d(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new Yl(t.insertionPosition.root,i);return[e,new Md(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const i=t[0];i.isDocumentOperation&&ah.call(this,i)}),{priority:"low"})}function ah(e){const t=this.getTransformedByOperation(e);if(!this.isEqual(t)){const e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}sh.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class lh{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},v("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=o}get type(){return v("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.batch=this,this.operations.push(e),e}}class ch{constructor(e){this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changedRoots=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set,this._markerCollection=e}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}bufferOperation(e){const t=e;switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=nc._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1);const n=t.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,t.targetPosition.offset,e.maxOffset);break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this.getChanges().length)return!0;if(this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,n=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||o)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offsete.position.root!=t.position.root?e.position.root.rootNamee));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(uh),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map((e=>{const t={...e};return void 0!==t.state&&delete t.attributes,t}))}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const o=this._changedRoots.get(e)||{name:e},s=o.attributes||{};if(s[t]){const e=s[t];n===e.oldValue?delete s[t]:e.newValue=n}else s[t]={oldValue:i,newValue:n};0===Object.entries(s).length?(delete o.attributes,void 0===o.state&&this._changedRoots.delete(e)):(o.attributes=s,this._changedRoots.set(e,o))}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e);const t=nc._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;ei.offset){if(n>o){const e={type:"attribute",offset:o,howMany:n-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offseto?(e.nodesToHandle=n-o,e.offset=o):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const o={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=o&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:Yl._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++,_element:i.element}}_getRemoveDiff(e,t,i){return{type:"remove",position:Yl._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++,_element:i.element}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[o,s]of t){const t=i.has(o)?i.get(o):null;t!==s&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:s,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(o)}for(const[t,o]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&nn){for(let t=0;tthis._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new _("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&et&&nthis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let s=this._baseVersionToOperationIndex.get(n);return void 0===s&&(s=this._operations.length-1),this._operations.slice(o,s+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class gh extends Kl{constructor(e,t,i="main"){super(t),this._isAttached=!0,this._isLoaded=!0,this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}gh.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e):"rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e||"node"===e||"model:node"===e};const fh="$graveyard";class ph extends(P()){constructor(e){super(),this.model=e,this.history=new mh,this.selection=new yc(this),this.roots=new Uo({idProperty:"rootName"}),this.differ=new ch(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",fh),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,i,n,o)=>{const s={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,o,s),null===i&&t.on("change",((e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)}))})),this.registerPostFixer((e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(fh)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new _("model-document-createroot-name-exists",this,{name:t});const i=new gh(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map((e=>e.rootName))}getRoots(e=!1){return this.roots.filter((t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=qs(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return bh(e.start)&&bh(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}}function bh(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!Yo(i,n)&&!Qo(i,n)}return!0}class wh extends(P()){constructor(){super(...arguments),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof _h?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const o=e instanceof _h?e.name:e;if(o.includes(","))throw new _("markercollection-incorrect-marker-name",this);const s=this._markers.get(o);if(s){const e=s.getData(),r=s.getRange();let a=!1;return r.isEqual(t)||(s._attachLiveRange(bc.fromRange(t)),a=!0),i!=s.managedUsingOperations&&(s._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=s.affectsData&&(s._affectsData=n,a=!0),a&&this.fire(`update:${o}`,s,r,t,e),s}const r=bc.fromRange(t),a=new _h(o,r,i,n);return this._markers.set(o,a),this.fire(`update:${o}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof _h?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof _h?e.name:e,i=this._markers.get(t);if(!i)throw new _("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire(`update:${t}`,i,n,n,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class _h extends(P(Wl)){constructor(e,t,i,n){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}_h.prototype.is=function(e){return"marker"===e||"model:marker"===e};class vh extends Td{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new _("detach-operation-on-document-node",this)}_execute(){Pd(nc._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class yh extends Wl{constructor(e){super(),this.markers=new Map,this._children=new Ul,e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(Kl.fromJSON(i)):t.push(ql.fromJSON(i));return new yh(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new ql(e)];ee(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new ql(e):e instanceof Gl?new ql(e.data,e.getAttributes()):e))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}}yh.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class kh{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new ql(e,t)}createElement(e,t){return new Kl(e,t)}createDocumentFragment(){return new yh}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof ql&&""==e.data)return;const n=Yl._createAt(t,i);if(e.parent){if(Th(e.root,n.root))return void this.move(nc._createOn(e),n);if(e.root.document)throw new _("model-writer-insert-forbidden-move",this);this.remove(e)}const o=n.root.document?n.root.document.version:null,s=new Fd(n,e,o);if(e instanceof ql&&(s.shouldReceiveAttributes=!0),this.batch.addOperation(s),this.model.applyOperation(s),e instanceof yh)for(const[t,i]of e.markers){const e=Yl._createAt(i.root,0),o={range:new nc(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,o):this.addMarker(t,o)}}insertText(e,t,i,n){t instanceof yh||t instanceof Kl||t instanceof Yl?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof yh||t instanceof Kl||t instanceof Yl?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof yh||t instanceof Kl?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof yh||t instanceof Kl?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof nc){const n=i.getMinimalFlatRanges();for(const i of n)Ch(this,e,t,i)}else Ah(this,e,t,i)}setAttributes(e,t){for(const[i,n]of Zo(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof nc){const i=t.getMinimalFlatRanges();for(const t of i)Ch(this,e,null,t)}else Ah(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof nc)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof nc))throw new _("writer-move-invalid-range",this);if(!e.isFlat)throw new _("writer-move-range-not-flat",this);const n=Yl._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Th(e.root,n.root))throw new _("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,s=new Md(e.start,e.end.offset-e.start.offset,n,o);this.batch.addOperation(s),this.model.applyOperation(s)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof nc?e:nc._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Eh(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof Kl))throw new _("writer-merge-no-element-before",this);if(!(i instanceof Kl))throw new _("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(nc._createIn(i),Yl._createAt(t,"end")),this.remove(i)}_merge(e){const t=Yl._createAt(e.nodeBefore,"end"),i=Yl._createAt(e.nodeAfter,0),n=e.root.document.graveyard,o=new Yl(n,[0]),s=e.root.document.version,r=new Dd(i,e.nodeAfter.maxOffset,t,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Kl))throw new _("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new Wd(Yl._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,o=e.parent;if(!o.parent)throw new _("writer-split-element-no-parent",this);if(t||(t=o.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new _("writer-split-invalid-limit-element",this);do{const t=o.root.document?o.root.document.version:null,s=o.maxOffset-e.offset,r=Nd.getInsertionPosition(e),a=new Nd(e,s,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=o,n=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new nc(Yl._createAt(i,"end"),Yl._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new _("writer-wrap-range-not-flat",this);const i=t instanceof Kl?t:new Kl(t);if(i.childCount>0)throw new _("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new _("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new nc(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,Yl._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new _("writer-unwrap-element-no-parent",this);this.move(nc._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new _("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new _("writer-addmarker-marker-exists",this);if(!n)throw new _("writer-addmarker-no-range",this);return i?(xh(this,e,null,n,o),this.model.markers.get(e)):this.model.markers._set(e,n,i,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new _("writer-updatemarker-marker-not-exists",this);if(!t)return v("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const o="boolean"==typeof t.usingOperation,s="boolean"==typeof t.affectsData,r=s?t.affectsData:n.affectsData;if(!o&&!t.range&&!s)throw new _("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;o&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?xh(this,i,null,l,r):(xh(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?xh(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new _("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);xh(this,t,i.getRange(),null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new _("writer-addroot-root-exists",this);const n=this.model.document,o=new Ud(e,t,!0,n,n.version);return this.batch.addOperation(o),this.model.applyOperation(o),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new _("writer-detachroot-no-root",this);for(const e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(const e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));const i=this.model.document,n=new Ud(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of Zo(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=yc._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=yc._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new _("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let o=!1;if("move"===e){const e=t;o=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,s=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==s&&0==n.end.offset,l=n.end.nodeAfter==s,c=n.start.nodeAfter==s;o=r||a||l||c}o&&this.updateMarker(i.name,{range:n})}}}function Ch(e,t,i,n){const o=e.model,s=o.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&d(),c=r),r=e.nextPosition,a=l;function d(){const n=new nc(c,r),l=n.root.document?s.version:null,d=new Hd(n,t,a,i,l);e.batch.addOperation(d),o.applyOperation(d)}r instanceof Yl&&r!=c&&a!=i&&d()}function Ah(e,t,i,n){const o=e.model,s=o.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?s.version:null;l=new jd(n,t,r,i,e)}else{a=new nc(Yl._createBefore(n),e.createPositionAfter(n));const o=a.root.document?s.version:null;l=new Hd(a,t,r,i,o)}e.batch.addOperation(l),o.applyOperation(l)}}function xh(e,t,i,n,o){const s=e.model,r=s.document,a=new Ld(t,i,n,s.markers,!!o,r.version);e.batch.addOperation(a),s.applyOperation(a)}function Eh(e,t,i,n){let o;if(e.root.document){const i=n.document,s=new Yl(i.graveyard,[0]);o=new Md(e,t,s,i.version)}else o=new vh(e,t);i.addOperation(o),n.applyOperation(o)}function Th(e,t){return e===t||e instanceof gh&&t instanceof gh}function Sh(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const o=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();if(n.start.parent==n.end.parent)return!1;return e.checkChild(i,"paragraph")}(o,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),Rh(e,e.createPositionAt(i,0),t)}(e,t);const s={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(s,o.getAttributesWithProperty(e,"copyOnReplace",!0))}const[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),s=t.createRange(o,n);t.hasContent(s,{ignoreMarkers:!0})||(n=o)}}return[sh.fromPosition(i,"toPrevious"),sh.fromPosition(n,"toNext")]}(n);r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!Vh(e.model.schema,t,i))return;const[o,s]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let o=0;for(;i[o]&&i[o]==n[o];)o++;return[i[o],n[o]]}(t,i);if(!o||!s)return;!n.hasContent(o,{ignoreMarkers:!0})&&n.hasContent(s,{ignoreMarkers:!0})?Ih(e,t,i,o.parent):Ph(e,t,i,o.parent)}(e,r,a),o.removeDisallowedAttributes(r.parent.getChildren(),e)),Oh(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(o,r)&&Rh(e,r,t,s),r.detach(),a.detach()}))}function Ph(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(s,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}Vh(e.model.schema,t,i)&&Ph(e,t,i,n)}}function Ih(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(o,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(s),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name);e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),Vh(e.model.schema,t,i)&&Ih(e,t,i,n)}}function Vh(e,t,i){const n=t.parent,o=i.parent;return n!=o&&(!e.isLimit(n)&&!e.isLimit(o)&&function(e,t,i){const n=new nc(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function Rh(e,t,i,n={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,n,e),e.insert(o,t),Oh(e,i,e.createPositionAt(o,0))}function Oh(e,t,i){t instanceof yc?e.setSelection(i):t.setTo(i)}function Bh(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{i.push(e.start.parent),t.remove(e)})),i.forEach((e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}}))}class Mh{constructor(e,t,i){this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null,this._nodeToSelect=null,this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new _("insertcontent-invalid-insertion-position",this);this.position=i,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(e){if(this.schema.isObject(e))return void this._handleObject(e);let t=this._checkAndAutoParagraphToAllowedPosition(e);t||(t=this._checkAndSplitToAllowedPosition(e),t)?(this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=sh.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleObject(e){this._checkAndSplitToAllowedPosition(e)?this._appendToFragment(e):this._tryAutoparagraphing(e)}_handleDisallowedNode(e){e.is("element")?this.handleNodes(e.getChildren()):this._tryAutoparagraphing(e)}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new _("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=sh.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=sh.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof Kl))return;if(!this._canMergeLeft(e))return;const t=sh._createBefore(e);t.stickiness="toNext";const i=sh.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=sh._createAt(t.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=sh._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof Kl))return;if(!this._canMergeRight(e))return;const t=sh._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new _("insertcontent-invalid-insertion-position",this);this.position=Yl._createAt(t.nodeBefore,"end");const i=sh.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=sh._createAt(t.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=sh._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof Kl&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof Kl&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_tryAutoparagraphing(e){const t=this.writer.createElement("paragraph");this._getAllowedIn(this.position.parent,t)&&this.schema.checkChild(t,e)&&(t._appendChild(e),this._handleNode(t))}_checkAndAutoParagraphToAllowedPosition(e){if(this.schema.checkChild(this.position.parent,e))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",e))return!1;this._insertPartialFragment();const t=this.writer.createElement("paragraph");return this.writer.insert(t,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=t,this.position=this.writer.createPositionAt(t,0),!0}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const e=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=e,this.canMergeWith.add(this.position.nodeAfter)}return!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function Fh(e,t,i,n={}){if(!e.schema.isObject(t))throw new _("insertobject-element-not-an-object",e,{object:t});const o=i||e.document.selection;let s=o;n.findOptimalPosition&&e.schema.isBlock(t)&&(s=e.createSelection(e.schema.findOptimalInsertionRange(o,n.findOptimalPosition)));const r=qo(o.getSelectedBlocks()),a={};return r&&Object.assign(a,e.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),e.change((i=>{s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});let o=t;const r=s.anchor.parent;!e.schema.checkChild(r,t)&&e.schema.checkChild(r,"paragraph")&&e.schema.checkChild("paragraph",t)&&(o=i.createElement("paragraph"),i.insert(t,o)),e.schema.setAllowedAttributes(o,a,i);const l=e.insertContent(o,s);return l.isCollapsed||n.setSelection&&function(e,t,i,n){const o=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new _("insertobject-invalid-place-parameter-value",o);let s=t.nextSibling;if(o.schema.isInline(t))return void e.setSelection(t,"after");const r=s&&o.schema.checkChild(s,"$text");!r&&o.schema.checkChild(t.parent,"paragraph")&&(s=e.createElement("paragraph"),o.schema.setAllowedAttributes(s,n,e),o.insertContent(s,e.createPositionAfter(t)));s&&e.setSelection(s,0)}(i,t,n.setSelection,a),l}))}const Nh=' ,.?!:;"-()';function Dh(e,t){const{isForward:i,walker:n,unit:o,schema:s,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;i||(i=t?e.position.nodeAfter:e.position.nodeBefore);for(;i&&i.is("$text");){const n=e.position.offset-i.startOffset;if(Hh(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(zh(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const o=n.data;let s=e.position.offset-n.startOffset;for(;Yo(o,s)||"character"==t&&Qo(o,s)||i&&es(o,s);)e.next(),s=e.position.offset-n.startOffset}return e.position}(n,o,r);if(a==(i?"elementStart":"elementEnd")){if(s.isSelectable(l))return Yl._createAt(l,i?"after":"before");if(s.checkChild(c,"$text"))return c}else{if(s.isLimit(l))return void n.skip((()=>!0));if(s.checkChild(c,"$text"))return c}}function Lh(e,t){const i=e.root,n=Yl._createAt(i,t?"end":0);return t?new nc(e,n):new nc(n,e)}function zh(e,t,i){const n=t+(i?0:-1);return Nh.includes(e.charAt(n))}function Hh(e,t,i){return t===(i?e.offsetSize:0)}class $h extends(U()){constructor(){super(),this.markers=new wh,this.document=new ph(this),this.schema=new sd,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((e=>this.decorate(e))),this.on("applyOperation",((e,t)=>{t[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(((e,t)=>{if("$marker"===t.name)return!0})),Yc(this),this.document.registerPostFixer(Hc),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((n=>{const o=i||e.document.selection;o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const s=new Mh(e,n,o.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:o}=n,s=t.isEqual(o);e.push({position:t,name:i,isCollapsed:s},{position:o,name:i,isCollapsed:s})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:o,isCollapsed:s}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?s&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:o,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];s.handleNodes(a);let l=s.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?bc.fromRange(l):null,t={};for(let e=r.length-1;e>=0;e--){const{name:i,element:o,collapsed:a}=r[e],l=!t[i];if(l&&(t[i]=[]),o){const e=n.createPositionAt(o,"before");t[i].push(e),n.remove(o)}else{const e=s.getAffectedRange();if(!e){a&&t[i].push(s.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,o]]of Object.entries(t))i&&o&&i.root===o.root&&i.root.document&&!n.model.markers.has(e)&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new nc(i,o)});e&&(l=e.toRange(),e.detach())}l&&(o instanceof yc?n.setSelection(l):o.setTo(l));const c=s.getAffectedRange()||e.createRange(o.anchor);return s.destroy(),c}))}(this,t,i)})),this.on("insertObject",((e,[t,i,n])=>{e.return=Fh(this,t,i,n)})),this.on("canEditAt",(e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()}))}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new lh,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){_.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new lh):e instanceof lh||(e=new lh(e)):e=new lh,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){_.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const o=Wh(t,i);return this.fire("insertContent",[e,o,i,...n])}insertObject(e,t,i,n,...o){const s=Wh(t,i);return this.fire("insertObject",[e,s,n,n,...o])}deleteContent(e,t){Sh(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,o="backward"!=i.direction,s=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new Zl({boundaries:Lh(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:n,isForward:o,unit:s,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const i=Dh(c,d.value);if(i)return void(t instanceof yc?e.change((e=>{e.setSelectionFocus(i)})):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const o=n.start.root,s=n.start.getCommonPath(n.end),r=o.getNodeByPath(s);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[s.length]),e.createPositionAt(r,n.end.path[s.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],o=e.createRange(e.createPositionAt(i,0),t.start);Bh(e.createRange(t.end,e.createPositionAt(i,"end")),e),Bh(o,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof nc?e:nc._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=Wh(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new Yl(e,t,i)}createPositionAt(e,t){return Yl._createAt(e,t)}createPositionAfter(e){return Yl._createAfter(e)}createPositionBefore(e){return Yl._createBefore(e)}createRange(e,t){return new nc(e,t)}createRangeIn(e){return nc._createIn(e)}createRangeOn(e){return nc._createOn(e)}createSelection(...e){return new dc(...e)}createBatch(e){return new lh(e)}createOperationFromJSON(e){return Gd.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new kh(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function Wh(e,t){if(e)return e instanceof dc||e instanceof yc?e:e instanceof jl?t||0===t?new dc(e,t):e.is("rootElement")?new dc(e,"in"):new dc(e,"on"):new dc(e)}class jh extends Ka{constructor(){super(...arguments),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}class Uh extends Ka{constructor(){super(...arguments),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}class qh{constructor(e){this.document=e}createDocumentFragment(e){return new la(this.document,e)}createElement(e,t,i){return new Ir(this.document,e,t,i)}createText(e){return new Ks(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new Ir(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){xe(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return Dr._createAt(e,t)}createPositionAfter(e){return Dr._createAfter(e)}createPositionBefore(e){return Dr._createBefore(e)}createRange(e,t){return new Lr(e,t)}createRangeOn(e){return Lr._createOn(e)}createRangeIn(e){return Lr._createIn(e)}createSelection(...e){return new Hr(...e)}}const Gh=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Kh=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Zh=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Jh=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Yh=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Qh=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Xh=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function eu(e){return e.startsWith("#")?Gh.test(e):e.startsWith("rgb")?Kh.test(e)||Zh.test(e):e.startsWith("hsl")?Jh.test(e)||Yh.test(e):Xh.has(e.toLowerCase())}const tu=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function iu(e){return tu.includes(e)}const nu=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function ou(e){return nu.test(e)}const su=/^[+-]?[0-9]*([.][0-9]+)?%$/;function ru(e){return su.test(e)}const au=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function lu(e){return au.includes(e)}const cu=["center","top","bottom","left","right"];function du(e){return cu.includes(e)}const hu=["fixed","scroll","local"];function uu(e){return hu.includes(e)}const mu=/^url\(/;function gu(e){return mu.test(e)}function fu(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=_u(e),i=t[0],n=t[2]||i,o=t[1]||i;return{top:i,bottom:n,right:o,left:t[3]||o}}function pu(e){return t=>{const{top:i,right:n,bottom:o,left:s}=t,r=[];return[i,n,s,o].every((e=>!!e))?r.push([e,bu(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),o&&r.push([e+"-bottom",o]),s&&r.push([e+"-left",s])),r}}function bu({top:e,right:t,bottom:i,left:n}){const o=[];return n!==t?o.push(e,t,i,n):i!==e?o.push(e,t,i):t!==e?o.push(e,t):o.push(e),o.join(" ")}function wu(e){return t=>({path:e,value:fu(t)})}function _u(e){const t=e.matchAll(Qh);return Array.from(t).map((e=>e[0]))}function vu(e){e.setNormalizer("background",(e=>{const t={},i=_u(e);for(const e of i)lu(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):du(e)?(t.position=t.position||[],t.position.push(e)):uu(e)?t.attachment=e:eu(e)?t.color=e:gu(e)&&(t.image=e);return{path:"background",value:t}})),e.setNormalizer("background-color",(e=>({path:"background.color",value:e}))),e.setReducer("background",(e=>{const t=[];return t.push(["background-color",e.color]),t})),e.setStyleRelation("background",["background-color"])}function yu(e){e.setNormalizer("border",(e=>{const{color:t,style:i,width:n}=Su(e);return{path:"border",value:{color:fu(t),style:fu(i),width:fu(n)}}})),e.setNormalizer("border-top",ku("top")),e.setNormalizer("border-right",ku("right")),e.setNormalizer("border-bottom",ku("bottom")),e.setNormalizer("border-left",ku("left")),e.setNormalizer("border-color",Cu("color")),e.setNormalizer("border-width",Cu("width")),e.setNormalizer("border-style",Cu("style")),e.setNormalizer("border-top-color",xu("color","top")),e.setNormalizer("border-top-style",xu("style","top")),e.setNormalizer("border-top-width",xu("width","top")),e.setNormalizer("border-right-color",xu("color","right")),e.setNormalizer("border-right-style",xu("style","right")),e.setNormalizer("border-right-width",xu("width","right")),e.setNormalizer("border-bottom-color",xu("color","bottom")),e.setNormalizer("border-bottom-style",xu("style","bottom")),e.setNormalizer("border-bottom-width",xu("width","bottom")),e.setNormalizer("border-left-color",xu("color","left")),e.setNormalizer("border-left-style",xu("style","left")),e.setNormalizer("border-left-width",xu("width","left")),e.setExtractor("border-top",Eu("top")),e.setExtractor("border-right",Eu("right")),e.setExtractor("border-bottom",Eu("bottom")),e.setExtractor("border-left",Eu("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",pu("border-color")),e.setReducer("border-style",pu("border-style")),e.setReducer("border-width",pu("border-width")),e.setReducer("border-top",Pu("top")),e.setReducer("border-right",Pu("right")),e.setReducer("border-bottom",Pu("bottom")),e.setReducer("border-left",Pu("left")),e.setReducer("border",function(){return t=>{const i=Tu(t,"top"),n=Tu(t,"right"),o=Tu(t,"bottom"),s=Tu(t,"left"),r=[i,n,o,s],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=Iu(a,"all");if(l.length)return l;const c=Object.entries(a).reduce(((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach((e=>delete e[t]))),e)),[]);return[...c,...Iu(i,"top"),...Iu(n,"right"),...Iu(o,"bottom"),...Iu(s,"left")]};function e(e,t){return e.map((e=>e[t])).reduce(((e,t)=>e==t?e:null))}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function ku(e){return t=>{const{color:i,style:n,width:o}=Su(t),s={};return void 0!==i&&(s.color={[e]:i}),void 0!==n&&(s.style={[e]:n}),void 0!==o&&(s.width={[e]:o}),{path:"border",value:s}}}function Cu(e){return t=>({path:"border",value:Au(t,e)})}function Au(e,t){return{[t]:fu(e)}}function xu(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function Eu(e){return(t,i)=>{if(i.border)return Tu(i.border,e)}}function Tu(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function Su(e){const t={},i=_u(e);for(const e of i)ou(e)||/thin|medium|thick/.test(e)?t.width=e:iu(e)?t.style=e:t.color=e;return t}function Pu(e){return t=>Iu(t,e)}function Iu(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map((t=>e[t])).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map((i=>[`border-${t}-${i}`,e[i]]))}function Vu(e){e.setNormalizer("margin",wu("margin")),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",pu("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Ru(e){e.setNormalizer("padding",wu("padding")),e.setNormalizer("padding-top",(e=>({path:"padding.top",value:e}))),e.setNormalizer("padding-right",(e=>({path:"padding.right",value:e}))),e.setNormalizer("padding-bottom",(e=>({path:"padding.bottom",value:e}))),e.setNormalizer("padding-left",(e=>({path:"padding.left",value:e}))),e.setReducer("padding",pu("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}class Ou{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new _("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class Bu extends Ko{constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}const Mu="contentEditing",Fu="common";class Nu{constructor(e){this.keystrokeInfos=new Map,this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Mu,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const n=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&n.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:n}]})}addKeystrokeInfoCategory({id:e,label:t,description:i,groups:n}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:Fu}),n&&n.forEach((t=>{this.addKeystrokeInfoGroup({categoryId:e,...t})}))}addKeystrokeInfoGroup({categoryId:e=Mu,id:t,label:i,keystrokes:n}){const o=this.keystrokeInfos.get(e);if(!o)throw new _("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});o.groups.set(t,{id:t,label:i,keystrokes:n||[]})}addKeystrokeInfos({categoryId:e=Mu,groupId:t=Fu,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new _("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const n=this.keystrokeInfos.get(e);if(!n.groups.has(t))throw new _("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});n.groups.get(t).keystrokes.push(...i)}}class Du extends(U()){constructor(e={}){super();const t=this.constructor,{translations:i,...n}=t.defaultConfig||{},{translations:o=i,...s}=e,r=e.language||n.language;this._context=e.context||new Bs({language:r,translations:o}),this._context._addEditor(this,!e.context);const a=Array.from(t.builtinPlugins||[]);this.config=new Cn(s,n),this.config.define("plugins",a),this.config.define(this._context._getEditorConfig()),this.plugins=new Os(this,a,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Ou,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new $h,this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const l=new Tr;this.data=new Cd(this.model,l),this.editing=new td(this.model,l),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Ad([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 Bu(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new Nu(this)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new _("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new _("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),1===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new _("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,o)}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise((e=>this.once("ready",e)))),e.then((()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()})).then((()=>this.plugins.destroy())).then((()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()})).then((()=>this._context._removeEditor(this)))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(e){_.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}}function Lu(e){return class extends e{updateSourceElement(e){if(!this.sourceElement)throw new _("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!i)return void jn(this.sourceElement,"");const n="string"==typeof e?e:this.data.get();jn(this.sourceElement,n)}}}Lu.updateSourceElement=Lu(Object).prototype.updateSourceElement;class zu extends Ms{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Uo({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new _("pendingactions-add-invalid-message",this);const t=new(U());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}const Hu={bold:'',cancel:'',caption:'',check:'',cog:'',colorPalette:'',eraser:'',history:'',image:'',imageUpload:'',imageAssetManager:'',imageUrl:'',lowVision:'',textAlternative:'',loupe:'',previousArrow:'',nextArrow:'',importExport:'',paragraph:'',plus:'',text:'',alignBottom:'',alignMiddle:'',alignTop:'',alignLeft:'',alignCenter:'',alignRight:'',alignJustify:'',objectLeft:'',objectCenter:'',objectRight:'',objectFullWidth:'',objectInline:'',objectBlockLeft:'',objectBlockRight:'',objectSizeCustom:'',objectSizeFull:'',objectSizeLarge:'',objectSizeSmall:'',objectSizeMedium:'',pencil:'',pilcrow:'',quote:'',threeVerticalDots:'',dragIndicator:'',redo:'',undo:'',bulletedList:'',numberedList:'',todoList:'',codeBlock:'',browseFiles:'',heading1:'',heading2:'',heading3:'',heading4:'',heading5:'',heading6:'',horizontalLine:'',html:'',indent:'',outdent:'',table:''};class $u extends Cs{constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${f()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}class Wu extends Cs{constructor(e,t){super(e);const i=e.t,n=new $u;n.text=i("Help Contents. To close this dialog press ESC."),this.setTemplate({tag:"div",attributes:{class:["ck","ck-accessibility-help-dialog__content"],"aria-labelledby":n.id,role:"document",tabindex:-1},children:[be(document,"p",{},i("Below, you can find a list of keyboard shortcuts that can be used in the editor.")),...this._createCategories(Array.from(t.values())),n]})}focus(){this.element.focus()}_createCategories(e){return e.map((e=>{const t=[be(document,"h3",{},e.label),...Array.from(e.groups.values()).map((e=>this._createGroup(e))).flat()];return e.description&&t.splice(1,0,be(document,"p",{},e.description)),be(document,"section",{},t)}))}_createGroup(e){const t=e.keystrokes.sort(((e,t)=>e.label.localeCompare(t.label))).map((e=>this._createGroupRow(e))).flat(),i=[be(document,"dl",{},t)];return e.label&&i.unshift(be(document,"h4",{},e.label)),i}_createGroupRow(e){const t=this.locale.t,i=be(document,"dt"),n=be(document,"dd"),o=function(e){if("string"==typeof e)return[[e]];if("string"==typeof e[0])return[e];return e}(e.keystroke),s=[];for(const e of o)s.push(e.map(ju).join(""));return i.innerHTML=e.label,n.innerHTML=s.join(", ")+(e.mayRequireFn&&r.isMac?` ${t("(may require Fn)")}`:""),[i,n]}}function ju(e){return wo(e).split("+").map((e=>`${e}`)).join("+")}const Uu='';class qu extends Ss{constructor(){super(...arguments),this.contentView=null}static get requires(){return[Qg]}static get pluginName(){return"AccessibilityHelp"}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("accessibilityHelp",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0,withText:!1,label:t("Accessibility help")}),e})),e.ui.componentFactory.add("menuBar:accessibilityHelp",(()=>{const e=this._createButton(pp);return e.label=t("Accessibility"),e})),e.keystrokes.set("Alt+0",((e,t)=>{this._showDialog(),t()})),this._setupRootLabels()}_createButton(e){const t=new e(this.editor.locale);return t.set({keystroke:"Alt+0",icon:Uu}),t.on("execute",(()=>this._showDialog())),t}_setupRootLabels(){const e=this.editor,t=e.editing.view,i=e.t;function n(e,t){const n=`${t.getAttribute("aria-label")}. ${i("Press %0 for help.",[wo("Alt+0")])}`;e.setAttribute("aria-label",n,t)}e.ui.on("ready",(()=>{t.change((e=>{for(const i of t.document.roots)n(e,i)})),e.on("addRoot",((i,o)=>{const s=e.editing.view.document.getRoot(o.rootName);t.change((e=>n(e,s)))}),{priority:"low"})}))}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.contentView||(this.contentView=new Wu(e.locale,e.accessibility.keystrokeInfos)),t.show({id:"accessibilityHelp",className:"ck-accessibility-help-dialog",title:i("Accessibility help"),icon:Uu,hasCloseButton:!0,content:this.contentView})}}class Gu extends ts{constructor(e,t=[]){super(t),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new is({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let e=document.querySelector(".ck-body-wrapper");e||(e=be(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(e)),e.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const e=document.querySelector(".ck-body-wrapper");e&&0==e.childElementCount&&e.remove()}}class Ku extends Cs{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",e.if("isVisible","ck-hidden",(e=>!e)),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox")}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",(()=>{this._updateXMLContent(),this._colorFillPaths()})),this.on("change:fillColor",(()=>{this._colorFillPaths()}))}_updateXMLContent(){if(this.content){const e=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:t,value:i}of Array.from(e.attributes))Ku.presentationalAttributeNames.includes(t)&&this.element.setAttribute(t,i);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((e=>{e.style.fill=this.fillColor}))}}Ku.presentationalAttributeNames=["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"];const Zu=Ku;class Ju extends Cs{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:e.to("style"),id:e.to("id")},children:[{text:e.to("text")}]})}}class Yu extends Cs{constructor(e,t=new Ju){super(e),this._focusDelayed=null;const i=this.bindTemplate,n=f();this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${n}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(t),this.iconView=new Zu,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const o={tag:"button",attributes:{class:["ck","ck-button",i.to("class"),i.if("isEnabled","ck-disabled",(e=>!e)),i.if("isVisible","ck-hidden",(e=>!e)),i.to("isOn",(e=>e?"ck-on":"ck-off")),i.if("withText","ck-button_with-text"),i.if("withKeystroke","ck-button_with-keystroke")],role:i.to("role"),type:i.to("type",(e=>e||"button")),tabindex:i.to("tabindex"),"aria-checked":i.to("ariaChecked"),"aria-label":i.to("ariaLabel"),"aria-labelledby":i.to("ariaLabelledBy"),"aria-disabled":i.if("isEnabled",!0,(e=>!e)),"aria-pressed":i.to("isOn",(e=>!!this.isToggleable&&String(!!e))),"data-cke-tooltip-text":i.to("_tooltipString"),"data-cke-tooltip-position":i.to("tooltipPosition")},children:this.children,on:{click:i.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}};r.isSafari&&(this._focusDelayed||(this._focusDelayed=Jo((()=>this.focus()),0)),o.on.mousedown=i.to((()=>{this._focusDelayed()})),o.on.mouseup=i.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(o)}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_setupLabelView(e){return e.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),e}_createKeystrokeView(){const e=new Cs;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>wo(e)))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=wo(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}class Qu extends Yu{constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new Cs;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}class Xu extends Yu{constructor(e){super(e),this.buttonView=this,this._fileInputView=new em(e),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",(()=>{this._fileInputView.open()})),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}render(){super.render(),this.children.add(this._fileInputView)}}class em extends Cs{constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}const tm='';class im extends Cs{constructor(e,t){super(e);const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){const e=new Yu(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:tm}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",(e=>!e)),e.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),e}}function nm(e,t){const i=e.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return t.map((e=>{const t=n[e.label];return t&&t!=e.label&&(e.label=t),e}))}function om(e){return e.map(sm).filter((e=>!!e))}function sm(e){return"string"==typeof e?{model:e,label:e,hasBorder:!1,view:{name:"span",styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:void 0!==e.hasBorder&&e.hasBorder,view:{name:"span",styles:{color:`${e.color}`}}}}class rm extends Yu{constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon='',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color",(e=>r.isMediaForcedColors?null:e))},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-selector__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}class am extends Cs{constructor(e,t){super(e);const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t&&t.columns?t.columns:5;const n={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new Go,this.keystrokes=new Ko,this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),i.forEach((e=>{const t=new rm;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",(()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})})),this.items.add(t)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",((e,t,i)=>{for(const e of this.items)e.isOn=e.color===i}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element),Ts({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}var lm=o(156);const cm=function(e){var t,i,n=[],o=1;if("string"==typeof e)if(lm[e])n=lm[e].slice(),i="rgb";else if("transparent"===e)o=0,i="rgb",n=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(e)){var s=e.slice(1);o=1,(l=s.length)<=4?(n=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],4===l&&(o=parseInt(s[3]+s[3],16)/255)):(n=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],8===l&&(o=parseInt(s[6]+s[7],16)/255)),n[0]||(n[0]=0),n[1]||(n[1]=0),n[2]||(n[2]=0),i="rgb"}else if(t=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(e)){var r=t[1],a="rgb"===r;i=s=r.replace(/a$/,"");var l="cmyk"===s?4:"gray"===s?1:3;n=t[2].trim().split(/\s*[,\/]\s*|\s+/).map((function(e,t){if(/%$/.test(e))return t===l?parseFloat(e)/100:"rgb"===s?255*parseFloat(e)/100:parseFloat(e);if("h"===s[t]){if(/deg$/.test(e))return parseFloat(e);if(void 0!==dm[e])return dm[e]}return parseFloat(e)})),r===s&&n.push(1),o=a||void 0===n[l]?1:n[l],n=n.slice(0,l)}else e.length>10&&/[0-9](?:\s|\/)/.test(e)&&(n=e.match(/([0-9]+)/g).map((function(e){return parseFloat(e)})),i=e.match(/([a-z])/gi).join("").toLowerCase());else isNaN(e)?Array.isArray(e)||e.length?(n=[e[0],e[1],e[2]],i="rgb",o=4===e.length?e[3]:1):e instanceof Object&&(null!=e.r||null!=e.red||null!=e.R?(i="rgb",n=[e.r||e.red||e.R||0,e.g||e.green||e.G||0,e.b||e.blue||e.B||0]):(i="hsl",n=[e.h||e.hue||e.H||0,e.s||e.saturation||e.S||0,e.l||e.lightness||e.L||e.b||e.brightness]),o=e.a||e.alpha||e.opacity||1,null!=e.opacity&&(o/=100)):(i="rgb",n=[e>>>16,(65280&e)>>>8,255&e]);return{space:i,values:n,alpha:o}};var dm={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};var hm=o(734),um=o.t(hm,2);function mm(e,t){if(!e)return"";const i=gm(e);if(!i)return"";if(i.space===t)return e;if(n=i,!Object.keys(um).includes(n.space))return"";var n;const o=um[i.space][t];if(!o)return"";return function(e,t){switch(t){case"hex":return`#${e}`;case"rgb":return`rgb( ${e[0]}, ${e[1]}, ${e[2]} )`;case"hsl":return`hsl( ${e[0]}, ${e[1]}%, ${e[2]}% )`;case"hwb":return`hwb( ${e[0]}, ${e[1]}, ${e[2]} )`;case"lab":return`lab( ${e[0]}% ${e[1]} ${e[2]} )`;case"lch":return`lch( ${e[0]}% ${e[1]} ${e[2]} )`;default:return""}}(o("hex"===i.space?i.hexValue:i.values),t)}function gm(e){if(e.startsWith("#")){const t=cm(e);return{space:"hex",values:t.values,hexValue:e,alpha:t.alpha}}const t=cm(e);return t.space?t:null}class fm extends Cs{constructor(e,t){super(e);const i=`ck-labeled-field-view-${f()}`,n=`ck-labeled-field-view-status-${f()}`;this.fieldView=t(this,i,n),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(n),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",(e=>!e)),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new $u(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Cs(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",(e=>!e))],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(e){this.fieldView.focus(e)}}class pm extends Cs{constructor(e){super(e),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new Go,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),tabindex:t.to("tabIndex"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById"),"aria-label":t.to("ariaLabel")},on:{input:t.to(((...e)=>{this.fire("input",...e),this._updateIsEmpty()})),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((e,t,i)=>{this._setDomElementValue(i),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class bm extends pm{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class wm extends bm{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class _m extends bm{constructor(e,{min:t,max:i,step:n}={}){super(e);const o=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",n),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:o.to("min"),max:o.to("max"),step:o.to("step")}})}}class vm extends Cs{constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",t.to("position",(e=>`ck-dropdown__panel_${e}`)),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():v("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}}class ym extends Cs{constructor(e,t,i){super(e);const n=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new Ko,this.focusTracker=new Go,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",(e=>!e))],id:n.to("id"),"aria-describedby":n.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":n.to("isOpen")}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",(()=>{this.isOpen=!this.isOpen})),this.on("change:isOpen",((e,t,i)=>{if(i)if("auto"===this.panelPosition){const e=ym._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=e?e.name:this._panelPositions[0].name}else this.panelView.position=this.panelPosition})),this.keystrokes.listenTo(this.element);const e=(e,t)=>{this.isOpen&&(this.isOpen=!1,t())};this.keystrokes.set("arrowdown",((e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())})),this.keystrokes.set("arrowright",((e,t)=>{this.isOpen&&t()})),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:n,northEast:o,northWest:s,southMiddleEast:r,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=ym.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,r,a,e,o,s,l,c,t]:[n,i,a,r,e,s,o,c,l,t]}}ym.defaultPanelPositions={south:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/2,name:"s"}),southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),southMiddleEast:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/4,name:"sme"}),southMiddleWest:(e,t)=>({top:e.bottom,left:e.left-3*(t.width-e.width)/4,name:"smw"}),north:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/2,name:"n"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),northMiddleEast:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/4,name:"nme"}),northMiddleWest:(e,t)=>({top:e.top-t.height,left:e.left-3*(t.width-e.width)/4,name:"nmw"})},ym._getOptimalPosition=Yn;const km=ym;class Cm extends Yu{constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(e=>String(e)))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new Zu;return e.content=tm,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class Am extends(P()){constructor(e){if(super(),this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,e.actions&&e.keystrokeHandler)for(const t in e.actions){let i=e.actions[t];"string"==typeof i&&(i=[i]);for(const n of i)e.keystrokeHandler.set(n,((e,i)=>{this[t](),i()}))}this.on("forwardCycle",(()=>this.focusFirst()),{priority:"low"}),this.on("backwardCycle",(()=>this.focusLast()),{priority:"low"})}get first(){return this.focusables.find(xm)||null}get last(){return this.focusables.filter(xm).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((t,i)=>{const n=t.element===this.focusTracker.focusedElement;return n&&(e=i),n})),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;e&&this.focusables.getIndex(e)===this.current||e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;e&&this.focusables.getIndex(e)===this.current||e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){const t=this.focusables.length;if(!t)return null;const i=this.current;if(null===i)return this[1===e?"first":"last"];let n=this.focusables.get(i),o=(i+t+e)%t;do{const i=this.focusables.get(o);if(xm(i)){n=i;break}o=(o+t+e)%t}while(o!==i);return n}}function xm(e){return Em(e)&&Jn(e.element)}function Em(e){return!(!("focus"in e)||"function"!=typeof e.focus)}class Tm extends Cs{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class Sm extends Cs{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function Pm(e){if(Array.isArray(e))return{items:e,removeItems:[]};const t={items:[],removeItems:[]};return e?{...t,...e}:t}const Im={alignLeft:Hu.alignLeft,bold:Hu.bold,importExport:Hu.importExport,paragraph:Hu.paragraph,plus:Hu.plus,text:Hu.text,threeVerticalDots:Hu.threeVerticalDots,pilcrow:Hu.pilcrow,dragIndicator:Hu.dragIndicator};class Vm extends Cs{constructor(e,t){super(e);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Go,this.keystrokes=new Ko,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new Rm(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const o="rtl"===e.uiLanguageDirection;this._focusCycler=new Am({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[o?"arrowright":"arrowleft","arrowup"],focusNext:[o?"arrowleft":"arrowright","arrowdown"]}});const s=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var r;this.options.shouldGroupWhenFull&&this.options.isFloating&&s.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:s,role:"toolbar","aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(r=this,r.bindTemplate.to((e=>{e.target===r.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new Bm(this):new Om(this)}render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t,i){this.items.addMany(this._buildItemsFromConfig(e,t,i))}_buildItemsFromConfig(e,t,i){const n=Pm(e),o=i||n.removeItems;return this._cleanItemsConfiguration(n.items,t,o).map((e=>N(e)?this._createNestedToolbarDropdown(e,t,o):"|"===e?new Tm:"-"===e?new Sm:t.create(e))).filter((e=>!!e))}_cleanItemsConfiguration(e,t,i){const n=e.filter(((e,n,o)=>"|"===e||-1===i.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(v("toolbarview-line-break-ignored-when-grouping-items",o),!1):!(!N(e)&&!t.has(e))||(v("toolbarview-item-unavailable",{item:e}),!1))));return this._cleanSeparatorsAndLineBreaks(n)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t);if(-1===n)return[];const o=i-e.slice().reverse().findIndex(t);return e.slice(n,o).filter(((e,i,n)=>{if(t(e))return!0;return!(i>0&&n[i-1]===e)}))}_createNestedToolbarDropdown(e,t,i){let{label:n,icon:o,items:s,tooltip:r=!0,withText:a=!1}=e;if(s=this._cleanItemsConfiguration(s,t,i),!s.length)return null;const l=zm(this.locale);return n||v("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:n,tooltip:r,withText:!!a}),!1!==o?l.buttonView.icon=Im[o]||o||Hu.threeVerticalDots:l.buttonView.withText=!0,Hm(l,(()=>l.toolbarView._buildItemsFromConfig(s,t,i))),l}}class Rm extends Cs{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Om{constructor(e){const t=e.bindTemplate;e.set("isVertical",!1),e.itemsView.children.bindTo(e.items).using((e=>e)),e.focusables.bindTo(e.items).using((e=>Em(e)?e:null)),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class Bm{constructor(e){this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),e.itemsView.children.bindTo(this.ungroupedItems).using((e=>e)),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",((e,t)=>{const i=t.index,n=Array.from(t.added);for(const e of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=i;ethis.ungroupedItems.length?this.groupedItems.add(t,e-this.ungroupedItems.length):this.ungroupedItems.add(t,e)}this._updateGrouping()})),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Jn(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,i=this.viewLocale.uiLanguageDirection,n=new Nn(e.lastChild),o=new Nn(e);if(!this.cachedPadding){const n=t.window.getComputedStyle(e),o="ltr"===i?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[o])}return"ltr"===i?n.right>o.right-this.cachedPadding:n.left{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Tm),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,i=zm(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",Hm(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Hu.threeVerticalDots}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{Em(e)&&this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class Mm extends Cs{constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",(e=>!e))],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class Fm extends Cs{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class Nm extends Cs{constructor(e,t=new $u){super(e);const i=this.bindTemplate,n=new Dm(e);this.set({label:"",isVisible:!0}),this.labelView=t,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,n]),n.set({role:"group",ariaLabelledBy:t.id}),n.focusTracker.destroy(),n.keystrokes.destroy(),this.items=n.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",(e=>!e))]},children:this.children})}focus(){if(this.items){const e=this.items.find((e=>!(e instanceof Fm)));e&&e.focus()}}}class Dm extends Cs{constructor(e){super(e),this._listItemGroupToChangeListeners=new WeakMap;const t=this.bindTemplate;this.focusables=new ts,this.items=this.createCollection(),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusCycler=new Am({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:t.to("role"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy")},children:this.items})}render(){super.render();for(const e of this.items)e instanceof Nm?this._registerFocusableItemsGroup(e):e instanceof Mm&&this._registerFocusableListItem(e);this.items.on("change",((e,t)=>{for(const e of t.removed)e instanceof Nm?this._deregisterFocusableItemsGroup(e):e instanceof Mm&&this._deregisterFocusableListItem(e);for(const e of Array.from(t.added).reverse())e instanceof Nm?this._registerFocusableItemsGroup(e,t.index):this._registerFocusableListItem(e,t.index)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(e,t){this.focusTracker.add(e.element),this.focusables.add(e,t)}_deregisterFocusableListItem(e){this.focusTracker.remove(e.element),this.focusables.remove(e)}_getOnGroupItemsChangeCallback(e){return(t,i)=>{for(const e of i.removed)this._deregisterFocusableListItem(e);for(const t of Array.from(i.added).reverse())this._registerFocusableListItem(t,this.items.getIndex(e)+i.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach(((e,i)=>{const n=void 0!==t?t+i:void 0;this._registerFocusableListItem(e,n)}));const i=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,i),e.items.on("change",i)}_deregisterFocusableItemsGroup(e){for(const t of e.items)this._deregisterFocusableListItem(t);e.items.off("change",this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}}class Lm extends Cs{constructor(e,t){super(e);const i=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(t),this.arrowView=this._createArrowView(),this.keystrokes=new Ko,this.focusTracker=new Go,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.if("isVisible","ck-hidden",(e=>!e)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",((e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())})),this.keystrokes.set("arrowleft",((e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(e){const t=e||new Yu;return e||t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const e=new Yu,t=e.bindTemplate;return e.icon=tm,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}function zm(e,i=Cm){const n="function"==typeof i?new i(e):i,o=new vm(e),s=new km(e,n,o);return n.bind("isEnabled").to(s),n instanceof Lm?n.arrowView.bind("isOn").to(s,"isOpen"):n.bind("isOn").to(s,"isOpen"),function(e){(function(e){e.on("render",(()=>{As({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>[e.element,...e.focusTracker._elements]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof Qu||(e.isOpen=!1)}))}(e),function(e){e.focusTracker.on("change:isFocused",((t,i,n)=>{e.isOpen&&!n&&(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,i)=>{e.isOpen&&(e.panelView.focus(),i())})),e.keystrokes.set("arrowup",((t,i)=>{e.isOpen&&(e.panelView.focusLast(),i())}))}(e),function(e){e.on("change:isOpen",((i,n,o)=>{if(o)return;const s=e.panelView.element;s&&s.contains(t.document.activeElement)&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,i,n)=>{n&&e.panelView.focus()}),{priority:"low"})}(e)}(s),s}function Hm(e,t,i={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?$m(e,t,i):e.once("change:isOpen",(()=>$m(e,t,i)),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&Um(e,(()=>e.toolbarView.items.find((e=>e.isOn))))}function $m(e,t,i){const n=e.locale,o=n.t,s=e.toolbarView=new Vm(n),r="function"==typeof t?t():t;s.ariaLabel=i.ariaLabel||o("Dropdown toolbar"),i.maxWidth&&(s.maxWidth=i.maxWidth),i.class&&(s.class=i.class),i.isCompact&&(s.isCompact=i.isCompact),i.isVertical&&(s.isVertical=!0),r instanceof ts?s.items.bindTo(r).using((e=>e)):s.items.addMany(r),e.panelView.children.add(s),s.items.delegate("execute").to(e)}function Wm(e,t,i={}){e.isOpen?jm(e,t,i):e.once("change:isOpen",(()=>jm(e,t,i)),{priority:"highest"}),Um(e,(()=>e.listView.items.find((e=>e instanceof Mm&&e.children.first.isOn))))}function jm(e,t,i){const n=e.locale,o=e.listView=new Dm(n),s="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel,o.role=i.role,qm(e,o.items,s,n),e.panelView.children.add(o),o.items.delegate("execute").to(e)}function Um(e,t){e.on("change:isOpen",(()=>{if(!e.isOpen)return;const i=t();i&&("function"==typeof i.focus?i.focus():v("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))}),{priority:p.low-10})}function qm(e,t,i,n){t.bindTo(i).using((t=>{if("separator"===t.type)return new Fm(n);if("group"===t.type){const i=new Nm(n);return i.set({label:t.label}),qm(e,i.items,t.items,n),i.items.delegate("execute").to(e),i}if("button"===t.type||"switchbutton"===t.type){const e=new Mm(n);let i;return"button"===t.type?(i=new Yu(n),i.bind("ariaChecked").to(i,"isOn")):i=new Qu(n),i.bind(...Object.keys(t.model)).to(t.model),i.delegate("execute").to(e),e.children.add(i),e}return null}))}const Gm=(e,t,i)=>{const n=new wm(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},Km=(e,t,i)=>{const n=new _m(e.locale);return n.set({id:t,ariaDescribedById:i,inputMode:"numeric"}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},Zm=(e,t,i)=>{const n=zm(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isEnabled").to(e),n},Jm=(e,t=0,i=1)=>e>i?i:eMath.round(i*e)/i,Qm=(Math.PI,e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?Ym(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?Ym(parseInt(e.substring(6,8),16)/255,2):1})),Xm=({h:e,s:t,v:i,a:n})=>{const o=(200-t)*i/100;return{h:Ym(e),s:Ym(o>0&&o<200?t*i/100/(o<=100?o:200-o)*100:0),l:Ym(o/2),a:Ym(n,2)}},eg=e=>{const{h:t,s:i,l:n}=Xm(e);return`hsl(${t}, ${i}%, ${n}%)`},tg=({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const o=Math.floor(e),s=i*(1-t),r=i*(1-(e-o)*t),a=i*(1-(1-e+o)*t),l=o%6;return{r:Ym(255*[i,r,s,s,a,i][l]),g:Ym(255*[a,i,i,r,s,s][l]),b:Ym(255*[s,s,a,i,i,r][l]),a:Ym(n,2)}},ig=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},ng=({r:e,g:t,b:i,a:n})=>{const o=n<1?ig(Ym(255*n)):"";return"#"+ig(e)+ig(t)+ig(i)+o},og=({r:e,g:t,b:i,a:n})=>{const o=Math.max(e,t,i),s=o-Math.min(e,t,i),r=s?o===e?(t-i)/s:o===t?2+(i-e)/s:4+(e-t)/s:0;return{h:Ym(60*(r<0?r+6:r)),s:Ym(o?s/o*100:0),v:Ym(o/255*100),a:n}},sg=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},rg={},ag=e=>{let t=rg[e];return t||(t=document.createElement("template"),t.innerHTML=e,rg[e]=t),t},lg=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let cg=!1;const dg=e=>"touches"in e,hg=(e,t)=>{const i=dg(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();lg(e.el,"move",e.getMove({x:Jm((i.pageX-(n.left+window.pageXOffset))/n.width),y:Jm((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class ug{constructor(e,t,i,n){const o=ag(`
`);e.appendChild(o.content.cloneNode(!0));const s=e.querySelector(`[part=${t}]`);s.addEventListener("mousedown",this),s.addEventListener("touchstart",this),s.addEventListener("keydown",this),this.el=s,this.xy=n,this.nodes=[s.firstChild,s]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(cg?"touchmove":"mousemove",this),t(cg?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(cg&&!dg(e)||(cg||(cg=dg(e)),0)))(e)||!cg&&0!=e.button)return;this.el.focus(),hg(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),hg(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const i=t.keyCode;i>40||e.xy&&i<37||i<33||(t.preventDefault(),lg(e.el,"move",e.getMove({x:39===i?.01:37===i?-.01:34===i?.05:33===i?-.05:35===i?1:36===i?-1:0,y:40===i?.01:38===i?-.01:0},!0)))})(this,e)}}style(e){e.forEach(((e,t)=>{for(const i in e)this.nodes[t].style.setProperty(i,e[i])}))}}class mg extends ug{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:eg({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${Ym(e)}`)}getMove(e,t){return{h:t?Jm(this.h+360*e.x,0,360):360*e.x}}}class gg extends ug{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:eg(e)},{"background-color":eg({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${Ym(e.s)}%, Brightness ${Ym(e.v)}%`)}getMove(e,t){return{s:t?Jm(this.hsva.s+100*e.x,0,100):100*e.x,v:t?Jm(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const fg=Symbol("same"),pg=Symbol("color"),bg=Symbol("hsva"),wg=Symbol("update"),_g=Symbol("parts"),vg=Symbol("css"),yg=Symbol("sliders");class kg extends HTMLElement{static get observedAttributes(){return["color"]}get[vg](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[yg](){return[gg,mg]}get color(){return this[pg]}set color(e){if(!this[fg](e)){const t=this.colorModel.toHsva(e);this[wg](t),this[pg]=e}}constructor(){super();const e=ag(``),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[_g]=this[yg].map((e=>new e(t)))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const n=this.colorModel.fromAttr(i);this[fg](n)||(this.color=n)}handleEvent(e){const t=this[bg],i={...t,...e.detail};let n;this[wg](i),sg(i,t)||this[fg](n=this.colorModel.fromHsva(i))||(this[pg]=n,lg(this,"color-changed",{value:n}))}[fg](e){return this.color&&this.colorModel.equal(e,this.color)}[wg](e){this[bg]=e,this[_g].forEach((t=>t.update(e)))}}const Cg={defaultColor:"#000",toHsva:e=>og(Qm(e)),fromHsva:({h:e,s:t,v:i})=>ng(tg({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||sg(Qm(e),Qm(t)),fromAttr:e=>e};class Ag extends kg{get colorModel(){return Cg}}class xg extends Cs{constructor(e,t={}){super(e),this.set({color:"",_hexColor:""}),this.hexInputRow=this._createInputRow();const i=this.createCollection();t.hideInput||i.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:i}),this._config=t,this._debounceColorPickerEvent=ll((e=>{this.set("color",e),this.fire("colorSelected",{color:this.color})}),150,{leading:!0}),this.on("set:color",((e,t,i)=>{e.return=mm(i,this._config.format||"hsl")})),this.on("change:color",(()=>{this._hexColor=Eg(this.color)})),this.on("change:_hexColor",(()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Eg(this.color)!=Eg(this._hexColor)&&(this.color=this._hexColor)}))}render(){var e,i;if(super.render(),e="hex-color-picker",i=Ag,void 0===customElements.get(e)&&customElements.define(e,i),this.picker=t.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);const e=document.createElement("style");e.textContent='[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}',this.picker.shadowRoot.appendChild(e)}this.picker.addEventListener("color-changed",(e=>{const t=e.detail.value;this._debounceColorPickerEvent(t)}))}focus(){if(!this._config.hideInput&&(r.isGecko||r.isiOS||r.isSafari)){this.hexInputRow.children.get(1).focus()}this.slidersView.first.focus()}_createSlidersView(){const e=[...this.picker.shadowRoot.children].filter((e=>"slider"===e.getAttribute("role"))).map((e=>new Tg(e)));this.slidersView=this.createCollection(),e.forEach((e=>{this.slidersView.add(e)}))}_createInputRow(){const e=this._createColorInput();return new Pg(this.locale,e)}_createColorInput(){const e=new fm(this.locale,Gm),{t}=this.locale;return e.set({label:t("HEX"),class:"color-picker-hex-input"}),e.fieldView.bind("value").to(this,"_hexColor",(t=>e.isFocused?e.fieldView.value:t.startsWith("#")?t.substring(1):t)),e.fieldView.on("input",(()=>{const t=e.fieldView.element.value;if(t){const e=Ig(t);e&&this._debounceColorPickerEvent(e)}})),e}isValid(){const{t:e}=this.locale;return this.resetValidationStatus(),!!this.hexInputRow.getParsedColor()||(this.hexInputRow.inputView.errorText=e('Please enter a valid color (e.g. "ff0000").'),!1)}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}}function Eg(e){let t=function(e){if(!e)return"";const t=gm(e);return t?"hex"===t.space?t.hexValue:mm(e,"hex"):"#000"}(e);return t||(t="#000"),4===t.length&&(t="#"+[t[1],t[1],t[2],t[2],t[3],t[3]].join("")),t.toLowerCase()}class Tg extends Cs{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Sg extends Cs{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Pg extends Cs{constructor(e,t){super(e),this.inputView=t,this.children=this.createCollection([new Sg,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}getParsedColor(){return Ig(this.inputView.fieldView.element.value)}}function Ig(e){if(!e)return null;const t=e.trim().replace(/^#/,"");return[3,4,6,8].includes(t.length)&&/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(t)?`#${t}`:null}class Vg extends(U(Uo)){constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(e,t){return this.find((t=>t.color===e.color))?this:super.add(e,t)}hasColor(e){return!!this.find((t=>t.color===e))}}const{eraser:Rg,colorPalette:Og}=Hu;class Bg extends Cs{constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerLabel:r,focusTracker:a,focusables:l}){super(e);const c=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=a,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Vg,this.documentColorsCount=s,this._focusables=l,this._removeButtonLabel=n,this._colorPickerLabel=r,this._documentColorsLabel=o,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",c.if("isVisible","ck-hidden",(e=>!e))]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const o of i.getRoots()){const i=e.createRangeIn(o);for(const e of i.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=n))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,i=this.selectedColor;t.selectedColor=i,e&&(e.selectedColor=i)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){const e=is.bind(this.documentColors,this.documentColors),t=new $u(this.locale);t.text=this._documentColorsLabel,t.extendTemplate({attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]}}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new Yu,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:Og,class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",(()=>{this.fire("colorPicker:show")}))}_createRemoveColorButton(){const e=new Yu;return e.set({withText:!0,icon:Rg,label:this._removeButtonLabel}),e.class="ck-color-selector__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null,source:"removeColorButton"})})),e.render(),e}_createStaticColorsGrid(){const e=new am(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on("execute",((e,t)=>{this.fire("execute",{value:t.value,source:"staticColorsGrid"})})),e}_createDocumentColorsGrid(){const e=is.bind(this.documentColors,this.documentColors),t=new am(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using((e=>{const t=new rm;return t.set({color:e.color,hasBorder:e.options&&e.options.hasBorder}),e.label&&t.set({label:e.label,tooltip:!0}),t.on("execute",(()=>{this.fire("execute",{value:e.color,source:"documentColorsGrid"})})),t})),this.documentColors.on("change:isEmpty",((e,i,n)=>{n&&(t.selectedColor=null)})),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find((t=>t.color===e));t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}class Mg extends Cs{constructor(e,{focusTracker:t,focusables:i,keystrokes:n,colorPickerViewConfig:o}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=n,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=o;const s=this.bindTemplate,{saveButtonView:r,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=r,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:r,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",s.if("isVisible","ck-hidden",(e=>!e))]},children:this.items})}render(){super.render();const e=new xg(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",((t,i,n)=>{e.color=n})),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set("enter",(e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire("execute",{value:this.selectedColor}),e.stopPropagation(),e.preventDefault())}))}_stopPropagationOnArrowsKeys(){const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}_addColorPickersElementsToFocusTracker(){for(const e of this.colorPickerView.slidersView)this.focusTracker.add(e.element),this._focusables.add(e);const e=this.colorPickerView.hexInputRow.children.get(1);e.element&&(this.focusTracker.add(e.element),this._focusables.add(e)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:e,cancelButtonView:t}){const i=new Cs,n=this.createCollection();return n.add(e),n.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:n}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new Yu(e),n=new Yu(e);return i.set({icon:Hu.check,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),n.set({icon:Hu.cancel,class:"ck-button-cancel",type:"button",withText:!1,label:t("Cancel")}),i.on("execute",(()=>{this.colorPickerView.isValid()&&this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})})),n.on("execute",(()=>{this.fire("colorPicker:cancel")})),{saveButtonView:i,cancelButtonView:n}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",((e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)}))}}class Fg extends Cs{constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerLabel:r,colorPickerViewConfig:a}){super(e),this.items=this.createCollection(),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts,this._colorPickerViewConfig=a,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Bg(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerLabel:r,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Mg(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:a}),this.set("_isColorGridsFragmentVisible",!0),this.set("_isColorPickerFragmentVisible",!1),this.set("selectedColor",void 0),this.colorGridsFragmentView.bind("isVisible").to(this,"_isColorGridsFragmentVisible"),this.colorPickerFragmentView.bind("isVisible").to(this,"_isColorPickerFragmentVisible"),this.on("change:selectedColor",((e,t,i)=>{this.colorGridsFragmentView.set("selectedColor",i),this.colorPickerFragmentView.set("selectedColor",i)})),this.colorGridsFragmentView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.colorPickerFragmentView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector"]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){this.colorPickerFragmentView.colorPickerView&&!this._isColorPickerFragmentVisible&&(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsFragmentView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate("execute").to(this),this.colorGridsFragmentView.delegate("colorPicker:show").to(this))}_appendColorPickerFragment(){2!==this.items.length&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{this.showColorPickerFragment()})),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate("execute").to(this),this.colorPickerFragmentView.delegate("colorPicker:cancel").to(this))}}class Ng{constructor(e){this._components=new Map,this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Dg(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new _("componentfactory-item-missing",this,{name:e});return this._components.get(Dg(e)).callback(this.editor.locale)}has(e){return this._components.has(Dg(e))}}function Dg(e){return String(e).toLowerCase()}class Lg extends Cs{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children}),t.icon&&(this.iconView=new Zu,this.iconView.content=t.icon,this.children.add(this.iconView));const n=new Cs(e);n.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(n)}}class zg extends Cs{constructor(e){super(e),this.children=this.createCollection(),this.keystrokes=new Ko,this._focusTracker=new Go,this._focusables=new ts,this.focusCycler=new Am({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(e){for(const t of e){const e=new Yu(this.locale);let i;for(i in e.on("execute",(()=>t.onExecute())),t.onCreate&&t.onCreate(e),t)"onExecute"!=i&&"onCreate"!=i&&e.set(i,t[i]);this.children.add(e)}this._updateFocusCyclableItems()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}}class Hg extends Cs{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}reset(){for(;this.children.length;)this.children.remove(0)}}const $g="screen-center",Wg="editor-center",jg="editor-top-side",Ug="editor-top-center",qg="editor-bottom-center",Gg="editor-above-center",Kg="editor-below-center",Zg=Un("px");class Jg extends(function(e){return class extends e{constructor(...e){super(...e),this._onDragBound=this._onDrag.bind(this),this._onDragEndBound=this._onDragEnd.bind(this),this._lastDraggingCoordinates={x:0,y:0},this.on("render",(()=>{this._attachListeners()})),this.set("isDragging",!1)}_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(t.document,"mouseup",this._onDragEndBound),this.listenTo(t.document,"touchend",this._onDragEndBound),this.listenTo(t.document,"mousemove",this._onDragBound),this.listenTo(t.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(t.document,"mouseup",this._onDragEndBound),this.stopListening(t.document,"touchend",this._onDragEndBound),this.stopListening(t.document,"mousemove",this._onDragBound),this.stopListening(t.document,"touchmove",this._onDragBound)}_onDragStart(e,t){if(!this._isHandleElementPressed(t))return;this._attachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),this._lastDraggingCoordinates={x:i,y:n},this.isDragging=!0}_onDrag(e,t){if(!this.isDragging)return void this._detachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),t.preventDefault(),this.fire("drag",{deltaX:Math.round(i-this._lastDraggingCoordinates.x),deltaY:Math.round(n-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:i,y:n}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(e){return!!this.dragHandleElement&&(this.dragHandleElement===e.target||e.target instanceof HTMLElement&&this.dragHandleElement.contains(e.target))}}}(Cs)){constructor(e,{getCurrentDomRoot:t,getViewportOffset:i}){super(e),this.wasMoved=!1;const n=this.bindTemplate,o=e.t;this.set("className",""),this.set("ariaLabel",o("Editor dialog")),this.set("isModal",!1),this.set("position",$g),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=t,this._getViewportOffset=i,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new Ko,this.focusTracker=new Go,this._focusables=new ts,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",n.if("isModal","ck-dialog-overlay__transparent",(e=>!e)),n.if("_isVisible","ck-hidden",(e=>!e))],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",n.to("className")],role:"dialog","aria-label":n.to("ariaLabel"),style:{top:n.to("_top",(e=>Zg(e))),left:n.to("_left",(e=>Zg(e))),visibility:n.if("_isTransparent","hidden")}},children:this.parts}]})}render(){super.render(),this.keystrokes.set("Esc",((e,t)=>{this.fire("close",{source:"escKeyPress"}),t()})),this.on("drag",((e,{deltaX:t,deltaY:i})=>{this.wasMoved=!0,this.moveBy(t,i)})),this.listenTo(t.window,"resize",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.listenTo(t.document,"scroll",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.on("change:_isVisible",((e,t,i)=>{i&&(this._isTransparent=!0,setTimeout((()=>{this.updatePosition(),this._isTransparent=!1,this.focus()}),10))})),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView?this.headerView.element:null}setupParts({icon:e,title:t,hasCloseButton:i=!0,content:n,actionButtons:o}){t&&(this.headerView=new Lg(this.locale,{icon:e}),i&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=t,this.ariaLabel=t,this.parts.add(this.headerView,0)),n&&(n instanceof Cs&&(n=[n]),this.contentView=new Hg(this.locale),this.contentView.children.addMany(n),this.parts.add(this.contentView)),o&&(this.actionsView=new zg(this.locale),this.actionsView.setButtons(o),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),n=this._getDialogRect();e+n.width>i.right&&(e=i.right-n.width),e{var t;this._focusables.add(e),this.focusTracker.add(e.element),Em(t=e)&&"focusCycler"in t&&t.focusCycler instanceof Am&&(this.listenTo(e.focusCycler,"forwardCycle",(e=>{this._focusCycler.focusNext(),this._focusCycler.next!==this._focusCycler.focusables.get(this._focusCycler.current)&&e.stop()})),this.listenTo(e.focusCycler,"backwardCycle",(e=>{this._focusCycler.focusPrevious(),this._focusCycler.previous!==this._focusCycler.focusables.get(this._focusCycler.current)&&e.stop()})))}))}_createCloseButton(){const e=new Yu(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:Hu.cancel}),e.on("execute",(()=>this.fire("close",{source:"closeButton"}))),e}}Jg.defaultOffset=15;const Yg=Jg;class Qg extends Ss{static get pluginName(){return"Dialog"}constructor(e){super(e);const t=e.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set("id",null),e.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:t("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}_initShowHideListeners(){this.on("show",((e,t)=>{this._show(t)})),this.on("show",((e,t)=>{t.onShow&&t.onShow(this)}),{priority:"low"}),this.on("hide",(()=>{Qg._visibleDialogPlugin&&Qg._visibleDialogPlugin._hide()})),this.on("hide",(()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)}),{priority:"low"})}_initFocusToggler(){const e=this.editor;e.keystrokes.set("Ctrl+F6",((t,i)=>{this.isOpen&&!this.view.isModal&&(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),i())}))}_initMultiRootIntegration(){const e=this.editor.model;e.document.on("change:data",(()=>{if(!this.view)return;const t=e.document.differ.getChangedRoots();for(const e of t)e.state&&this.view.updatePosition()}))}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:e,icon:t,title:i,hasCloseButton:n=!0,content:o,actionButtons:s,className:r,isModal:a,position:l,onHide:c}){const d=this.editor;this.view=new Yg(d.locale,{getCurrentDomRoot:()=>d.editing.view.getDomRoot(d.model.document.selection.anchor.root.rootName),getViewportOffset:()=>d.ui.viewportOffset});const h=this.view;h.on("close",(()=>{this.hide()})),d.ui.view.body.add(h),d.ui.focusTracker.add(h.element),d.keystrokes.listenTo(h.element),l||(l=a?$g:Wg),h.set({position:l,_isVisible:!0,className:r,isModal:a}),h.setupParts({icon:t,title:i,hasCloseButton:n,content:o,actionButtons:s}),this.id=e,c&&(this._onHide=c),this.isOpen=!0,Qg._visibleDialogPlugin=this}hide(){Qg._visibleDialogPlugin&&Qg._visibleDialogPlugin.fire(`hide:${Qg._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;const e=this.editor,t=this.view;t.contentView&&t.contentView.reset(),e.ui.view.body.remove(t),e.ui.focusTracker.remove(t.element),e.keystrokes.stopListening(t.element),t.destroy(),e.editing.view.focus(),this.id=null,this.isOpen=!1,Qg._visibleDialogPlugin=null}}const Xg=Un("px"),ef=t.document.body,tf={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class nf extends Cs{constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",(e=>`ck-balloon-panel_${e}`)),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Xg),left:t.to("left",Xg)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=nf.defaultPositions,i=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast,t.viewportStickyNorth],limiter:ef,fitInViewport:!0},e),n=nf._getOptimalPosition(i)||tf,o=parseInt(n.left),s=parseInt(n.top),r=n.name,a=n.config||{},{withArrow:l=!0}=a;this.top=s,this.left=o,this.position=r,this.withArrow=l}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback)}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){this.attachTo(e);const i=sf(e.target),n=e.limiter?sf(e.limiter):ef;this.listenTo(t.document,"scroll",((t,o)=>{const s=o.target,r=i&&s.contains(i),a=n&&s.contains(n);!r&&!a&&i&&n||this.attachTo(e)}),{useCapture:!0}),this.listenTo(t.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(t.document,"scroll"),this.stopListening(t.window,"resize")}}nf.arrowSideOffset=25,nf.arrowHeightOffset=10,nf.stickyVerticalOffset=20,nf._getOptimalPosition=Yn,nf.defaultPositions=rf();const of=nf;function sf(e){return kn(e)?e:Bn(e)?e.commonAncestorContainer:"function"==typeof e?sf(e()):null}function rf(e={}){const{sideOffset:t=nf.arrowSideOffset,heightOffset:i=nf.arrowHeightOffset,stickyVerticalOffset:n=nf.stickyVerticalOffset,config:o}=e;return{northWestArrowSouthWest:(e,i)=>({top:s(e,i),left:e.left-t,name:"arrow_sw",...o&&{config:o}}),northWestArrowSouthMiddleWest:(e,i)=>({top:s(e,i),left:e.left-.25*i.width-t,name:"arrow_smw",...o&&{config:o}}),northWestArrowSouth:(e,t)=>({top:s(e,t),left:e.left-t.width/2,name:"arrow_s",...o&&{config:o}}),northWestArrowSouthMiddleEast:(e,i)=>({top:s(e,i),left:e.left-.75*i.width+t,name:"arrow_sme",...o&&{config:o}}),northWestArrowSouthEast:(e,i)=>({top:s(e,i),left:e.left-i.width+t,name:"arrow_se",...o&&{config:o}}),northArrowSouthWest:(e,i)=>({top:s(e,i),left:e.left+e.width/2-t,name:"arrow_sw",...o&&{config:o}}),northArrowSouthMiddleWest:(e,i)=>({top:s(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw",...o&&{config:o}}),northArrowSouth:(e,t)=>({top:s(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...o&&{config:o}}),northArrowSouthMiddleEast:(e,i)=>({top:s(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme",...o&&{config:o}}),northArrowSouthEast:(e,i)=>({top:s(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se",...o&&{config:o}}),northEastArrowSouthWest:(e,i)=>({top:s(e,i),left:e.right-t,name:"arrow_sw",...o&&{config:o}}),northEastArrowSouthMiddleWest:(e,i)=>({top:s(e,i),left:e.right-.25*i.width-t,name:"arrow_smw",...o&&{config:o}}),northEastArrowSouth:(e,t)=>({top:s(e,t),left:e.right-t.width/2,name:"arrow_s",...o&&{config:o}}),northEastArrowSouthMiddleEast:(e,i)=>({top:s(e,i),left:e.right-.75*i.width+t,name:"arrow_sme",...o&&{config:o}}),northEastArrowSouthEast:(e,i)=>({top:s(e,i),left:e.right-i.width+t,name:"arrow_se",...o&&{config:o}}),southWestArrowNorthWest:e=>({top:r(e),left:e.left-t,name:"arrow_nw",...o&&{config:o}}),southWestArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.left-.25*i.width-t,name:"arrow_nmw",...o&&{config:o}}),southWestArrowNorth:(e,t)=>({top:r(e),left:e.left-t.width/2,name:"arrow_n",...o&&{config:o}}),southWestArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.left-.75*i.width+t,name:"arrow_nme",...o&&{config:o}}),southWestArrowNorthEast:(e,i)=>({top:r(e),left:e.left-i.width+t,name:"arrow_ne",...o&&{config:o}}),southArrowNorthWest:e=>({top:r(e),left:e.left+e.width/2-t,name:"arrow_nw",...o&&{config:o}}),southArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw",...o&&{config:o}}),southArrowNorth:(e,t)=>({top:r(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...o&&{config:o}}),southArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme",...o&&{config:o}}),southArrowNorthEast:(e,i)=>({top:r(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne",...o&&{config:o}}),southEastArrowNorthWest:e=>({top:r(e),left:e.right-t,name:"arrow_nw",...o&&{config:o}}),southEastArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.right-.25*i.width-t,name:"arrow_nmw",...o&&{config:o}}),southEastArrowNorth:(e,t)=>({top:r(e),left:e.right-t.width/2,name:"arrow_n",...o&&{config:o}}),southEastArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.right-.75*i.width+t,name:"arrow_nme",...o&&{config:o}}),southEastArrowNorthEast:(e,i)=>({top:r(e),left:e.right-i.width+t,name:"arrow_ne",...o&&{config:o}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e",...o&&{config:o}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w",...o&&{config:o}}),viewportStickyNorth:(e,t,i,s)=>{const r=s||i;return e.getIntersection(r)?r.height-e.height>n?null:{top:r.top+n,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...o}}:null}};function s(e,t){return e.top-t.height-i}function r(e){return e.bottom+i}}const af="ck-tooltip";class lf extends(Pn()){constructor(e){if(super(),this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver=null,this._mutationObserver=null,lf._editors.add(e),lf._instance)return lf._instance;lf._instance=this,this.tooltipTextView=new Cs(e.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new of(e.locale),this.balloonPanelView.class=af,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=function(e){const t=new MutationObserver((()=>{e()}));return{attach(e){t.observe(e,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){t.disconnect()}}}((()=>{this._updateTooltipPosition()})),this._pinTooltipDebounced=ll(this._pinTooltip,600),this._unpinTooltipDebounced=ll(this._unpinTooltip,400),this.listenTo(t.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(t.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(t.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(t.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(t.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(t.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;lf._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),lf._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),lf._instance=null)}static getPositioningFunctions(e){const t=lf.defaultBalloonPositions;return{s:[t.southArrowNorth,t.southArrowNorthEast,t.southArrowNorthWest],n:[t.northArrowSouth],e:[t.eastArrowWest],w:[t.westArrowEast],sw:[t.southArrowNorthEast],se:[t.southArrowNorthWest]}[e]}_onKeyDown(e,t){"Escape"===t.key&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){const i=df(t);i?i!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(i,hf(i))):"focus"===e.name&&this._unpinTooltip()}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if("mouseleave"===e.name){if(!kn(t))return;const e=this.balloonPanelView.element,n=e&&(e===i||e.contains(i)),o=!n&&t===e;if(n)return void this._unpinTooltipDebounced.cancel();if(!o&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const s=df(t),r=df(i);(o||s&&s!==r)&&this._unpinTooltipDebounced()}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._unpinTooltipDebounced()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:i,cssClass:n}){this._unpinTooltip();const o=qo(lf._editors.values()).ui.view.body;o.has(this.balloonPanelView)||o.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.pin({target:e,positions:lf.getPositioningFunctions(i)}),this._resizeObserver=new Wn(e,(()=>{Jn(e)||this._unpinTooltip()})),this._mutationObserver.attach(e),this.balloonPanelView.class=[af,n].filter((e=>e)).join(" ");for(const e of lf._editors)this.listenTo(e.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of lf._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._resizeObserver&&this._resizeObserver.destroy(),this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;const e=hf(this._currentElementWithTooltip);Jn(this._currentElementWithTooltip)&&e.text?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:lf.getPositioningFunctions(e.position)}):this._unpinTooltip()}}lf.defaultBalloonPositions=rf({heightOffset:5,sideOffset:13}),lf._editors=new Set,lf._instance=null;const cf=lf;function df(e){return kn(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function hf(e){return{text:e.dataset.ckeTooltipText,position:e.dataset.ckeTooltipPosition||"s",cssClass:e.dataset.ckeTooltipClass||""}}const uf=function(e,t,i){var n=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return N(i)&&(n="leading"in i?!!i.leading:n,o="trailing"in i?!!i.trailing:o),ll(e,t,{leading:n,maxWait:t,trailing:o})},mf=50,gf=350,ff="Powered by";class pf extends(Pn()){constructor(e){super(),this.editor=e,this._balloonView=null,this._lastFocusedEditableElement=null,this._showBalloonThrottled=uf(this._showBalloon.bind(this),50,{leading:!0}),e.on("ready",this._handleEditorReady.bind(this))}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;(!!e.config.get("ui.poweredBy.forceVisible")||"VALID"!==function(e){function t(e){return e.length>=40&&e.length<=255?"VALID":"INVALID"}if(!e)return"INVALID";let i="";try{i=atob(e)}catch(e){return"INVALID"}const n=i.split("-"),o=n[0],s=n[1];if(!s)return t(e);try{atob(s)}catch(i){try{if(atob(o),!atob(o).length)return t(e)}catch(i){return t(e)}}if(o.length<40||o.length>255)return"INVALID";let r="";try{atob(o),r=atob(s)}catch(e){return"INVALID"}if(8!==r.length)return"INVALID";const a=Number(r.substring(0,4)),l=Number(r.substring(4,6))-1,c=Number(r.substring(6,8)),d=new Date(a,l,c);return d{this._updateLastFocusedEditableElement(),i?this._showBalloon():this._hideBalloon()})),e.ui.focusTracker.on("change:focusedElement",((e,t,i)=>{this._updateLastFocusedEditableElement(),i&&this._showBalloon()})),e.ui.on("update",(()=>{this._showBalloonThrottled()})))}_createBalloonView(){const e=this.editor,t=this._balloonView=new of,i=_f(e),n=new bf(e.locale,i.label);t.content.add(n),t.set({class:"ck-powered-by-balloon"}),e.ui.view.body.add(t),e.ui.focusTracker.add(t.element),this._balloonView=t}_showBalloon(){if(!this._lastFocusedEditableElement)return;const e=function(e,t){const i=_f(e),n="right"===i.side?function(e,t){return wf(e,t,((e,i)=>e.left+e.width-i.width-t.horizontalOffset))}(t,i):function(e,t){return wf(e,t,(e=>e.left+t.horizontalOffset))}(t,i);return{target:t,positions:[n]}}(this.editor,this._lastFocusedEditableElement);e&&(this._balloonView||this._createBalloonView(),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i)return void(this._lastFocusedEditableElement=null);const n=Array.from(e.ui.getEditableElementsNames()).map((t=>e.ui.getEditableElement(t)));n.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=n[0]}}class bf extends Cs{constructor(e,t){super(e);const i=new Zu,n=this.bindTemplate;i.set({content:'\n',isColorInherited:!1}),i.extendTemplate({attributes:{style:{width:"53px",height:"10px"}}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...t?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[t]}]:[],i],on:{dragstart:n.to((e=>e.preventDefault()))}}]})}}function wf(e,t,i){return(n,o)=>{const s=new Nn(e);if(s.width{for(const e of Object.values(vf))this.announce("",e)}))}announce(e,t=vf.POLITE){const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new kf(i.locale),i.ui.view.body.add(this.view));const{politeness:n,isUnsafeHTML:o}="string"==typeof t?{politeness:t}:t;let s=this.view.regionViews.find((e=>e.politeness===n));s||(s=new Cf(i,n),this.view.regionViews.add(s)),s.announce({announcement:e,isUnsafeHTML:o})}}class kf extends Cs{constructor(e){super(e),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class Cf extends Cs{constructor(e,t){super(e.locale),this.setTemplate({tag:"div",attributes:{role:"region","aria-live":t,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),e.on("destroy",(()=>{null!==this._pruneAnnouncementsInterval&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)})),this.politeness=t,this._domConverter=e.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval((()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()}),5e3)}announce({announcement:e,isUnsafeHTML:t}){if(!e.trim().length)return;const i=document.createElement("li");t?this._domConverter.setContentOf(i,e):i.innerText=e,this._listElement.appendChild(i)}get _listElement(){return this.element.querySelector("ul")}}class Af extends(U()){constructor(e){super(),this.isReady=!1,this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[];const t=e.editing.view;this.editor=e,this.componentFactory=new Ng(e),this.focusTracker=new Go,this.tooltipManager=new cf(e),this.poweredBy=new pf(e),this.ariaLiveAnnouncer=new yf(e),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.once("ready",(()=>{this.isReady=!0})),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[]}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const i=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?i():this.once("ready",i)}removeEditableElement(e){const t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e,t={}){e.isRendered?(this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)):e.once("render",(()=>{this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)})),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:i}):{top:0}}_initFocusTracking(){const e=this.editor,t=e.editing.view;let i,n;e.keystrokes.set("Alt+F10",((e,o)=>{const s=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(s)&&!Array.from(t.domRoots.values()).includes(s)&&(i=s);const r=this._getCurrentFocusedToolbarDefinition();r&&n||(n=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{const o=this._getCurrentFocusedToolbarDefinition();o&&(i?(i.focus(),i=null):e.editing.view.focus(),o.options.afterBlur&&o.options.afterBlur(),n())}))}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:n}=t;(Jn(i.element)||n.beforeFocus)&&e.push(t)}return e.sort(((e,t)=>xf(e)-xf(t))),e}_getCurrentFocusedToolbarDefinition(){for(const e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){const{toolbarView:t,options:{beforeFocus:i}}=e;return i&&i(),!!Jn(t.element)&&(t.focus(),!0)}_handleScrollToTheSelection(e,t){const i={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=i.top,t.viewportOffset.bottom+=i.bottom,t.viewportOffset.left+=i.left,t.viewportOffset.right+=i.right}}function xf(e){const{toolbarView:t,options:i}=e;let n=10;return Jn(t.element)&&n--,i.isContextual&&n--,n}class Ef extends Cs{constructor(e){super(e),this.body=new Gu(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class Tf extends Ef{constructor(e){super(e),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:e.uiLanguageDirection,lang:e.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}_createVoiceLabel(){const e=this.t,t=new $u;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class Sf extends Cs{constructor(e,t,i){super(e),this.name=null,this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=t}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",(()=>this._updateIsFocusedClasses())),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}get hasExternalElement(){return this._hasExternalElement}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change((i=>{const n=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",n)}))}e.isRenderingInProgress?function i(n){e.once("change:isRenderingInProgress",((e,o,s)=>{s?i(n):t(n)}))}(this):t(this)}}class Pf extends Sf{constructor(e,t,i,n={}){super(e,t,i);const o=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=n.label||(()=>o("Editor editing area: %0",this.name))}render(){super.render();const e=this._editingView;e.change((t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this._generateLabel(this),i)}))}}class If extends Ms{static get pluginName(){return"Notification"}init(){this.on("show:warning",((e,t)=>{window.alert(t.message)}),{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=e.namespace?`show:${e.type}:${e.namespace}`:`show:${e.type}`;this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class Vf extends(U()){constructor(e,t){super(),t&&qa(this,t),e&&this.set(e)}}const Rf=Un("px");class Of extends Ss{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this._viewToStack=new Map,this._idToStack=new Map,this._view=null,this._rotatorView=null,this._fakePanelsView=null,this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new _("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new _("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new _("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new of(this.editor.locale),this.editor.ui.view.body.add(this._view),this.editor.ui.focusTracker.add(this._view.element),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find((t=>t[1]===e))[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new Bf(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>1)),e.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((e,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[n,i])})),e.buttonNextView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),e.buttonPrevView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),e}_createFakePanelsView(){const e=new Mf(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>=2?Math.min(e-1,2):0)),e.listenTo(this.view,"change:top",(()=>e.updatePosition())),e.listenTo(this.view,"change:left",(()=>e.updatePosition())),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:this.editor.ui.viewportOffset})),e}}class Bf extends Cs{constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Go,this.buttonPrevView=this._createButtonView(t("Previous"),Hu.previousArrow),this.buttonNextView=this._createButtonView(t("Next"),Hu.nextArrow),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",i.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new Yu(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class Mf extends Cs{constructor(e,t){super(e);const i=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:i.to("top",Rf),left:i.to("left",Rf),width:i.to("width",Rf),height:i.to("height",Rf)}},children:this.content}),this.on("change:numberOfPanels",((e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new Cs;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:n}=new Nn(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}const Ff=Un("px");class Nf extends Cs{constructor(e){super(e);const t=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheBottomOfLimiter",!1),this.set("_stickyTopOffset",null),this.set("_stickyBottomOffset",null),this.content=this.createCollection(),this._contentPanelPlaceholder=new is({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?Ff(this._contentPanelRect.height):null))}}}).render(),this.contentPanelElement=new is({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheBottomOfLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",(e=>e?Ff(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_stickyTopOffset",(e=>e?Ff(e):e)),bottom:t.to("_stickyBottomOffset",(e=>e?Ff(e):e)),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this.contentPanelElement]})}render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(t.document,"scroll",(()=>{this.checkIfShouldBeSticky()}),{useCapture:!0}),this.listenTo(this,"change:isActive",(()=>{this.checkIfShouldBeSticky()}))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const e=new Nn(this.limiterElement);let i=e.getVisible();if(i){const e=new Nn(t.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,i=i.getIntersection(e)}if(i&&e.topi.bottom){const t=Math.max(e.bottom-i.bottom,0)+this.limiterBottomOffset;e.bottom-t>e.top+this._contentPanelRect.height?this._stickToBottomOfLimiter(t):this._unstick()}else this._contentPanelRect.height+this.limiterBottomOffset{this.reset(),this.focus(),this.fire("reset")})),this.resetButtonView.bind("isVisible").to(this.fieldView,"isEmpty",(e=>!e)),this.fieldWrapperChildren.add(this.resetButtonView),this.extendTemplate({attributes:{class:"ck-search__query_with-reset"}}))}reset(){this.fieldView.reset(),this._viewConfig.showResetButton&&(this.resetButtonView.isVisible=!1)}}class Lf extends Cs{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,primaryText:"",secondaryText:""}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__info",e.if("isVisible","ck-hidden",(e=>!e))],tabindex:-1},children:[{tag:"span",children:[{text:[e.to("primaryText")]}]},{tag:"span",children:[{text:[e.to("secondaryText")]}]}]})}focus(){this.element.focus()}}class zf extends Cs{constructor(e){super(e),this.children=this.createCollection(),this.focusTracker=new Go,this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__results"],tabindex:-1},children:this.children}),this._focusCycler=new Am({focusables:this.children,focusTracker:this.focusTracker})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element)}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}var Hf=/[\\^$.*+?()[\]{}|]/g,$f=RegExp(Hf.source);const Wf=function(e){return(e=gr(e))&&$f.test(e)?e.replace(Hf,"\\$&"):e};class jf extends Cs{constructor(e,t){super(e),this._config=t,this.filteredView=t.filteredView,this.queryView=this._createSearchTextQueryView(),this.focusTracker=new Go,this.keystrokes=new Ko,this.resultsView=new zf(e),this.children=this.createCollection(),this.focusableChildren=this.createCollection([this.queryView,this.resultsView]),this.set("isEnabled",!0),this.set("resultsCount",0),this.set("totalItemsCount",0),t.infoView&&t.infoView.instance?this.infoView=t.infoView.instance:(this.infoView=new Lf,this._enableDefaultInfoViewBehavior(),this.on("render",(()=>{this.search("")}))),this.resultsView.children.addMany([this.infoView,this.filteredView]),this.focusCycler=new Am({focusables:this.focusableChildren,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.on("search",((e,{resultsCount:t,totalItemsCount:i})=>{this.resultsCount=t,this.totalItemsCount=i})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search",t.class||null],tabindex:"-1"},children:this.children})}render(){super.render(),this.children.addMany([this.queryView,this.resultsView]);const e=e=>e.stopPropagation();for(const e of this.focusableChildren)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}focus(){this.queryView.focus()}reset(){this.queryView.reset(),this.search("")}search(e){const t=e?new RegExp(Wf(e),"ig"):null,i=this.filteredView.filter(t);this.fire("search",{query:e,...i})}_createSearchTextQueryView(){const e=new Df(this.locale,this._config.queryView);return this.listenTo(e.fieldView,"input",(()=>{this.search(e.fieldView.element.value)})),e.on("reset",(()=>this.reset())),e.bind("isEnabled").to(this),e}_enableDefaultInfoViewBehavior(){const e=this.locale.t,t=this.infoView;function i(e,{query:t,resultsCount:i,totalItemsCount:n}){return"function"==typeof e?e(t,i,n):e}this.on("search",((n,o)=>{if(o.resultsCount)t.set({isVisible:!1});else{const n=this._config.infoView&&this._config.infoView.text;let s,r;o.totalItemsCount?n&&n.notFound?(s=n.notFound.primary,r=n.notFound.secondary):(s=e("No results found"),r=""):n&&n.noSearchableItems?(s=n.noSearchableItems.primary,r=n.noSearchableItems.secondary):(s=e("No searchable items"),r=""),t.set({primaryText:i(s,o),secondaryText:i(r,o),isVisible:!0})}}))}}class Uf extends jf{constructor(e,i){super(e,i),this._config=i;const n=Un("px");this.extendTemplate({attributes:{class:["ck-autocomplete"]}});const o=this.resultsView.bindTemplate;this.resultsView.set("isVisible",!1),this.resultsView.set("_position","s"),this.resultsView.set("_width",0),this.resultsView.extendTemplate({attributes:{class:[o.if("isVisible","ck-hidden",(e=>!e)),o.to("_position",(e=>`ck-search__results_${e}`))],style:{width:o.to("_width",n)}}}),this.focusTracker.on("change:isFocused",((e,t,n)=>{this._updateResultsVisibility(),n?this.resultsView.element.scrollTop=0:i.resetOnBlur&&this.queryView.reset()})),this.on("search",(()=>{this._updateResultsVisibility(),this._updateResultsViewWidthAndPosition()})),this.keystrokes.set("esc",((e,t)=>{this.resultsView.isVisible&&(this.queryView.focus(),this.resultsView.isVisible=!1,t())})),this.listenTo(t.document,"scroll",(()=>{this._updateResultsViewWidthAndPosition()})),this.on("change:isEnabled",(()=>{this._updateResultsVisibility()})),this.filteredView.on("execute",((e,{value:t})=>{this.focus(),this.reset(),this.queryView.fieldView.value=this.queryView.fieldView.element.value=t,this.resultsView.isVisible=!1})),this.resultsView.on("change:isVisible",(()=>{this._updateResultsViewWidthAndPosition()}))}_updateResultsViewWidthAndPosition(){if(!this.resultsView.isVisible)return;this.resultsView._width=new Nn(this.queryView.fieldView.element).width;const e=Uf._getOptimalPosition({element:this.resultsView.element,target:this.queryView.element,fitInViewport:!0,positions:Uf.defaultResultsPositions});this.resultsView._position=e?e.name:"s"}_updateResultsVisibility(){const e=void 0===this._config.queryMinChars?0:this._config.queryMinChars,t=this.queryView.fieldView.element.value.length;this.resultsView.isVisible=this.focusTracker.isFocused&&this.isEnabled&&t>=e}}Uf.defaultResultsPositions=[e=>({top:e.bottom,left:e.left,name:"s"}),(e,t)=>({top:e.top-t.height,left:e.left,name:"n"})],Uf._getOptimalPosition=Yn;const qf=function(e){return function(t){return null==e?void 0:e[t]}};qf({"&":"&","<":"<",">":">",'"':""","'":"'"});var Gf=/[&<>"']/g;RegExp(Gf.source);Un("px");Un("px");Un("px");class Kf extends Yu{constructor(e){super(e);const t=this.bindTemplate;this.set({withText:!0,role:"menuitem"}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__button"],"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(e=>String(e))),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new Zu;return e.content=tm,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}}class Zf extends Mm{constructor(e,t){super(e);const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:i.to("mouseenter")}}),this.delegate("mouseenter").to(t)}}const Jf={toggleMenusAndFocusItemsOnHover(e){e.on("menu:mouseenter",(t=>{if(e.isOpen){for(const i of e.menus){const e=t.path[0],n=e instanceof Zf&&e.children.first===i;i.isOpen=(t.path.includes(i)||n)&&i.isEnabled}t.source.focus()}}))},focusCycleMenusOnArrows(e){const t="rtl"===e.locale.uiLanguageDirection;function i(t,i){const n=e.children.getIndex(t),o=t.isOpen,s=e.children.length,r=e.children.get((n+s+i)%s);t.isOpen=!1,o&&(r.isOpen=!0),r.buttonView.focus()}e.on("menu:arrowright",(e=>{i(e.source,t?-1:1)})),e.on("menu:arrowleft",(e=>{i(e.source,t?1:-1)}))},closeMenusWhenTheBarCloses(e){e.on("change:isOpen",(()=>{e.isOpen||e.menus.forEach((e=>{e.isOpen=!1}))}))},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on("menu:change:isOpen",((t,i,n)=>{n&&e.menus.filter((e=>t.source.parentMenuView===e.parentMenuView&&t.source!==e&&e.isOpen)).forEach((e=>{e.isOpen=!1}))}))},closeOnClickOutside(e){As({emitter:e,activator:()=>e.isOpen,callback:()=>e.close(),contextElements:()=>e.children.map((e=>e.element))})}},Yf={openAndFocusPanelOnArrowDownKey(e){e.keystrokes.set("arrowdown",((t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())}))},openOnArrowRightKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowleft":"arrowright";e.keystrokes.set(t,((t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&e.isEnabled&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())}))},openOnButtonClick(e){e.buttonView.on("execute",(()=>{e.isOpen=!0,e.panelView.focus()}))},toggleOnButtonClick(e){e.buttonView.on("execute",(()=>{e.isOpen=!e.isOpen,e.isOpen&&e.panelView.focus()}))},closeOnArrowLeftKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowright":"arrowleft";e.keystrokes.set(t,((t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())}))},closeOnEscKey(e){e.keystrokes.set("esc",((t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())}))},closeOnParentClose(e){e.parentMenuView.on("change:isOpen",((t,i,n)=>{n||t.source!==e.parentMenuView||(e.isOpen=!1)}))}},Qf={southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),eastSouth:e=>({top:e.top,left:e.right-5,name:"es"}),eastNorth:(e,t)=>({top:e.top-t.height,left:e.right-5,name:"en"}),westSouth:(e,t)=>({top:e.top,left:e.left-t.width+5,name:"ws"}),westNorth:(e,t)=>({top:e.top-t.height,left:e.left-t.width+5,name:"wn"})},Xf=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:uploadImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable"]},{groupId:"insertInline",items:["menuBar:link","menuBar:comment"]},{groupId:"insertMinorWidgets",items:["menuBar:insertTemplate","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function ep({normalizedConfig:e,locale:t,componentFactory:i}){const n=Hl(e);return function(e,t){const i=t.removeItems,n=[];t.items=t.items.filter((({menuId:e})=>!i.includes(e)||(n.push(e),!1))),op(t.items,(e=>{e.groups=e.groups.filter((({groupId:e})=>!i.includes(e)||(n.push(e),!1)));for(const t of e.groups)t.items=t.items.filter((e=>{const t=cp(e);return!i.includes(t)||(n.push(t),!1)}))}));for(const t of i)n.includes(t)||v("menu-bar-item-could-not-be-removed",{menuBarConfig:e,itemName:t})}(e,n),function(e,t){const i=t.addItems,n=[];for(const e of i){const i=ap(e.position),o=lp(e.position);if(sp(e))if(o){const s=t.items.findIndex((e=>e.menuId===o));if(-1!=s)"before"===i?(t.items.splice(s,0,e.menu),n.push(e)):"after"===i&&(t.items.splice(s+1,0,e.menu),n.push(e));else{tp(t,e.menu,o,i)&&n.push(e)}}else"start"===i?(t.items.unshift(e.menu),n.push(e)):"end"===i&&(t.items.push(e.menu),n.push(e));else if(rp(e))op(t.items,(t=>{if(t.menuId===o)"start"===i?(t.groups.unshift(e.group),n.push(e)):"end"===i&&(t.groups.push(e.group),n.push(e));else{const s=t.groups.findIndex((e=>e.groupId===o));-1!==s&&("before"===i?(t.groups.splice(s,0,e.group),n.push(e)):"after"===i&&(t.groups.splice(s+1,0,e.group),n.push(e)))}}));else{tp(t,e.item,o,i)&&n.push(e)}}for(const t of i)n.includes(t)||v("menu-bar-item-could-not-be-added",{menuBarConfig:e,addedItemConfig:t})}(e,n),function(e,t,i){op(t.items,(n=>{for(const o of n.groups)o.items=o.items.filter((o=>{const s="string"==typeof o&&!i.has(o);return s&&!t.isUsingDefaultConfig&&v("menu-bar-item-unavailable",{menuBarConfig:e,parentMenuConfig:Hl(n),componentName:o}),!s}))}))}(e,n,i),ip(e,n),function(e,t){const i=t.t,n={File:i({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:i({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:i({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:i({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:i({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:i({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:i({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:i({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:i({string:"Font",id:"MENU_BAR_MENU_FONT"})};op(e.items,(e=>{e.label in n&&(e.label=n[e.label])}))}(n,t),n}function tp(e,t,i,n){let o=!1;return op(e.items,(e=>{for(const{groupId:s,items:r}of e.groups){if(o)return;if(s===i)"start"===n?(r.unshift(t),o=!0):"end"===n&&(r.push(t),o=!0);else{const e=r.findIndex((e=>cp(e)===i));-1!==e&&("before"===n?(r.splice(e,0,t),o=!0):"after"===n&&(r.splice(e+1,0,t),o=!0))}}})),o}function ip(e,t){const i=t.isUsingDefaultConfig;let n=!1;t.items=t.items.filter((t=>!!t.groups.length||(np(e,t,i),!1))),t.items.length?(op(t.items,(t=>{t.groups=t.groups.filter((e=>!!e.items.length||(n=!0,!1)));for(const o of t.groups)o.items=o.items.filter((t=>!(dp(t)&&!t.groups.length)||(np(e,t,i),n=!0,!1)))})),n&&ip(e,t)):np(e,e,i)}function np(e,t,i){i||v("menu-bar-menu-empty",{menuBarConfig:e,emptyMenuConfig:t})}function op(e,t){if(Array.isArray(e))for(const t of e)i(t);function i(e){t(e);for(const t of e.groups)for(const e of t.items)dp(e)&&i(e)}}function sp(e){return"object"==typeof e&&"menu"in e}function rp(e){return"object"==typeof e&&"group"in e}function ap(e){return e.startsWith("start")?"start":e.startsWith("end")?"end":e.startsWith("after")?"after":"before"}function lp(e){const t=e.match(/^[^:]+:(.+)/);return t?t[1]:null}function cp(e){return"string"==typeof e?e:e.menuId}function dp(e){return"object"==typeof e&&"menuId"in e}function hp(e,t){const i=t.element;e.ui.focusTracker.add(i),e.keystrokes.listenTo(i);const n=function(e){let t;return t="items"in e&&e.items?{items:e.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...e}:{items:Hl(Xf),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...e},t}(e.config.get("menuBar")||{});t.fillFromConfig(n,e.ui.componentFactory),e.keystrokes.set("Esc",((t,n)=>{i.contains(e.ui.focusTracker.focusedElement)&&(e.editing.view.focus(),n())})),e.keystrokes.set("Alt+F9",((n,o)=>{i.contains(e.ui.focusTracker.focusedElement)||(t.focus(),o())}))}class up extends Cs{constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-menu-bar__menu__panel",t.to("position",(e=>`ck-menu-bar__menu__panel_position_${e}`)),t.if("isVisible","ck-hidden",(e=>!e))],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}focus(e=1){this.children.length&&(1===e?this.children.first.focus():this.children.last.focus())}}class mp extends Cs{constructor(e){super(e);const t=this.bindTemplate;this.buttonView=new Kf(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new up(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new Ko,this.focusTracker=new Go,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",t.to("class"),t.if("isEnabled","ck-disabled",(e=>!e)),t.if("parentMenuView","ck-menu-bar__menu_top-level",(e=>!e))]},children:[this.buttonView,this.panelView]})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),Yf.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Yf.openOnButtonClick(this),Yf.openOnArrowRightKey(this),Yf.closeOnArrowLeftKey(this),Yf.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Yf.openAndFocusPanelOnArrowDownKey(this),Yf.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",((e,t)=>{this.fire("arrowright"),t()})),this.keystrokes.set("arrowleft",((e,t)=>{this.fire("arrowleft"),t()}))}_repositionPanelOnOpen(){this.on("change:isOpen",((e,t,i)=>{if(!i)return;const n=mp._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=n?n.name:this._panelPositions[0].name}))}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:n,westSouth:o,eastSouth:s,westNorth:r,eastNorth:a}=Qf;return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?[s,a,o,r]:[e,t,i,n]:this.parentMenuView?[o,r,s,a]:[t,e,n,i]}}mp._getOptimalPosition=Yn;const gp=mp;class fp extends Dm{constructor(e){super(e),this.role="menu"}}class pp extends Yu{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class bp extends Xu{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const wp=["mouseenter","arrowleft","arrowright","change:isOpen"];class _p extends Cs{constructor(e){super(e),this.menus=[];const t=e.t;this.set("isOpen",!1),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar"],"aria-label":t("Editor menu bar"),role:"menubar"},children:this.children})}fillFromConfig(e,t){const i=ep({normalizedConfig:e,locale:this.locale,componentFactory:t}).items.map((e=>this._createMenu({componentFactory:t,menuDefinition:e})));this.children.addMany(i)}render(){super.render(),Jf.toggleMenusAndFocusItemsOnHover(this),Jf.closeMenusWhenTheBarCloses(this),Jf.closeMenuWhenAnotherOnTheSameLevelOpens(this),Jf.focusCycleMenusOnArrows(this),Jf.closeOnClickOutside(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const e of this.children)e.isOpen=!1}registerMenu(e,t=null){t?(e.delegate(...wp).to(t),e.parentMenuView=t):e.delegate(...wp).to(this,(e=>"menu:"+e)),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:i}){const n=this.locale,o=new gp(n);return this.registerMenu(o,i),o.buttonView.set({label:t.label}),o.once("change:isOpen",(()=>{const i=new fp(n);i.ariaLabel=t.label,o.panelView.children.add(i),i.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:o,componentFactory:e}))})),o}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:i}){const n=this.locale,o=[];for(const s of e.groups){for(const e of s.items){const s=new Zf(n,t);if(N(e))s.children.add(this._createMenu({componentFactory:i,menuDefinition:e,parentMenuView:t}));else{const n=this._createMenuItemContentFromFactory({componentName:e,componentFactory:i,parentMenuView:t});if(!n)continue;s.children.add(n)}o.push(s)}s!==e.groups[e.groups.length-1]&&o.push(new Fm(n))}return o}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:i}){const n=i.create(e);return n instanceof gp||n instanceof pp||n instanceof bp?(this._registerMenuTree(n,t),n.on("execute",(()=>{this.close()})),n):(v("menu-bar-component-unsupported",{componentName:e,componentView:n}),null)}_registerMenuTree(e,t){if(!(e instanceof gp))return void e.delegate("mouseenter").to(t);this.registerMenu(e,t);const i=e.panelView.children.filter((e=>e instanceof fp))[0];if(!i)return void e.delegate("mouseenter").to(t);const n=i.items.filter((e=>e instanceof Mm));for(const t of n)this._registerMenuTree(t.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",((t,i,n)=>{clearTimeout(e),n?this.isOpen=!0:e=setTimeout((()=>{this.isOpen=Array.from(this.children).some((e=>e.isOpen))}),0)}))}}class vp extends Af{constructor(e,t){super(e),this.view=t,this._toolbarConfig=Pm(e.config.get("toolbar")),this._elementReplacer=new Y,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,o=i.editable,s=n.document.getRoot();o.name=s.rootName,i.render();const r=o.element;this.setEditableElement(o.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),i.menuBarView&&hp(t,i.menuBarView),this._initDialogPluginIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e||0)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let o;const s=e.config.get("placeholder");s&&(o="string"==typeof s?s:s[this.view.editable.name]),!o&&n&&"textarea"===n.tagName.toLowerCase()&&(o=n.getAttribute("placeholder")),o&&(i.placeholder=o),Ds({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new Nn(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout((()=>{this.stopListening(n,"change:isSticky",e)}),20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const e=this.view.stickyPanel,t=this.editor.plugins.get("Dialog");t.on("show",(()=>{const i=t.view;i.on("moveTo",((t,n)=>{if(!e.isSticky||i.wasMoved)return;const o=new Nn(e.contentPanelElement);n[1]{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter((e=>e!==t))}_fire(e,...t){const i=this._listeners[e]||[];for(const e of i)e.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function Cp(e,t=new Set){const i=[e],n=new Set;let o=0;for(;i.length>o;){const e=i[o++];if(!n.has(e)&&Ap(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch(e){}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function Ap(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function xp(e,t,i=new Set){if(e===t&&("object"==typeof(n=e)&&null!==n))return!0;var n;const o=Cp(e,i),s=Cp(t,i);for(const e of o)if(s.has(e))return!0;return!1}class Ep extends kp{constructor(e,t={}){super(t),this._editor=null,this._lifecyclePromise=null,this._initUsingData=!0,this._editables={},this._throttledSave=uf(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>e.create(t,i)),this._destructor=e=>e.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((e=>{console.error("An error happened during the editor destroying.",e)})).then((()=>{const e={},t=[],i=this._config.rootsAttributes||{},n={};for(const[o,s]of Object.entries(this._data.roots))s.isLoaded?(e[o]="",n[o]=i[o]||{}):t.push(o);const o={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:n,_watchdogInitialData:this._data};return delete o.initialData,o.extraPlugins.push(Tp),this._initUsingData?this.create(e,o,o.context):kn(this._elementOrData)?this.create(this._elementOrData,o,o.context):this.create(this._editables,o,o.context)})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then((()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData="string"==typeof e||Object.keys(e).length>0&&"string"==typeof Object.values(e)[0],this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config)))).then((e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")})).finally((()=>{this._lifecyclePromise=null})),this._lifecyclePromise}destroy(){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))).finally((()=>{this._lifecyclePromise=null})),this._lifecyclePromise}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)}))}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter((e=>e.isAttached()&&"$graveyard"!=e.rootName)),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),o=i.has("TrackChanges")&&i.get("TrackChanges"),s={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach((e=>{s.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}}));for(const t of e.model.markers)t._affectsData&&(s.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return n&&(s.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),o&&(s.suggestions=JSON.stringify(o.getSuggestions({toJSON:!0,skipNotAttached:!0}))),s}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return xp(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return yn(e,((e,t)=>kn(e)||"context"===t?e:void 0))}}class Tp{constructor(e){this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",(e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},(e=>{this._restoreCollaborationData(),this._restoreEditorData(e)})),this.editor.data.fire("ready")}),{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach((([i,{content:n,attributes:o}])=>{const s=JSON.parse(n),r=JSON.parse(o),a=t.model.document.getRoot(i);for(const[t,i]of r)e.setAttribute(t,i,a);for(const t of s){const i=this._createNode(e,t);e.insert(i,a,"end")}})),Object.entries(this._data.markers).forEach((([i,n])=>{const{document:o}=t.model,{rangeJSON:{start:s,end:r},...a}=n,l=o.getRoot(s.root),c=e.createPositionFromPath(l,s.path,s.stickiness),d=e.createPositionFromPath(l,r.path,r.stickiness),h=e.createRange(c,d);e.addMarker(i,{range:h,...a})}))}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach((e=>{const t=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");if(i.hasCommentThread(e.threadId)){i.getCommentThread(e.threadId).remove()}i.addCommentThread({channelId:t,...e})})),t.forEach((e=>{const t=this.editor.plugins.get("TrackChangesEditing");if(t.hasSuggestion(e.id)){t.getSuggestion(e.id).attributes=e.attributes}else t.addSuggestionData(e)}))}}const Sp=Symbol("MainQueueId");class Pp{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===Sp;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(Sp),this._queues.get(e)])).then(t),o=n.catch((()=>{}));return this._queues.set(e,o),n.finally((()=>{this._activeActions--,this._queues.get(e)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function Ip(e){return Array.isArray(e)?e:[e]}class Vp extends(Lu(Du)){constructor(e,t={}){if(!Op(e)&&void 0!==t.initialData)throw new _("editor-create-initial-data",null);super(t),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Op(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),Op(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),o=new yp(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i,useMenuBar:n.isVisible});this.ui=new vp(this,o),function(e){if(!ze(e.updateSourceElement))throw new _("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,o=()=>e.updateSourceElement();ze(n.submit)&&(i=n.submit,n.submit=()=>{o(),i.apply(n)}),n.addEventListener("submit",o),e.on("destroy",(()=>{n.removeEventListener("submit",o),i&&(n.submit=i)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init(Op(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}}Vp.Context=Bs,Vp.EditorWatchdog=Ep,Vp.ContextWatchdog=class extends kp{constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new Pp,this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(Sp,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=Ip(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw new Error(`Item with the given id is already added: '${e.id}'.`);if("editor"===e.type)return t=new Ep(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",((i,{error:n,causesRestart:o})=>{this._fire("itemError",{itemId:e.id,error:n}),o&&this._actionQueues.enqueue(e.id,(()=>new Promise((i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=Ip(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e,(()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))))}destroy(){return this._actionQueues.enqueue(Sp,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Sp,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((e=>{console.error("An error happened during destroying the context or items.",e)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((e=>(this._context=e,this._contextProps=Cp(this._context),Promise.all(Array.from(this._watchdogs.values()).map((e=>(e._setExcludedProperties(this._contextProps),e.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((e=>e.destroy()))).then((()=>this._destructor(e)))}))}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return xp(this._context,e.context)}};const Rp=Vp;function Op(e){return kn(e)}const Bp=["left","right","center","justify"];function Mp(e){return Bp.includes(e)}function Fp(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function Np(e){const t=e.map((e=>{let t;return t="string"==typeof e?{name:e}:e,t})).filter((e=>{const t=Bp.includes(e.name);return t||v("alignment-config-name-not-recognized",{option:e}),t})),i=t.filter((e=>Boolean(e.className))).length;if(i&&i{const o=n.slice(i+1);if(o.some((e=>e.name==t.name)))throw new _("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className){if(o.some((e=>e.className==t.className)))throw new _("alignment-config-classname-already-defined",{option:t,configuredOptions:e})}})),t}const Dp="alignment";class Lp extends Is{refresh(){const e=this.editor.locale,t=qo(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(t)&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,o=n.document,s=e.value;n.change((e=>{const t=Array.from(o.selection.getSelectedBlocks()).filter((e=>this._canBeAligned(e))),n=t[0].getAttribute("alignment");Fp(s,i)||n===s||!s?function(e,t){for(const i of e)t.removeAttribute(Dp,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(Dp,i,n)}(t,e,s)}))}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,Dp)}}class zp extends Ss{static get pluginName(){return"AlignmentEditing"}constructor(e){super(e),e.config.define("alignment",{options:Bp.map((e=>({name:e})))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=Np(e.config.get("alignment.options")).filter((e=>Mp(e.name)&&!Fp(e.name,t))),o=n.some((e=>!!e.className));i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?e.conversion.attributeToAttribute(function(e){const t={};for(const i of e)t[i.name]={key:"class",value:i.className};const i={model:{key:"alignment",values:e.map((e=>e.name))},view:t};return i}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:i}of e)t[i]={key:"style",value:{"text-align":i}};const i={model:{key:"alignment",values:e.map((e=>e.name))},view:t};return i}(n));const s=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of s)e.conversion.for("upcast").attributeToAttribute(t);const r=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of r)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new Lp(e))}}const Hp=new Map([["left",Hu.alignLeft],["right",Hu.alignRight],["center",Hu.alignCenter],["justify",Hu.alignJustify]]);class $p extends Ss{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const e=Np(this.editor.config.get("alignment.options"));e.map((e=>e.name)).filter(Mp).forEach((e=>this._addButton(e))),this._addToolbarDropdown(e),this._addMenuBarMenu(e)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,(t=>this._createButton(t,e)))}_createButton(e,t,i={}){const n=this.editor,o=n.commands.get("alignment"),s=new Yu(e);return s.set({label:this.localizedOptionTitles[t],icon:Hp.get(t),tooltip:!0,isToggleable:!0,...i}),s.bind("isEnabled").to(o),s.bind("isOn").to(o,"value",(e=>e===t)),this.listenTo(s,"execute",(()=>{n.execute("alignment",{value:t}),n.editing.view.focus()})),s}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",(i=>{const n=zm(i),o="rtl"===i.uiLanguageDirection?"w":"e",s=i.t;Hm(n,(()=>e.map((e=>this._createButton(i,e.name,{tooltipPosition:o})))),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:s("Text alignment toolbar")}),n.buttonView.set({label:s("Text alignment"),tooltip:!0}),n.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===i.contentLanguageDirection?Hp.get("right"):Hp.get("left"),a=t.commands.get("alignment");return n.buttonView.bind("icon").to(a,"value",(e=>Hp.get(e)||r)),n.bind("isEnabled").to(a,"isEnabled"),this.listenTo(n,"execute",(()=>{t.editing.view.focus()})),n}))}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",(i=>{const n=t.commands.get("alignment"),o=i.t,s=new gp(i),r=new fp(i);s.bind("isEnabled").to(n),r.set({ariaLabel:o("Text alignment"),role:"menu"}),s.buttonView.set({label:o("Text alignment")});for(const o of e){const e=new Zf(i,s),a=new pp(i);a.extendTemplate({attributes:{"aria-checked":a.bindTemplate.to("isOn")}}),a.delegate("execute").to(s),a.set({label:this.localizedOptionTitles[o.name],icon:Hp.get(o.name)}),a.on("execute",(()=>{t.execute("alignment",{value:o.name}),t.editing.view.focus()})),a.bind("isOn").to(n,"value",(e=>e===o.name)),a.bind("isEnabled").to(n,"isEnabled"),e.children.add(a),r.items.add(e)}return s.panelView.children.add(r),s}))}}class Wp extends Is{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const jp="bold";class Up extends Ss{static get pluginName(){return"BoldEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:jp}),e.model.schema.setAttributeProperties(jp,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:jp,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(jp,new Wp(e,jp)),e.keystrokes.set("CTRL+B",jp),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function qp({editor:e,commandName:t,plugin:i,icon:n,label:o,keystroke:s}){return r=>{const a=e.commands.get(t),l=new r(e.locale);return l.set({label:o,icon:n,keystroke:s,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),i.listenTo(l,"execute",(()=>{e.execute(t),e.editing.view.focus()})),l}}const Gp="bold";class Kp extends Ss{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.locale.t,i=e.commands.get(Gp),n=qp({editor:e,commandName:Gp,plugin:this,icon:Hu.bold,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(Gp,(()=>{const e=n(Yu);return e.set({tooltip:!0}),e.bind("isOn").to(i,"value"),e})),e.ui.componentFactory.add("menuBar:"+Gp,(()=>n(pp)))}}class Zp{constructor(e,t=20){this._batch=null,this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e=!1){this.isLocked&&!e||(this._batch=null,this._size=0)}}class Jp extends Is{constructor(e,t){super(e),this._buffer=new Zp(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,n=e.text||"",o=n.length;let s=i.selection;if(e.selection?s=e.selection:e.range&&(s=t.createSelection(e.range)),!t.canEditAt(s))return;const r=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock();const a=Array.from(i.selection.getAttributes());t.deleteContent(s),n&&t.insertContent(e.createText(n,a),s),r?e.setSelection(r):s.is("documentSelection")||e.setSelection(s),this._buffer.unlock(),this._buffer.input(o)}))}}const Yp=["insertText","insertReplacementText"];class Qp extends Ua{constructor(e){super(e),this.focusObserver=e.getObserver(Ol),r.isAndroid&&Yp.push("insertCompositionText");const t=e.document;t.on("beforeinput",((i,n)=>{if(!this.isEnabled)return;const{data:o,targetRanges:s,inputType:r,domEvent:a}=n;if(!Yp.includes(r))return;this.focusObserver.flush();const l=new m(t,"insertText");t.fire(l,new Ga(e,a,{text:o,selection:e.createSelection(s)})),l.stop.called&&i.stop()})),t.on("compositionend",((i,{data:n,domEvent:o})=>{this.isEnabled&&!r.isAndroid&&n&&t.fire("insertText",new Ga(e,o,{text:n,selection:t.selection}))}),{priority:"lowest"})}observe(){}stopObserving(){}}class Xp extends Ss{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,i=e.editing.view,n=t.document.selection;i.addObserver(Qp);const o=new Jp(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(i.document,"insertText",((n,o)=>{i.document.isComposing||o.preventDefault();const{text:s,selection:a,resultRange:l}=o,c=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));let d=s;if(r.isAndroid){const e=Array.from(c[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),c[0].start=c[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(c[0].start=c[0].start.getShiftedBy(d.length),d=""))}const h={text:d,selection:t.createSelection(c)};l&&(h.resultRange=e.editing.mapper.toModelRange(l)),e.execute("insertText",h),i.scrollToTheSelection()})),r.isAndroid?this.listenTo(i.document,"keydown",((e,s)=>{!n.isCollapsed&&229==s.keyCode&&i.document.isComposing&&eb(t,o)})):this.listenTo(i.document,"compositionstart",(()=>{n.isCollapsed||eb(t,o)}))}}function eb(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,(()=>{e.deleteContent(e.document.selection)})),i.unlock()}class tb extends Is{constructor(e,t){super(e),this.direction=t,this._buffer=new Zp(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,(n=>{this._buffer.lock();const o=n.createSelection(e.selection||i.selection);if(!t.canEditAt(o))return;const s=e.sequence||1,r=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(s))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(o,s))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=Q(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(a),n.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(n)))return!1;if(!t.schema.checkChild(n,"paragraph"))return!1;const o=n.getChild(0);return!o||!o.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),o=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(o,n),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const n=e.getFirstPosition(),o=i.schema.getLimitElement(n),s=o.getChild(0);return n.parent==s&&(!!e.containsEntireContent(s)&&(!!i.schema.checkChild(o,"paragraph")&&"paragraph"!=s.name))}}const ib="word",nb="selection",ob="backward",sb="forward",rb={deleteContent:{unit:nb,direction:ob},deleteContentBackward:{unit:"codePoint",direction:ob},deleteWordBackward:{unit:ib,direction:ob},deleteHardLineBackward:{unit:nb,direction:ob},deleteSoftLineBackward:{unit:nb,direction:ob},deleteContentForward:{unit:"character",direction:sb},deleteWordForward:{unit:ib,direction:sb},deleteHardLineForward:{unit:nb,direction:sb},deleteSoftLineForward:{unit:nb,direction:sb}};class ab extends Ua{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",(()=>{i++})),t.on("keyup",(()=>{i=0})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;const{targetRanges:s,domEvent:a,inputType:l}=o,c=rb[l];if(!c)return;const d={direction:c.direction,unit:c.unit,sequence:i};d.unit==nb&&(d.selectionToRemove=e.createSelection(s[0])),"deleteContentBackward"===l&&(r.isAndroid&&(d.sequence=1),function(e){if(1!=e.length||e[0].isCollapsed)return!1;const t=e[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let i=0;for(const{nextPosition:e,item:n}of t){if(e.parent.is("$text")){const t=e.parent.data,n=e.offset;if(Yo(t,n)||Qo(t,n)||es(t,n))continue;i++}else(n.is("containerElement")||n.is("emptyElement"))&&i++;if(i>1)return!0}return!1}(s)&&(d.unit=nb,d.selectionToRemove=e.createSelection(s)));const h=new Wr(t,"delete",s[0]);t.fire(h,new Ga(e,a,d)),h.stop.called&&n.stop()})),r.isBlink&&function(e){const t=e.view,i=t.document;let n=null,o=!1;function s(e){return e==go.backspace||e==go.delete}function r(e){return e==go.backspace?ob:sb}i.on("keydown",((e,{keyCode:t})=>{n=t,o=!1})),i.on("keyup",((a,{keyCode:l,domEvent:c})=>{const d=i.selection,h=e.isEnabled&&l==n&&s(l)&&!d.isCollapsed&&!o;if(n=null,h){const e=d.getFirstRange(),n=new Wr(i,"delete",e),o={unit:nb,direction:r(l),selectionToRemove:d};i.fire(n,new Ga(t,c,o))}})),i.on("beforeinput",((e,{inputType:t})=>{const i=rb[t];s(n)&&i&&i.direction==r(n)&&(o=!0)}),{priority:"high"}),i.on("beforeinput",((e,{inputType:t,data:i})=>{n==go.delete&&"insertText"==t&&""==i&&e.stop()}),{priority:"high"})}(this)}observe(){}stopObserving(){}}class lb extends Ss{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(ab),this._undoOnBackspace=!1;const o=new tb(e,"forward");e.commands.add("deleteForward",o),e.commands.add("forwardDelete",o),e.commands.add("delete",new tb(e,"backward")),this.listenTo(i,"delete",((n,o)=>{i.isComposing||o.preventDefault();const{direction:s,sequence:r,selectionToRemove:a,unit:l}=o,c="forward"===s?"deleteForward":"delete",d={sequence:r};if("selection"==l){const t=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));d.selection=e.model.createSelection(t)}else d.unit=l;e.execute(c,d),t.scrollToTheSelection()}),{priority:"low"}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",((t,i)=>{this._undoOnBackspace&&"backward"==i.direction&&1==i.sequence&&"codePoint"==i.unit&&(this._undoOnBackspace=!1,e.execute("undo"),i.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(n,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class cb extends Ss{static get requires(){return[Xp,lb]}static get pluginName(){return"Typing"}}function db(e,t){let i=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce(((e,{item:n})=>n.is("$text")||n.is("$textProxy")?e+n.data:(i=t.createPositionAfter(n),"")),""),range:t.createRange(i,e.end)}}class hb extends(U()){constructor(e,t){super(),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:i})=>{i&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const i=this.model,n=i.document.selection,o=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:s,range:r}=db(o,i),a=this.testCallback(s);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const i=Object.assign(t,{text:s,range:r});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}}class ub extends Ss{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this._isNextGravityRestorationSkipped=!1,this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,o=t.document.selection;this.listenTo(i.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==go.arrowright,s=t.keyCode==go.arrowleft;if(!i&&!s)return;const r=n.contentLanguageDirection;let a=!1;a="ltr"===r&&i||"rtl"===r&&s?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&wb(o.getFirstPosition(),this.attributes)||this._restoreGravity())})),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,o=n.getFirstPosition();return!this._isGravityOverridden&&((!o.isAtStart||!mb(n,t))&&(!!wb(o,t)&&(pb(e),mb(n,t)&&wb(o,t,!0)?fb(i,t):this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,o=n.getFirstPosition();return this._isGravityOverridden?(pb(e),this._restoreGravity(),wb(o,t,!0)?fb(i,t):gb(i,t,o),!0):o.isAtStart?!!mb(n,t)&&(pb(e),gb(i,t,o),!0):!mb(n,t)&&wb(o,t,!0)?(pb(e),gb(i,t,o),!0):!!bb(o,t)&&(o.isAtEnd&&!mb(n,t)&&wb(o,t)?(pb(e),gb(i,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view.document;e.editing.view.addObserver(Uh);let o=!1;this.listenTo(n,"mousedown",(()=>{o=!0})),this.listenTo(n,"selectionChange",(()=>{const e=this.attributes;if(!o)return;if(o=!1,!i.isCollapsed)return;if(!mb(i,e))return;const n=i.getFirstPosition();wb(n,e)&&(n.isAtStart||wb(n,e,!0)?fb(t,e):this._isGravityOverridden||this._overrideGravity())}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",(()=>{const n=t.getFirstPosition();mb(t,i)&&wb(n,i)&&fb(e,i)}),{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let o=!1,s=!1;this.listenTo(n.document,"delete",((e,t)=>{o="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{if(!o)return;const e=i.getFirstPosition();s=mb(i,this.attributes)&&!bb(e,this.attributes)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{o&&(o=!1,s||e.model.enqueueChange((()=>{const e=i.getFirstPosition();mb(i,this.attributes)&&wb(e,this.attributes)&&(e.isAtStart||wb(e,this.attributes,!0)?fb(t,this.attributes):this._isGravityOverridden||this._overrideGravity())})))}),{priority:"low"})}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function mb(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function gb(e,t,i){const n=i.nodeBefore;e.change((i=>{if(n){const t=[],o=e.schema.isObject(n)&&e.schema.isInline(n);for(const[i,s]of n.getAttributes())!e.schema.checkAttribute("$text",i)||o&&!1===e.schema.getAttributeProperties(i).copyFromObject||t.push([i,s]);i.setSelectionAttribute(t)}else i.removeSelectionAttribute(t)}))}function fb(e,t){e.change((e=>{e.removeSelectionAttribute(t)}))}function pb(e){e.preventDefault()}function bb(e,t){return wb(e.getShiftedBy(-1),t)}function wb(e,t,i=!1){const{nodeBefore:n,nodeAfter:o}=e;for(const e of t){const t=n?n.getAttribute(e):void 0,s=o?o.getAttribute(e):void 0;if((!i||void 0!==t&&void 0!==s)&&s!==t)return!0}return!1}_b('"'),_b("'"),_b("'"),_b('"'),_b('"'),_b("'");function _b(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function vb(e,t,i,n){return n.createRange(yb(e,t,i,!0,n),yb(e,t,i,!1,n))}function yb(e,t,i,n,o){let s=e.textNode||(n?e.nodeBefore:e.nodeAfter),r=null;for(;s&&s.getAttribute(t)==i;)r=s,s=n?s.previousSibling:s.nextSibling;return r?o.createPositionAt(r,n?"before":"after"):e}const kb="italic";class Cb extends Ss{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:kb}),e.model.schema.setAttributeProperties(kb,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:kb,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(kb,new Wp(e,kb)),e.keystrokes.set("CTRL+I",kb),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const Ab="italic";class xb extends Ss{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.commands.get(Ab),i=e.locale.t,n=qp({editor:e,commandName:Ab,plugin:this,icon:'',keystroke:"CTRL+I",label:i("Italic")});e.ui.componentFactory.add(Ab,(()=>{const e=n(Yu);return e.set({tooltip:!0}),e.bind("isOn").to(t,"value"),e})),e.ui.componentFactory.add("menuBar:"+Ab,(()=>n(pp)))}}const Eb="strikethrough";class Tb extends Ss{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Eb}),e.model.schema.setAttributeProperties(Eb,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Eb,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Eb,new Wp(e,Eb)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const Sb="strikethrough";class Pb extends Ss{static get pluginName(){return"StrikethroughUI"}init(){const e=this.editor,t=e.locale.t,i=qp({editor:e,commandName:Sb,plugin:this,icon:'',keystroke:"CTRL+SHIFT+X",label:t("Strikethrough")});e.ui.componentFactory.add(Sb,(()=>{const t=i(Yu),n=e.commands.get(Sb);return t.set({tooltip:!0}),t.bind("isOn").to(n,"value"),t})),e.ui.componentFactory.add("menuBar:"+Sb,(()=>i(pp)))}}const Ib="underline";class Vb extends Ss{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Ib}),e.model.schema.setAttributeProperties(Ib,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Ib,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(Ib,new Wp(e,Ib)),e.keystrokes.set("CTRL+U","underline"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Underline text"),keystroke:"CTRL+U"}]})}}const Rb="underline";class Ob extends Ss{static get pluginName(){return"UnderlineUI"}init(){const e=this.editor,t=e.commands.get(Rb),i=e.locale.t,n=qp({editor:e,commandName:Rb,plugin:this,icon:'',label:i("Underline"),keystroke:"CTRL+U"});e.ui.componentFactory.add(Rb,(()=>{const e=n(Yu);return e.set({tooltip:!0}),e.bind("isOn").to(t,"value"),e})),e.ui.componentFactory.add("menuBar:"+Rb,(()=>n(pp)))}}function*Bb(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class Mb extends Is{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,i=t.document.selection,n=t.schema,o=i.isCollapsed,s=i.getFirstRange(),r=s.start.parent,a=s.end.parent;if(n.isLimit(r)||n.isLimit(a))return o||r!=a||t.deleteContent(i),!1;if(o){const t=Bb(e.model.schema,i.getAttributes());return Fb(e,s.start),e.setSelectionAttribute(t),!0}{const n=!(s.start.isAtStart&&s.end.isAtEnd),o=r==a;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(o)return Fb(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function Fb(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const Nb={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class Db extends Ua{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",((e,t)=>{i=t.shiftKey})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;let s=o.inputType;r.isSafari&&i&&"insertParagraph"==s&&(s="insertLineBreak");const a=o.domEvent,l=Nb[s];if(!l)return;const c=new Wr(t,"enter",o.targetRanges[0]);t.fire(c,new Ga(e,a,{isSoft:l.isSoft})),c.stop.called&&n.stop()}))}observe(){}stopObserving(){}}class Lb extends Ss{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document,n=this.editor.t;t.addObserver(Db),e.commands.add("enter",new Mb(e)),this.listenTo(i,"enter",((n,o)=>{i.isComposing||o.preventDefault(),o.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class zb extends Is{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,o=i.getFirstRange(),s=o.start.parent,r=o.end.parent,a=s==r;if(n){const n=Bb(e.schema,i.getAttributes());Hb(e,t,o.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?Hb(e,t,i.focus):n&&t.setSelection(r,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),o=n.start.parent,s=n.end.parent;if(($b(o,e)||$b(s,e))&&o!==s)return!1;return!0}(e.schema,t.selection)}}function Hb(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function $b(e,t){return!e.is("rootElement")&&(t.isLimit(e)||$b(e.parent,t))}class Wb extends Ss{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,o=n.document,s=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(Db),e.commands.add("shiftEnter",new zb(e)),this.listenTo(o,"enter",((t,i)=>{o.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:s("Insert a soft break (a <br> element)"),keystroke:"Shift+Enter"}]})}}class jb extends Is{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,o=Array.from(n.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(s){const t=o.filter((e=>Ub(e)||Gb(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(Ub))}))}_getValue(){const e=qo(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Ub(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=qo(e.getSelectedBlocks());return!!i&&Gb(t,i)}_removeQuote(e,t){qb(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)}))}_applyQuote(e,t){const i=[];qb(e,t).reverse().forEach((t=>{let n=Ub(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function Ub(e){return"blockQuote"==e.parent.name?e.parent:null}function qb(e,t){let i,n=0;const o=[];for(;n{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1}));const i=this.editor.editing.view.document,n=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!n.isCollapsed||!o.value)return;n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(i,"delete",((t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!o.value)return;const s=n.getLastPosition().parent;s.isEmpty&&!s.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}class Zb extends Ss{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.commands.get("blockQuote");e.ui.componentFactory.add("blockQuote",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0}),e.bind("isOn").to(t,"value"),e})),e.ui.componentFactory.add("menuBar:blockQuote",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("blockQuote"),o=new e(t.locale),s=i.t;return o.set({label:s("Block quote"),icon:Hu.quote,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),o}}function Jb(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function Yb(e,t,i){const n={};for(const o of e)if("class"===t){n[o[t].split(" ").shift()]=o[i]}else n[o[t]]=o[i];return n}function Qb(e){return e.data.match(/^(\s*)/)[0]}function Xb(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const n=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of n){if(!t.is("$textProxy"))continue;const{parent:n,startOffset:o}=t.textNode;if(!n.is("element","codeBlock"))continue;const s=Qb(t.textNode),r=e.createPositionAt(n,o+s.length);i.push(r)}return i}function ew(e){const t=qo(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function tw(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}function iw(e,t,i,n){const o=Yb(t,"language","label"),s=i.getAttribute("language");if(s in o){const t=o[s];return e("enter"===n?"Entering %0 code snippet":"Leaving %0 code snippet",t)}return e("enter"===n?"Entering code snippet":"Leaving code snippet")}class nw extends Is{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,o=Jb(t)[0],s=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,o.language);i.change((e=>{r?this._applyCodeBlock(e,s,a):this._removeCodeBlock(e,s)}))}_getValue(){const e=qo(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!e.is("element","codeBlock"))&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=qo(e.getSelectedBlocks());return!!i&&tw(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,o=t.filter((e=>tw(n,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!n.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,i)=>{const n=o[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const i=t.filter((e=>e.is("element","codeBlock")));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class ow extends Is{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=Xb(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&ew(this.editor.model.document.selection)}}class sw extends Is{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((()=>{const t=Xb(e);for(const i of t){const t=rw(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!ew(e.document.selection)&&Xb(e).some((t=>rw(e,t,this._indentSequence)))}}function rw(e,t,i){const n=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}(t);if(!n)return null;const o=Qb(n),s=o.lastIndexOf(i);if(s+i.length!==o.length)return null;if(-1===s)return null;const{parent:r,startOffset:a}=n;return e.createRange(e.createPositionAt(r,a+s),e.createPositionAt(r,a+s+i.length))}function aw(e,t,i=!1){const n=Yb(t,"language","class"),o=Yb(t,"language","label");return(t,s,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(s.item,"insert"))return;const d=s.item.getAttribute("language"),h=l.toViewPosition(e.createPositionBefore(s.item)),u={};i&&(u["data-language"]=o[d],u.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",u,g);a.insert(h,f),l.bindElements(s.item,g)}}const lw="paragraph";class cw extends Ss{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Wb]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,o=e.plugins.has("ListEditing")?e.plugins.get("ListEditing"):null,s=Jb(e);e.commands.add("codeBlock",new nw(e)),e.commands.add("indentCodeBlock",new ow(e)),e.commands.add("outdentCodeBlock",new sw(e)),this.listenTo(n.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>!!(e.endsWith("codeBlock")&&o&&o.getListAttributeNames().includes(t))||!e.endsWith("codeBlock $text")&&void 0)),e.model.schema.addChildCheck(((e,t)=>{if(e.endsWith("codeBlock")&&t.isObject)return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",aw(i,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",aw(i,s)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:o,mapper:s,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=s.toViewPosition(e.createPositionBefore(i.item));o.insert(a,o.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=Yb(t,"class","language"),n=t[0].language;return(e,t,o)=>{const s=t.viewItem,r=s.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=o;if(!a.test(s,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...s.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),o.convertChildren(s,c),o.safeInsert(c,t.modelCursor)&&(a.consume(s,{name:!0}),o.updateConversionResult(c,t))}}(0,s)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let o=t.modelCursor;if(!i.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;i.consume(t.viewItem);const s=t.viewItem.data.split("\n").map((e=>n.createText(e))),r=s[s.length-1];for(const e of s)if(n.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,o),o=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const o=Array.from(n.getChildren()),s=o.find((e=>e.is("element","code")));if(s)for(const e of o)e!==s&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let o=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(o=e.editing.mapper.toModelRange(n.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const s=n.dataTransfer.getData("text/plain"),r=new qh(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),o=n.reduce(((t,i,o)=>(t.push(i),o{const o=n.anchor;!n.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(n.focus)&&i.change((i=>{const s=e.return;if(o.parent.is("element")&&(s.childCount>1||n.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(s,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=s.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model,n=i.document,o=e.editing.view,s=n.selection.getLastPosition(),r=s.nodeAfter;if(t||!n.selection.isCollapsed||!s.isAtStart)return!1;if(!hw(r))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,lw),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,o=e.editing.view,s=n.selection.getLastPosition(),r=s.nodeBefore;let a;if(t||!n.selection.isCollapsed||!s.isAtEnd||!r||!r.previousSibling)return!1;if(hw(r)&&hw(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(dw(r)&&hw(r.previousSibling)&&hw(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(dw(r)&&hw(r.previousSibling)&&dw(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&hw(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,lw),e.model.schema.removeDisallowedAttributes([i],t)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document,n=i.selection.getLastPosition(),o=n.nodeBefore||n.textNode;let s;o&&o.is("$text")&&(s=Qb(o));e.model.change((t=>{e.execute("shiftEnter"),s&&t.insertText(s,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,n=Jb(this.editor);let o=null;e.document.selection.on("change:range",(()=>{const s=e.document.selection.focus.parent;t&&o!==s&&s.is("element")&&(o&&o.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(iw(i,n,o,"leave")),s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(iw(i,n,s,"enter")),o=s)}))}}function dw(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function hw(e){return e&&e.is("element","softBreak")}class uw extends Ss{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=Jb(e),o=this._getLanguageListItemDefinitions(n),s=e.commands.get("codeBlock");i.add("codeBlock",(i=>{const n=zm(i,Lm),r=n.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:Hu.codeBlock,isToggleable:!0}),r.bind("isOn").to(s,"value",(e=>!!e)),r.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),n.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),n.class="ck-code-block-dropdown",n.bind("isEnabled").to(s),Wm(n,o,{role:"menu",ariaLabel:a}),n})),i.add("menuBar:codeBlock",(i=>{const n=new gp(i);n.buttonView.set({label:t("Code block"),icon:Hu.codeBlock}),n.bind("isEnabled").to(s);const r=new fp(i);r.set({ariaLabel:t("Insert code block")});for(const t of o){const o=new Zf(i,n),a=new pp(i);a.bind(...Object.keys(t.model)).to(t.model),a.bind("ariaChecked").to(a,"isOn"),a.delegate("execute").to(n),a.on("execute",(()=>{e.execute("codeBlock",{language:t.model._codeBlockLanguage,forceValue:s.value!=t.model._codeBlockLanguage}),e.editing.view.focus()})),o.children.add(a),r.items.add(o)}return n.panelView.children.add(r),n}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new Uo;for(const n of e){const e={type:"button",model:new Vf({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class mw extends Ka{constructor(e){super(e),this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];const t=this.document;function i(e){return(i,n)=>{n.preventDefault();const o=n.dropRange?[n.dropRange]:null,s=new m(t,e);t.fire(s,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:o,target:n.target,domEvent:n.domEvent}),s.stop.called&&n.stopPropagation()}}this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"})}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,i="drop"==e.type||"paste"==e.type,n={dataTransfer:new Fl(t,{cacheFiles:i})};"drop"!=e.type&&"dragover"!=e.type||(n.dropRange=function(e,t){const i=t.target.ownerDocument,n=t.clientX,o=t.clientY;let s;i.caretRangeFromPoint&&i.caretRangeFromPoint(n,o)?s=i.caretRangeFromPoint(n,o):t.rangeParent&&(s=i.createRange(),s.setStart(t.rangeParent,t.rangeOffset),s.collapse(!0));if(s)return e.domConverter.domRangeToView(s);return null}(this.view,e)),this.fire(e.type,e,n)}}const gw=["figcaption","li"],fw=["ol","ul"];function pw(e){if(e.is("$text")||e.is("$textProxy"))return e.data;if(e.is("element","img")&&e.hasAttribute("alt"))return e.getAttribute("alt");if(e.is("element","br"))return"\n";let t="",i=null;for(const n of e.getChildren())t+=bw(n,i)+pw(n),i=n;return t}function bw(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||fw.includes(e.name)&&fw.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?gw.includes(e.name)||gw.includes(t.name)?"\n":"\n\n":"":""}const ww=function(e,t){return e&&ko(e,t,ai)};const _w=function(e,t,i,n){var o=i.length,s=o,r=!n;if(null==e)return!s;for(e=Object(e);o--;){var a=i[o];if(r&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++oe.model.getSelectedContent(e.model.document.selection))){return this.editor.model.change((n=>{const o=n.model.document.selection;n.setSelection(t);const s=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),r=i(n),a=this._removeFakeMarkersInsideElement(n,r);for(const[e,t]of Object.entries(s)){a[e]||(a[e]=n.createRangeIn(r));for(const e of t)n.remove(e)}r.markers.clear();for(const[e,t]of Object.entries(a))r.markers.set(e,t);return n.setSelection(o),r}))}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change((e=>{const n=this._insertFakeMarkersElements(e,i),o=t(e),s=this._removeFakeMarkersInsideElement(e,o);for(const t of Object.values(n).flat())e.remove(t);for(const[t,i]of Object.entries(s))e.model.markers.has(t)||e.addMarker(t,{usingOperation:!0,affectsData:!0,range:i});return o}))}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,i={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const n=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:n}=i;return"all"===n||n.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const n=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,i){const n=Array.from(t.getRanges()),o=new Set(n.flatMap((t=>Array.from(e.model.markers.getMarkersIntersectingRange(t)))));return Array.from(o).filter((e=>{if(!this._isMarkerCopyable(e.name,i))return!1;const{copyPartiallySelected:t}=this._getMarkerClipboardConfig(e.name);if(!t){const t=e.getRange();return n.some((e=>e.containsRange(t,!0)))}return!0})).map((e=>({name:"dragstart"===i?this._getUniqueMarkerName(e.name):e.name,range:e.getRange()})))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap((([e,n])=>{if(!this._hasMarkerConfiguration(e))return[{name:e,range:n}];if(this._isMarkerCopyable(e,t)){const t=this._getMarkerClipboardConfig(e),o=i.markers.has(e)&&"$graveyard"===i.markers.get(e).getRange().root.rootName;return(t.duplicateOnPaste||o)&&(e=this._getUniqueMarkerName(e)),[{name:e,range:n}]}return[]}))}_insertFakeMarkersElements(e,t){const i={},n=t.flatMap((e=>{const{start:t,end:i}=e.range;return[{position:t,marker:e,type:"start"},{position:i,marker:e,type:"end"}]})).sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:t,marker:o,type:s}of n){const n=e.createElement("$marker",{"data-name":o.name,"data-type":s});i[o.name]||(i[o.name]=[]),i[o.name].push(n),e.insert(n,t)}return i}_removeFakeMarkersInsideElement(e,t){const i=this._getAllFakeMarkersFromElement(e,t).reduce(((t,i)=>{const n=i.markerElement&&e.createPositionBefore(i.markerElement);let o=t[i.name],s=!1;if(o&&o.start&&o.end){this._getMarkerClipboardConfig(i.name).duplicateOnPaste?t[this._getUniqueMarkerName(i.name)]=t[i.name]:s=!0,o=null}return s||(t[i.name]={...o,[i.type]:n}),i.markerElement&&e.remove(i.markerElement),t}),{});return Rw(i,(i=>new nc(i.start||e.createPositionFromPath(t,[0]),i.end||e.createPositionAt(t,"end"))))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap((({item:e})=>{if(!e.is("element","$marker"))return[];const t=e.getAttribute("data-name"),i=e.getAttribute("data-type");return[{markerElement:e,name:t,type:i}]})),n=[],o=[];for(const e of i){if("end"===e.type){i.some((t=>t.name===e.name&&"start"===t.type))||n.push({markerElement:null,name:e.name,type:"start"})}if("start"===e.type){i.some((t=>t.name===e.name&&"end"===t.type))||o.unshift({markerElement:null,name:e.name,type:"end"})}}return[...n,...i,...o]}_getUniqueMarkerName(e){const t=e.split(":"),i=f().substring(1,6);return 3===t.length?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}}class Bw extends Ss{static get pluginName(){return"ClipboardPipeline"}static get requires(){return[Ow]}init(){this.editor.editing.view.addObserver(mw),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===i},(()=>{const o=n._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:o,method:i})}))}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",((t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()}),{priority:"highest"}),this.listenTo(n,"clipboardInput",((e,t)=>{const n=t.dataTransfer;let o;if(t.content)o=t.content;else{let e="";n.getData("text/html")?e=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((s=(s=n.getData("text/plain")).replace(/&/g,"&").replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${s}

`),e=s),o=this.editor.data.htmlProcessor.toView(e)}var s;const r=new m(this,"inputTransformation");this.fire(r,{content:o,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),r.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,t)=>{t.resultRange=o._pasteFragmentWithMarkers(t.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((t,n)=>{const o=e.data.toView(n.content);i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:o,method:n.method})}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",pw(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class Mw extends(P()){constructor(){super(...arguments),this._stack=[]}add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const o=i[0];n===o||Fw(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const o=i[0];n===o||Fw(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(Fw(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Nw(t[n],e);)n++;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e));i>-1&&t.splice(i,1)}}function Fw(e,t){return e&&t&&e.priority==t.priority&&Dw(e.classes)==Dw(t.classes)}function Nw(e,t){return e.priority>t.priority||!(e.priorityDw(t.classes)}function Dw(e){return Array.isArray(e)?e.sort().join(","):e}const Lw='',zw="ck-widget",Hw="ck-widget_selected";function $w(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function Ww(e,t,i={}){if(!e.is("containerElement"))throw new _("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass(zw,e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=Zw,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){const i=e.getCustomProperty("widgetLabel");i.push(t)}(e,i.label),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),i=new Zu;return i.set("content",Lw),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),qw(e,t),e}function jw(e,t,i){if(t.classes&&i.addClass(vo(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function Uw(e,t,i){if(t.classes&&i.removeClass(vo(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function qw(e,t,i=jw,n=Uw){const o=new Mw;o.on("change:top",((t,o)=>{o.oldDescriptor&&n(e,o.oldDescriptor,o.writer),o.newDescriptor&&i(e,o.newDescriptor,o.writer)}));t.setCustomProperty("addHighlight",((e,t,i)=>o.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>o.remove(t,i)),e)}function Gw(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),t.setAttribute("tabindex","-1",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,n,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((i,n,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),qw(e,t),e}function Kw(e,t){const i=e.getSelectedElement();if(i){const n=Xw(e);if(n)return t.createRange(t.createPositionAt(i,n))}return t.schema.findOptimalInsertionRange(e)}function Zw(){return null}function Jw(e){const t=e=>{const{width:t,paddingLeft:i,paddingRight:n}=e.ownerDocument.defaultView.getComputedStyle(e);return parseFloat(t)-(parseFloat(i)||0)-(parseFloat(n)||0)},i=e.parentElement;if(!i)return 0;let n=t(i);let o=0,s=i;for(;isNaN(n);){if(s=s.parentElement,++o>5)return 0;n=t(s)}return n}const Yw="widget-type-around";function Qw(e,t,i){return!!e&&$w(e)&&!i.isInline(t)}function Xw(e){return e.getAttribute(Yw)}const e_=["before","after"],t_=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,i_="ck-widget__type-around_disabled";class n_ extends Ss{constructor(){super(...arguments),this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Lb,lb]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,n,o)=>{t.change((e=>{for(const i of t.document.roots)o?e.removeClass(i_,i):e.addClass(i_,i)})),o||e.model.change((e=>{e.removeSelectionAttribute(Yw)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view,o=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:o}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,((...e)=>{this.isEnabled&&i(...e)}),n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Xw(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,o,s)=>{const r=s.mapper.toViewElement(o.item);if(r&&Qw(r,o.item,t)){!function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const i=this.toDomElement(e);return function(e,t){for(const i of e_){const n=new is({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${i}`],title:t[i],"aria-hidden":"true"},children:[e.ownerDocument.importNode(t_,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new is({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(s.writer,n,r);r.getCustomProperty("widgetLabel").push((()=>this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):""))}}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,n=t.schema,o=e.editing.view;function s(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[$w,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(Yw)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();if(t){if(Qw(e.editing.mapper.toViewElement(t),t,n))return}e.model.change((e=>{e.removeSelectionAttribute(Yw)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const o=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(e_.map(s),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!Qw(a,r,n))return;const l=Xw(t.selection);l&&(o.addClass(s(l),a),this._currentFakeCaretModelElement=r)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,n)=>{n||e.model.change((e=>{e.removeSelectionAttribute(Yw)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,o=n.document.selection,s=n.schema,r=i.editing.view,a=function(e,t){const i=_o(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;Qw(l,i.editing.mapper.toModelElement(l),s)?c=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=Xw(t.document.selection);return t.change((t=>{if(!i)return t.setSelectionAttribute(Yw,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(Yw),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,o=t.plugins.get("Widget"),s=o._getObjectElementNextToSelection(e);return!!Qw(t.editing.mapper.toViewElement(s),s,n)&&(i.change((t=>{o._setSelectionOverElement(s),t.setSelectionAttribute(Yw,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,o=t.editing.mapper,s=i.document.selection,r=e?s.getLastPosition().nodeBefore:s.getFirstPosition().nodeAfter;return!!Qw(o.toViewElement(r),r,n)&&(i.change((t=>{t.setSelection(r,"on"),t.setSelectionAttribute(Yw,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,n)=>{const o=n.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const s=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(o,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,s),n.preventDefault(),i.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",((i,n)=>{if("atTarget"!=i.eventPhase)return;const o=t.getSelectedElement(),s=e.editing.mapper.toViewElement(o),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:Qw(s,o,r)&&(this._insertParagraph(o,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())}),{context:$w})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)}),{priority:"high"}),r.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const s=Xw(i.document.selection);if(!s)return;const r=o.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===s===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,s),r);if(t)if(t.isCollapsed){const o=i.createSelection(t.start);if(i.modifySelection(o,{direction:r}),o.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:$w})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[n,o])=>{if(o&&!o.is("documentSelection"))return;const s=Xw(i);return s?(e.stop(),t.change((e=>{const o=i.getSelectedElement(),r=t.createPositionAt(o,s),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,i)=>{const[,n,o={}]=i;if(n&&!n.is("documentSelection"))return;const s=Xw(t);s&&(o.findOptimalPosition=s,i[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[i])=>{if(i&&!i.is("documentSelection"))return;Xw(t)&&e.stop()}),{priority:"high"})}}function o_(e){const t=e.model;return(i,n)=>{const o=n.keyCode==go.arrowup,s=n.keyCode==go.arrowdown,r=n.shiftKey,a=t.document.selection;if(!o&&!s)return;const l=s;if(r&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,l))return;const c=function(e,t,i){const n=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=s_(n,e,"forward");if(!i)return null;const o=n.createRange(e,i),s=r_(n.schema,o,"backward");return s?n.createRange(e,s):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=s_(n,e,"backward");if(!i)return null;const o=n.createRange(i,e),s=r_(n.schema,o,"forward");return s?n.createRange(s,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||function(e,t,i){const n=e.model,o=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const s=e.mapper.toViewRange(t),r=o.viewRangeToDom(s),a=Nn.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change((e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)})),i.stop(),n.preventDefault(),n.stopPropagation())}}}function s_(e,t,i){const n=e.schema,o=e.createRangeIn(t.root),s="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of o.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==s&&n.isBlock(r))return null}return null}function r_(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n;return null}class a_ extends Ss{constructor(){super(...arguments),this._previouslySelected=new Set}static get pluginName(){return"Widget"}static get requires(){return[n_,lb]}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.t;this.editor.editing.downcastDispatcher.on("selection",((t,i,n)=>{const o=n.writer,s=i.selection;if(s.isCollapsed)return;const r=s.getSelectedElement();if(!r)return;const a=e.editing.mapper.toViewElement(r);var l;$w(a)&&(n.consumable.consume(s,"selection")&&o.setSelection(o.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce(((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t),""))}))})),this.editor.editing.downcastDispatcher.on("selection",((e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,o=n.document.selection;let s=null;for(const e of o.getRanges())for(const t of e){const e=t.item;$w(e)&&!l_(e,s)&&(n.addClass(Hw,e),this._previouslySelected.add(e),s=e)}}),{priority:"low"}),t.addObserver(Uh),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[$w,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",o_(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"}),this.listenTo(i,"tab",((e,t)=>{"atTarget"==e.eventPhase&&(t.shiftKey||this._selectFirstNestedEditable()&&(t.preventDefault(),e.stop()))}),{context:$w,priority:"low"}),this.listenTo(i,"tab",((e,t)=>{t.shiftKey&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{priority:"low"}),this.listenTo(i,"keydown",((e,t)=>{t.keystroke==go.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:n("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:n("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:n("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:n("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:n("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,n=i.editing.view,o=n.document;let s=t.target;if(t.domEvent.detail>=3)return void(this._selectBlockContent(s)&&t.preventDefault());if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if($w(t))return!1;t=t.parent}return!1}(s))return;if(!$w(s)&&(s=s.findAncestor($w),!s))return;r.isAndroid&&t.preventDefault(),o.isFocused||n.focus();const a=i.editing.mapper.toModelElement(s);this._setSelectionOverElement(a)}_selectBlockContent(e){const t=this.editor,i=t.model,n=t.editing.mapper,o=i.schema,s=n.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),r=function(e,t){for(const i of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(i,"$text"))return i;if(t.isLimit(i)&&!t.isObject(i))break}return null}(n.toModelElement(s),i.schema);return!!r&&(i.change((e=>{const t=o.isLimit(r)?null:function(e,t){const i=new Zl({startPosition:e});for(const{item:e}of i){if(t.isLimit(e)||!e.is("element"))return null;if(t.checkChild(e,"$text"))return e}return null}(e.createPositionAfter(r),o),i=e.createPositionAt(r,0),n=t?e.createPositionAt(t,0):e.createPositionAt(r,"end");e.setSelection(e.createRange(i,n))})),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,o=n.schema,s=n.document.selection,r=s.getSelectedElement(),a=_o(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(r&&o.isObject(r)){const i=l?s.getLastPosition():s.getFirstPosition(),r=o.getNearestSelectionRange(i,l?"forward":"backward");return void(r&&(n.change((e=>{e.setSelection(r)})),t.preventDefault(),e.stop()))}if(!s.isCollapsed&&!t.shiftKey){const i=s.getFirstPosition(),r=s.getLastPosition(),a=i.nodeAfter,c=r.nodeBefore;return void((a&&o.isObject(a)||c&&o.isObject(c))&&(n.change((e=>{e.setSelection(l?r:i)})),t.preventDefault(),e.stop()))}if(!s.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&o.isObject(d)){if(o.isInline(d)&&c)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,o=i.document.selection.getSelectedElement();o&&n.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change((e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,o=t.createSelection(n);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(n))return null;const s=e?o.focus.nodeBefore:o.focus.nodeAfter;return s&&i.isObject(s)?s:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Hw,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,t=this.editor.editing.view.document;for(const i of t.selection.getFirstRange().getItems())if(i.is("editableElement")){const t=e.editing.mapper.toModelElement(i);if(!t)continue;const n=e.model.createPositionAt(t,0),o=e.model.schema.getNearestSelectionRange(n,"forward");return e.model.change((e=>{e.setSelection(o)})),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,n=(i.is("$text")?i.parent:i).findAncestor($w);if(!n)return!1;const o=t.toModelElement(n);return!!o&&(e.model.change((e=>{e.setSelection(o,"on")})),!0)}}function l_(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class c_ extends Ss{constructor(){super(...arguments),this._toolbarDefinitions=new Map}static get requires(){return[Of]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!$w(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:n,balloonClassName:o="ck-toolbar-container"}){if(!i.length)return void v("widget-toolbar-no-items",{toolbarId:e});const s=this.editor,r=s.t,a=new Vm(s.locale);if(a.ariaLabel=t||r("Widget toolbar"),this._toolbarDefinitions.has(e))throw new _("widget-toolbar-duplicated",this,{toolbarId:e});const l={view:a,getRelatedElement:n,balloonClassName:o,itemsConfig:i,initialized:!1};s.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=n(s.editing.view.document.selection);e&&this._showToolbar(l,e)},afterBlur:()=>{this._hideToolbar(l)}}),this._toolbarDefinitions.set(e,l)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const o=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const s=o.getAncestors().length;s>e&&(e=s,t=o,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?d_(this.editor,t):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:h_(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);d_(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function d_(e,t){const i=e.plugins.get("ContextualBalloon"),n=h_(e,t);i.updatePosition(n)}function h_(e,t){const i=e.editing.view,n=of.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class u_ extends(U()){constructor(e){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,i){const n=new Nn(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(m_(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new Nn(e),n=t.split("-"),o={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return o.x+=e.ownerDocument.defaultView.scrollX,o.y+=e.ownerDocument.defaultView.scrollY,o}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}(this.activeHandlePosition)),this._originalWidth=n.width,this._originalHeight=n.height,this._aspectRatio=n.width/n.height;const o=i.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(o):this._originalWidthPercents=function(e,t=new Nn(e)){const i=Jw(e);return i?t.width/i*100:0}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function m_(e){return`ck-widget__resizer__handle-${e}`}class g_ extends Cs{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("_isVisible","none",(e=>!e))}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,i,n)=>"px"===e.unit?`${t}×${i}`:`${n}%`)),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",((e,t,i)=>t<50||i<50?"above-center":e))}_dismiss(){this.unbind(),this._isVisible=!1}}class f_ extends(U()){constructor(e){super(),this._viewResizerWrapper=null,this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",((e,t)=>e&&t)),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change((e=>{e.removeClass("ck-hidden",this._viewResizerWrapper)}))}hide(){this._options.editor.editing.view.change((e=>{e.addClass("ck-hidden",this._viewResizerWrapper)}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((i=>{const n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),i}));i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n,this.isVisible||this.hide()})),this.on("change:isVisible",(()=>{this.isVisible?(this.show(),this.redraw()):this.hide()}))}begin(e){this._state=new u_(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)}));const i=this._getHandleHost(),n=new Nn(i),o=Math.round(n.width),s=Math.round(n.height),r=new Nn(i);t.width=Math.round(r.width),t.height=Math.round(r.height),this.redraw(n),this.state.update({...t,handleHostWidth:o,handleHostHeight:s})}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;const n=t.parentElement,o=this._getHandleHost(),s=this._viewResizerWrapper,r=[s.getStyle("width"),s.getStyle("height"),s.getStyle("left"),s.getStyle("top")];let a;if(n.isSameNode(o)){const t=e||new Nn(o);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==X(r,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},s)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,i={x:(n=e).pageX,y:n.pageY};var n;const o=!this._options.isCentered||this._options.isCentered(this),s={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(s.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(s.x*=2);let r=Math.abs(t.originalWidth+s.x),a=Math.abs(t.originalHeight+s.y);return"width"==(r/t.aspectRatio>a?"width":"height")?a=r/t.aspectRatio:r=a*t.aspectRatio,{width:Math.round(r),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*r*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new is({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new g_,this._sizeView.render(),e.appendChild(this._sizeView.element)}}class p_ extends Ss{constructor(){super(...arguments),this._resizers=new Map}static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,i=t.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(Uh),this._observer=new(Pn()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(i,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(i,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=uf((()=>this.redrawSelectedResizer()),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())}),{priority:"lowest"}),this._observer.listenTo(t.window,"resize",this._redrawSelectedResizerThrottled);const n=this.editor.editing.view.document.selection;n.on("change",(()=>{const e=n.getSelectedElement(),t=this.getResizerByViewElement(e)||null;t?this.select(t):this.deselect()}))}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){const t=new f_(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;f_.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i)||null,this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}const b_=Un("px");class w_ extends Cs{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",(e=>!e))],style:{left:e.to("left",(e=>b_(e))),top:e.to("top",(e=>b_(e))),width:e.to("width",(e=>b_(e)))}}})}}class __ extends Ss{constructor(){super(...arguments),this.removeDropMarkerDelayed=Jo((()=>this.removeDropMarker()),40),this._updateDropMarkerThrottled=uf((e=>this._updateDropMarker(e)),40),this._reconvertMarkerThrottled=uf((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0),this._dropTargetLineView=new w_,this._domEmitter=new(Pn()),this._scrollables=new Map}static get pluginName(){return"DragDropTarget"}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,n,o,s){this.removeDropMarkerDelayed.cancel();const r=v_(this.editor,e,t,i,n,o,s);if(r)return s&&s.containsRange(r)?this.removeDropMarker():void this._updateDropMarkerThrottled(r)}getFinalDropRange(e,t,i,n,o,s){const r=v_(this.editor,e,t,i,n,o,s);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change((t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}_updateDropTargetLine(e){const i=this.editor.editing,n=e.start.nodeBefore,o=e.start.nodeAfter,s=e.start.parent,r=n?i.mapper.toViewElement(n):null,a=r?i.view.domConverter.mapViewToDom(r):null,l=o?i.mapper.toViewElement(o):null,c=l?i.view.domConverter.mapViewToDom(l):null,d=i.mapper.toViewElement(s);if(!d)return;const h=i.view.domConverter.mapViewToDom(d),u=this._getScrollableRect(d),{scrollX:m,scrollY:g}=t.window,f=a?new Nn(a):null,p=c?new Nn(c):null,b=new Nn(h).excludeScrollbarsAndBorders(),w=f?f.bottom:b.top,_=p?p.top:b.bottom,v=t.window.getComputedStyle(h),y=w<=_?(w+_)/2:_;if(u.topa.schema.checkChild(s,e)))){if(a.schema.checkChild(s,"$text"))return a.createRange(s);if(t)return k_(e,A_(e,t.parent),n,o)}}}else if(a.schema.isInline(c))return k_(e,c,n,o);if(a.schema.isBlock(c))return k_(e,c,n,o);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter((t=>t.is("element")&&!y_(e,t)));let i=0,s=t.length;if(0==s)return a.createRange(a.createPositionAt(c,"end"));for(;i{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),r.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const i=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(i,"dragstart",((e,t)=>this._handleBlockDragStart(t))),this._domEmitter.listenTo(t.document,"dragover",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(t.document,"drop",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(t.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&i.setAttribute("draggable","true"),this.on("change:isEnabled",((e,t,n)=>{i.setAttribute("draggable",n?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,o=Array.from(i.getSelectedBlocks()),s=t.createRange(t.createPositionBefore(o[0]),t.createPositionAfter(o[o.length-1]));t.change((e=>e.setSelection(s))),this._isBlockDragging=!0,n.focus(),n.getObserver(mw).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),o=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&o.getObserver(mw).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class E_ extends Ss{constructor(){super(...arguments),this._clearDraggableAttributesDelayed=Jo((()=>this._clearDraggableAttributes()),40),this._blockMode=!1,this._domEmitter=new(Pn())}static get pluginName(){return"DragDrop"}static get requires(){return[Bw,a_,__,x_]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(mw),t.addObserver(Uh),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,i)=>{i||this._finalizeDragging(!1)})),r.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,i=e.model,n=e.editing.view,o=n.document,s=e.plugins.get(__);this.listenTo(o,"dragstart",((e,t)=>{if(t.target&&t.target.is("editableElement"))return void t.preventDefault();if(this._prepareDraggedRange(t.target),!this._draggedRange)return void t.preventDefault();this._draggingUid=f(),t.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",t.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const n=i.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(t.dataTransfer,n,"dragstart");const{dataTransfer:o,domTarget:s,domEvent:r}=t,{clientX:a}=r;this._updatePreview({dataTransfer:o,domTarget:s,clientX:a}),t.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(t.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(o,"dragleave",(()=>{s.removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:n}=t.domEvent;s.updateDropMarker(t.target,t.targetRanges,i,n,this._blockMode,this._draggedRange),this._draggedRange||(t.dataTransfer.dropEffect="copy"),r.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(__);this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const{clientX:o,clientY:s}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,o,s,this._blockMode,this._draggedRange);if(!r)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==T_(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(r)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Bw);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(i)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==T_(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((n,o)=>{if(r.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let s=S_(o.target);if(r.isBlink&&!e.isReadOnly&&!s&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&$w(e)||(s=i.selection.editableElement)}s&&(t.change((e=>{e.setAttribute("draggable","true",s)})),this._draggableElement=e.editing.mapper.toModelElement(s))})),this.listenTo(i,"mouseup",(()=>{r.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_finalizeDragging(e){const t=this.editor,i=t.model;if(t.plugins.get(__).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change((e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,o=e?S_(e):null;if(o){const e=t.editing.mapper.toModelElement(o);if(this._draggedRange=bc.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const s=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==s.length)return void(this._draggedRange=bc.fromRange(r));const a=P_(i,s);if(s.length>1)this._draggedRange=bc.fromRange(a),this._blockMode=!0;else if(1==s.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=bc.fromRange(e?a:r),this._blockMode=e}i.change((e=>e.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:e,domTarget:i,clientX:n}){const o=this.editor.editing.view,s=o.document.selection.editableElement,a=o.domConverter.mapViewToDom(s),l=t.window.getComputedStyle(a);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=be(t.document,"div",{style:"position: fixed; left: -999999px;"}),t.document.body.appendChild(this._previewContainer));const c=new Nn(a);if(a.contains(i))return;const d=parseFloat(l.paddingLeft),h=be(t.document,"div");h.className="ck ck-content",h.style.width=l.width,h.style.paddingLeft=`${c.left-n+d}px`,r.isiOS&&(h.style.backgroundColor="white"),h.innerHTML=e.getData("text/html"),e.setDragImage(h,0,0),this._previewContainer.appendChild(h)}}function T_(e){return r.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function S_(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor($w);if($w(e))return e;const t=e.findAncestor((e=>$w(e)||e.is("editableElement")));return $w(t)?t:null}function P_(e,t){const i=t[0],n=t[t.length-1],o=i.getCommonAncestor(n),s=e.createPositionBefore(i),r=e.createPositionAfter(n);if(o&&o.is("element")&&!e.schema.isLimit(o)){const t=e.createRangeOn(o),i=s.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return P_(e,[o])}return e.createRange(s,r)}class I_ extends Ss{static get pluginName(){return"PastePlainText"}static get requires(){return[Bw]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=t.document.selection;let s=!1;i.addObserver(mw),this.listenTo(n,"keydown",((e,t)=>{s=t.shiftKey})),e.plugins.get(Bw).on("contentInsertion",((e,i)=>{(s||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const n=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),n.push(...o.getAttributes());const s=e.createRangeIn(i.content);for(const t of s.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class V_ extends Ss{static get pluginName(){return"Clipboard"}static get requires(){return[Ow,Bw,E_,I_]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}class R_ extends Is{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!O_(e.schema,i))do{if(i=i.parent,!i)return}while(!O_(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function O_(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const B_=bo("Ctrl+A");class M_ extends Ss{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new R_(e)),this.listenTo(i,"keydown",((t,i)=>{po(i)===B_&&(e.execute("selectAll"),i.preventDefault())})),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class F_ extends Ss{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:selectAll",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),o=new e(t.locale),s=i.t;return o.set({label:s("Select all"),icon:'',keystroke:"Ctrl+A"}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),o}}class N_ extends Ss{static get requires(){return[M_,F_]}static get pluginName(){return"SelectAll"}}class D_ extends Is{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",((e,t)=>{t[1]={...t[1]};const i=t[1];i.batchType||(i.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(e.data,"set",((e,t)=>{t[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,o=n.document,s=[],r=e.map((e=>e.getTransformedByOperations(i))),a=r.flat();for(const e of r){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!z_(e,a)));t.length&&(L_(t),s.push(t[0]))}s.length&&n.change((e=>{e.setSelection(s,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,s=Array.from(n.history.getOperations(o)),r=Qd([e.getReversed()],s,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let o of r){const s=o.affectedSelectable;s&&!i.canEditAt(s)&&(o=new $d(o.baseVersion)),t.addOperation(o),i.applyOperation(o),n.history.setOperationAsUndone(e,o)}}}}function L_(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class H_ extends D_{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(n,(()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e)})),this.fire("revert",i.batch,n),this.refresh()}}class $_ extends D_{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)})),this.refresh()}}class W_ extends Ss{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor,t=e.t;this._undoCommand=new H_(e),this._redoCommand=new $_(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,o=this._redoCommand.createdBatches.has(n),s=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(o?this._undoCommand.addBatch(n):s||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,i)=>{this._redoCommand.addBatch(i)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class j_ extends Ss{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Hu.undo:Hu.redo,o="ltr"==t.uiLanguageDirection?Hu.redo:Hu.undo;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",o)}_addButtonsToFactory(e,t,i,n){const o=this.editor;o.ui.componentFactory.add(e,(()=>{const o=this._createButton(Yu,e,t,i,n);return o.set({tooltip:!0}),o})),o.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(pp,e,t,i,n)))}_createButton(e,t,i,n,o){const s=this.editor,r=s.locale,a=s.commands.get(t),l=new e(r);return l.set({label:i,icon:o,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",(()=>{s.execute(t),s.editing.view.focus()})),l}}class U_ extends Ss{static get requires(){return[W_,j_]}static get pluginName(){return"Undo"}}class q_ extends Is{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,o=e.batch,s=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{s(e)})):t.change((e=>{s(e)}))}}const G_="fontSize",K_="fontFamily",Z_="fontColor",J_="fontBackgroundColor";function Y_(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function Q_(e){return t=>t.getStyle(e).replace(/\s/g,"")}function X_(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class ev extends q_{constructor(e){super(e,K_)}}function tv(e){return e.map(iv).filter((e=>void 0!==e))}function iv(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],n=t.map(nv).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function nv(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class ov extends Ss{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(K_,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:K_}),e.model.schema.setAttributeProperties(K_,{isFormatting:!0,copyOnEnter:!0});const t=tv(e.config.get("fontFamily.options")).filter((e=>e.model)),i=Y_(K_,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(K_,new ev(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:K_,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:K_,value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:K_,value:e=>e.getAttribute("face")}})}}const sv='';class rv extends Ss{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(K_),o=t("Font Family"),s=function(e,t){const i=new Uo;for(const n of e){const e={type:"button",model:new Vf({commandName:K_,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.model||!(!e||!n.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===n.model.toLowerCase())),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n);e.ui.componentFactory.add(K_,(t=>{const i=zm(t);return Wm(i,s,{role:"menu",ariaLabel:o}),i.buttonView.set({label:o,icon:sv,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${K_}`,(t=>{const i=new gp(t);i.buttonView.set({label:o,icon:sv}),i.bind("isEnabled").to(n);const r=new fp(t);for(const n of s){const o=new Zf(t,i),s=new pp(t);s.bind(...Object.keys(n.model)).to(n.model),s.bind("ariaChecked").to(s,"isOn"),s.delegate("execute").to(i),s.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),o.children.add(s),r.items.add(o)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return tv(e.config.get(K_).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class av extends q_{constructor(e){super(e,G_)}}function lv(e){return e.map((e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&(t=e,t.title&&t.model&&t.view))return dv(e);var t;const i=function(e){return"string"==typeof e?cv[e]:cv[e.model]}(e);if(i)return dv(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new _("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},dv(e)}(e)}(e))).filter((e=>void 0!==e))}const cv={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function dv(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const hv=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class uv extends Ss{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(G_,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:G_}),e.model.schema.setAttributeProperties(G_,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=lv(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=Y_(G_,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(G_,new av(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!ou(String(e))&&!ru(String(e))));if(i.length)throw new _("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:G_,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:G_,value:e=>e.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:G_,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=hv.length-1,s=Math.min(Math.max(n,0),o);return hv[s]}}})}}const mv='';class gv extends Ss{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(G_),o=t("Font Size"),s=function(e,t){const i=new Uo;for(const n of e){const e={type:"button",model:new Vf({commandName:G_,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===n.model)),i.add(e)}return i}(i,n);e.ui.componentFactory.add(G_,(t=>{const i=zm(t);return Wm(i,s,{role:"menu",ariaLabel:o}),i.buttonView.set({label:o,icon:mv,tooltip:!0}),i.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${G_}`,(t=>{const i=new gp(t);i.buttonView.set({label:o,icon:mv}),i.bind("isEnabled").to(n);const r=new fp(t);for(const n of s){const o=new Zf(t,i),s=new pp(t);s.bind(...Object.keys(n.model)).to(n.model),s.bind("ariaChecked").to(s,"isOn"),s.delegate("execute").to(i),s.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),o.children.add(s),r.items.add(o)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return lv(e.config.get(G_).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class fv extends q_{constructor(e){super(e,Z_)}}class pv extends Ss{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(Z_,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:Z_,value:Q_("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Z_,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:Z_,view:X_("color")}),e.commands.add(Z_,new fv(e)),e.model.schema.extend("$text",{allowAttributes:Z_}),e.model.schema.setAttributeProperties(Z_,{isFormatting:!0,copyOnEnter:!0})}}class bv extends Ss{constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),s=nm(t,om(o.colors)),r=o.documentColors,a=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const l=zm(t);let c=!1;const d=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a}){const l=e.locale,c=new Fg(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}({dropdownView:l,colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!!a&&(o.colorPicker||{})});return d.bind("selectedColor").to(n,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(n),d.on("execute",((t,i)=>{l.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(l.isOpen=!1)})),d.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),d.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),l.on("change:isOpen",((t,i,n)=>{c||(c=!0,l.colorSelectorView.appendUI()),n&&(0!==r&&d.updateDocumentColors(e.model,this.componentName),d.updateSelectedColors(),d.showColorGridsFragment())})),Um(l,(()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),l})),e.ui.componentFactory.add(`menuBar:${this.componentName}`,(t=>{const o=new gp(t);o.buttonView.set({label:this.dropdownLabel,icon:this.icon}),o.bind("isEnabled").to(n);let a=!1;const l=new Fg(t,{colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!1});return l.bind("selectedColor").to(n,"value"),l.delegate("execute").to(o),l.on("execute",((t,i)=>{e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),e.editing.view.focus()})),o.on("change:isOpen",((t,i,n)=>{a||(a=!0,l.appendUI()),n&&(0!==r&&l.updateDocumentColors(e.model,this.componentName),l.updateSelectedColors(),l.showColorGridsFragment())})),o.panelView.children.add(l),o}))}}class wv extends bv{constructor(e){const t=e.locale.t;super(e,{commandName:Z_,componentName:Z_,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class _v extends q_{constructor(e){super(e,J_)}}class vv extends Ss{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(J_,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(vu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:J_,value:Q_("background-color")}}),e.conversion.for("downcast").attributeToElement({model:J_,view:X_("background-color")}),e.commands.add(J_,new _v(e)),e.model.schema.extend("$text",{allowAttributes:J_}),e.model.schema.setAttributeProperties(J_,{isFormatting:!0,copyOnEnter:!0})}}class yv extends bv{constructor(e){const t=e.locale.t;super(e,{commandName:J_,componentName:J_,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class kv extends Is{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=qo(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Cv(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change((e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&Cv(n,t.schema)&&e.rename(n,"paragraph")}))}}function Cv(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Av extends Is{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.canEditAt(n)&&t.change((e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return;const o=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(o,i,e),t.insertContent(o,n),e.setSelection(o,"in")}))}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const o=e.parent,s=i.schema.checkChild(o,"$text");return o.isEmpty||s&&e.isAtEnd?i.createPositionAfter(o):!o.isEmpty&&s&&e.isAtStart?i.createPositionBefore(o):t.split(e,n).position}}class xv extends Ss{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new kv(e)),e.commands.add("insertParagraph",new Av(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>xv.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}xv.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);const Ev=xv;class Tv extends Is{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=qo(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>Sv(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>Sv(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function Sv(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const Pv="paragraph";class Iv extends Ss{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[Ev]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Tv(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",Pv)&&0===o.childCount&&n.writer.rename(o,Pv)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:p.low+1})}}class Vv extends Ss{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=function(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const s={},r=new Uo,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new Vf({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),s[e.model]=e.title}const d=zm(t);return Wm(d,r,{ariaLabel:o,role:"menu"}),d.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?n:s[i]?s[i]:n})),d.buttonView.bind("ariaLabel").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?o:s[i]?`${s[i]}, ${o}`:o})),this.listenTo(d,"execute",(t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()})),d})),e.ui.componentFactory.add("menuBar:heading",(n=>{const o=new gp(n),s=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[s],l=new fp(n);o.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),o.buttonView.set({label:t("Heading")}),o.panelView.children.add(l);for(const t of i){const i=new Zf(n,o),c=new pp(n);i.children.add(c),l.items.add(i),c.set({label:t.title,role:"menuitemradio",class:t.class}),c.bind("ariaChecked").to(c,"isOn"),c.delegate("execute").to(o),c.on("execute",(()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()})),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(s,"value",(e=>e===t.model))}return o.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),o}))}}new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class Rv extends Is{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change((e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,o=t.getLastMatchingPosition(i,{direction:"backward"}),s=t.getLastMatchingPosition(i),r=e.createRange(o,s);n&&this.value!==n?(t.isEqual(s)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(s)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const o=t.schema.getValidRanges(i.getRanges(),"highlight");for(const t of o)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)}}))}}class Ov extends Ss{static get pluginName(){return"HighlightEditing"}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new Rv(e))}}class Bv extends Ss{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),Hu.eraser,null,(e=>{e.bind("isEnabled").to(t,"isEnabled")}))}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,Mv(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(t=>t===e.model)),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,o){const s=this.editor;s.ui.componentFactory.add(e,(e=>{const r=new Yu(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",(()=>{s.execute("highlight",{value:n}),s.editing.view.focus()})),o(r),r}))}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,o=e[0],s=e.reduce(((e,t)=>(e[t.model]=t,e)),{});n.add("highlight",(r=>{const a=t.commands.get("highlight"),l=zm(r,Lm),c=l.buttonView;c.set({label:i("Highlight"),tooltip:!0,lastExecuted:o.model,commandValue:o.model,isToggleable:!0}),c.bind("icon").to(a,"value",(e=>Mv(d(e,"type")))),c.bind("color").to(a,"value",(e=>d(e,"color"))),c.bind("commandValue").to(a,"value",(e=>d(e,"model"))),c.bind("isOn").to(a,"value",(e=>!!e)),c.delegate("execute").to(l);function d(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return s[i][t]}return l.bind("isEnabled").to(a,"isEnabled"),Hm(l,(()=>{const t=e.map((e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",(()=>{l.buttonView.set({lastExecuted:e.model})})),t}));return t.push(new Tm),t.push(n.create("removeHighlight")),t}),{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){const t=e.buttonView.actionView;t.iconView.bind("fillColor").to(e.buttonView,"color")}(l),c.on("execute",(()=>{t.execute("highlight",{value:c.commandValue})})),this.listenTo(l,"execute",(()=>{t.editing.view.focus()})),l}))}_addMenuBarButton(e){const t=this.editor,i=t.t;t.ui.componentFactory.add("menuBar:highlight",(n=>{const o=t.commands.get("highlight"),s=new gp(n);s.buttonView.set({label:i("Highlight"),icon:Mv("marker")}),s.bind("isEnabled").to(o),s.buttonView.iconView.fillColor="transparent";const r=new fp(n);for(const i of e){const e=new Zf(n,s),a=new pp(n);a.set({label:i.title,icon:Mv(i.type)}),a.delegate("execute").to(s),a.bind("isOn").to(o,"value",(e=>e===i.model)),a.bind("ariaChecked").to(a,"isOn"),a.iconView.bind("fillColor").to(a,"isOn",(e=>e?"transparent":i.color)),a.on("execute",(()=>{t.execute("highlight",{value:i.model}),t.editing.view.focus()})),e.children.add(a),r.items.add(e)}r.items.add(new Fm(n));const a=new Zf(n,s),l=new pp(n);return l.set({label:i("Remove highlight"),icon:Hu.eraser}),l.delegate("execute").to(s),l.on("execute",(()=>{t.execute("highlight",{value:null}),t.editing.view.focus()})),a.children.add(l),r.items.add(a),s.panelView.children.add(r),s}))}}function Mv(e){return"marker"===e?'':''}class Fv extends Is{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=Kw(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class Nv extends Ss{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),o=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",o),t.setCustomProperty("hr",!0,o),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),Ww(e,t,{label:i})}(o,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new Fv(e))}}class Dv extends Ss{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:horizontalLine",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("horizontalLine"),o=new e(t.locale),s=i.t;return o.set({label:s("Horizontal line"),icon:Hu.horizontalLine}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("horizontalLine"),t.editing.view.focus()})),o}}const Lv=function(e,t,i,n){var o=-1,s=null==e?0:e.length;for(n&&s&&(i=e[++o]);++o=n?e:_r(e,t,i)};var yy=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const ky=function(e){return yy.test(e)};const Cy=function(e){return e.split("")};var Ay="\\ud800-\\udfff",xy="["+Ay+"]",Ey="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Ty="\\ud83c[\\udffb-\\udfff]",Sy="[^"+Ay+"]",Py="(?:\\ud83c[\\udde6-\\uddff]){2}",Iy="[\\ud800-\\udbff][\\udc00-\\udfff]",Vy="(?:"+Ey+"|"+Ty+")"+"?",Ry="[\\ufe0e\\ufe0f]?",Oy=Ry+Vy+("(?:\\u200d(?:"+[Sy,Py,Iy].join("|")+")"+Ry+Vy+")*"),By="(?:"+[Sy+Ey+"?",Ey,Py,Iy,xy].join("|")+")",My=RegExp(Ty+"(?="+Ty+")|"+By+Oy,"g");const Fy=function(e){return e.match(My)||[]};const Ny=function(e){return ky(e)?Fy(e):Cy(e)};const Dy=function(e){return function(t){t=gr(t);var i=ky(t)?Ny(t):void 0,n=i?i[0]:t.charAt(0),o=i?vy(i,1).join(""):t.slice(1);return n[e]()+o}}("toUpperCase");const Ly=_y((function(e,t,i){return e+(i?" ":"")+Dy(t)}));function zy(e,t,i,n){t&&function(e,t,i){if(t.attributes)for(const[n]of Object.entries(t.attributes))e.removeAttribute(n,i);if(t.styles)for(const n of Object.keys(t.styles))e.removeStyle(n,i);t.classes&&e.removeClass(t.classes,i)}(e,t,n),i&&Hy(e,i,n)}function Hy(e,t,i){if(t.attributes)for(const[n,o]of Object.entries(t.attributes))e.setAttribute(n,o,i);t.styles&&e.setStyle(t.styles,i),t.classes&&e.addClass(t.classes,i)}function $y(e,t,i,n,o){const s=t.getAttribute(i),r={};for(const e of["attributes","styles","classes"]){if(e!=n){s&&s[e]&&(r[e]=s[e]);continue}if("classes"==n){const t=new Set(s&&s.classes||[]);o(t),t.size&&(r[e]=Array.from(t));continue}const t=new Map(Object.entries(s&&s[e]||{}));o(t),t.size&&(r[e]=Object.fromEntries(t))}Object.keys(r).length?t.is("documentSelection")?e.setSelectionAttribute(i,r):e.setAttribute(i,r,t):s&&(t.is("documentSelection")?e.removeSelectionAttribute(i):e.removeAttribute(i,t))}function Wy(e){return`html${t=e,Ly(t).replace(/ /g,"")}Attributes`;var t}function jy({model:e}){return(t,i)=>i.writer.createElement(e,{htmlContent:t.getCustomProperty("$rawContent")})}function Uy(e,{view:t,isInline:i}){const n=e.t;return(e,{writer:o})=>{const s=n("HTML object"),r=qy(t,e,o),a=e.getAttribute(Wy(t));o.addClass("html-object-embed__content",r),a&&Hy(o,a,r);return Ww(o.createContainerElement(i?"span":"div",{class:"html-object-embed","data-html-object-embed-label":s},r),o,{label:s})}}function qy(e,t,i){return i.createRawElement(e,null,((e,i)=>{i.setContentOf(e,t.getAttribute("htmlContent"))}))}function Gy({view:e,model:t,allowEmpty:i},n){return t=>{t.on(`element:${e}`,((e,t,s)=>{let r=n.processViewAttributes(t.viewItem,s);if(r||s.consumable.test(t.viewItem,{name:!0})){if(r=r||{},s.consumable.consume(t.viewItem,{name:!0}),t.modelRange||(t=Object.assign(t,s.convertChildren(t.viewItem,t.modelCursor))),i&&t.modelRange.isCollapsed&&Object.keys(r).length){const e=s.writer.createElement("htmlEmptyElement");if(!s.safeInsert(e,t.modelCursor))return;const i=s.getSplitParts(e);return t.modelRange=s.writer.createRange(t.modelRange.start,s.writer.createPositionAfter(i[i.length-1])),s.updateConversionResult(e,t),void o(e,r,s)}for(const e of t.modelRange.getItems())o(e,r,s)}}),{priority:"low"})};function o(e,i,n){if(n.schema.checkAttribute(e,t)){const o=function(e,t){const i=Hl(e);let n="attributes";for(n in t)i[n]="classes"==n?Array.from(new Set([...e[n]||[],...t[n]])):{...e[n],...t[n]};return i}(i,e.getAttribute(t)||{});n.writer.setAttribute(t,o,e)}}}function Ky({model:e,view:t},i){return(n,{writer:o,consumable:s})=>{if(!n.hasAttribute(e))return null;const r=o.createContainerElement(t),a=n.getAttribute(e);return s.consume(n,`attribute:${e}`),Hy(o,a,r),r.getFillerOffset=()=>null,i?Ww(r,o):r}}function Zy({priority:e,view:t}){return(i,n)=>{if(!i)return;const{writer:o}=n,s=o.createAttributeElement(t,null,{priority:e});return Hy(o,i,s),s}}function Jy({view:e},t){return i=>{i.on(`element:${e}`,((e,i,n)=>{if(!i.modelRange||i.modelRange.isCollapsed)return;const o=t.processViewAttributes(i.viewItem,n);o&&n.writer.setAttribute(Wy(i.viewItem.name),o,i.modelRange)}),{priority:"low"})}}function Yy({view:e,model:t}){return i=>{i.on(`attribute:${Wy(e)}:${t}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t;zy(i.writer,n,o,i.mapper.toViewElement(t.item))}))}}const Qy=[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:"$text",allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}}],Xy=[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref"},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}];const ek=Lo((function(e,t,i,n){To(e,t,i,n)}));class tk extends Ss{constructor(){super(...arguments),this._definitions=[]}static get pluginName(){return"DataSchema"}init(){for(const e of Qy)this.registerBlockElement(e);for(const e of Xy)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const n of this._getMatchingViewDefinitions(e)){if(t)for(const e of this._getReferences(n.model))i.add(e);i.add(n)}return i}getDefinitionsForModel(e){return this._definitions.filter((t=>t.model==e))}_getMatchingViewDefinitions(e){return this._definitions.filter((t=>t.view&&function(e,t){if("string"==typeof e)return e===t;if(e instanceof RegExp)return e.test(t);return!1}(e,t.view)))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter((t=>t.model==e));for(const{modelSchema:n}of i)if(n)for(const i of t)for(const t of vo(n[i]||[])){const i=this._definitions.filter((e=>e.model==t));for(const n of i)t!==e&&(yield*this._getReferences(n.model),yield n)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter((([,t])=>t.model==e.model));if(0!=t.length)for(const[i,n]of t)this._definitions[i]=ek({},n,e,((e,t)=>Array.isArray(e)?e.concat(t):void 0));else this._definitions.push(e)}}class ik extends Ss{constructor(e){super(e),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new Js,this._disallowedAttributes=new Js,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get requires(){return[tk,a_]}loadAllowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=ak(t);this.allowElement(e),i.forEach((e=>this.allowAttributes(e)))}}loadDisallowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=ak(t);0==i.length?this.disallowElement(e):i.forEach((e=>this.disallowAttributes(e)))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return nk(e,this._disallowedAttributes,i),function(e,{attributes:t,classes:i,styles:n}){if(!t.length&&!i.length&&!n.length)return null;return{...t.length&&{attributes:ok(e,t)},...n.length&&{styles:sk(e,n)},...i.length&&{classes:i}}}(e,nk(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&"string"==typeof e.appliesToBlock)for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",(()=>{this._fireRegisterEvent(e)}),{priority:p.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",(()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)}),{priority:p.highest+1})}_registerElementHandlers(){this.on("register",((e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else{if(!t.isInline)throw new _("data-filter-invalid-definition",null,t);this._registerInlineElement(t)}e.stop()}),{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;const o=this._getCoupledAttributesMap();for(const e of i){if("attribute"!=e.type||null!==e.attributeNewValue)continue;const i=o.get(e.attributeKey);if(i)for(const{item:o}of e.range.getWalker())for(const e of i)o.hasAttribute(e)&&(t.removeAttribute(e,o),n=!0)}return n})),this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{const o=new Set,s=this._getCoupledAttributesMap();for(const e of n){if(t.hasAttribute(e))continue;const i=s.get(e);if(i)for(const e of i)t.hasAttribute(e)&&o.add(e)}0!=o.size&&e.change((e=>{for(const t of o)e.removeSelectionAttribute(t)}))}))}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;for(const o of i)if("insert"===o.type&&"$text"!==o.name)for(const i of o.attributes.keys())i.startsWith("html")&&i.endsWith("Attributes")&&(e.schema.checkAttribute(o.name,i)||(t.removeAttribute(i,o.position.nodeAfter),n=!0));return n}))}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:o,model:s}=e;i.register(s,e.modelSchema),o&&(i.extend(e.model,{allowAttributes:[Wy(o),"htmlContent"]}),t.data.registerRawContentMatcher({name:o}),n.for("upcast").elementToElement({view:o,model:jy(e),converterPriority:p.low+2}),n.for("upcast").add(Jy(e,this)),n.for("editingDowncast").elementToStructure({model:{name:s,attributes:[Wy(o)]},view:Uy(t,e)}),n.for("dataDowncast").elementToElement({model:s,view:(e,{writer:t})=>qy(o,e,t)}),n.for("dataDowncast").add(Yy(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:o,model:s}=e;if(!i.isRegistered(e.model)){if(i.register(e.model,e.modelSchema),!o)return;n.for("upcast").elementToElement({model:s,view:o,converterPriority:p.low+2}),n.for("downcast").elementToElement({model:s,view:o})}o&&(i.extend(e.model,{allowAttributes:Wy(o)}),n.for("upcast").add(Jy(e,this)),n.for("downcast").add(Yy(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,o=e.model;e.appliesToBlock||(i.extend("$text",{allowAttributes:o}),e.attributeProperties&&i.setAttributeProperties(o,e.attributeProperties),n.for("upcast").add(Gy(e,this)),n.for("downcast").attributeToElement({model:o,view:Zy(e)}),e.allowEmpty&&(i.setAttributeProperties(o,{copyFromObject:!1}),i.isRegistered("htmlEmptyElement")||i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"}),t.data.htmlProcessor.domConverter.registerInlineObjectMatcher((t=>t.name==e.view&&t.isEmpty&&Array.from(t.getAttributeKeys()).length?{name:!0}:null)),n.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:Ky(e,!0)}),n.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:Ky(e)})))}}function nk(e,t,i){const n=t.matchAll(e)||[],o=e.document.stylesProcessor;return n.reduce(((t,{match:n})=>{for(const s of n.styles||[]){const n=o.getRelatedStyles(s).filter((e=>e.split("-").length>s.split("-").length)).sort(((e,t)=>t.split("-").length-e.split("-").length));for(const o of n)i.consume(e,{styles:[o]})&&t.styles.push(o);i.consume(e,{styles:[s]})&&t.styles.push(s)}for(const o of n.classes||[])i.consume(e,{classes:[o]})&&t.classes.push(o);for(const o of n.attributes||[])i.consume(e,{attributes:[o]})&&t.attributes.push(o);return t}),{attributes:[],classes:[],styles:[]})}function ok(e,t){const i={};for(const n of t){const t=e.getAttribute(n);void 0!==t&&Zn(n)&&(i[n]=t)}return i}function sk(e,t){const i=new Er(e.document.stylesProcessor);for(const n of t){const t=e.getStyle(n);void 0!==t&&i.set(n,t)}return Object.fromEntries(i.getStylesEntries())}function rk(e,t){const{name:i}=e,n=e[t];return xe(n)?Object.entries(n).map((([e,n])=>({name:i,[t]:{[e]:n}}))):Array.isArray(n)?n.map((e=>({name:i,[t]:[e]}))):[e]}function ak(e){const{name:t,attributes:i,classes:n,styles:o}=e,s=[];return i&&s.push(...rk({name:t,attributes:i},"attributes")),n&&s.push(...rk({name:t,classes:n},"classes")),o&&s.push(...rk({name:t,styles:o},"styles")),s}class lk extends Ss{static get requires(){return[ik]}static get pluginName(){return"CodeBlockElementSupport"}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(ik);e.on("register:pre",((t,i)=>{if("codeBlock"!==i.model)return;const n=this.editor,o=n.model.schema,s=n.conversion;o.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),s.for("upcast").add(function(e){return t=>{t.on("element:code",((t,i,n)=>{const o=i.viewItem,s=o.parent;function r(t,o){const s=e.processViewAttributes(t,n);s&&n.writer.setAttribute(o,s,i.modelRange)}s&&s.is("element","pre")&&(r(s,"htmlPreAttributes"),r(o,"htmlContentAttributes"))}),{priority:"low"})}}(e)),s.for("downcast").add((e=>{e.on("attribute:htmlPreAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item).parent;zy(i.writer,n,o,s)})),e.on("attribute:htmlContentAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item);zy(i.writer,n,o,s)}))})),t.stop()}))}}class ck extends Ss{static get requires(){return[ik]}static get pluginName(){return"DualContentModelElementSupport"}init(){this.editor.plugins.get(ik).on("register",((e,t)=>{const i=t,n=this.editor,o=n.model.schema,s=n.conversion;if(!i.paragraphLikeModel)return;if(o.isRegistered(i.model)||o.isRegistered(i.paragraphLikeModel))return;const r={model:i.paragraphLikeModel,view:i.view};o.register(i.model,i.modelSchema),o.register(r.model,{inheritAllFrom:"$block"}),s.for("upcast").elementToElement({view:i.view,model:(e,{writer:t})=>this._hasBlockContent(e)?t.createElement(i.model):t.createElement(r.model),converterPriority:p.low+.5}),s.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),s.for("downcast").elementToElement({view:r.view,model:r.model}),this._addAttributeConversion(r),e.stop()}))}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const n of t.createRangeIn(e).getItems())if(n.is("element")&&i.includes(n.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,n=t.plugins.get(ik);t.model.schema.extend(e.model,{allowAttributes:Wy(e.view)}),i.for("upcast").add(Jy(e,n)),i.for("downcast").add(Yy(e))}}class dk extends Ss{static get requires(){return[tk,Lb]}static get pluginName(){return"HeadingElementSupport"}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(tk),n=[];for(const e of t)"model"in e&&"view"in e&&(i.registerBlockElement({view:e.view,model:e.model}),n.push(e.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:n}})}}function hk(e,t,i){const n=e.createRangeOn(t);for(const{item:e}of n.getWalker())if(e.is("element",i))return e}class uk extends Ss{static get requires(){return[ik]}static get pluginName(){return"ImageElementSupport"}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(ik);n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("image"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:img",((o,s)=>{"imageBlock"!==s.model&&"imageInline"!==s.model||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:img",((t,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlImgAttributes",s,i.modelRange)}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t){e.on(`attribute:${t}:imageInline`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item);zy(i.writer,n,o,s)}),{priority:"low"})}function i(t,i){e.on(`attribute:${i}:imageBlock`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=i,r=n.mapper.toViewElement(i.item),a=hk(n.writer,r,t);a&&(zy(n.writer,o,s,a),n.consumable.consume(i.item,e.name))}),{priority:"low"}),"a"===t&&e.on("attribute:linkHref:imageBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,"attribute:htmlLinkAttributes:imageBlock"))return;const n=i.mapper.toViewElement(t.item),o=hk(i.writer,n,"a");Hy(i.writer,t.item.getAttribute("htmlLinkAttributes"),o)}),{priority:"low"})}t("htmlImgAttributes"),i("img","htmlImgAttributes"),i("figure","htmlFigureAttributes"),i("a","htmlLinkAttributes")})),e.plugins.has("LinkImage")&&i.for("upcast").add(function(e,t){const i=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,n,o)=>{const s=n.viewItem;if(!i.findViewImgElement(s))return;const r=n.modelCursor.parent;if(!r.is("element","imageBlock"))return;const a=e.processViewAttributes(s,o);a&&o.writer.setAttribute("htmlLinkAttributes",a,r)}),{priority:"low"})}}(n,e)),o.stop())}))}}class mk extends Ss{static get requires(){return[ik]}static get pluginName(){return"MediaEmbedElementSupport"}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,n=this.editor.plugins.get(ik),o=this.editor.plugins.get(tk),s=e.config.get("mediaEmbed.elementName");o.registerBlockElement({model:"media",view:s}),n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("media"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on(`register:${s}`,((e,o)=>{"media"===o.model&&(t.extend("media",{allowAttributes:[Wy(s),"htmlFigureAttributes"]}),i.for("upcast").add(function(e,t){const i=(i,n,o)=>{function s(t,i){const s=e.processViewAttributes(t,o);s&&o.writer.setAttribute(i,s,n.modelRange)}s(n.viewItem,Wy(t))};return e=>{e.on(`element:${t}`,i,{priority:"low"})}}(n,s)),i.for("dataDowncast").add(function(e){return t=>{function i(e,i){t.on(`attribute:${i}:media`,((t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const{attributeOldValue:o,attributeNewValue:s}=i,r=n.mapper.toViewElement(i.item),a=hk(n.writer,r,e);zy(n.writer,o,s,a)}))}i(e,Wy(e)),i("figure","htmlFigureAttributes")}}(s)),e.stop())}))}}class gk extends Ss{static get requires(){return[ik]}static get pluginName(){return"ScriptElementSupport"}init(){const e=this.editor.plugins.get(ik);e.on("register:script",((t,i)=>{const n=this.editor,o=n.model.schema,s=n.conversion;o.register("htmlScript",i.modelSchema),o.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"script"}),s.for("upcast").elementToElement({view:"script",model:jy(i)}),s.for("upcast").add(Jy(i,e)),s.for("downcast").elementToElement({model:"htmlScript",view:(e,{writer:t})=>qy("script",e,t)}),s.for("downcast").add(Yy(i)),t.stop()}))}}class fk extends Ss{static get requires(){return[ik]}static get pluginName(){return"TableElementSupport"}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(ik),o=e.plugins.get("TableUtils");n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("table"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:table",((s,r)=>{"table"===r.model&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:table",((t,i,n)=>{if(!i.modelRange)return;const o=i.viewItem;s(o,"htmlTableAttributes");for(const e of o.getChildren())e.is("element","thead")&&s(e,"htmlTheadAttributes"),e.is("element","tbody")&&s(e,"htmlTbodyAttributes");function s(t,o){const s=e.processViewAttributes(t,n);s&&n.writer.setAttribute(o,s,i.modelRange)}}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t,i){e.on(`attribute:${i}:table`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const o=n.mapper.toViewElement(i.item),s=hk(n.writer,o,t);s&&(n.consumable.consume(i.item,e.name),zy(n.writer,i.attributeOldValue,i.attributeNewValue,s))}))}t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes")})),e.model.document.registerPostFixer(function(e,t){return i=>{const n=e.document.differ.getChanges();let o=!1;for(const e of n){if("attribute"!=e.type||"headingRows"!=e.attributeKey)continue;const n=e.range.start.nodeAfter,s=n.getAttribute("htmlTheadAttributes"),r=n.getAttribute("htmlTbodyAttributes");s&&!e.attributeNewValue?(i.removeAttribute("htmlTheadAttributes",n),o=!0):r&&e.attributeNewValue==t.getRows(n)&&(i.removeAttribute("htmlTbodyAttributes",n),o=!0)}return o}}(e.model,o)),s.stop())}))}}class pk extends Ss{static get requires(){return[ik]}static get pluginName(){return"StyleElementSupport"}init(){const e=this.editor.plugins.get(ik);e.on("register:style",((t,i)=>{const n=this.editor,o=n.model.schema,s=n.conversion;o.register("htmlStyle",i.modelSchema),o.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"style"}),s.for("upcast").elementToElement({view:"style",model:jy(i)}),s.for("upcast").add(Jy(i,e)),s.for("downcast").elementToElement({model:"htmlStyle",view:(e,{writer:t})=>qy("style",e,t)}),s.for("downcast").add(Yy(i)),t.stop()}))}}class bk extends Ss{static get requires(){return[ik]}static get pluginName(){return"ListElementSupport"}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(ik),o=e.plugins.get("ListEditing"),s=e.plugins.get("ListUtils"),r=["ul","ol","li"];o.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:Hy}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:Hy}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:Hy}),n.on("register",((e,o)=>{if(!r.includes(o.view))return;if(e.stop(),t.checkAttribute("$block","htmlLiAttributes"))return;const s=r.map((e=>Wy(e)));t.extend("$listItem",{allowAttributes:s}),i.for("upcast").add((e=>{e.on("element:ul",wk("htmlUlAttributes",n),{priority:"low"}),e.on("element:ol",wk("htmlOlAttributes",n),{priority:"low"}),e.on("element:li",wk("htmlLiAttributes",n),{priority:"low"})}))})),o.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:o}of t)if(o){if(o.getAttribute("listType")==n.getAttribute("listType")){const t=_k(o.getAttribute("listType")),s=o.getAttribute(t);!zd(n.getAttribute(t),s)&&i.model.schema.checkAttribute(n,t)&&(i.setAttribute(t,s,n),e.return=!0)}if(o.getAttribute("listItemId")==n.getAttribute("listItemId")){const t=o.getAttribute("htmlLiAttributes");!zd(n.getAttribute("htmlLiAttributes"),t)&&i.model.schema.checkAttribute(n,"htmlLiAttributes")&&(i.setAttribute("htmlLiAttributes",t,n),e.return=!0)}}})),o.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n}of t){const t=n.getAttribute("listType");!s.isNumberedListType(t)&&n.getAttribute("htmlOlAttributes")&&(i.removeAttribute("htmlOlAttributes",n),e.return=!0),s.isNumberedListType(t)&&n.getAttribute("htmlUlAttributes")&&(i.removeAttribute("htmlUlAttributes",n),e.return=!0)}}))}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",((t,i)=>{e.model.change((t=>{for(const n of i){const i=_k(n.getAttribute("listType"));e.model.schema.checkAttribute(n,i)&&t.setAttribute(i,{},n)}}))}))}}function wk(e,t){return(i,n,o)=>{const s=n.viewItem;n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor));const r=t.processViewAttributes(s,o);for(const t of n.modelRange.getItems({shallow:!0}))t.hasAttribute("listItemId")&&(t.hasAttribute("htmlUlAttributes")||t.hasAttribute("htmlOlAttributes")||o.writer.model.schema.checkAttribute(t,e)&&o.writer.setAttribute(e,r||{},t))}}function _k(e){return"numbered"===e||"customNumbered"==e?"htmlOlAttributes":"htmlUlAttributes"}class vk extends Ss{static get requires(){return[ik,tk]}static get pluginName(){return"CustomElementSupport"}init(){const e=this.editor.plugins.get(ik),t=this.editor.plugins.get(tk);e.on("register:$customElement",((i,n)=>{i.stop();const o=this.editor,s=o.model.schema,r=o.conversion,a=o.editing.view.domConverter.unsafeElements,l=o.data.htmlProcessor.domConverter.preElements;s.register(n.model,n.modelSchema),s.extend(n.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),o.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),r.for("upcast").elementToElement({view:/.*/,model:(i,s)=>{if("$comment"==i.name)return null;if(!function(e){try{document.createElement(e)}catch(e){return!1}return!0}(i.name))return null;if(t.getDefinitionsForView(i.name).size)return null;a.includes(i.name)||a.push(i.name),l.includes(i.name)||l.push(i.name);const r=s.writer.createElement(n.model,{htmlElementName:i.name}),c=e.processViewAttributes(i,s);let d;if(c&&s.writer.setAttribute("htmlCustomElementAttributes",c,r),i.is("element","template")&&i.getCustomProperty("$rawContent"))d=i.getCustomProperty("$rawContent");else{const e=new qh(i.document).createDocumentFragment(i),t=o.data.htmlProcessor.domConverter.viewToDom(e),n=t.firstChild;for(;n.firstChild;)t.appendChild(n.firstChild);n.remove(),d=o.data.htmlProcessor.htmlWriter.getHtml(t)}s.writer.setAttribute("htmlContent",d,r);for(const{item:e}of o.editing.view.createRangeIn(i))s.consumable.consume(e,{name:!0});return r},converterPriority:"low"}),r.for("editingDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=t.createRawElement(i);return e.hasAttribute("htmlCustomElementAttributes")&&Hy(t,e.getAttribute("htmlCustomElementAttributes"),n),n}}),r.for("dataDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=e.getAttribute("htmlContent"),o=t.createRawElement(i,null,((e,t)=>{t.setContentOf(e,n)}));return e.hasAttribute("htmlCustomElementAttributes")&&Hy(t,e.getAttribute("htmlCustomElementAttributes"),o),o}})}))}}function*yk(e,t,i){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)e.schema.checkAttributeInSelection(t,i)&&(yield t);else for(const n of function(e,t,i){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?e.schema.checkAttribute(t,i)?[e.createRangeOn(t)]:[]:e.schema.getValidRanges(e.createSelection(t).getRanges(),i)}(e,t,i))yield*n.getItems({shallow:!0})}function kk(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function Ck(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return o(e);return("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:o(e)};function o(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function Ak(e,t){const i=qo(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function xk(e){return e&&e.endsWith("px")?parseInt(e):null}function Ek(e){const t=xk(e.getStyle("width")),i=xk(e.getStyle("height"));return!(!t||!i)}const Tk=/^(image|image-inline)$/;class Sk extends Ss{constructor(){super(...arguments),this._domEmitter=new(Pn())}static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,n={}){const o=this.editor,s=o.model,r=s.document.selection,a=Pk(o,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const t in e)s.schema.checkAttribute(a,t)||delete e[t];return s.change((i=>{const{setImageSizes:o=!0}=n,r=i.createElement(a,e);return s.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==a?void 0:"auto"}),r.parent?(o&&this.setImageNaturalSizeAttributes(r),r):null}))}setImageNaturalSizeAttributes(e){const i=e.getAttribute("src");i&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change((n=>{const o=new t.window.Image;this._domEmitter.listenTo(o,"load",(()=>{e.getAttribute("width")||e.getAttribute("height")||this.editor.model.enqueueChange(n.batch,(t=>{t.setAttribute("width",o.naturalWidth,e),t.setAttribute("height",o.naturalHeight,e)})),this._domEmitter.stopListening(o,"load")})),o.src=i})))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:Tk})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){const i=Pk(e,t,null);if("imageBlock"==i){const i=function(e,t){const i=Kw(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return Ww(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&$w(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function Pk(e,t,i){const n=e.model.schema,o=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===o?"imageInline":"auto"!==o?"imageBlock":t.is("selection")?Ak(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class Ik extends Is{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,o=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,o)}))}}class Vk extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Ik(this.editor))}}class Rk extends Cs{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new Go,this.keystrokes=new Ko,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Hu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),Hu.cancel,"ck-button-cancel","cancel"),this._focusables=new ts,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Es({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const o=new Yu(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new fm(this.locale,Gm);return t.label=e("Text alternative"),t}}function Ok(e){const t=e.editing.view,i=of.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class Bk extends Ss{static get requires(){return[Of]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const n=e.commands.get("imageTextAlternative"),o=new Yu(i);return o.set({label:t("Change image text alternative"),icon:Hu.textAlternative,tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>!!e)),this.listenTo(o,"execute",(()=>{this._showForm()})),o}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(xs(Rk))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=Ok(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),As({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Ok(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class Mk extends Ss{static get requires(){return[Vk,Bk]}static get pluginName(){return"ImageTextAlternative"}}function Fk(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);null===i.attributeNewValue?(o.removeAttribute("srcset",r),o.removeAttribute("sizes",r)):i.attributeNewValue&&(o.setAttribute("srcset",i.attributeNewValue,r),o.setAttribute("sizes","100vw",r))};return e=>{e.on(`attribute:srcset:${t}`,i)}}function Nk(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);o.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class Dk extends Ua{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class Lk extends Is{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&v("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&v("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=vo(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);n.insertImage({...e,...o},t)}else n.insertImage({...e,...o})}))}}class zk extends Is{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change((n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)}))}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class Hk extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Dk),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new Lk(e),n=new zk(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class $k extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageSizeAttributes"}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function o(t,n,o,s){t.on(`attribute:${n}:${e}`,((t,n,r)=>{if(!r.consumable.consume(n.item,t.name))return;const a=r.writer,l=r.mapper.toViewElement(n.item),c=i.findViewImgElement(l);if(null!==n.attributeNewValue?a.setAttribute(o,n.attributeNewValue,c):a.removeAttribute(o,c),n.item.hasAttribute("sources"))return;const d=n.item.hasAttribute("resizedWidth");if("imageInline"===e&&!d&&!s)return;const h=n.item.getAttribute("width"),u=n.item.getAttribute("height");h&&u&&a.setStyle("aspect-ratio",`${h}/${u}`,c)}))}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>Ek(e)?xk(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>Ek(e)?xk(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add((e=>{o(e,"width","width",!0),o(e,"height","height",!0)})),t.conversion.for("dataDowncast").add((e=>{o(e,"width","width",!1),o(e,"height","height",!1)}))}}class Wk extends Is{constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(i.document.selection),s=Object.fromEntries(o.getAttributes());return s.src||s.uploadId?i.change((t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter((e=>e.getRange().containsItem(o))),l=n.insertImage(s,i.createSelection(o,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:o,newElement:l}})):null}}class jk extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImagePlaceholder"}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add((e=>{e.on("attribute:placeholder",((e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const o=n.writer,s=n.mapper.toViewElement(t.item),r=i.findViewImgElement(s);t.attributeNewValue?(o.addClass("image_placeholder",r),o.setStyle("background-image",`url(${t.attributeNewValue})`,r),o.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(o.removeClass("image_placeholder",r),o.removeStyle("background-image",r))}))}))}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,o=e.plugins.get("ImageUtils");n.addObserver(Dk),this.listenTo(n.document,"imageLoaded",((e,s)=>{const r=n.domConverter.mapDomToView(s.target);if(!r)return;const a=o.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},(e=>{e.removeAttribute("placeholder",l)}))}))}}class Uk extends Ss{static get requires(){return[Hk,$k,Sk,jk,Bw]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new Wk(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>kk(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(kk(i),i,t("image widget"))}),i.for("downcast").add(Nk(n,"imageBlock","src")).add(Nk(n,"imageBlock","alt")).add(Fk(n,"imageBlock")),i.for("upcast").elementToElement({view:Ck(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const o=e.findViewImgElement(i.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const s=qo(n.convertItem(o,i.modelCursor).modelRange.getItems());s?(n.convertChildren(i.viewItem,s),n.updateConversionResult(s,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,s)=>{const r=Array.from(s.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=s.targetRanges?e.editing.mapper.toModelRange(s.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===Ak(t.schema,l)){const e=new qh(i.document),t=r.map((t=>e.createElement("figure",{class:"image"},t)));s.content=e.createDocumentFragment(t)}})),this.listenTo(o,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(e)}))}))}}class qk extends Cs{constructor(e,t=[]){super(e),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts,this.children=this.createCollection(),this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const e of t)this.children.add(e),this._focusables.add(e),e instanceof im&&this._focusables.addMany(e.children);if(this._focusables.length>1)for(const e of this._focusables)Gk(e)&&(e.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()})));this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),Es({view:this});for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}function Gk(e){return"focusCycler"in e}class Kk extends Ss{static get pluginName(){return"ImageInsertUI"}static get requires(){return[Sk]}constructor(e){super(e),this._integrations=new Map,e.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",(()=>{this.isImageSelected=i.isImage(t.getSelectedElement())}));const n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n)}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,requiresForm:o}){this._integrations.has(e)&&v("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,formViewCreator:n,requiresForm:!!o})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let o;const s=n[0];if(1==n.length){if(!s.requiresForm)return s.buttonViewCreator(!0);o=s.buttonViewCreator(!0)}else{const t=s.buttonViewCreator(!1);o=new Lm(e,t),o.tooltip=!0,o.bind("label").to(this,"isImageSelected",(e=>i(e?"Replace image":"Insert image")))}const r=this.dropdownView=zm(e,o),a=n.map((({observable:e})=>"function"==typeof e?e():e));return r.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),r.once("change:isOpen",(()=>{const e=n.map((({formViewCreator:e})=>e(1==n.length))),i=new qk(t.locale,e);r.panelView.children.add(i)})),r}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return v("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||v("image-insert-unknown-integration",{item:i});return t.length||v("image-insert-integrations-not-registered"),t}}class Zk extends Ss{static get requires(){return[Uk,a_,Mk,Kk]}static get pluginName(){return"ImageBlock"}}class Jk extends Ss{static get requires(){return[Hk,$k,Sk,jk,Bw]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new Wk(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(Nk(n,"imageInline","src")).add(Nk(n,"imageInline","alt")).add(Fk(n,"imageInline")),i.for("upcast").elementToElement({view:Ck(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,s)=>{const r=Array.from(s.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=s.targetRanges?e.editing.mapper.toModelRange(s.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===Ak(t.schema,l)){const e=new qh(i.document),t=r.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));s.content=e.createDocumentFragment(t)}})),this.listenTo(o,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageInline")&&n.setImageNaturalSizeAttributes(e)}))}))}}class Yk extends Ss{static get requires(){return[Jk,a_,Mk,Kk]}static get pluginName(){return"ImageInline"}}class Qk extends Ss{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[Sk]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class Xk extends Is{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(Uk))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,o=n.getSelectedElement();if(!o){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(o),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(o):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let s=i.getSelectedElement();const r=n._getSavedCaption(s);o.isInlineImage(s)&&(this.editor.execute("imageTypeBlock"),s=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,s),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),o=t.plugins.get("ImageCaptionUtils");let s,r=i.getSelectedElement();r?s=o.getCaptionFromImageModelElement(r):(s=o.getCaptionFromModelSelection(i),r=s.parent),n._saveCaption(r,s),e.setSelection(r,"on"),e.remove(s)}}class eC extends Ss{static get requires(){return[Sk,Qk]}static get pluginName(){return"ImageCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new Xk(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),o=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const s=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,s),s.placeholder=o("Enter image caption"),Ds({view:t,element:s,keepOnFocus:!0});const r=e.parent.getAttribute("alt");return Gw(s,n,{label:r?o("Caption for image: %0",[r]):o("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),o=e.commands.get("imageTypeBlock"),s=e=>{if(!e.return)return;const{oldElement:n,newElement:o}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(o,e)}const s=this._getSavedCaption(n);s&&this._saveCaption(o,s)};n&&this.listenTo(n,"execute",s,{priority:"low"}),o&&this.listenTo(o,"execute",s,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Kl.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const o=t.document.differ.getChanges();for(const t of o){if("alt"!==t.attributeKey)continue;const o=t.range.start.nodeAfter;if(i.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(!t)return;e.editing.reconvertItem(t)}}}))}}class tC extends Ss{static get requires(){return[Qk]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",(o=>{const s=e.commands.get("toggleImageCaption"),r=new Yu(o);return r.set({icon:Hu.caption,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.bind("label").to(s,"value",(e=>n(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(r,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",i)}))}e.editing.view.focus()})),r}))}}function iC(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function nC(e){return new Promise(((i,n)=>{const o=e.getAttribute("src");fetch(o).then((e=>e.blob())).then((e=>{const t=oC(e,o),n=t.replace("image/",""),s=new File([e],`image.${n}`,{type:t});i(s)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((i,n)=>{const o=t.document.createElement("img");o.addEventListener("load",(()=>{const e=t.document.createElement("canvas");e.width=o.width,e.height=o.height;e.getContext("2d").drawImage(o,0,0),e.toBlob((e=>e?i(e):n()))})),o.addEventListener("error",(()=>n())),o.src=e}))}(e).then((t=>{const i=oC(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(o).then(i).catch(n):n(e)))}))}function oC(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class sC extends Ss{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=()=>{const e=this._createButton(Xu);return e.set({label:t("Upload image from computer"),tooltip:!0}),e};if(e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i),e.ui.componentFactory.add("menuBar:uploadImage",(()=>{const e=this._createButton(bp);return e.label=t("Image from computer"),e})),e.plugins.has("ImageInsertUI")){const i=e.plugins.get("ImageInsertUI");i.registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>{const n=e.ui.componentFactory.create("uploadImage");return n.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace image from computer":"Upload image from computer"))),n},formViewCreator:()=>{const n=e.ui.componentFactory.create("uploadImage");return n.withText=!0,n.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace from computer":"Upload from computer"))),n.on("execute",(()=>{i.dropdownView.isOpen=!1})),n}})}}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),o=t.config.get("image.upload.types"),s=iC(o),r=new e(t.locale),a=i.t;return r.set({acceptedType:o.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0,label:a("Upload image from computer"),icon:Hu.imageUpload}),r.bind("isEnabled").to(n),r.on("done",((e,i)=>{const n=Array.from(i).filter((e=>s.test(e.type)));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())})),r}}class rC extends(U()){constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}class aC extends Ss{constructor(){super(...arguments),this.loaders=new Uo,this._loadersMap=new Map,this._pendingAction=null}static get pluginName(){return"FileRepository"}static get requires(){return[zu]}init(){this.loaders.on("change",(()=>this._updatePendingAction())),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return v("filerepository-no-upload-adapter"),null;const t=new lC(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof lC?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,i)=>{e===t&&this._loadersMap.delete(i)}))}_updatePendingAction(){const e=this.editor.plugins.get(zu);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}class lC extends(U()){constructor(e,t){super(),this.id=f(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new rC,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new _("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new _("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,i(e)})).catch((e=>{t.isFulfilled=!0,n(e)}))})),t}}class cC extends Ss{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.uploadStatusChange=(e,t,i)=>{const n=this.editor,o=t.item,s=o.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(aC),l=s?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(o),h=i.writer;if("reading"==l)return dC(d,h),void hC(r,c,d,h);if("uploading"==l){const e=a.loaders.get(s);return dC(d,h),void(e?(uC(d,h),function(e,t,i,n){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",o)}))}))}(d,h,e,n.editing.view),function(e,t,i,n){if(n.data){const o=e.findViewImgElement(t);i.setAttribute("src",n.data,o)}}(r,d,h,e)):hC(r,c,d,h))}"complete"==l&&a.loaders.get(s)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(d,h,n.editing.view),function(e,t){gC(e,t,"progressBar")}(d,h),uC(d,h),function(e,t){t.removeClass("ck-appear",e)}(d,h)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function dC(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function hC(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const o=e.findViewImgElement(i);o.getAttribute("src")!==t&&n.setAttribute("src",t,o),mC(i,"placeholder")||n.insert(n.createPositionAfter(o),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function uC(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),gC(e,t,"placeholder")}function mC(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function gC(e,t,i){const n=mC(e,i);n&&t.remove(t.createRangeOn(n))}class fC extends Is{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=vo(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if(t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);this._uploadImage(e,o,t)}else this._uploadImage(e,o)}))}_uploadImage(e,t,i){const n=this.editor,o=n.plugins.get(aC).createLoader(e),s=n.plugins.get("ImageUtils");o&&s.insertImage({...t,uploadId:o.id},i)}}class pC extends Ss{static get requires(){return[aC,If,Bw,Sk]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(aC),o=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline"),r=iC(e.config.get("image.upload.types")),a=new fC(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const o=Array.from(i.dataTransfer.files).filter((e=>!!e&&r.test(e.type)));o.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.execute("uploadImage",{file:o})})))})),this.listenTo(s,"inputTransformation",((t,i)=>{const s=Array.from(e.editing.view.createRangeIn(i.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(o,e)&&!e.getAttribute("uploadProcessed"))).map((e=>({promise:nC(e),imageElement:e})));if(!s.length)return;const r=new qh(e.editing.view.document);for(const e of s){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),o=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,s="$graveyard"==t.position.root.rootName;for(const t of bC(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=n.loaders.get(e);i&&(s?o.has(e)||i.abort():(o.add(e),this._uploadImageElements.set(e,t),"idle"==i.status&&this._readAndUpload(i)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e),o.setImageNaturalSizeAttributes(t)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,o=t.plugins.get(aC),s=t.plugins.get(If),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",l.get(e.id))})),e.read().then((()=>{const o=e.upload(),s=l.get(e.id);if(r.isSafari){const e=t.editing.mapper.toViewElement(s),i=a.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}return t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Uploading image")),i.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",s)})),o})).then((o=>{i.enqueueChange({isUndoable:!1},(i=>{const s=l.get(e.id);i.setAttribute("uploadStatus","complete",s),t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Image upload complete")),this.fire("uploadComplete",{data:o,imageElement:s})})),c()})).catch((o=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw o;"error"==e.status&&o&&s.showWarning(o,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},(t=>{t.remove(l.get(e.id))})),c()}));function c(){i.enqueueChange({isUndoable:!1},(t=>{const i=l.get(e.id);t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i),l.delete(e.id)})),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");if(""!=o){const e={srcset:o};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}}function bC(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}const wC=function(e,t){return function(i,n){if(null==i)return i;if(!ri(i))return e(i,n);for(var o=i.length,s=t?o:-1,r=Object(i);(t?s--:++s{t.setAttribute("resizedWidth",e.width,o),t.removeAttribute("resizedHeight",o),n.setImageNaturalSizeAttributes(o)}))}}class kC extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new yC(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add((t=>t.on(`attribute:resizedWidth:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,o),n.addClass("image_resized",o)):(n.removeStyle("width",o),n.removeClass("image_resized",o))})))),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:e=>({key:"style",value:{height:e}})}),t.conversion.for("editingDowncast").add((t=>t.on(`attribute:resizedHeight:${e}`,((t,n,o)=>{if(!o.consumable.consume(n.item,t.name))return;const s=o.writer,r=o.mapper.toViewElement(n.item),a="imageInline"===e?i.findViewImgElement(r):r;null!==n.attributeNewValue?s.setStyle("height",n.attributeNewValue,a):s.removeStyle("height",a)})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:e=>Ek(e)?null:e.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:e=>Ek(e)?null:e.getStyle("height")}})}}const CC={small:Hu.objectSizeSmall,medium:Hu.objectSizeMedium,large:Hu.objectSizeLarge,custom:Hu.objectSizeCustom,original:Hu.objectSizeFull};class AC extends Ss{static get requires(){return[kC]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:o}=e;t.ui.componentFactory.add(i,(i=>{const s=new Yu(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!CC[o])throw new _("imageresizebuttons-missing-icon",t,e);if(s.set({label:a,icon:CC[o],tooltip:a,isToggleable:!0}),s.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&xC(e)){const e=t.plugins.get("ImageCustomResizeUI");this.listenTo(s,"execute",(()=>{e._showForm(this._resizeUnit)}))}else{const e=n?n+this._resizeUnit:null;s.bind("isOn").to(r,"value",EC(e)),this.listenTo(s,"execute",(()=>{t.execute("resizeImage",{width:e})}))}return s}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),o=o=>{const s=t.commands.get("resizeImage"),r=zm(o,Cm),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:CC.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(s,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isEnabled").to(this),Wm(r,(()=>this._getResizeDropdownListItemDefinitions(e,s)),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",(e=>{"onClick"in e.source?e.source.onClick():(t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus())})),r};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?xC(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):xC(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new Uo,o=e.map((e=>xC(e)?{...e,valueWithUnits:"custom"}:e.value?{...e,valueWithUnits:`${e.value}${this._resizeUnit}`}:{...e,valueWithUnits:null}));for(const e of o){let s=null;if(i.plugins.has("ImageCustomResizeUI")&&xC(e)){const n=i.plugins.get("ImageCustomResizeUI");s={type:"button",model:new Vf({label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{n._showForm(this._resizeUnit)}})};const r=vC(o,"valueWithUnits");s.model.bind("isOn").to(t,"value",TC(r))}else s={type:"button",model:new Vf({commandName:"resizeImage",commandValue:e.valueWithUnits,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})},s.model.bind("isOn").to(t,"value",EC(e.valueWithUnits));s.model.bind("isEnabled").to(t,"isEnabled"),n.add(s)}return n}}function xC(e){return"custom"===e.value}function EC(e){return t=>null===e&&t===e||null!==t&&t.width===e}function TC(e){return t=>!e.some((e=>EC(e)(t)))}const SC="image_resized";class PC extends Ss{static get requires(){return[p_,Sk]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(Dk),this.listenTo(t.document,"imageLoaded",((n,o)=>{if(!o.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const s=e.editing.view.domConverter,r=s.domToView(o.target),a=i.getImageWidgetFromImageView(r);let l=this.editor.plugins.get(p_).getResizerByViewElement(a);if(l)return void l.redraw();const c=e.editing.mapper,d=c.toModelElement(a);l=e.plugins.get(p_).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:a,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>s.mapViewToDom(c.toViewElement(d)),isCentered:()=>"alignCenter"==d.getAttribute("imageStyle"),onCommit(i){t.change((e=>{e.removeClass(SC,a)})),e.execute("resizeImage",{width:i})}}),l.on("updateSize",(()=>{a.hasClass(SC)||t.change((e=>{e.addClass(SC,a)}));const e="imageInline"===d.name?r:a;e.getStyle("height")&&t.change((t=>{t.removeStyle("height",e)}))})),l.bind("isEnabled").to(this)}))}}function IC(e){if(!e)return null;const[,t,i]=e.trim().match(/([.,\d]+)(%|px)$/)||[],n=Number.parseFloat(t);return Number.isNaN(n)?null:{value:n,unit:i}}function VC(e,t,i){return"px"===i?{value:t.value,unit:"px"}:{value:t.value/e*100,unit:"%"}}function RC(e){const{editing:t}=e,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);if(!i)return null;const n=t.mapper.toViewElement(i);return{model:i,view:n,dom:t.view.domConverter.mapViewToDom(n)}}class OC extends Cs{constructor(e,t,i){super(e);const n=this.locale.t;this.focusTracker=new Go,this.keystrokes=new Ko,this.unit=t,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(n("Save"),Hu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Hu.cancel,"ck-button-cancel","cancel"),this._focusables=new ts,this._validators=i,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Es({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const o=new Yu(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new fm(this.locale,Km);return t.label=e("Resize image (in %0)",this.unit),t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(null===e)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return null===e?null:`${e}${t}`}}class BC extends Ss{static get requires(){return[Of]}static get pluginName(){return"ImageCustomResizeUI"}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(xs(OC))(t.locale,e,function(e){const t=e.t;return[e=>""===e.rawSize.trim()?t("The value must not be empty."):null===e.parsedSize?t("The value should be a plain number."):void 0]}(t)),this._form.render(),this.listenTo(this._form,"submit",(()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))})),this.listenTo(this._form.labeledInput,"change:errorText",(()=>{t.ui.update()})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),As({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:Ok(t)});const n=function(e,t){const i=RC(e);if(!i)return null;const n=IC(i.model.getAttribute("resizedWidth")||null);return n?n.unit===t?n:VC(Jw(i.dom),{unit:"px",value:new Nn(i.dom).width},t):null}(t,e),o=n?n.value.toFixed(1):"",s=function(e,t){const i=RC(e);if(!i)return null;const n=Jw(i.dom),o=IC(window.getComputedStyle(i.dom).minWidth)||{value:1,unit:"px"};return{unit:t,lower:Math.max(.1,VC(n,o,t).value),upper:"px"===t?n:100}}(t,e);i.fieldView.value=i.fieldView.element.value=o,s&&Object.assign(i.fieldView,{min:s.lower.toFixed(1),max:Math.ceil(s.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class MC extends Is{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const o=e.value,{setImageSizes:s=!0}=e;let r=n.getClosestSelectedImageElement(i.document.selection);o&&this.shouldConvertImageType(o,r)&&(this.editor.execute(n.isBlockImage(r)?"imageTypeInline":"imageTypeBlock",{setImageSizes:s}),r=n.getClosestSelectedImageElement(i.document.selection)),!o||this._styles.get(o).isDefault?t.removeAttribute("imageStyle",r):t.setAttribute("imageStyle",o,r),s&&n.setImageNaturalSizeAttributes(r)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const{objectFullWidth:FC,objectInline:NC,objectLeft:DC,objectRight:LC,objectCenter:zC,objectBlockLeft:HC,objectBlockRight:$C}=Hu,WC={get inline(){return{name:"inline",title:"In line",icon:NC,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:DC,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:HC,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:zC,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:LC,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:$C,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:zC,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:LC,modelElements:["imageBlock"],className:"image-style-side"}}},jC={full:FC,left:HC,right:$C,center:zC,inlineLeft:DC,inlineRight:LC,inline:NC},UC=[{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 qC(e){v("image-style-configuration-definition-invalid",e)}const GC={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>function(e){e="string"==typeof e?WC[e]?{...WC[e]}:{name:e}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(WC[e.name],e);"string"==typeof e.icon&&(e.icon=jC[e.icon]||e.icon);return e}(e))).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:o}=e;if(!(n&&n.length&&o))return qC({style:e}),!1;{const o=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>o.includes(e))))return v("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...UC]:[]},warnInvalidStyle:qC,DEFAULT_OPTIONS:WC,DEFAULT_ICONS:jC,DEFAULT_DROPDOWN_DEFINITIONS:UC};function KC(e,t){for(const i of t)if(i.name===e)return i}class ZC extends Ss{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[Sk]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=GC,i=this.editor,n=i.plugins.has("ImageBlockEditing"),o=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(n,o)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:n,isInlinePluginLoaded:o}),this._setupConversion(n,o),this._setupPostFixer(),i.commands.add("imageStyle",new MC(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,o=(s=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=KC(t.attributeNewValue,s),o=KC(t.attributeOldValue,s),r=i.mapper.toViewElement(t.item),a=i.writer;o&&a.removeClass(o.className,r),n&&a.addClass(n.className,r)});var s;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=qo(i.modelRange.getItems());if(s&&n.schema.checkAttribute(s,"imageStyle"))for(const e of t[s.name])n.consumable.consume(o,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,s)}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",o),i.data.downcastDispatcher.on("attribute:imageStyle",o),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(Sk),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let o=!1;for(const s of t.differ.getChanges())if("insert"==s.type||"attribute"==s.type&&"imageStyle"==s.attributeKey){let t="insert"==s.type?s.position.nodeAfter:s.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),o=!0)}return o}))}}class JC extends Ss{static get requires(){return[ZC]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=YC(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=YC([...t.filter(N),...GC.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let o;const{defaultItem:s,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>QC(t)===e)))).map((e=>{const t=i.create(e);return e===s&&(o=t),t}));r.length!==l.length&&GC.warnInvalidStyle({dropdown:e});const c=zm(n,Lm),d=c.buttonView,h=d.arrowView;return Hm(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:XC(a,o.label),class:null,tooltip:!0}),h.unbind("label"),h.set({label:a}),d.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(So);return t<0?o.icon:l[t].icon})),d.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(So);return XC(a,t<0?o.label:l[t].label)})),d.bind("isOn").toMany(l,"isOn",((...e)=>e.some(So))),d.bind("class").toMany(l,"isOn",((...e)=>e.some(So)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:o.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(So))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(QC(t),(i=>{const n=this.editor.commands.get("imageStyle"),o=new Yu(i);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>e===t)),o.on("execute",this._executeCommand.bind(this,t)),o}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function YC(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function QC(e){return`imageStyle:${e}`}function XC(e,t){return(e?e+": ":"")+t}class eA extends Ss{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new Rs(e)),e.commands.add("outdent",new Rs(e))}}class tA extends Ss{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Hu.indent:Hu.outdent,o="ltr"==t.uiLanguageDirection?Hu.outdent:Hu.indent;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),o)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(()=>{const n=this._createButton(Yu,e,t,i);return n.set({tooltip:!0}),n})),n.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(pp,e,t,i)))}_createButton(e,t,i,n){const o=this.editor,s=o.commands.get(t),r=new e(o.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(s,"isEnabled"),this.listenTo(r,"execute",(()=>{o.execute(t),o.editing.view.focus()})),r}}class iA extends Is{constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=qo(this.editor.model.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter((e=>this._isIndentationChangeAllowed(e)))}_isIndentationChangeAllowed(e){const t=this.editor;if(!t.model.schema.checkAttribute(e,"blockIndent"))return!1;if(!t.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!t.plugins.get("ListUtils").isListItemBlock(e)}}class nA{constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class oA{constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const sA=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class rA{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const s=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,s);for(const t in e.styles)n.setStyle(t,e.styles[t],s);n.setCustomProperty("link",!0,s),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),s):n.wrap(i.mapper.toViewRange(t.range),s):n.unwrap(i.mapper.toViewRange(t.range),s)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const o=n.toViewElement(t.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));for(const e of this._definitions){const n=Zo(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,s):i.setAttribute(e,t,s);e.classes&&i.addClass(e.classes,s);for(const t in e.styles)i.setStyle(t,e.styles[t],s)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,s):i.removeAttribute(e,s);e.classes&&i.removeClass(e.classes,s);for(const t in e.styles)i.removeStyle(t,s)}}}))}}}const aA=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,lA=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,cA=/^((\w+:(\/{2,})?)|(\W))/i,dA=["https?","ftps?","mailto"],hA="Ctrl+K";function uA(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function mA(e,t=dA){const i=String(e),n=t.join("|");return function(e,t){const i=e.replace(aA,"");return!!i.match(t)}(i,new RegExp(`${"^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("",n)}`,"i"))?i:"#"}function gA(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function fA(e,t){const i=(n=e,lA.test(n)?"mailto:":t);var n;const o=!!i&&!pA(e);return e&&o?i+e:e}function pA(e){return cA.test(e)}function bA(e){window.open(e,"_blank","noopener")}class wA extends Is{constructor(){super(...arguments),this.manualDecorators=new Uo,this.automaticDecorators=new rA}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||qo(t.getSelectedBlocks());gA(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,o=[],s=[];for(const e in t)t[e]?o.push(e):s.push(e);i.change((t=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=_A(n);let l=vb(r,"linkHref",n.getAttribute("linkHref"),i);n.getAttribute("linkHref")===a&&(l=this._updateLinkContent(i,t,l,e)),t.setAttribute("linkHref",e,l),o.forEach((e=>{t.setAttribute(e,!0,l)})),s.forEach((e=>{t.removeAttribute(e,l)})),t.setSelection(t.createPositionAfter(l.end.nodeBefore))}else if(""!==e){const s=Zo(n.getAttributes());s.set("linkHref",e),o.forEach((e=>{s.set(e,!0)}));const{end:a}=i.insertContent(t.createText(e,s),r);t.setSelection(a)}["linkHref",...o,...s].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const r=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of r)this._isRangeToUpdate(e,a)&&l.push(e);for(const r of l){let a=r;if(1===l.length){const o=_A(n);n.getAttribute("linkHref")===o&&(a=this._updateLinkContent(i,t,r,e),t.setSelection(t.createSelection(a)))}t.setAttribute("linkHref",e,a),o.forEach((e=>{t.setAttribute(e,!0,a)})),s.forEach((e=>{t.removeAttribute(e,a)}))}}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return gA(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}_updateLinkContent(e,t,i,n){const o=t.createText(n,{linkHref:n});return e.insertContent(o,i)}}function _A(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const i=t[0];return i.is("$text")||i.is("$textProxy")?i.data:null}}class vA extends Is{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();gA(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const o=i.isCollapsed?[vb(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class yA extends(U()){constructor({id:e,label:t,attributes:i,classes:n,styles:o,defaultValue:s}){super(),this.id=e,this.set("value",void 0),this.defaultValue=s,this.label=t,this.attributes=i,this.classes=n,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const kA="automatic",CA=/^(https?:)?\/\//;class AA extends Ss{static get pluginName(){return"LinkEditing"}static get requires(){return[ub,Xp,Bw]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:uA}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>uA(mA(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new wA(e)),e.commands.add("unlink",new vA(e));const i=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${Dy(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter((e=>e.mode===kA))),this._enableManualDecorators(i.filter((e=>"manual"===e.mode)));e.plugins.get(ub).registerAttribute("linkHref"),function(e,t,i,n){const o=e.editing.view,s=new Set;o.document.registerPostFixer((o=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=vb(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(o.addClass(n,e),s.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of s.values())e.removeClass(n,t),s.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:kA,callback:e=>!!e&&CA.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new yA(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:o})=>{if((o.is("selection")||i.isInline(o))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((e,t)=>{if(!(r.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let i=t.domTarget;if("a"!=i.tagName.toLowerCase()&&(i=i.closest("a")),!i)return;const n=i.getAttribute("href");n&&(e.stop(),t.preventDefault(),bA(n))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,i)=>{const n=e.commands.get("link").value;!!n&&i.keyCode===go.enter&&i.altKey&&(t.stop(),bA(n))}))}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{n.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change((t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))))}))}))}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,n)=>{t.change((e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=fA(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}}))}))}}class xA extends Cs{constructor(e,t,i){super(e),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts;const n=e.t;this._validators=i,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Hu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Hu.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),Es({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createUrlInput(){const e=this.locale.t,t=new fm(this.locale,Gm);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const o=new Yu(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new Qu(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",((e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e)),n.on("execute",(()=>{i.set("value",!n.isOn)})),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Cs;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class EA extends Cs{constructor(e,t={}){super(e),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts;const i=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(i("Unlink"),'',"unlink"),this.editButtonView=this._createButton(i("Edit link"),Hu.pencil,"edit"),this.set("href",void 0),this._linkConfig=t,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new Yu(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new Yu(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&mA(e,this._linkConfig.allowedProtocols))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||i("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}const TA="link-ui";class SA extends Ss{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[Of]}static get pluginName(){return"LinkUI"}init(){const e=this.editor,t=this.editor.t;e.editing.view.addObserver(jh),this._balloon=e.plugins.get(Of),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:TA,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:TA,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:hA},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new EA(e.locale,e.config.get("link")),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(hA,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new(xs(xA))(e.locale,t,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isEnabled").to(t,"isEnabled"),n.saveButtonView.bind("isEnabled").to(t,"isEnabled"),this.listenTo(n,"submit",(()=>{if(n.isValid()){const{value:t}=n.urlInputView.fieldView.element,o=fA(t,i);e.execute("link",o,n.getDecoratorSwitchesState()),this._closeFormView()}})),this.listenTo(n.urlInputView,"change:errorText",(()=>{e.ui.update()})),this.listenTo(n,"cancel",(()=>{this._closeFormView()})),n.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link");e.ui.componentFactory.add("link",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0,isToggleable:!0}),e.bind("isOn").to(t,"value",(e=>!!e)),e})),e.ui.componentFactory.add("menuBar:link",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),o=new e(t.locale),s=i.t;return o.set({label:s("Link"),icon:'',keystroke:hA}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>this._showUI(!0))),o}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(hA,((t,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),As({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=s();const o=()=>{const e=this._getSelectedLinkElement(),t=s();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function s(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n;if(t.markers.has(TA)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(TA)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&$w(i))return PA(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=PA(i.start),o=PA(i.end);return n&&n==o&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(TA))t.updateMarker(TA,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(TA,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(TA,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(TA)&&e.change((e=>{e.removeMarker(TA)}))}}function PA(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const IA=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 VA extends Ss{static get requires(){return[lb,AA]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?vb(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,o=n.getFirstPosition(),s=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,o)||t);r&&(r=r.getJoined(this._expandLinkRange(i,s)||t)),r&&(r.start.isBefore(o)||r.end.isAfter(s))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),o=e.commands.get("link");n.on("inputTransformation",((e,n)=>{if(!this.isEnabled||!o.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const s=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(IA);a&&a[2]===r&&(t.change((e=>{this._selectEntireLinks(e,s),o.execute(r)})),e.stop())}),{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new hb(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=RA(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:o,url:s}=i;if(!n.isTyping)return;const r=o.end.getShiftedBy(-1),a=r.getShiftedBy(-s.length),l=e.model.createRange(a,r);this._applyAutoLink(s,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=db(e,t),o=RA(i);if(o){const e=t.createRange(n.end.getShiftedBy(-o.length),n.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=fA(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&pA(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange((o=>{o.setAttribute("linkHref",e,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function RA(e){const t=IA.exec(e);return t?t[2]:null}class OA{constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=vo(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){return qo(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of BA(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some((e=>t.getAttribute(e)!==this._startElement.getAttribute(e))))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}function*BA(e,t="forward"){const i="forward"==t,n=[];let o=null;for(;NA(e);){let t=null;if(o){const i=e.getAttribute("listIndent"),s=o.getAttribute("listIndent");i>s?n[s]=o:ie.getAttribute("listItemId")!=t))}function JA(e){return Array.from(e).filter((e=>"$graveyard"!==e.root.rootName)).sort(((e,t)=>e.index-t.index))}function YA(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function QA(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function XA(e){return"numbered"==e||"customNumbered"==e}function ex(e,t,i){return LA(t,{direction:"forward"}).pop().index>e.index?qA(e,t,i):[]}class tx extends Is{constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=ix(e.document.selection);e.change((e=>{const i=[];ZA(t)&&!HA(t[0])?("forward"==this._direction&&i.push(...GA(t,e)),i.push(...UA(t[0],e))):"forward"==this._direction?i.push(...GA(t,e,{expand:!0})):i.push(...function(e,t){const i=WA(e=vo(e)),n=new Set,o=Math.min(...i.map((e=>e.getAttribute("listIndent")))),s=new Map;for(const e of i)s.set(e,OA.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)KA(e,t);else{if(e.getAttribute("listIndent")==o){const i=ex(e,s.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return JA(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=OA.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)}))}_fireAfterExecute(e){this.fire("afterExecute",JA(new Set(e)))}_checkEnabled(){let e=ix(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(ZA(e)&&!HA(e[0]))return!0;e=WA(e),t=e[0];const i=OA.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function ix(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex((e=>!NA(e)));return-1!=i&&(t.length=i),t}class nx extends Is{constructor(e,t,i={}){super(e),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=YA(t),o=Array.from(i.selection.getSelectedBlocks()).filter((e=>t.schema.checkAttribute(e,"listType")||QA(e,t.schema))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((r=>{if(s){const e=o[o.length-1],t=LA(e,{direction:"forward"}),i=[];t.length>1&&i.push(...UA(t[1],r)),i.push(...KA(o,r)),i.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:o}of BA(e.nextSibling,"forward")){const e=o.getAttribute("listIndent");if(0==e)break;e{const{firstElement:s,lastElement:r}=this._getMergeSubjectElements(i,e),a=s.getAttribute("listIndent")||0,l=r.getAttribute("listIndent"),c=r.getAttribute("listItemId");if(a!=l){const e=(d=r,Array.from(new OA(d,{direction:"forward",higherIndent:!0})));n.push(...GA([r,...e],o,{indentBy:a-l,expand:a{const t=UA(this._getStartBlock(),e);this._fireAfterExecute(t)}))}_fireAfterExecute(e){this.fire("afterExecute",JA(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&NA(t)&&!HA(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class rx extends Ss{static get pluginName(){return"ListUtils"}expandListBlocksToCompleteList(e){return jA(e)}isFirstBlockOfListItem(e){return HA(e)}isListItemBlock(e){return NA(e)}expandListBlocksToCompleteItems(e,t={}){return WA(e,t)}isNumberedListType(e){return XA(e)}}function ax(e){return e.is("element","ol")||e.is("element","ul")}function lx(e){return e.is("element","li")}function cx(e,t,i,n=ux(i,t)){return e.createAttributeElement(hx(i),null,{priority:2*t/100-100,id:n})}function dx(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function hx(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function ux(e,t){return`list-${e}-${t}`}function mx(e,t){const i=e.nodeBefore;if(NA(i)){let e=i;for(const{node:i}of BA(e,"backward"))if(e=i,t.has(e))return;t.set(i,e)}else{const i=e.nodeAfter;NA(i)&&t.set(i,i)}}function gx(){return(e,t,i)=>{const{writer:n,schema:o}=i;if(!t.modelRange)return;const s=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>o.checkAttribute(e,"listItemId")));if(!s.length)return;const r=FA.next(),a=function(e){let t=0,i=e.parent;for(;i;){if(lx(i))t++;else{const e=i.previousSibling;e&&lx(e)&&t++}i=i.parent}return t}(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=s[0].getAttribute("listType");c&&(l=c);const d={listItemId:r,listIndent:a,listType:l};for(const e of s)e.hasAttribute("listItemId")||n.setAttributes(d,e);s.length>1&&s[1].getAttribute("listItemId")!=d.listItemId&&i.keepEmptyElement(s[0])}}function fx(){return(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0}))return;const n=new qh(t.viewItem.document);for(const e of Array.from(t.viewItem.getChildren()))lx(e)||ax(e)||n.remove(e)}}function px(e,t,i,{dataPipeline:n}={}){const o=function(e){return(t,i)=>{const n=[];for(const i of e)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every((e=>!1!==i.test(t,e)))&&(n.forEach((e=>i.consume(t,e))),!0)}}(e);return(s,r,a)=>{const{writer:l,mapper:c,consumable:d}=a,h=r.item;if(!e.includes(r.attributeKey))return;if(!o(h,d))return;const u=function(e,t,i){const n=i.createRangeOn(e),o=t.toViewRange(n).getTrimmed();return o.end.nodeBefore}(h,c,i);wx(u,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(u,l);const m=function(e,t,i,n,{dataPipeline:o}){let s=n.createRangeOn(t);if(!HA(e))return s;for(const r of i){if("itemMarker"!=r.scope)continue;const i=r.createElement(n,e,{dataPipeline:o});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(s.start,i),s=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!r.createWrapperElement||!r.canWrapElement)continue;const a=r.createWrapperElement(n,e,{dataPipeline:o});n.setCustomProperty("listItemWrapper",!0,a),r.canWrapElement(e)?s=n.wrap(s,a):(s=n.wrap(n.createRangeOn(i),a),s=n.createRange(s.start,n.createPositionAfter(t)))}return s}(h,u,t,l,{dataPipeline:n});!function(e,t,i,n){if(!e.hasAttribute("listIndent"))return;const o=e.getAttribute("listIndent");let s=e;for(let e=o;e>=0;e--){const o=dx(n,e,s.getAttribute("listItemId")),r=cx(n,e,s.getAttribute("listType"));for(const e of i)"list"!=e.scope&&"item"!=e.scope||!s.hasAttribute(e.attributeName)||e.setAttributeOnDowncast(n,s.getAttribute(e.attributeName),"list"==e.scope?r:o);if(t=n.wrap(t,o),t=n.wrap(t,r),0==e)break;if(s=OA.first(s,{lowerIndent:!0}),!s)break}}(h,m,t,l)}}function bx(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!_x(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function wx(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];o(t.createPositionBefore(e).getWalker({direction:"backward"})),o(t.createRangeIn(e).getWalker());for(const e of n)t.remove(e);function o(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function _x(e,t,i=DA(e)){if(!NA(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return i.length<2}const vx=["listType","listIndent","listItemId"];class yx extends Ss{static get pluginName(){return"ListEditing"}static get requires(){return[Lb,lb,rx,Bw]}constructor(e){super(e),this._downcastStrategies=[],e.config.define("list.multiBlock",!0)}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new _("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:vx}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const e of vx)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new nx(e,"numbered")),e.commands.add("bulletedList",new nx(e,"bulleted")),e.commands.add("customNumberedList",new nx(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new nx(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new tx(e,"forward")),e.commands.add("outdentList",new tx(e,"backward")),e.commands.add("splitListItemBefore",new sx(e,"before")),e.commands.add("splitListItemAfter",new sx(e,"after")),i&&(e.commands.add("mergeListItemBackward",new ox(e,"backward")),e.commands.add("mergeListItemForward",new ox(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...vx,...this._downcastStrategies.map((e=>e.attributeName))]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",((n,o)=>{const s=e.model.document.selection;YA(e.model)||e.model.change((()=>{const r=s.getFirstPosition();if(s.isCollapsed&&"backward"==o.direction){if(!r.isAtStart)return;const i=r.parent;if(!NA(i))return;if(OA.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:kx(e.model,"backward")})}else $A(i)||e.execute("splitListItemAfter"),e.execute("outdentList");o.preventDefault(),n.stop()}else{if(s.isCollapsed&&!s.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:kx(e.model,"forward")}),o.preventDefault(),n.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",((i,n)=>{const o=t.document,s=o.selection.getFirstPosition().parent;if(o.selection.isCollapsed&&NA(s)&&s.isEmpty&&!n.isSoft){const t=HA(s),o=$A(s);t&&o?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!o?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):o&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}}),{context:"li"}),this.listenTo(n,"afterExecute",(()=>{const t=i.get("splitListItemBefore");if(t.refresh(),!t.isEnabled)return;2===DA(e.model.document.selection.getLastPosition().parent).length&&t.execute()}))}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),o=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,{writer:t})=>t.createElement(o,{listType:""})}).elementToElement({view:"p",model:(e,{writer:t})=>e.parent&&e.parent.is("element","li")?t.createElement(o,{listType:""}):null,converterPriority:"high"}).add((e=>{e.on("element:li",gx()),e.on("element:ul",fx(),{priority:"high"}),e.on("element:ol",fx(),{priority:"high"})})),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:o,view:bx(i),converterPriority:"high"}).add((e=>{var n;e.on("attribute",px(i,this._downcastStrategies,t)),e.on("remove",(n=t.schema,(e,t,i)=>{const{writer:o,mapper:s}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=s.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=s.toViewPosition(l,{isPhantom:!0}),d=o.createRange(a,c).getTrimmed().end.nodeBefore;d&&wx(d,o,s)}))})),e.conversion.for("dataDowncast").elementToElement({model:o,view:bx(i,{dataPipeline:!0}),converterPriority:"high"}).add((e=>{e.on("attribute",px(i,this._downcastStrategies,t,{dataPipeline:!0}))}));const s=(r=this._downcastStrategies,a=e.editing.view,(e,t)=>{if(t.modelPosition.offset>0)return;const i=t.modelPosition.parent;if(!NA(i))return;if(!r.some((e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(i))))return;const n=t.mapper.toViewElement(i),o=a.createRangeIn(n),s=o.getWalker();let l=o.start;for(const{item:e}of s){if(e.is("element")&&t.mapper.toModelElement(e)||e.is("$textProxy"))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(e),s.skip((({previousPosition:e})=>!e.isEqual(l))))}t.viewPosition=l});var r,a;e.editing.mapper.on("modelToViewPosition",s),e.data.mapper.on("modelToViewPosition",s),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Map,l=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)mx(e.position,a),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):mx(e.position.getShiftedBy(e.length),a);else if("remove"==e.type&&e.attributes.has("listItemId"))mx(e.position,a);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(mx(e.range.start,a),null===e.attributeNewValue?(mx(e.range.start.getShiftedBy(1),a),s(t)&&r.push(t)):l.add(t)):NA(t)&&s(t)&&r.push(t)}for(const e of a.values())r.push(...o(e,l));for(const e of new Set(r))t.reconvertItem(e)};function o(e,t){const n=[],o=new Set,a=[];for(const{node:l,previous:c}of BA(e,"forward")){if(o.has(l))continue;const e=l.getAttribute("listIndent");c&&ei.includes(e))));const d=LA(l,{direction:"forward"});for(const e of d)o.add(e),(s(e,d)||r(e,a,t))&&n.push(e)}return n}function s(e,o){const s=t.mapper.toViewElement(e);if(!s)return!1;if(n.fire("checkElement",{modelElement:e,viewElement:s}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=_x(e,i,o);return!(!r||!s.is("element","p"))||!(r||!s.is("element","span"))}function r(e,i,o){if(o.has(e))return!1;const s=t.mapper.toViewElement(e);let r=i.length-1;for(let e=s.parent;!e.is("editableElement");e=e.parent){const t=lx(e),o=ax(e);if(!o&&!t)continue;const s="checkAttributes:"+(t?"item":"list");if(n.fire(s,{viewElement:e,modelAttributes:i[r]}))break;if(o&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",((e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())})),this.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{t.name==hx(i.listType)&&t.id==ux(i.listType,i.listIndent)||(e.return=!0,e.stop())}))}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer((i=>function(e,t,i,n){const o=e.document.differ.getChanges(),s=new Map,r=n.editor.config.get("list.multiBlock");let a=!1;for(const n of o){if("insert"==n.type&&"$text"!=n.name){const o=n.position.nodeAfter;if(!e.schema.checkAttribute(o,"listItemId"))for(const e of Array.from(o.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,o),a=!0);mx(n.position,s),n.attributes.has("listItemId")||mx(n.position.getShiftedBy(n.length),s);for(const{item:t,previousPosition:i}of e.createRangeIn(o))NA(t)&&mx(i,s)}else"remove"==n.type?mx(n.position,s):"attribute"==n.type&&i.includes(n.attributeKey)&&(mx(n.range.start,s),null===n.attributeNewValue&&mx(n.range.start.getShiftedBy(1),s));if(!r&&"attribute"==n.type&&vx.includes(n.attributeKey)){const e=n.range.start.nodeAfter;null===n.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),a=!0):null===n.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),a=!0)}}const l=new Set;for(const e of s.values())a=n.fire("postFixer",{listNodes:new MA(e),listHead:e,writer:t,seenIds:l})||a;return a}(e,i,t,this))),this.on("postFixer",((e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,o=null,s=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===o?(o=e-i,a=i):(o>e&&(o=e),a=e-o),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),s=!0,n=a}else o=null,i=e+1,n=e}return s}(t,i)||e.return}),{priority:"high"}),this.on("postFixer",((e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let o=!1;for(const{node:s}of e){if(n.has(s))continue;let e=s.getAttribute("listType"),r=s.getAttribute("listItemId");if(t.has(r)&&(r=FA.next()),t.add(r),s.is("element","listItem"))s.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,s),o=!0);else for(const t of LA(s,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=FA.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),o=!0)}return o}(t,n,i)||e.return}),{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const o=i.is("documentFragment")?Array.from(i.getChildren()):[i];if(!o.length)return;const s=(n?e.createSelection(n):e.document.selection).getFirstPosition();let r;if(NA(s.parent))r=s.parent;else{if(!NA(s.nodeBefore))return;r=s.nodeBefore}e.change((e=>{const t=r.getAttribute("listType"),i=r.getAttribute("listIndent"),n=o[0].getAttribute("listIndent")||0,s=Math.max(i-n,0);for(const i of o){const n=NA(i);r.is("element","listItem")&&i.is("element","paragraph")&&e.rename(i,"listItem"),e.setAttributes({listIndent:(n?i.getAttribute("listIndent"):0)+s,listItemId:n?i.getAttribute("listItemId"):FA.next(),listType:t},i)}}))}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",((t,i)=>{e.change((e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty){t.slice(0,-1).every(NA)&&e.remove(n)}if("copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());ZA(t)&&KA(t,e)}}))}))}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function kx(e,t){const i=e.document.selection;if(!i.isCollapsed)return!YA(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,o=n.previousSibling;return!e.schema.isObject(o)&&(!!o.isEmpty||ZA([n,o]))}function Cx(e,t,i,n){e.ui.componentFactory.add(t,(()=>{const o=Ax(Yu,e,t,i,n);return o.set({tooltip:!0,isToggleable:!0}),o})),e.ui.componentFactory.add(`menuBar:${t}`,(()=>Ax(pp,e,t,i,n)))}function Ax(e,t,i,n,o){const s=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:o}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",(()=>{t.execute(i),t.editing.view.focus()})),r}class xx extends Ss{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||Cx(this.editor,"numberedList",e("Numbered List"),Hu.numberedList),this.editor.ui.componentFactory.has("bulletedList")||Cx(this.editor,"bulletedList",e("Bulleted List"),Hu.bulletedList)}}class Ex extends Ss{static get requires(){return[yx,xx]}static get pluginName(){return"List"}}const Tx={},Sx={},Px={},Ix=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of Ix)Tx[e]=i,Sx[e]=t,t&&(Px[t]=e);bo("Ctrl+Enter");bo("Ctrl+Enter");const Vx={"(":")","[":"]","{":"}"};class Rx extends Is{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,o=n.id,s=e.range||i.getFirstRange();if(!t.canEditAt(s))return;const r=e.text||o,a=Bx({_text:r,id:o},n);if(1!=e.marker.length)throw new _("mentioncommand-incorrect-marker",this);if(o.charAt(0)!=e.marker)throw new _("mentioncommand-incorrect-id",this);t.change((e=>{const n=Zo(i.getAttributes()),o=new Map(n.entries());o.set("mention",a);const l=t.insertContent(e.createText(r,o),s),c=l.start.nodeBefore,d=l.end.nodeAfter,h=d&&d.is("$text")&&d.data.startsWith(" ");let u=!1;if(c&&d&&c.is("$text")&&d.is("$text")){const e=c.data.slice(-1),t=e in Vx,i=t&&d.data.startsWith(Vx[e]);u=t&&i}u||h||t.insertContent(e.createText(" ",n),s.start.getShiftedBy(r.length))}))}}class Ox extends Ss{static get pluginName(){return"MentionEditing"}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",key:"data-mention",classes:"mention"},model:{key:"mention",value:e=>Mx(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:Nx}),e.conversion.for("downcast").add(Fx),i.registerPostFixer((e=>function(e,t,i){const n=t.differ.getChanges();let o=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;o=Lx(n.textNode,e)||o,o=Lx(t,e)||o,o=Lx(n.nodeBefore,e)||o,o=Lx(n.nodeAfter,e)||o}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())o=Lx(i,e)||o}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;o=Lx(n.nodeBefore,e)||o,o=Lx(t,e)||o}}return o}(e,i,t.schema))),i.registerPostFixer((e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,o=t.range.end.nodeAfter;for(const s of[i,o])Dx(s)&&s.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,s),n=!0)}return n}(e,i))),i.registerPostFixer((e=>function(e,t){const i=t.selection,n=i.focus;if(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))return e.removeSelectionAttribute("mention"),!0;return!1}(e,i))),e.commands.add("mention",new Rx(e))}}function Bx(e,t){return Object.assign({uid:f()},e,t||{})}function Mx(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(!n)return;return Bx({id:i,_text:n.data},t)}function Fx(e){e.on("attribute:mention",((e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const o=t.range.start;(o.textNode||o.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)}),{priority:"highest"})}function Nx(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function Dx(e){if(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))return!1;return e.data!=e.getAttribute("mention")._text}function Lx(e,t){return!!Dx(e)&&(t.removeAttribute("mention",e),!0)}class zx extends Dm{constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))})),this.listenTo(this.domElement,"click",(()=>{this.fire("execute")}))}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class $x extends Mm{highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const Wx=[go.arrowup,go.arrowdown,go.esc],jx=[go.enter,go.tab];class Ux extends Ss{static get pluginName(){return"MentionUI"}static get requires(){return[Of]}constructor(e){super(e),this._items=new Uo,this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=ll(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||jx,i=Wx.concat(t);this._balloon=e.plugins.get(Of),e.editing.view.document.on("keydown",((e,n)=>{var o;o=n.keyCode,i.includes(o)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==go.arrowdown&&this._mentionsView.selectNext(),n.keyCode==go.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==go.esc&&this._hideUIAndRemoveMarker())}),{priority:"highest"}),As({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!Jx(i))throw new _("mentionconfig-incorrect-marker",null,{marker:i});const o={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):Zx(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,o)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",(()=>{this._hideUIAndRemoveMarker()})),this.on("requestFeed:response",((e,t)=>this._handleFeedResponse(t))),this.on("requestFeed:error",(()=>this._hideUIAndRemoveMarker()))}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new zx(e);return t.items.bindTo(this._items).using((i=>{const{item:n,marker:o}=i,{dropdownLimit:s}=this._mentionsConfigurations.get(o),r=s||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new $x(e),l=this._renderItem(n,o);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=o,a.on("execute",(()=>{t.fire("execute",{item:n,marker:o})})),a})),t.on("execute",((e,t)=>{const i=this.editor,n=i.model,o=t.item,s=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:o,text:o.text,marker:s,range:c}),i.editing.view.focus()})),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then((i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})})).catch((t=>{this.fire("requestFeed:error",{error:t}),v("mention-feed-callback-error",{marker:e})})):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map((e=>({...e,pattern:Kx(e.marker,e.minimumCharacters||0)}))),n=new hb(t.model,function(e){const t=t=>{const i=Gx(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const o=t.substring(n);return i.pattern.test(o)};return t}(i));n.on("matched",((e,n)=>{const o=Gx(i,n.text),s=t.model.document.selection.focus,r=t.model.createPositionAt(s.parent,o.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(s)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=Kx(e.marker,0),o=t.substring(i);return o.match(n)[2]}(o,n.text),l=o.marker.length+a.length,c=s.getShiftedBy(-l),d=s.getShiftedBy(-a.length),h=t.model.createRange(c,d);if(Yx(t)){const e=t.model.markers.get("mention");t.model.change((t=>{t.updateMarker(e,{range:h})}))}else t.model.change((e=>{e.addMarker("mention",{range:h,usingOperation:!1,affectsData:!1})}));this._requestFeedDebounced(o.marker,a)})),n.on("unmatched",(()=>{this._hideUIAndRemoveMarker()}));const o=t.commands.get("mention");return n.bind("isEnabled").to(o),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!Yx(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),Yx(this.editor)&&this.editor.model.change((e=>e.removeMarker("mention"))),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,o=e.id;const s=this._getItemRenderer(t);if(s){const t=s(e);"string"!=typeof t?n=new Hx(i.locale,t):o=t}if(!n){const e=new Yu(i.locale);e.label=o,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,o=n.view.domConverter,s=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=s.toViewRange(t);return Nn.getDomRangeRects(o.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:qx(t,i.locale.uiLanguageDirection)}}}function qx(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function Gx(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function Kx(e,t){const i=0==t?"*":`{${t},}`,n=r.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";return new RegExp(`(?:^|[ ${n}])([${e}])(.${i})$`,"u")}function Zx(e){return t=>e.filter((e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase())))}function Jx(e){return e&&1==e.length}function Yx(e){return e.model.markers.has("mention")}function Qx(e){return void 0!==e&&e.endsWith("px")}function Xx(e){return e.toFixed(2).replace(/\.?0+$/,"")+"px"}function eE(e,t,i){if(!e.childCount)return;const n=new qh(e.document),o=function(e,t){const i=t.createRangeIn(e),n=[],o=new Set;for(const e of i.getItems()){if(!e.is("element")||!e.name.match(/^(p|h\d+|li|div)$/))continue;let t=lE(e);if(void 0===t||0!=parseFloat(t)||Array.from(e.getClassNames()).find((e=>e.startsWith("MsoList")))||(t=void 0),e.hasStyle("mso-list")||void 0!==t&&o.has(t)){const i=rE(e);n.push({element:e,id:i.id,order:i.order,indent:i.indent,marginLeft:t}),void 0!==t&&o.add(t)}else o.clear()}return n}(e,n);if(!o.length)return;const s={},r=[];for(const e of o)if(void 0!==e.indent){tE(e)||(r.length=0);const o=`${e.id}:${e.indent}`,a=Math.min(e.indent-1,r.length);if(ar.length-1||r[a].listElement.name!=l.type){0==a&&"ol"==l.type&&void 0!==e.id&&s[o]&&(l.startIndex=s[o]);const t=sE(l,n,i);if(Qx(e.marginLeft)&&(0==a||Qx(r[a-1].marginLeft))){let i=e.marginLeft;a>0&&(i=Xx(parseFloat(i)-parseFloat(r[a-1].marginLeft))),n.setStyle("padding-left",i,t)}if(0==r.length){const i=e.element.parent,o=i.getChildIndex(e.element)+1;n.insertChild(o,t,i)}else{const e=r[a-1].listItemElements;n.appendChild(t,e[e.length-1])}r[a]={...e,listElement:t,listItemElements:[]},0==a&&void 0!==e.id&&(s[o]=l.startIndex||1)}}const l="li"==e.element.name?e.element:n.createElement("li");n.appendChild(l,r[a].listElement),r[a].listItemElements.push(l),0==a&&void 0!==e.id&&s[o]++,e.element!=l&&n.appendChild(e.element,l),aE(e.element,n),n.removeStyle("text-indent",e.element),n.removeStyle("margin-left",e.element)}else{const t=r.find((t=>t.marginLeft==e.marginLeft));if(t){const i=t.listItemElements;n.appendChild(e.element,i[i.length-1]),n.removeStyle("margin-left",e.element)}else r.length=0}}function tE(e){const t=e.element.previousSibling;return iE(t||e.element.parent)}function iE(e){return e.is("element","ol")||e.is("element","ul")}function nE(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,s=new RegExp(`@list\\s+l${e.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${e.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=s.exec(t),l=r.exec(t),c=a&&!l,d=i.exec(t);let h="decimal",u="ol",m=null;if(d&&d[1]){const t=n.exec(d[1]);if(t&&t[1]&&(h=t[1].trim(),u="bullet"!==h&&"image"!==h?"ol":"ul"),"bullet"===h){const t=function(e){if("li"==e.name&&"ul"==e.parent.name&&e.parent.hasAttribute("type"))return e.parent.getAttribute("type");const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(h=t)}else{const e=o.exec(d[1]);e&&e[1]&&(m=parseInt(e[1]))}c&&(u="ol")}return{type:u,startIndex:m,style:oE(h),isLegalStyleList:c}}function oE(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function sE(e,t,i){const n=t.createElement(e.type);return e.style&&t.setStyle("list-style-type",e.style,n),e.startIndex&&e.startIndex>1&&t.setAttribute("start",e.startIndex,n),e.isLegalStyleList&&i&&t.addClass("legal-list",n),n}function rE(e){const t=e.getStyle("mso-list");if(void 0===t)return{};const i=t.match(/(^|\s{1,100})l(\d+)/i),n=t.match(/\s{0,100}lfo(\d+)/i),o=t.match(/\s{0,100}level(\d+)/i);return i&&n&&o?{id:i[2],order:n[1],indent:parseInt(o[1])}:{indent:1}}function aE(e,t){const i=new Js({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}function lE(e){const t=e.getStyle("margin-left");return void 0===t||t.endsWith("px")?t:function(e){const t=parseFloat(e);return e.endsWith("pt")?Xx(96*t/72):e.endsWith("pc")?Xx(12*t*96/72):e.endsWith("in")?Xx(96*t):e.endsWith("cm")?Xx(96*t/2.54):e.endsWith("mm")?Xx(t/10*96/2.54):e}(t)}function cE(e,t){if(!e.childCount)return;const i=new qh(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Js({name:/v:(.+)/}),o=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,s=i&&i.is("element")?i.name:null,r=["Chart"],a=n.match(t),l=t.getAttribute("o:gfxdata"),c="v:shapetype"===s,d=l&&r.some((e=>t.getAttribute("id").includes(e)));a&&l&&!c&&!d&&o.push(e.item.getAttribute("id"))}return o}(e,i);!function(e,t,i){const n=i.createRangeIn(t),o=new Js({name:"img"}),s=[];for(const t of n)if(t.item.is("element")&&o.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every((t=>e.indexOf(t)>-1))?s.push(i):i.getAttribute("src")||s.push(i)}for(const e of s)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;s(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function s(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(s(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new Js({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new Js({name:"img"}),o=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,i);o.length&&function(e,t,i){if(e.length===t.length)for(let n=0;nString.fromCharCode(parseInt(e,16)))).join(""))}const hE=//i,uE=/xmlns:o="urn:schemas-microsoft-com/i;class mE{constructor(e,t=!1){this.document=e,this.hasMultiLevelListPlugin=t}isActive(e){return hE.test(e)||uE.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;eE(t,i,this.hasMultiLevelListPlugin),cE(t,e.dataTransfer.getData("text/rtf")),function(e){const t=[],i=new qh(e.document);for(const{item:n}of i.createRangeIn(e))if(n.is("element")){for(const e of n.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,n);for(const e of n.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,n);(n.is("element","w:sdt")||n.is("element","w:sdtpr")&&n.isEmpty||n.is("element","o:p")&&n.isEmpty)&&t.push(n)}for(const e of t){const t=e.parent,n=t.getChildIndex(e);i.insertChild(n,e.getChildren(),t),i.remove(e)}}(t),e.content=t}}function gE(e,t,i,{blockElements:n,inlineObjectElements:o}){let s=i.createPositionAt(e,"forward"==t?"after":"before");return s=s.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?s.nodeAfter:s.nodeBefore}function fE(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const pE=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class bE{constructor(e){this.document=e}isActive(e){return pE.test(e)}execute(e){const t=new qh(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new Jr(t.document.stylesProcessor),n=new za(i,{renderingMode:"data"}),o=n.blockElements,s=n.inlineObjectElements,r=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=gE(e,"forward",t,{blockElements:o,inlineObjectElements:s}),n=gE(e,"backward",t,{blockElements:o,inlineObjectElements:s}),a=fE(i,o);(fE(n,o)||a)&&r.push(e)}}for(const e of r)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const wE=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function yE(e,t){const i=new DOMParser,n=function(e){return vE(vE(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i="",n=e.indexOf(t);if(n<0)return e;const o=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(o>=0?e.substring(o):"")}(e=(e=e.replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((s=(s=n.getData("text/plain")).replace(/&/g,"&").replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${s}

`),e=s),o=this.editor.data.htmlProcessor.toView(e)}var s;const r=new m(this,"inputTransformation");this.fire(r,{content:o,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),r.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,t)=>{t.resultRange=o._pasteFragmentWithMarkers(t.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((t,n)=>{const o=e.data.toView(n.content);i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:o,method:n.method})}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",pw(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class Mw extends(P()){constructor(){super(...arguments),this._stack=[]}add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const o=i[0];n===o||Fw(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const o=i[0];n===o||Fw(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(Fw(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Nw(t[n],e);)n++;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e));i>-1&&t.splice(i,1)}}function Fw(e,t){return e&&t&&e.priority==t.priority&&Dw(e.classes)==Dw(t.classes)}function Nw(e,t){return e.priority>t.priority||!(e.priorityDw(t.classes)}function Dw(e){return Array.isArray(e)?e.sort().join(","):e}const Lw='',zw="ck-widget",Hw="ck-widget_selected";function $w(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function Ww(e,t,i={}){if(!e.is("containerElement"))throw new _("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass(zw,e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=Zw,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){const i=e.getCustomProperty("widgetLabel");i.push(t)}(e,i.label),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),i=new Zu;return i.set("content",Lw),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),qw(e,t),e}function jw(e,t,i){if(t.classes&&i.addClass(vo(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function Uw(e,t,i){if(t.classes&&i.removeClass(vo(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function qw(e,t,i=jw,n=Uw){const o=new Mw;o.on("change:top",((t,o)=>{o.oldDescriptor&&n(e,o.oldDescriptor,o.writer),o.newDescriptor&&i(e,o.newDescriptor,o.writer)}));t.setCustomProperty("addHighlight",((e,t,i)=>o.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>o.remove(t,i)),e)}function Gw(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),t.setAttribute("tabindex","-1",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,n,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((i,n,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),qw(e,t),e}function Kw(e,t){const i=e.getSelectedElement();if(i){const n=Xw(e);if(n)return t.createRange(t.createPositionAt(i,n))}return t.schema.findOptimalInsertionRange(e)}function Zw(){return null}function Jw(e){const t=e=>{const{width:t,paddingLeft:i,paddingRight:n}=e.ownerDocument.defaultView.getComputedStyle(e);return parseFloat(t)-(parseFloat(i)||0)-(parseFloat(n)||0)},i=e.parentElement;if(!i)return 0;let n=t(i);let o=0,s=i;for(;isNaN(n);){if(s=s.parentElement,++o>5)return 0;n=t(s)}return n}const Yw="widget-type-around";function Qw(e,t,i){return!!e&&$w(e)&&!i.isInline(t)}function Xw(e){return e.getAttribute(Yw)}const e_=["before","after"],t_=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,i_="ck-widget__type-around_disabled";class n_ extends Ss{constructor(){super(...arguments),this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Lb,lb]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,n,o)=>{t.change((e=>{for(const i of t.document.roots)o?e.removeClass(i_,i):e.addClass(i_,i)})),o||e.model.change((e=>{e.removeSelectionAttribute(Yw)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view,o=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:o}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,((...e)=>{this.isEnabled&&i(...e)}),n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Xw(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,o,s)=>{const r=s.mapper.toViewElement(o.item);if(r&&Qw(r,o.item,t)){!function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const i=this.toDomElement(e);return function(e,t){for(const i of e_){const n=new is({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${i}`],title:t[i],"aria-hidden":"true"},children:[e.ownerDocument.importNode(t_,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new is({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(s.writer,n,r);r.getCustomProperty("widgetLabel").push((()=>this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):""))}}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,n=t.schema,o=e.editing.view;function s(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[$w,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(Yw)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();if(t){if(Qw(e.editing.mapper.toViewElement(t),t,n))return}e.model.change((e=>{e.removeSelectionAttribute(Yw)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const o=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(e_.map(s),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!Qw(a,r,n))return;const l=Xw(t.selection);l&&(o.addClass(s(l),a),this._currentFakeCaretModelElement=r)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,n)=>{n||e.model.change((e=>{e.removeSelectionAttribute(Yw)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,o=n.document.selection,s=n.schema,r=i.editing.view,a=function(e,t){const i=_o(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;Qw(l,i.editing.mapper.toModelElement(l),s)?c=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=Xw(t.document.selection);return t.change((t=>{if(!i)return t.setSelectionAttribute(Yw,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(Yw),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,o=t.plugins.get("Widget"),s=o._getObjectElementNextToSelection(e);return!!Qw(t.editing.mapper.toViewElement(s),s,n)&&(i.change((t=>{o._setSelectionOverElement(s),t.setSelectionAttribute(Yw,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,o=t.editing.mapper,s=i.document.selection,r=e?s.getLastPosition().nodeBefore:s.getFirstPosition().nodeAfter;return!!Qw(o.toViewElement(r),r,n)&&(i.change((t=>{t.setSelection(r,"on"),t.setSelectionAttribute(Yw,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,n)=>{const o=n.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const s=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(o,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,s),n.preventDefault(),i.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",((i,n)=>{if("atTarget"!=i.eventPhase)return;const o=t.getSelectedElement(),s=e.editing.mapper.toViewElement(o),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:Qw(s,o,r)&&(this._insertParagraph(o,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())}),{context:$w})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)}),{priority:"high"}),r.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const s=Xw(i.document.selection);if(!s)return;const r=o.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===s===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,s),r);if(t)if(t.isCollapsed){const o=i.createSelection(t.start);if(i.modifySelection(o,{direction:r}),o.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:$w})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[n,o])=>{if(o&&!o.is("documentSelection"))return;const s=Xw(i);return s?(e.stop(),t.change((e=>{const o=i.getSelectedElement(),r=t.createPositionAt(o,s),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,i)=>{const[,n,o={}]=i;if(n&&!n.is("documentSelection"))return;const s=Xw(t);s&&(o.findOptimalPosition=s,i[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[i])=>{if(i&&!i.is("documentSelection"))return;Xw(t)&&e.stop()}),{priority:"high"})}}function o_(e){const t=e.model;return(i,n)=>{const o=n.keyCode==go.arrowup,s=n.keyCode==go.arrowdown,r=n.shiftKey,a=t.document.selection;if(!o&&!s)return;const l=s;if(r&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,l))return;const c=function(e,t,i){const n=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=s_(n,e,"forward");if(!i)return null;const o=n.createRange(e,i),s=r_(n.schema,o,"backward");return s?n.createRange(e,s):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=s_(n,e,"backward");if(!i)return null;const o=n.createRange(i,e),s=r_(n.schema,o,"forward");return s?n.createRange(s,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||function(e,t,i){const n=e.model,o=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const s=e.mapper.toViewRange(t),r=o.viewRangeToDom(s),a=Nn.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change((e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)})),i.stop(),n.preventDefault(),n.stopPropagation())}}}function s_(e,t,i){const n=e.schema,o=e.createRangeIn(t.root),s="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of o.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==s&&n.isBlock(r))return null}return null}function r_(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n;return null}class a_ extends Ss{constructor(){super(...arguments),this._previouslySelected=new Set}static get pluginName(){return"Widget"}static get requires(){return[n_,lb]}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.t;this.editor.editing.downcastDispatcher.on("selection",((t,i,n)=>{const o=n.writer,s=i.selection;if(s.isCollapsed)return;const r=s.getSelectedElement();if(!r)return;const a=e.editing.mapper.toViewElement(r);var l;$w(a)&&(n.consumable.consume(s,"selection")&&o.setSelection(o.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce(((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t),""))}))})),this.editor.editing.downcastDispatcher.on("selection",((e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,o=n.document.selection;let s=null;for(const e of o.getRanges())for(const t of e){const e=t.item;$w(e)&&!l_(e,s)&&(n.addClass(Hw,e),this._previouslySelected.add(e),s=e)}}),{priority:"low"}),t.addObserver(Uh),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[$w,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",o_(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"}),this.listenTo(i,"tab",((e,t)=>{"atTarget"==e.eventPhase&&(t.shiftKey||this._selectFirstNestedEditable()&&(t.preventDefault(),e.stop()))}),{context:$w,priority:"low"}),this.listenTo(i,"tab",((e,t)=>{t.shiftKey&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{priority:"low"}),this.listenTo(i,"keydown",((e,t)=>{t.keystroke==go.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:n("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:n("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:n("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:n("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:n("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,n=i.editing.view,o=n.document;let s=t.target;if(t.domEvent.detail>=3)return void(this._selectBlockContent(s)&&t.preventDefault());if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if($w(t))return!1;t=t.parent}return!1}(s))return;if(!$w(s)&&(s=s.findAncestor($w),!s))return;r.isAndroid&&t.preventDefault(),o.isFocused||n.focus();const a=i.editing.mapper.toModelElement(s);this._setSelectionOverElement(a)}_selectBlockContent(e){const t=this.editor,i=t.model,n=t.editing.mapper,o=i.schema,s=n.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),r=function(e,t){for(const i of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(i,"$text"))return i;if(t.isLimit(i)&&!t.isObject(i))break}return null}(n.toModelElement(s),i.schema);return!!r&&(i.change((e=>{const t=o.isLimit(r)?null:function(e,t){const i=new Zl({startPosition:e});for(const{item:e}of i){if(t.isLimit(e)||!e.is("element"))return null;if(t.checkChild(e,"$text"))return e}return null}(e.createPositionAfter(r),o),i=e.createPositionAt(r,0),n=t?e.createPositionAt(t,0):e.createPositionAt(r,"end");e.setSelection(e.createRange(i,n))})),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,o=n.schema,s=n.document.selection,r=s.getSelectedElement(),a=_o(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(r&&o.isObject(r)){const i=l?s.getLastPosition():s.getFirstPosition(),r=o.getNearestSelectionRange(i,l?"forward":"backward");return void(r&&(n.change((e=>{e.setSelection(r)})),t.preventDefault(),e.stop()))}if(!s.isCollapsed&&!t.shiftKey){const i=s.getFirstPosition(),r=s.getLastPosition(),a=i.nodeAfter,c=r.nodeBefore;return void((a&&o.isObject(a)||c&&o.isObject(c))&&(n.change((e=>{e.setSelection(l?r:i)})),t.preventDefault(),e.stop()))}if(!s.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&o.isObject(d)){if(o.isInline(d)&&c)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,o=i.document.selection.getSelectedElement();o&&n.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change((e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,o=t.createSelection(n);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(n))return null;const s=e?o.focus.nodeBefore:o.focus.nodeAfter;return s&&i.isObject(s)?s:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Hw,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,t=this.editor.editing.view.document;for(const i of t.selection.getFirstRange().getItems())if(i.is("editableElement")){const t=e.editing.mapper.toModelElement(i);if(!t)continue;const n=e.model.createPositionAt(t,0),o=e.model.schema.getNearestSelectionRange(n,"forward");return e.model.change((e=>{e.setSelection(o)})),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,n=(i.is("$text")?i.parent:i).findAncestor($w);if(!n)return!1;const o=t.toModelElement(n);return!!o&&(e.model.change((e=>{e.setSelection(o,"on")})),!0)}}function l_(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class c_ extends Ss{constructor(){super(...arguments),this._toolbarDefinitions=new Map}static get requires(){return[Of]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!$w(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:n,balloonClassName:o="ck-toolbar-container"}){if(!i.length)return void v("widget-toolbar-no-items",{toolbarId:e});const s=this.editor,r=s.t,a=new Vm(s.locale);if(a.ariaLabel=t||r("Widget toolbar"),this._toolbarDefinitions.has(e))throw new _("widget-toolbar-duplicated",this,{toolbarId:e});const l={view:a,getRelatedElement:n,balloonClassName:o,itemsConfig:i,initialized:!1};s.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=n(s.editing.view.document.selection);e&&this._showToolbar(l,e)},afterBlur:()=>{this._hideToolbar(l)}}),this._toolbarDefinitions.set(e,l)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const o=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const s=o.getAncestors().length;s>e&&(e=s,t=o,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?d_(this.editor,t):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:h_(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);d_(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function d_(e,t){const i=e.plugins.get("ContextualBalloon"),n=h_(e,t);i.updatePosition(n)}function h_(e,t){const i=e.editing.view,n=of.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class u_ extends(U()){constructor(e){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,i){const n=new Nn(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(m_(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new Nn(e),n=t.split("-"),o={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return o.x+=e.ownerDocument.defaultView.scrollX,o.y+=e.ownerDocument.defaultView.scrollY,o}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}(this.activeHandlePosition)),this._originalWidth=n.width,this._originalHeight=n.height,this._aspectRatio=n.width/n.height;const o=i.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(o):this._originalWidthPercents=function(e,t=new Nn(e)){const i=Jw(e);return i?t.width/i*100:0}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function m_(e){return`ck-widget__resizer__handle-${e}`}class g_ extends Cs{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("_isVisible","none",(e=>!e))}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,i,n)=>"px"===e.unit?`${t}×${i}`:`${n}%`)),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",((e,t,i)=>t<50||i<50?"above-center":e))}_dismiss(){this.unbind(),this._isVisible=!1}}class f_ extends(U()){constructor(e){super(),this._viewResizerWrapper=null,this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",((e,t)=>e&&t)),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change((e=>{e.removeClass("ck-hidden",this._viewResizerWrapper)}))}hide(){this._options.editor.editing.view.change((e=>{e.addClass("ck-hidden",this._viewResizerWrapper)}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((i=>{const n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),i}));i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n,this.isVisible||this.hide()})),this.on("change:isVisible",(()=>{this.isVisible?(this.show(),this.redraw()):this.hide()}))}begin(e){this._state=new u_(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)}));const i=this._getHandleHost(),n=new Nn(i),o=Math.round(n.width),s=Math.round(n.height),r=new Nn(i);t.width=Math.round(r.width),t.height=Math.round(r.height),this.redraw(n),this.state.update({...t,handleHostWidth:o,handleHostHeight:s})}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;const n=t.parentElement,o=this._getHandleHost(),s=this._viewResizerWrapper,r=[s.getStyle("width"),s.getStyle("height"),s.getStyle("left"),s.getStyle("top")];let a;if(n.isSameNode(o)){const t=e||new Nn(o);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==X(r,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},s)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,i={x:(n=e).pageX,y:n.pageY};var n;const o=!this._options.isCentered||this._options.isCentered(this),s={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(s.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(s.x*=2);let r=Math.abs(t.originalWidth+s.x),a=Math.abs(t.originalHeight+s.y);return"width"==(r/t.aspectRatio>a?"width":"height")?a=r/t.aspectRatio:r=a*t.aspectRatio,{width:Math.round(r),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*r*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new is({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new g_,this._sizeView.render(),e.appendChild(this._sizeView.element)}}class p_ extends Ss{constructor(){super(...arguments),this._resizers=new Map}static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,i=t.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(Uh),this._observer=new(Pn()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(i,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(i,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=uf((()=>this.redrawSelectedResizer()),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())}),{priority:"lowest"}),this._observer.listenTo(t.window,"resize",this._redrawSelectedResizerThrottled);const n=this.editor.editing.view.document.selection;n.on("change",(()=>{const e=n.getSelectedElement(),t=this.getResizerByViewElement(e)||null;t?this.select(t):this.deselect()}))}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){const t=new f_(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;f_.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i)||null,this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}const b_=Un("px");class w_ extends Cs{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",(e=>!e))],style:{left:e.to("left",(e=>b_(e))),top:e.to("top",(e=>b_(e))),width:e.to("width",(e=>b_(e)))}}})}}class __ extends Ss{constructor(){super(...arguments),this.removeDropMarkerDelayed=Jo((()=>this.removeDropMarker()),40),this._updateDropMarkerThrottled=uf((e=>this._updateDropMarker(e)),40),this._reconvertMarkerThrottled=uf((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0),this._dropTargetLineView=new w_,this._domEmitter=new(Pn()),this._scrollables=new Map}static get pluginName(){return"DragDropTarget"}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,n,o,s){this.removeDropMarkerDelayed.cancel();const r=v_(this.editor,e,t,i,n,o,s);if(r)return s&&s.containsRange(r)?this.removeDropMarker():void this._updateDropMarkerThrottled(r)}getFinalDropRange(e,t,i,n,o,s){const r=v_(this.editor,e,t,i,n,o,s);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change((t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}_updateDropTargetLine(e){const i=this.editor.editing,n=e.start.nodeBefore,o=e.start.nodeAfter,s=e.start.parent,r=n?i.mapper.toViewElement(n):null,a=r?i.view.domConverter.mapViewToDom(r):null,l=o?i.mapper.toViewElement(o):null,c=l?i.view.domConverter.mapViewToDom(l):null,d=i.mapper.toViewElement(s);if(!d)return;const h=i.view.domConverter.mapViewToDom(d),u=this._getScrollableRect(d),{scrollX:m,scrollY:g}=t.window,f=a?new Nn(a):null,p=c?new Nn(c):null,b=new Nn(h).excludeScrollbarsAndBorders(),w=f?f.bottom:b.top,_=p?p.top:b.bottom,v=t.window.getComputedStyle(h),y=w<=_?(w+_)/2:_;if(u.topa.schema.checkChild(s,e)))){if(a.schema.checkChild(s,"$text"))return a.createRange(s);if(t)return k_(e,A_(e,t.parent),n,o)}}}else if(a.schema.isInline(c))return k_(e,c,n,o);if(a.schema.isBlock(c))return k_(e,c,n,o);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter((t=>t.is("element")&&!y_(e,t)));let i=0,s=t.length;if(0==s)return a.createRange(a.createPositionAt(c,"end"));for(;i{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),r.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const i=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(i,"dragstart",((e,t)=>this._handleBlockDragStart(t))),this._domEmitter.listenTo(t.document,"dragover",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(t.document,"drop",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(t.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&i.setAttribute("draggable","true"),this.on("change:isEnabled",((e,t,n)=>{i.setAttribute("draggable",n?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,o=Array.from(i.getSelectedBlocks()),s=t.createRange(t.createPositionBefore(o[0]),t.createPositionAfter(o[o.length-1]));t.change((e=>e.setSelection(s))),this._isBlockDragging=!0,n.focus(),n.getObserver(mw).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),o=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&o.getObserver(mw).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class E_ extends Ss{constructor(){super(...arguments),this._clearDraggableAttributesDelayed=Jo((()=>this._clearDraggableAttributes()),40),this._blockMode=!1,this._domEmitter=new(Pn())}static get pluginName(){return"DragDrop"}static get requires(){return[Bw,a_,__,x_]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(mw),t.addObserver(Uh),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,i)=>{i||this._finalizeDragging(!1)})),r.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,i=e.model,n=e.editing.view,o=n.document,s=e.plugins.get(__);this.listenTo(o,"dragstart",((e,t)=>{if(t.target&&t.target.is("editableElement"))return void t.preventDefault();if(this._prepareDraggedRange(t.target),!this._draggedRange)return void t.preventDefault();this._draggingUid=f(),t.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",t.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const n=i.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(t.dataTransfer,n,"dragstart");const{dataTransfer:o,domTarget:s,domEvent:r}=t,{clientX:a}=r;this._updatePreview({dataTransfer:o,domTarget:s,clientX:a}),t.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(t.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(o,"dragleave",(()=>{s.removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:n}=t.domEvent;s.updateDropMarker(t.target,t.targetRanges,i,n,this._blockMode,this._draggedRange),this._draggedRange||(t.dataTransfer.dropEffect="copy"),r.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(__);this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const{clientX:o,clientY:s}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,o,s,this._blockMode,this._draggedRange);if(!r)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==T_(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(r)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Bw);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(i)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==T_(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((n,o)=>{if(r.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let s=S_(o.target);if(r.isBlink&&!e.isReadOnly&&!s&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&$w(e)||(s=i.selection.editableElement)}s&&(t.change((e=>{e.setAttribute("draggable","true",s)})),this._draggableElement=e.editing.mapper.toModelElement(s))})),this.listenTo(i,"mouseup",(()=>{r.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_finalizeDragging(e){const t=this.editor,i=t.model;if(t.plugins.get(__).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change((e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,o=e?S_(e):null;if(o){const e=t.editing.mapper.toModelElement(o);if(this._draggedRange=bc.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const s=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==s.length)return void(this._draggedRange=bc.fromRange(r));const a=P_(i,s);if(s.length>1)this._draggedRange=bc.fromRange(a),this._blockMode=!0;else if(1==s.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=bc.fromRange(e?a:r),this._blockMode=e}i.change((e=>e.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:e,domTarget:i,clientX:n}){const o=this.editor.editing.view,s=o.document.selection.editableElement,a=o.domConverter.mapViewToDom(s),l=t.window.getComputedStyle(a);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=be(t.document,"div",{style:"position: fixed; left: -999999px;"}),t.document.body.appendChild(this._previewContainer));const c=new Nn(a);if(a.contains(i))return;const d=parseFloat(l.paddingLeft),h=be(t.document,"div");h.className="ck ck-content",h.style.width=l.width,h.style.paddingLeft=`${c.left-n+d}px`,r.isiOS&&(h.style.backgroundColor="white"),h.innerHTML=e.getData("text/html"),e.setDragImage(h,0,0),this._previewContainer.appendChild(h)}}function T_(e){return r.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function S_(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor($w);if($w(e))return e;const t=e.findAncestor((e=>$w(e)||e.is("editableElement")));return $w(t)?t:null}function P_(e,t){const i=t[0],n=t[t.length-1],o=i.getCommonAncestor(n),s=e.createPositionBefore(i),r=e.createPositionAfter(n);if(o&&o.is("element")&&!e.schema.isLimit(o)){const t=e.createRangeOn(o),i=s.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return P_(e,[o])}return e.createRange(s,r)}class I_ extends Ss{static get pluginName(){return"PastePlainText"}static get requires(){return[Bw]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=t.document.selection;let s=!1;i.addObserver(mw),this.listenTo(n,"keydown",((e,t)=>{s=t.shiftKey})),e.plugins.get(Bw).on("contentInsertion",((e,i)=>{(s||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const n=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),n.push(...o.getAttributes());const s=e.createRangeIn(i.content);for(const t of s.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class V_ extends Ss{static get pluginName(){return"Clipboard"}static get requires(){return[Ow,Bw,E_,I_]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}class R_ extends Is{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!O_(e.schema,i))do{if(i=i.parent,!i)return}while(!O_(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function O_(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const B_=bo("Ctrl+A");class M_ extends Ss{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new R_(e)),this.listenTo(i,"keydown",((t,i)=>{po(i)===B_&&(e.execute("selectAll"),i.preventDefault())})),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class F_ extends Ss{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:selectAll",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),o=new e(t.locale),s=i.t;return o.set({label:s("Select all"),icon:'',keystroke:"Ctrl+A"}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),o}}class N_ extends Ss{static get requires(){return[M_,F_]}static get pluginName(){return"SelectAll"}}class D_ extends Is{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",((e,t)=>{t[1]={...t[1]};const i=t[1];i.batchType||(i.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(e.data,"set",((e,t)=>{t[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,o=n.document,s=[],r=e.map((e=>e.getTransformedByOperations(i))),a=r.flat();for(const e of r){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!z_(e,a)));t.length&&(L_(t),s.push(t[0]))}s.length&&n.change((e=>{e.setSelection(s,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,s=Array.from(n.history.getOperations(o)),r=Qd([e.getReversed()],s,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let o of r){const s=o.affectedSelectable;s&&!i.canEditAt(s)&&(o=new $d(o.baseVersion)),t.addOperation(o),i.applyOperation(o),n.history.setOperationAsUndone(e,o)}}}}function L_(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class H_ extends D_{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(n,(()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e)})),this.fire("revert",i.batch,n),this.refresh()}}class $_ extends D_{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)})),this.refresh()}}class W_ extends Ss{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor,t=e.t;this._undoCommand=new H_(e),this._redoCommand=new $_(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,o=this._redoCommand.createdBatches.has(n),s=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(o?this._undoCommand.addBatch(n):s||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,i)=>{this._redoCommand.addBatch(i)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class j_ extends Ss{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Hu.undo:Hu.redo,o="ltr"==t.uiLanguageDirection?Hu.redo:Hu.undo;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",o)}_addButtonsToFactory(e,t,i,n){const o=this.editor;o.ui.componentFactory.add(e,(()=>{const o=this._createButton(Yu,e,t,i,n);return o.set({tooltip:!0}),o})),o.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(pp,e,t,i,n)))}_createButton(e,t,i,n,o){const s=this.editor,r=s.locale,a=s.commands.get(t),l=new e(r);return l.set({label:i,icon:o,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",(()=>{s.execute(t),s.editing.view.focus()})),l}}class U_ extends Ss{static get requires(){return[W_,j_]}static get pluginName(){return"Undo"}}class q_ extends Is{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,o=e.batch,s=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{s(e)})):t.change((e=>{s(e)}))}}const G_="fontSize",K_="fontFamily",Z_="fontColor",J_="fontBackgroundColor";function Y_(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function Q_(e){return t=>t.getStyle(e).replace(/\s/g,"")}function X_(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class ev extends q_{constructor(e){super(e,K_)}}function tv(e){return e.map(iv).filter((e=>void 0!==e))}function iv(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],n=t.map(nv).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function nv(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class ov extends Ss{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(K_,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:K_}),e.model.schema.setAttributeProperties(K_,{isFormatting:!0,copyOnEnter:!0});const t=tv(e.config.get("fontFamily.options")).filter((e=>e.model)),i=Y_(K_,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(K_,new ev(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:K_,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:K_,value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:K_,value:e=>e.getAttribute("face")}})}}const sv='';class rv extends Ss{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(K_),o=t("Font Family"),s=function(e,t){const i=new Uo;for(const n of e){const e={type:"button",model:new Vf({commandName:K_,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.model||!(!e||!n.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===n.model.toLowerCase())),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n);e.ui.componentFactory.add(K_,(t=>{const i=zm(t);return Wm(i,s,{role:"menu",ariaLabel:o}),i.buttonView.set({label:o,icon:sv,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${K_}`,(t=>{const i=new gp(t);i.buttonView.set({label:o,icon:sv}),i.bind("isEnabled").to(n);const r=new fp(t);for(const n of s){const o=new Zf(t,i),s=new pp(t);s.bind(...Object.keys(n.model)).to(n.model),s.bind("ariaChecked").to(s,"isOn"),s.delegate("execute").to(i),s.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),o.children.add(s),r.items.add(o)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return tv(e.config.get(K_).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class av extends q_{constructor(e){super(e,G_)}}function lv(e){return e.map((e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&(t=e,t.title&&t.model&&t.view))return dv(e);var t;const i=function(e){return"string"==typeof e?cv[e]:cv[e.model]}(e);if(i)return dv(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new _("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},dv(e)}(e)}(e))).filter((e=>void 0!==e))}const cv={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function dv(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const hv=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class uv extends Ss{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(G_,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:G_}),e.model.schema.setAttributeProperties(G_,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=lv(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=Y_(G_,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(G_,new av(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!ou(String(e))&&!ru(String(e))));if(i.length)throw new _("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:G_,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:G_,value:e=>e.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:G_,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=hv.length-1,s=Math.min(Math.max(n,0),o);return hv[s]}}})}}const mv='';class gv extends Ss{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(G_),o=t("Font Size"),s=function(e,t){const i=new Uo;for(const n of e){const e={type:"button",model:new Vf({commandName:G_,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===n.model)),i.add(e)}return i}(i,n);e.ui.componentFactory.add(G_,(t=>{const i=zm(t);return Wm(i,s,{role:"menu",ariaLabel:o}),i.buttonView.set({label:o,icon:mv,tooltip:!0}),i.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${G_}`,(t=>{const i=new gp(t);i.buttonView.set({label:o,icon:mv}),i.bind("isEnabled").to(n);const r=new fp(t);for(const n of s){const o=new Zf(t,i),s=new pp(t);s.bind(...Object.keys(n.model)).to(n.model),s.bind("ariaChecked").to(s,"isOn"),s.delegate("execute").to(i),s.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),o.children.add(s),r.items.add(o)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return lv(e.config.get(G_).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class fv extends q_{constructor(e){super(e,Z_)}}class pv extends Ss{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(Z_,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:Z_,value:Q_("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Z_,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:Z_,view:X_("color")}),e.commands.add(Z_,new fv(e)),e.model.schema.extend("$text",{allowAttributes:Z_}),e.model.schema.setAttributeProperties(Z_,{isFormatting:!0,copyOnEnter:!0})}}class bv extends Ss{constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),s=nm(t,om(o.colors)),r=o.documentColors,a=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const l=zm(t);let c=!1;const d=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a}){const l=e.locale,c=new Fg(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}({dropdownView:l,colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!!a&&(o.colorPicker||{})});return d.bind("selectedColor").to(n,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(n),d.on("execute",((t,i)=>{l.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(l.isOpen=!1)})),d.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),d.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),l.on("change:isOpen",((t,i,n)=>{c||(c=!0,l.colorSelectorView.appendUI()),n&&(0!==r&&d.updateDocumentColors(e.model,this.componentName),d.updateSelectedColors(),d.showColorGridsFragment())})),Um(l,(()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),l})),e.ui.componentFactory.add(`menuBar:${this.componentName}`,(t=>{const o=new gp(t);o.buttonView.set({label:this.dropdownLabel,icon:this.icon}),o.bind("isEnabled").to(n);let a=!1;const l=new Fg(t,{colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!1});return l.bind("selectedColor").to(n,"value"),l.delegate("execute").to(o),l.on("execute",((t,i)=>{e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),e.editing.view.focus()})),o.on("change:isOpen",((t,i,n)=>{a||(a=!0,l.appendUI()),n&&(0!==r&&l.updateDocumentColors(e.model,this.componentName),l.updateSelectedColors(),l.showColorGridsFragment())})),o.panelView.children.add(l),o}))}}class wv extends bv{constructor(e){const t=e.locale.t;super(e,{commandName:Z_,componentName:Z_,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class _v extends q_{constructor(e){super(e,J_)}}class vv extends Ss{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(J_,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(vu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:J_,value:Q_("background-color")}}),e.conversion.for("downcast").attributeToElement({model:J_,view:X_("background-color")}),e.commands.add(J_,new _v(e)),e.model.schema.extend("$text",{allowAttributes:J_}),e.model.schema.setAttributeProperties(J_,{isFormatting:!0,copyOnEnter:!0})}}class yv extends bv{constructor(e){const t=e.locale.t;super(e,{commandName:J_,componentName:J_,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class kv extends Is{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=qo(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Cv(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change((e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&Cv(n,t.schema)&&e.rename(n,"paragraph")}))}}function Cv(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Av extends Is{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.canEditAt(n)&&t.change((e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return;const o=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(o,i,e),t.insertContent(o,n),e.setSelection(o,"in")}))}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const o=e.parent,s=i.schema.checkChild(o,"$text");return o.isEmpty||s&&e.isAtEnd?i.createPositionAfter(o):!o.isEmpty&&s&&e.isAtStart?i.createPositionBefore(o):t.split(e,n).position}}class xv extends Ss{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new kv(e)),e.commands.add("insertParagraph",new Av(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>xv.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}xv.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);const Ev=xv;class Tv extends Is{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=qo(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>Sv(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>Sv(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function Sv(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const Pv="paragraph";class Iv extends Ss{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[Ev]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Tv(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",Pv)&&0===o.childCount&&n.writer.rename(o,Pv)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:p.low+1})}}class Vv extends Ss{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=function(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const s={},r=new Uo,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new Vf({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),s[e.model]=e.title}const d=zm(t);return Wm(d,r,{ariaLabel:o,role:"menu"}),d.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?n:s[i]?s[i]:n})),d.buttonView.bind("ariaLabel").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?o:s[i]?`${s[i]}, ${o}`:o})),this.listenTo(d,"execute",(t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()})),d})),e.ui.componentFactory.add("menuBar:heading",(n=>{const o=new gp(n),s=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[s],l=new fp(n);o.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),o.buttonView.set({label:t("Heading")}),o.panelView.children.add(l);for(const t of i){const i=new Zf(n,o),c=new pp(n);i.children.add(c),l.items.add(i),c.set({label:t.title,role:"menuitemradio",class:t.class}),c.bind("ariaChecked").to(c,"isOn"),c.delegate("execute").to(o),c.on("execute",(()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()})),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(s,"value",(e=>e===t.model))}return o.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),o}))}}new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class Rv extends Is{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change((e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,o=t.getLastMatchingPosition(i,{direction:"backward"}),s=t.getLastMatchingPosition(i),r=e.createRange(o,s);n&&this.value!==n?(t.isEqual(s)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(s)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const o=t.schema.getValidRanges(i.getRanges(),"highlight");for(const t of o)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)}}))}}class Ov extends Ss{static get pluginName(){return"HighlightEditing"}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new Rv(e))}}class Bv extends Ss{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),Hu.eraser,null,(e=>{e.bind("isEnabled").to(t,"isEnabled")}))}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,Mv(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(t=>t===e.model)),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,o){const s=this.editor;s.ui.componentFactory.add(e,(e=>{const r=new Yu(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",(()=>{s.execute("highlight",{value:n}),s.editing.view.focus()})),o(r),r}))}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,o=e[0],s=e.reduce(((e,t)=>(e[t.model]=t,e)),{});n.add("highlight",(r=>{const a=t.commands.get("highlight"),l=zm(r,Lm),c=l.buttonView;c.set({label:i("Highlight"),tooltip:!0,lastExecuted:o.model,commandValue:o.model,isToggleable:!0}),c.bind("icon").to(a,"value",(e=>Mv(d(e,"type")))),c.bind("color").to(a,"value",(e=>d(e,"color"))),c.bind("commandValue").to(a,"value",(e=>d(e,"model"))),c.bind("isOn").to(a,"value",(e=>!!e)),c.delegate("execute").to(l);function d(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return s[i][t]}return l.bind("isEnabled").to(a,"isEnabled"),Hm(l,(()=>{const t=e.map((e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",(()=>{l.buttonView.set({lastExecuted:e.model})})),t}));return t.push(new Tm),t.push(n.create("removeHighlight")),t}),{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){const t=e.buttonView.actionView;t.iconView.bind("fillColor").to(e.buttonView,"color")}(l),c.on("execute",(()=>{t.execute("highlight",{value:c.commandValue})})),this.listenTo(l,"execute",(()=>{t.editing.view.focus()})),l}))}_addMenuBarButton(e){const t=this.editor,i=t.t;t.ui.componentFactory.add("menuBar:highlight",(n=>{const o=t.commands.get("highlight"),s=new gp(n);s.buttonView.set({label:i("Highlight"),icon:Mv("marker")}),s.bind("isEnabled").to(o),s.buttonView.iconView.fillColor="transparent";const r=new fp(n);for(const i of e){const e=new Zf(n,s),a=new pp(n);a.set({label:i.title,icon:Mv(i.type)}),a.delegate("execute").to(s),a.bind("isOn").to(o,"value",(e=>e===i.model)),a.bind("ariaChecked").to(a,"isOn"),a.iconView.bind("fillColor").to(a,"isOn",(e=>e?"transparent":i.color)),a.on("execute",(()=>{t.execute("highlight",{value:i.model}),t.editing.view.focus()})),e.children.add(a),r.items.add(e)}r.items.add(new Fm(n));const a=new Zf(n,s),l=new pp(n);return l.set({label:i("Remove highlight"),icon:Hu.eraser}),l.delegate("execute").to(s),l.on("execute",(()=>{t.execute("highlight",{value:null}),t.editing.view.focus()})),a.children.add(l),r.items.add(a),s.panelView.children.add(r),s}))}}function Mv(e){return"marker"===e?'':''}class Fv extends Is{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=Kw(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class Nv extends Ss{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),o=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",o),t.setCustomProperty("hr",!0,o),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),Ww(e,t,{label:i})}(o,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new Fv(e))}}class Dv extends Ss{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:horizontalLine",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("horizontalLine"),o=new e(t.locale),s=i.t;return o.set({label:s("Horizontal line"),icon:Hu.horizontalLine}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("horizontalLine"),t.editing.view.focus()})),o}}const Lv=function(e,t,i,n){var o=-1,s=null==e?0:e.length;for(n&&s&&(i=e[++o]);++o=n?e:_r(e,t,i)};var yy=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const ky=function(e){return yy.test(e)};const Cy=function(e){return e.split("")};var Ay="\\ud800-\\udfff",xy="["+Ay+"]",Ey="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Ty="\\ud83c[\\udffb-\\udfff]",Sy="[^"+Ay+"]",Py="(?:\\ud83c[\\udde6-\\uddff]){2}",Iy="[\\ud800-\\udbff][\\udc00-\\udfff]",Vy="(?:"+Ey+"|"+Ty+")"+"?",Ry="[\\ufe0e\\ufe0f]?",Oy=Ry+Vy+("(?:\\u200d(?:"+[Sy,Py,Iy].join("|")+")"+Ry+Vy+")*"),By="(?:"+[Sy+Ey+"?",Ey,Py,Iy,xy].join("|")+")",My=RegExp(Ty+"(?="+Ty+")|"+By+Oy,"g");const Fy=function(e){return e.match(My)||[]};const Ny=function(e){return ky(e)?Fy(e):Cy(e)};const Dy=function(e){return function(t){t=gr(t);var i=ky(t)?Ny(t):void 0,n=i?i[0]:t.charAt(0),o=i?vy(i,1).join(""):t.slice(1);return n[e]()+o}}("toUpperCase");const Ly=_y((function(e,t,i){return e+(i?" ":"")+Dy(t)}));function zy(e,t,i,n){t&&function(e,t,i){if(t.attributes)for(const[n]of Object.entries(t.attributes))e.removeAttribute(n,i);if(t.styles)for(const n of Object.keys(t.styles))e.removeStyle(n,i);t.classes&&e.removeClass(t.classes,i)}(e,t,n),i&&Hy(e,i,n)}function Hy(e,t,i){if(t.attributes)for(const[n,o]of Object.entries(t.attributes))e.setAttribute(n,o,i);t.styles&&e.setStyle(t.styles,i),t.classes&&e.addClass(t.classes,i)}function $y(e,t,i,n,o){const s=t.getAttribute(i),r={};for(const e of["attributes","styles","classes"]){if(e!=n){s&&s[e]&&(r[e]=s[e]);continue}if("classes"==n){const t=new Set(s&&s.classes||[]);o(t),t.size&&(r[e]=Array.from(t));continue}const t=new Map(Object.entries(s&&s[e]||{}));o(t),t.size&&(r[e]=Object.fromEntries(t))}Object.keys(r).length?t.is("documentSelection")?e.setSelectionAttribute(i,r):e.setAttribute(i,r,t):s&&(t.is("documentSelection")?e.removeSelectionAttribute(i):e.removeAttribute(i,t))}function Wy(e){return`html${t=e,Ly(t).replace(/ /g,"")}Attributes`;var t}function jy({model:e}){return(t,i)=>i.writer.createElement(e,{htmlContent:t.getCustomProperty("$rawContent")})}function Uy(e,{view:t,isInline:i}){const n=e.t;return(e,{writer:o})=>{const s=n("HTML object"),r=qy(t,e,o),a=e.getAttribute(Wy(t));o.addClass("html-object-embed__content",r),a&&Hy(o,a,r);return Ww(o.createContainerElement(i?"span":"div",{class:"html-object-embed","data-html-object-embed-label":s},r),o,{label:s})}}function qy(e,t,i){return i.createRawElement(e,null,((e,i)=>{i.setContentOf(e,t.getAttribute("htmlContent"))}))}function Gy({view:e,model:t,allowEmpty:i},n){return t=>{t.on(`element:${e}`,((e,t,s)=>{let r=n.processViewAttributes(t.viewItem,s);if(r||s.consumable.test(t.viewItem,{name:!0})){if(r=r||{},s.consumable.consume(t.viewItem,{name:!0}),t.modelRange||(t=Object.assign(t,s.convertChildren(t.viewItem,t.modelCursor))),i&&t.modelRange.isCollapsed&&Object.keys(r).length){const e=s.writer.createElement("htmlEmptyElement");if(!s.safeInsert(e,t.modelCursor))return;const i=s.getSplitParts(e);return t.modelRange=s.writer.createRange(t.modelRange.start,s.writer.createPositionAfter(i[i.length-1])),s.updateConversionResult(e,t),void o(e,r,s)}for(const e of t.modelRange.getItems())o(e,r,s)}}),{priority:"low"})};function o(e,i,n){if(n.schema.checkAttribute(e,t)){const o=function(e,t){const i=Hl(e);let n="attributes";for(n in t)i[n]="classes"==n?Array.from(new Set([...e[n]||[],...t[n]])):{...e[n],...t[n]};return i}(i,e.getAttribute(t)||{});n.writer.setAttribute(t,o,e)}}}function Ky({model:e,view:t},i){return(n,{writer:o,consumable:s})=>{if(!n.hasAttribute(e))return null;const r=o.createContainerElement(t),a=n.getAttribute(e);return s.consume(n,`attribute:${e}`),Hy(o,a,r),r.getFillerOffset=()=>null,i?Ww(r,o):r}}function Zy({priority:e,view:t}){return(i,n)=>{if(!i)return;const{writer:o}=n,s=o.createAttributeElement(t,null,{priority:e});return Hy(o,i,s),s}}function Jy({view:e},t){return i=>{i.on(`element:${e}`,((e,i,n)=>{if(!i.modelRange||i.modelRange.isCollapsed)return;const o=t.processViewAttributes(i.viewItem,n);o&&n.writer.setAttribute(Wy(i.viewItem.name),o,i.modelRange)}),{priority:"low"})}}function Yy({view:e,model:t}){return i=>{i.on(`attribute:${Wy(e)}:${t}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t;zy(i.writer,n,o,i.mapper.toViewElement(t.item))}))}}const Qy=[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:"$text",allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}}],Xy=[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref"},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}];const ek=Lo((function(e,t,i,n){To(e,t,i,n)}));class tk extends Ss{constructor(){super(...arguments),this._definitions=[]}static get pluginName(){return"DataSchema"}init(){for(const e of Qy)this.registerBlockElement(e);for(const e of Xy)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const n of this._getMatchingViewDefinitions(e)){if(t)for(const e of this._getReferences(n.model))i.add(e);i.add(n)}return i}getDefinitionsForModel(e){return this._definitions.filter((t=>t.model==e))}_getMatchingViewDefinitions(e){return this._definitions.filter((t=>t.view&&function(e,t){if("string"==typeof e)return e===t;if(e instanceof RegExp)return e.test(t);return!1}(e,t.view)))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter((t=>t.model==e));for(const{modelSchema:n}of i)if(n)for(const i of t)for(const t of vo(n[i]||[])){const i=this._definitions.filter((e=>e.model==t));for(const n of i)t!==e&&(yield*this._getReferences(n.model),yield n)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter((([,t])=>t.model==e.model));if(0!=t.length)for(const[i,n]of t)this._definitions[i]=ek({},n,e,((e,t)=>Array.isArray(e)?e.concat(t):void 0));else this._definitions.push(e)}}class ik extends Ss{constructor(e){super(e),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new Js,this._disallowedAttributes=new Js,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get requires(){return[tk,a_]}loadAllowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=ak(t);this.allowElement(e),i.forEach((e=>this.allowAttributes(e)))}}loadDisallowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=ak(t);0==i.length?this.disallowElement(e):i.forEach((e=>this.disallowAttributes(e)))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return nk(e,this._disallowedAttributes,i),function(e,{attributes:t,classes:i,styles:n}){if(!t.length&&!i.length&&!n.length)return null;return{...t.length&&{attributes:ok(e,t)},...n.length&&{styles:sk(e,n)},...i.length&&{classes:i}}}(e,nk(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&"string"==typeof e.appliesToBlock)for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",(()=>{this._fireRegisterEvent(e)}),{priority:p.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",(()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)}),{priority:p.highest+1})}_registerElementHandlers(){this.on("register",((e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else{if(!t.isInline)throw new _("data-filter-invalid-definition",null,t);this._registerInlineElement(t)}e.stop()}),{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;const o=this._getCoupledAttributesMap();for(const e of i){if("attribute"!=e.type||null!==e.attributeNewValue)continue;const i=o.get(e.attributeKey);if(i)for(const{item:o}of e.range.getWalker())for(const e of i)o.hasAttribute(e)&&(t.removeAttribute(e,o),n=!0)}return n})),this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{const o=new Set,s=this._getCoupledAttributesMap();for(const e of n){if(t.hasAttribute(e))continue;const i=s.get(e);if(i)for(const e of i)t.hasAttribute(e)&&o.add(e)}0!=o.size&&e.change((e=>{for(const t of o)e.removeSelectionAttribute(t)}))}))}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;for(const o of i)if("insert"===o.type&&"$text"!==o.name)for(const i of o.attributes.keys())i.startsWith("html")&&i.endsWith("Attributes")&&(e.schema.checkAttribute(o.name,i)||(t.removeAttribute(i,o.position.nodeAfter),n=!0));return n}))}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:o,model:s}=e;i.register(s,e.modelSchema),o&&(i.extend(e.model,{allowAttributes:[Wy(o),"htmlContent"]}),t.data.registerRawContentMatcher({name:o}),n.for("upcast").elementToElement({view:o,model:jy(e),converterPriority:p.low+2}),n.for("upcast").add(Jy(e,this)),n.for("editingDowncast").elementToStructure({model:{name:s,attributes:[Wy(o)]},view:Uy(t,e)}),n.for("dataDowncast").elementToElement({model:s,view:(e,{writer:t})=>qy(o,e,t)}),n.for("dataDowncast").add(Yy(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:o,model:s}=e;if(!i.isRegistered(e.model)){if(i.register(e.model,e.modelSchema),!o)return;n.for("upcast").elementToElement({model:s,view:o,converterPriority:p.low+2}),n.for("downcast").elementToElement({model:s,view:o})}o&&(i.extend(e.model,{allowAttributes:Wy(o)}),n.for("upcast").add(Jy(e,this)),n.for("downcast").add(Yy(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,o=e.model;e.appliesToBlock||(i.extend("$text",{allowAttributes:o}),e.attributeProperties&&i.setAttributeProperties(o,e.attributeProperties),n.for("upcast").add(Gy(e,this)),n.for("downcast").attributeToElement({model:o,view:Zy(e)}),e.allowEmpty&&(i.setAttributeProperties(o,{copyFromObject:!1}),i.isRegistered("htmlEmptyElement")||i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"}),t.data.htmlProcessor.domConverter.registerInlineObjectMatcher((t=>t.name==e.view&&t.isEmpty&&Array.from(t.getAttributeKeys()).length?{name:!0}:null)),n.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:Ky(e,!0)}),n.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:Ky(e)})))}}function nk(e,t,i){const n=t.matchAll(e)||[],o=e.document.stylesProcessor;return n.reduce(((t,{match:n})=>{for(const s of n.styles||[]){const n=o.getRelatedStyles(s).filter((e=>e.split("-").length>s.split("-").length)).sort(((e,t)=>t.split("-").length-e.split("-").length));for(const o of n)i.consume(e,{styles:[o]})&&t.styles.push(o);i.consume(e,{styles:[s]})&&t.styles.push(s)}for(const o of n.classes||[])i.consume(e,{classes:[o]})&&t.classes.push(o);for(const o of n.attributes||[])i.consume(e,{attributes:[o]})&&t.attributes.push(o);return t}),{attributes:[],classes:[],styles:[]})}function ok(e,t){const i={};for(const n of t){const t=e.getAttribute(n);void 0!==t&&Zn(n)&&(i[n]=t)}return i}function sk(e,t){const i=new Er(e.document.stylesProcessor);for(const n of t){const t=e.getStyle(n);void 0!==t&&i.set(n,t)}return Object.fromEntries(i.getStylesEntries())}function rk(e,t){const{name:i}=e,n=e[t];return xe(n)?Object.entries(n).map((([e,n])=>({name:i,[t]:{[e]:n}}))):Array.isArray(n)?n.map((e=>({name:i,[t]:[e]}))):[e]}function ak(e){const{name:t,attributes:i,classes:n,styles:o}=e,s=[];return i&&s.push(...rk({name:t,attributes:i},"attributes")),n&&s.push(...rk({name:t,classes:n},"classes")),o&&s.push(...rk({name:t,styles:o},"styles")),s}class lk extends Ss{static get requires(){return[ik]}static get pluginName(){return"CodeBlockElementSupport"}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(ik);e.on("register:pre",((t,i)=>{if("codeBlock"!==i.model)return;const n=this.editor,o=n.model.schema,s=n.conversion;o.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),s.for("upcast").add(function(e){return t=>{t.on("element:code",((t,i,n)=>{const o=i.viewItem,s=o.parent;function r(t,o){const s=e.processViewAttributes(t,n);s&&n.writer.setAttribute(o,s,i.modelRange)}s&&s.is("element","pre")&&(r(s,"htmlPreAttributes"),r(o,"htmlContentAttributes"))}),{priority:"low"})}}(e)),s.for("downcast").add((e=>{e.on("attribute:htmlPreAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item).parent;zy(i.writer,n,o,s)})),e.on("attribute:htmlContentAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item);zy(i.writer,n,o,s)}))})),t.stop()}))}}class ck extends Ss{static get requires(){return[ik]}static get pluginName(){return"DualContentModelElementSupport"}init(){this.editor.plugins.get(ik).on("register",((e,t)=>{const i=t,n=this.editor,o=n.model.schema,s=n.conversion;if(!i.paragraphLikeModel)return;if(o.isRegistered(i.model)||o.isRegistered(i.paragraphLikeModel))return;const r={model:i.paragraphLikeModel,view:i.view};o.register(i.model,i.modelSchema),o.register(r.model,{inheritAllFrom:"$block"}),s.for("upcast").elementToElement({view:i.view,model:(e,{writer:t})=>this._hasBlockContent(e)?t.createElement(i.model):t.createElement(r.model),converterPriority:p.low+.5}),s.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),s.for("downcast").elementToElement({view:r.view,model:r.model}),this._addAttributeConversion(r),e.stop()}))}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const n of t.createRangeIn(e).getItems())if(n.is("element")&&i.includes(n.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,n=t.plugins.get(ik);t.model.schema.extend(e.model,{allowAttributes:Wy(e.view)}),i.for("upcast").add(Jy(e,n)),i.for("downcast").add(Yy(e))}}class dk extends Ss{static get requires(){return[tk,Lb]}static get pluginName(){return"HeadingElementSupport"}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(tk),n=[];for(const e of t)"model"in e&&"view"in e&&(i.registerBlockElement({view:e.view,model:e.model}),n.push(e.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:n}})}}function hk(e,t,i){const n=e.createRangeOn(t);for(const{item:e}of n.getWalker())if(e.is("element",i))return e}class uk extends Ss{static get requires(){return[ik]}static get pluginName(){return"ImageElementSupport"}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(ik);n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("image"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:img",((o,s)=>{"imageBlock"!==s.model&&"imageInline"!==s.model||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:img",((t,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlImgAttributes",s,i.modelRange)}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t){e.on(`attribute:${t}:imageInline`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item);zy(i.writer,n,o,s)}),{priority:"low"})}function i(t,i){e.on(`attribute:${i}:imageBlock`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=i,r=n.mapper.toViewElement(i.item),a=hk(n.writer,r,t);a&&(zy(n.writer,o,s,a),n.consumable.consume(i.item,e.name))}),{priority:"low"}),"a"===t&&e.on("attribute:linkHref:imageBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,"attribute:htmlLinkAttributes:imageBlock"))return;const n=i.mapper.toViewElement(t.item),o=hk(i.writer,n,"a");Hy(i.writer,t.item.getAttribute("htmlLinkAttributes"),o)}),{priority:"low"})}t("htmlImgAttributes"),i("img","htmlImgAttributes"),i("figure","htmlFigureAttributes"),i("a","htmlLinkAttributes")})),e.plugins.has("LinkImage")&&i.for("upcast").add(function(e,t){const i=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,n,o)=>{const s=n.viewItem;if(!i.findViewImgElement(s))return;const r=n.modelCursor.parent;if(!r.is("element","imageBlock"))return;const a=e.processViewAttributes(s,o);a&&o.writer.setAttribute("htmlLinkAttributes",a,r)}),{priority:"low"})}}(n,e)),o.stop())}))}}class mk extends Ss{static get requires(){return[ik]}static get pluginName(){return"MediaEmbedElementSupport"}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,n=this.editor.plugins.get(ik),o=this.editor.plugins.get(tk),s=e.config.get("mediaEmbed.elementName");o.registerBlockElement({model:"media",view:s}),n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("media"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on(`register:${s}`,((e,o)=>{"media"===o.model&&(t.extend("media",{allowAttributes:[Wy(s),"htmlFigureAttributes"]}),i.for("upcast").add(function(e,t){const i=(i,n,o)=>{function s(t,i){const s=e.processViewAttributes(t,o);s&&o.writer.setAttribute(i,s,n.modelRange)}s(n.viewItem,Wy(t))};return e=>{e.on(`element:${t}`,i,{priority:"low"})}}(n,s)),i.for("dataDowncast").add(function(e){return t=>{function i(e,i){t.on(`attribute:${i}:media`,((t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const{attributeOldValue:o,attributeNewValue:s}=i,r=n.mapper.toViewElement(i.item),a=hk(n.writer,r,e);zy(n.writer,o,s,a)}))}i(e,Wy(e)),i("figure","htmlFigureAttributes")}}(s)),e.stop())}))}}class gk extends Ss{static get requires(){return[ik]}static get pluginName(){return"ScriptElementSupport"}init(){const e=this.editor.plugins.get(ik);e.on("register:script",((t,i)=>{const n=this.editor,o=n.model.schema,s=n.conversion;o.register("htmlScript",i.modelSchema),o.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"script"}),s.for("upcast").elementToElement({view:"script",model:jy(i)}),s.for("upcast").add(Jy(i,e)),s.for("downcast").elementToElement({model:"htmlScript",view:(e,{writer:t})=>qy("script",e,t)}),s.for("downcast").add(Yy(i)),t.stop()}))}}class fk extends Ss{static get requires(){return[ik]}static get pluginName(){return"TableElementSupport"}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(ik),o=e.plugins.get("TableUtils");n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("table"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:table",((s,r)=>{"table"===r.model&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:table",((t,i,n)=>{if(!i.modelRange)return;const o=i.viewItem;s(o,"htmlTableAttributes");for(const e of o.getChildren())e.is("element","thead")&&s(e,"htmlTheadAttributes"),e.is("element","tbody")&&s(e,"htmlTbodyAttributes");function s(t,o){const s=e.processViewAttributes(t,n);s&&n.writer.setAttribute(o,s,i.modelRange)}}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t,i){e.on(`attribute:${i}:table`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const o=n.mapper.toViewElement(i.item),s=hk(n.writer,o,t);s&&(n.consumable.consume(i.item,e.name),zy(n.writer,i.attributeOldValue,i.attributeNewValue,s))}))}t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes")})),e.model.document.registerPostFixer(function(e,t){return i=>{const n=e.document.differ.getChanges();let o=!1;for(const e of n){if("attribute"!=e.type||"headingRows"!=e.attributeKey)continue;const n=e.range.start.nodeAfter,s=n.getAttribute("htmlTheadAttributes"),r=n.getAttribute("htmlTbodyAttributes");s&&!e.attributeNewValue?(i.removeAttribute("htmlTheadAttributes",n),o=!0):r&&e.attributeNewValue==t.getRows(n)&&(i.removeAttribute("htmlTbodyAttributes",n),o=!0)}return o}}(e.model,o)),s.stop())}))}}class pk extends Ss{static get requires(){return[ik]}static get pluginName(){return"StyleElementSupport"}init(){const e=this.editor.plugins.get(ik);e.on("register:style",((t,i)=>{const n=this.editor,o=n.model.schema,s=n.conversion;o.register("htmlStyle",i.modelSchema),o.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"style"}),s.for("upcast").elementToElement({view:"style",model:jy(i)}),s.for("upcast").add(Jy(i,e)),s.for("downcast").elementToElement({model:"htmlStyle",view:(e,{writer:t})=>qy("style",e,t)}),s.for("downcast").add(Yy(i)),t.stop()}))}}class bk extends Ss{static get requires(){return[ik]}static get pluginName(){return"ListElementSupport"}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(ik),o=e.plugins.get("ListEditing"),s=e.plugins.get("ListUtils"),r=["ul","ol","li"];o.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:Hy}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:Hy}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:Hy}),n.on("register",((e,o)=>{if(!r.includes(o.view))return;if(e.stop(),t.checkAttribute("$block","htmlLiAttributes"))return;const s=r.map((e=>Wy(e)));t.extend("$listItem",{allowAttributes:s}),i.for("upcast").add((e=>{e.on("element:ul",wk("htmlUlAttributes",n),{priority:"low"}),e.on("element:ol",wk("htmlOlAttributes",n),{priority:"low"}),e.on("element:li",wk("htmlLiAttributes",n),{priority:"low"})}))})),o.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:o}of t)if(o){if(o.getAttribute("listType")==n.getAttribute("listType")){const t=_k(o.getAttribute("listType")),s=o.getAttribute(t);!zd(n.getAttribute(t),s)&&i.model.schema.checkAttribute(n,t)&&(i.setAttribute(t,s,n),e.return=!0)}if(o.getAttribute("listItemId")==n.getAttribute("listItemId")){const t=o.getAttribute("htmlLiAttributes");!zd(n.getAttribute("htmlLiAttributes"),t)&&i.model.schema.checkAttribute(n,"htmlLiAttributes")&&(i.setAttribute("htmlLiAttributes",t,n),e.return=!0)}}})),o.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n}of t){const t=n.getAttribute("listType");!s.isNumberedListType(t)&&n.getAttribute("htmlOlAttributes")&&(i.removeAttribute("htmlOlAttributes",n),e.return=!0),s.isNumberedListType(t)&&n.getAttribute("htmlUlAttributes")&&(i.removeAttribute("htmlUlAttributes",n),e.return=!0)}}))}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",((t,i)=>{e.model.change((t=>{for(const n of i){const i=_k(n.getAttribute("listType"));e.model.schema.checkAttribute(n,i)&&t.setAttribute(i,{},n)}}))}))}}function wk(e,t){return(i,n,o)=>{const s=n.viewItem;n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor));const r=t.processViewAttributes(s,o);for(const t of n.modelRange.getItems({shallow:!0}))t.hasAttribute("listItemId")&&(t.hasAttribute("htmlUlAttributes")||t.hasAttribute("htmlOlAttributes")||o.writer.model.schema.checkAttribute(t,e)&&o.writer.setAttribute(e,r||{},t))}}function _k(e){return"numbered"===e||"customNumbered"==e?"htmlOlAttributes":"htmlUlAttributes"}class vk extends Ss{static get requires(){return[ik,tk]}static get pluginName(){return"CustomElementSupport"}init(){const e=this.editor.plugins.get(ik),t=this.editor.plugins.get(tk);e.on("register:$customElement",((i,n)=>{i.stop();const o=this.editor,s=o.model.schema,r=o.conversion,a=o.editing.view.domConverter.unsafeElements,l=o.data.htmlProcessor.domConverter.preElements;s.register(n.model,n.modelSchema),s.extend(n.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),o.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),r.for("upcast").elementToElement({view:/.*/,model:(i,s)=>{if("$comment"==i.name)return null;if(!function(e){try{document.createElement(e)}catch(e){return!1}return!0}(i.name))return null;if(t.getDefinitionsForView(i.name).size)return null;a.includes(i.name)||a.push(i.name),l.includes(i.name)||l.push(i.name);const r=s.writer.createElement(n.model,{htmlElementName:i.name}),c=e.processViewAttributes(i,s);let d;if(c&&s.writer.setAttribute("htmlCustomElementAttributes",c,r),i.is("element","template")&&i.getCustomProperty("$rawContent"))d=i.getCustomProperty("$rawContent");else{const e=new qh(i.document).createDocumentFragment(i),t=o.data.htmlProcessor.domConverter.viewToDom(e),n=t.firstChild;for(;n.firstChild;)t.appendChild(n.firstChild);n.remove(),d=o.data.htmlProcessor.htmlWriter.getHtml(t)}s.writer.setAttribute("htmlContent",d,r);for(const{item:e}of o.editing.view.createRangeIn(i))s.consumable.consume(e,{name:!0});return r},converterPriority:"low"}),r.for("editingDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=t.createRawElement(i);return e.hasAttribute("htmlCustomElementAttributes")&&Hy(t,e.getAttribute("htmlCustomElementAttributes"),n),n}}),r.for("dataDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=e.getAttribute("htmlContent"),o=t.createRawElement(i,null,((e,t)=>{t.setContentOf(e,n)}));return e.hasAttribute("htmlCustomElementAttributes")&&Hy(t,e.getAttribute("htmlCustomElementAttributes"),o),o}})}))}}function*yk(e,t,i){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)e.schema.checkAttributeInSelection(t,i)&&(yield t);else for(const n of function(e,t,i){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?e.schema.checkAttribute(t,i)?[e.createRangeOn(t)]:[]:e.schema.getValidRanges(e.createSelection(t).getRanges(),i)}(e,t,i))yield*n.getItems({shallow:!0})}function kk(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function Ck(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return o(e);return("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:o(e)};function o(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function Ak(e,t){const i=qo(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function xk(e){return e&&e.endsWith("px")?parseInt(e):null}function Ek(e){const t=xk(e.getStyle("width")),i=xk(e.getStyle("height"));return!(!t||!i)}const Tk=/^(image|image-inline)$/;class Sk extends Ss{constructor(){super(...arguments),this._domEmitter=new(Pn())}static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,n={}){const o=this.editor,s=o.model,r=s.document.selection,a=Pk(o,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const t in e)s.schema.checkAttribute(a,t)||delete e[t];return s.change((i=>{const{setImageSizes:o=!0}=n,r=i.createElement(a,e);return s.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==a?void 0:"auto"}),r.parent?(o&&this.setImageNaturalSizeAttributes(r),r):null}))}setImageNaturalSizeAttributes(e){const i=e.getAttribute("src");i&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change((n=>{const o=new t.window.Image;this._domEmitter.listenTo(o,"load",(()=>{e.getAttribute("width")||e.getAttribute("height")||this.editor.model.enqueueChange(n.batch,(t=>{t.setAttribute("width",o.naturalWidth,e),t.setAttribute("height",o.naturalHeight,e)})),this._domEmitter.stopListening(o,"load")})),o.src=i})))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:Tk})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){const i=Pk(e,t,null);if("imageBlock"==i){const i=function(e,t){const i=Kw(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return Ww(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&$w(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function Pk(e,t,i){const n=e.model.schema,o=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===o?"imageInline":"auto"!==o?"imageBlock":t.is("selection")?Ak(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class Ik extends Is{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,o=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,o)}))}}class Vk extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Ik(this.editor))}}class Rk extends Cs{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new Go,this.keystrokes=new Ko,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Hu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),Hu.cancel,"ck-button-cancel","cancel"),this._focusables=new ts,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Es({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const o=new Yu(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new fm(this.locale,Gm);return t.label=e("Text alternative"),t}}function Ok(e){const t=e.editing.view,i=of.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class Bk extends Ss{static get requires(){return[Of]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const n=e.commands.get("imageTextAlternative"),o=new Yu(i);return o.set({label:t("Change image text alternative"),icon:Hu.textAlternative,tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>!!e)),this.listenTo(o,"execute",(()=>{this._showForm()})),o}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(xs(Rk))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=Ok(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),As({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Ok(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class Mk extends Ss{static get requires(){return[Vk,Bk]}static get pluginName(){return"ImageTextAlternative"}}function Fk(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);null===i.attributeNewValue?(o.removeAttribute("srcset",r),o.removeAttribute("sizes",r)):i.attributeNewValue&&(o.setAttribute("srcset",i.attributeNewValue,r),o.setAttribute("sizes","100vw",r))};return e=>{e.on(`attribute:srcset:${t}`,i)}}function Nk(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);o.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class Dk extends Ua{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class Lk extends Is{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&v("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&v("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=vo(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);n.insertImage({...e,...o},t)}else n.insertImage({...e,...o})}))}}class zk extends Is{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change((n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)}))}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class Hk extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Dk),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new Lk(e),n=new zk(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class $k extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageSizeAttributes"}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function o(t,n,o,s){t.on(`attribute:${n}:${e}`,((t,n,r)=>{if(!r.consumable.consume(n.item,t.name))return;const a=r.writer,l=r.mapper.toViewElement(n.item),c=i.findViewImgElement(l);if(null!==n.attributeNewValue?a.setAttribute(o,n.attributeNewValue,c):a.removeAttribute(o,c),n.item.hasAttribute("sources"))return;const d=n.item.hasAttribute("resizedWidth");if("imageInline"===e&&!d&&!s)return;const h=n.item.getAttribute("width"),u=n.item.getAttribute("height");h&&u&&a.setStyle("aspect-ratio",`${h}/${u}`,c)}))}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>Ek(e)?xk(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>Ek(e)?xk(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add((e=>{o(e,"width","width",!0),o(e,"height","height",!0)})),t.conversion.for("dataDowncast").add((e=>{o(e,"width","width",!1),o(e,"height","height",!1)}))}}class Wk extends Is{constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(i.document.selection),s=Object.fromEntries(o.getAttributes());return s.src||s.uploadId?i.change((t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter((e=>e.getRange().containsItem(o))),l=n.insertImage(s,i.createSelection(o,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:o,newElement:l}})):null}}class jk extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImagePlaceholder"}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add((e=>{e.on("attribute:placeholder",((e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const o=n.writer,s=n.mapper.toViewElement(t.item),r=i.findViewImgElement(s);t.attributeNewValue?(o.addClass("image_placeholder",r),o.setStyle("background-image",`url(${t.attributeNewValue})`,r),o.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(o.removeClass("image_placeholder",r),o.removeStyle("background-image",r))}))}))}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,o=e.plugins.get("ImageUtils");n.addObserver(Dk),this.listenTo(n.document,"imageLoaded",((e,s)=>{const r=n.domConverter.mapDomToView(s.target);if(!r)return;const a=o.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},(e=>{e.removeAttribute("placeholder",l)}))}))}}class Uk extends Ss{static get requires(){return[Hk,$k,Sk,jk,Bw]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new Wk(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>kk(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(kk(i),i,t("image widget"))}),i.for("downcast").add(Nk(n,"imageBlock","src")).add(Nk(n,"imageBlock","alt")).add(Fk(n,"imageBlock")),i.for("upcast").elementToElement({view:Ck(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const o=e.findViewImgElement(i.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const s=qo(n.convertItem(o,i.modelCursor).modelRange.getItems());s?(n.convertChildren(i.viewItem,s),n.updateConversionResult(s,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,s)=>{const r=Array.from(s.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=s.targetRanges?e.editing.mapper.toModelRange(s.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===Ak(t.schema,l)){const e=new qh(i.document),t=r.map((t=>e.createElement("figure",{class:"image"},t)));s.content=e.createDocumentFragment(t)}})),this.listenTo(o,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(e)}))}))}}class qk extends Cs{constructor(e,t=[]){super(e),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts,this.children=this.createCollection(),this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const e of t)this.children.add(e),this._focusables.add(e),e instanceof im&&this._focusables.addMany(e.children);if(this._focusables.length>1)for(const e of this._focusables)Gk(e)&&(e.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()})));this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),Es({view:this});for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}function Gk(e){return"focusCycler"in e}class Kk extends Ss{static get pluginName(){return"ImageInsertUI"}static get requires(){return[Sk]}constructor(e){super(e),this._integrations=new Map,e.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",(()=>{this.isImageSelected=i.isImage(t.getSelectedElement())}));const n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n)}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,requiresForm:o}){this._integrations.has(e)&&v("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,formViewCreator:n,requiresForm:!!o})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let o;const s=n[0];if(1==n.length){if(!s.requiresForm)return s.buttonViewCreator(!0);o=s.buttonViewCreator(!0)}else{const t=s.buttonViewCreator(!1);o=new Lm(e,t),o.tooltip=!0,o.bind("label").to(this,"isImageSelected",(e=>i(e?"Replace image":"Insert image")))}const r=this.dropdownView=zm(e,o),a=n.map((({observable:e})=>"function"==typeof e?e():e));return r.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),r.once("change:isOpen",(()=>{const e=n.map((({formViewCreator:e})=>e(1==n.length))),i=new qk(t.locale,e);r.panelView.children.add(i)})),r}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return v("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||v("image-insert-unknown-integration",{item:i});return t.length||v("image-insert-integrations-not-registered"),t}}class Zk extends Ss{static get requires(){return[Uk,a_,Mk,Kk]}static get pluginName(){return"ImageBlock"}}class Jk extends Ss{static get requires(){return[Hk,$k,Sk,jk,Bw]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new Wk(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(Nk(n,"imageInline","src")).add(Nk(n,"imageInline","alt")).add(Fk(n,"imageInline")),i.for("upcast").elementToElement({view:Ck(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,s)=>{const r=Array.from(s.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=s.targetRanges?e.editing.mapper.toModelRange(s.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===Ak(t.schema,l)){const e=new qh(i.document),t=r.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));s.content=e.createDocumentFragment(t)}})),this.listenTo(o,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageInline")&&n.setImageNaturalSizeAttributes(e)}))}))}}class Yk extends Ss{static get requires(){return[Jk,a_,Mk,Kk]}static get pluginName(){return"ImageInline"}}class Qk extends Ss{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[Sk]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class Xk extends Is{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(Uk))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,o=n.getSelectedElement();if(!o){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(o),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(o):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let s=i.getSelectedElement();const r=n._getSavedCaption(s);o.isInlineImage(s)&&(this.editor.execute("imageTypeBlock"),s=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,s),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),o=t.plugins.get("ImageCaptionUtils");let s,r=i.getSelectedElement();r?s=o.getCaptionFromImageModelElement(r):(s=o.getCaptionFromModelSelection(i),r=s.parent),n._saveCaption(r,s),e.setSelection(r,"on"),e.remove(s)}}class eC extends Ss{static get requires(){return[Sk,Qk]}static get pluginName(){return"ImageCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new Xk(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),o=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const s=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,s),s.placeholder=o("Enter image caption"),Ds({view:t,element:s,keepOnFocus:!0});const r=e.parent.getAttribute("alt");return Gw(s,n,{label:r?o("Caption for image: %0",[r]):o("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),o=e.commands.get("imageTypeBlock"),s=e=>{if(!e.return)return;const{oldElement:n,newElement:o}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(o,e)}const s=this._getSavedCaption(n);s&&this._saveCaption(o,s)};n&&this.listenTo(n,"execute",s,{priority:"low"}),o&&this.listenTo(o,"execute",s,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Kl.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const o=t.document.differ.getChanges();for(const t of o){if("alt"!==t.attributeKey)continue;const o=t.range.start.nodeAfter;if(i.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(!t)return;e.editing.reconvertItem(t)}}}))}}class tC extends Ss{static get requires(){return[Qk]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",(o=>{const s=e.commands.get("toggleImageCaption"),r=new Yu(o);return r.set({icon:Hu.caption,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.bind("label").to(s,"value",(e=>n(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(r,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",i)}))}e.editing.view.focus()})),r}))}}function iC(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function nC(e){return new Promise(((i,n)=>{const o=e.getAttribute("src");fetch(o).then((e=>e.blob())).then((e=>{const t=oC(e,o),n=t.replace("image/",""),s=new File([e],`image.${n}`,{type:t});i(s)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((i,n)=>{const o=t.document.createElement("img");o.addEventListener("load",(()=>{const e=t.document.createElement("canvas");e.width=o.width,e.height=o.height;e.getContext("2d").drawImage(o,0,0),e.toBlob((e=>e?i(e):n()))})),o.addEventListener("error",(()=>n())),o.src=e}))}(e).then((t=>{const i=oC(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(o).then(i).catch(n):n(e)))}))}function oC(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class sC extends Ss{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=()=>{const e=this._createButton(Xu);return e.set({label:t("Upload image from computer"),tooltip:!0}),e};if(e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i),e.ui.componentFactory.add("menuBar:uploadImage",(()=>{const e=this._createButton(bp);return e.label=t("Image from computer"),e})),e.plugins.has("ImageInsertUI")){const i=e.plugins.get("ImageInsertUI");i.registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>{const n=e.ui.componentFactory.create("uploadImage");return n.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace image from computer":"Upload image from computer"))),n},formViewCreator:()=>{const n=e.ui.componentFactory.create("uploadImage");return n.withText=!0,n.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace from computer":"Upload from computer"))),n.on("execute",(()=>{i.dropdownView.isOpen=!1})),n}})}}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),o=t.config.get("image.upload.types"),s=iC(o),r=new e(t.locale),a=i.t;return r.set({acceptedType:o.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0,label:a("Upload image from computer"),icon:Hu.imageUpload}),r.bind("isEnabled").to(n),r.on("done",((e,i)=>{const n=Array.from(i).filter((e=>s.test(e.type)));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())})),r}}class rC extends(U()){constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}class aC extends Ss{constructor(){super(...arguments),this.loaders=new Uo,this._loadersMap=new Map,this._pendingAction=null}static get pluginName(){return"FileRepository"}static get requires(){return[zu]}init(){this.loaders.on("change",(()=>this._updatePendingAction())),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return v("filerepository-no-upload-adapter"),null;const t=new lC(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof lC?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,i)=>{e===t&&this._loadersMap.delete(i)}))}_updatePendingAction(){const e=this.editor.plugins.get(zu);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}class lC extends(U()){constructor(e,t){super(),this.id=f(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new rC,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new _("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new _("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,i(e)})).catch((e=>{t.isFulfilled=!0,n(e)}))})),t}}class cC extends Ss{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.uploadStatusChange=(e,t,i)=>{const n=this.editor,o=t.item,s=o.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(aC),l=s?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(o),h=i.writer;if("reading"==l)return dC(d,h),void hC(r,c,d,h);if("uploading"==l){const e=a.loaders.get(s);return dC(d,h),void(e?(uC(d,h),function(e,t,i,n){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",o)}))}))}(d,h,e,n.editing.view),function(e,t,i,n){if(n.data){const o=e.findViewImgElement(t);i.setAttribute("src",n.data,o)}}(r,d,h,e)):hC(r,c,d,h))}"complete"==l&&a.loaders.get(s)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(d,h,n.editing.view),function(e,t){gC(e,t,"progressBar")}(d,h),uC(d,h),function(e,t){t.removeClass("ck-appear",e)}(d,h)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function dC(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function hC(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const o=e.findViewImgElement(i);o.getAttribute("src")!==t&&n.setAttribute("src",t,o),mC(i,"placeholder")||n.insert(n.createPositionAfter(o),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function uC(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),gC(e,t,"placeholder")}function mC(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function gC(e,t,i){const n=mC(e,i);n&&t.remove(t.createRangeOn(n))}class fC extends Is{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=vo(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if(t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);this._uploadImage(e,o,t)}else this._uploadImage(e,o)}))}_uploadImage(e,t,i){const n=this.editor,o=n.plugins.get(aC).createLoader(e),s=n.plugins.get("ImageUtils");o&&s.insertImage({...t,uploadId:o.id},i)}}class pC extends Ss{static get requires(){return[aC,If,Bw,Sk]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(aC),o=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline"),r=iC(e.config.get("image.upload.types")),a=new fC(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const o=Array.from(i.dataTransfer.files).filter((e=>!!e&&r.test(e.type)));o.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.execute("uploadImage",{file:o})})))})),this.listenTo(s,"inputTransformation",((t,i)=>{const s=Array.from(e.editing.view.createRangeIn(i.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(o,e)&&!e.getAttribute("uploadProcessed"))).map((e=>({promise:nC(e),imageElement:e})));if(!s.length)return;const r=new qh(e.editing.view.document);for(const e of s){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),o=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,s="$graveyard"==t.position.root.rootName;for(const t of bC(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=n.loaders.get(e);i&&(s?o.has(e)||i.abort():(o.add(e),this._uploadImageElements.set(e,t),"idle"==i.status&&this._readAndUpload(i)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e),o.setImageNaturalSizeAttributes(t)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,o=t.plugins.get(aC),s=t.plugins.get(If),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",l.get(e.id))})),e.read().then((()=>{const o=e.upload(),s=l.get(e.id);if(r.isSafari){const e=t.editing.mapper.toViewElement(s),i=a.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}return t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Uploading image")),i.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",s)})),o})).then((o=>{i.enqueueChange({isUndoable:!1},(i=>{const s=l.get(e.id);i.setAttribute("uploadStatus","complete",s),t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Image upload complete")),this.fire("uploadComplete",{data:o,imageElement:s})})),c()})).catch((o=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw o;"error"==e.status&&o&&s.showWarning(o,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},(t=>{t.remove(l.get(e.id))})),c()}));function c(){i.enqueueChange({isUndoable:!1},(t=>{const i=l.get(e.id);t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i),l.delete(e.id)})),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");if(""!=o){const e={srcset:o};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}}function bC(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}const wC=function(e,t){return function(i,n){if(null==i)return i;if(!ri(i))return e(i,n);for(var o=i.length,s=t?o:-1,r=Object(i);(t?s--:++s{t.setAttribute("resizedWidth",e.width,o),t.removeAttribute("resizedHeight",o),n.setImageNaturalSizeAttributes(o)}))}}class kC extends Ss{static get requires(){return[Sk]}static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new yC(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add((t=>t.on(`attribute:resizedWidth:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,o),n.addClass("image_resized",o)):(n.removeStyle("width",o),n.removeClass("image_resized",o))})))),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:e=>({key:"style",value:{height:e}})}),t.conversion.for("editingDowncast").add((t=>t.on(`attribute:resizedHeight:${e}`,((t,n,o)=>{if(!o.consumable.consume(n.item,t.name))return;const s=o.writer,r=o.mapper.toViewElement(n.item),a="imageInline"===e?i.findViewImgElement(r):r;null!==n.attributeNewValue?s.setStyle("height",n.attributeNewValue,a):s.removeStyle("height",a)})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:e=>Ek(e)?null:e.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:e=>Ek(e)?null:e.getStyle("height")}})}}const CC={small:Hu.objectSizeSmall,medium:Hu.objectSizeMedium,large:Hu.objectSizeLarge,custom:Hu.objectSizeCustom,original:Hu.objectSizeFull};class AC extends Ss{static get requires(){return[kC]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:o}=e;t.ui.componentFactory.add(i,(i=>{const s=new Yu(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!CC[o])throw new _("imageresizebuttons-missing-icon",t,e);if(s.set({label:a,icon:CC[o],tooltip:a,isToggleable:!0}),s.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&xC(e)){const e=t.plugins.get("ImageCustomResizeUI");this.listenTo(s,"execute",(()=>{e._showForm(this._resizeUnit)}))}else{const e=n?n+this._resizeUnit:null;s.bind("isOn").to(r,"value",EC(e)),this.listenTo(s,"execute",(()=>{t.execute("resizeImage",{width:e})}))}return s}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),o=o=>{const s=t.commands.get("resizeImage"),r=zm(o,Cm),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:CC.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(s,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isEnabled").to(this),Wm(r,(()=>this._getResizeDropdownListItemDefinitions(e,s)),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",(e=>{"onClick"in e.source?e.source.onClick():(t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus())})),r};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?xC(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):xC(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new Uo,o=e.map((e=>xC(e)?{...e,valueWithUnits:"custom"}:e.value?{...e,valueWithUnits:`${e.value}${this._resizeUnit}`}:{...e,valueWithUnits:null}));for(const e of o){let s=null;if(i.plugins.has("ImageCustomResizeUI")&&xC(e)){const n=i.plugins.get("ImageCustomResizeUI");s={type:"button",model:new Vf({label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{n._showForm(this._resizeUnit)}})};const r=vC(o,"valueWithUnits");s.model.bind("isOn").to(t,"value",TC(r))}else s={type:"button",model:new Vf({commandName:"resizeImage",commandValue:e.valueWithUnits,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})},s.model.bind("isOn").to(t,"value",EC(e.valueWithUnits));s.model.bind("isEnabled").to(t,"isEnabled"),n.add(s)}return n}}function xC(e){return"custom"===e.value}function EC(e){return t=>null===e&&t===e||null!==t&&t.width===e}function TC(e){return t=>!e.some((e=>EC(e)(t)))}const SC="image_resized";class PC extends Ss{static get requires(){return[p_,Sk]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(Dk),this.listenTo(t.document,"imageLoaded",((n,o)=>{if(!o.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const s=e.editing.view.domConverter,r=s.domToView(o.target),a=i.getImageWidgetFromImageView(r);let l=this.editor.plugins.get(p_).getResizerByViewElement(a);if(l)return void l.redraw();const c=e.editing.mapper,d=c.toModelElement(a);l=e.plugins.get(p_).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:a,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>s.mapViewToDom(c.toViewElement(d)),isCentered:()=>"alignCenter"==d.getAttribute("imageStyle"),onCommit(i){t.change((e=>{e.removeClass(SC,a)})),e.execute("resizeImage",{width:i})}}),l.on("updateSize",(()=>{a.hasClass(SC)||t.change((e=>{e.addClass(SC,a)}));const e="imageInline"===d.name?r:a;e.getStyle("height")&&t.change((t=>{t.removeStyle("height",e)}))})),l.bind("isEnabled").to(this)}))}}function IC(e){if(!e)return null;const[,t,i]=e.trim().match(/([.,\d]+)(%|px)$/)||[],n=Number.parseFloat(t);return Number.isNaN(n)?null:{value:n,unit:i}}function VC(e,t,i){return"px"===i?{value:t.value,unit:"px"}:{value:t.value/e*100,unit:"%"}}function RC(e){const{editing:t}=e,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);if(!i)return null;const n=t.mapper.toViewElement(i);return{model:i,view:n,dom:t.view.domConverter.mapViewToDom(n)}}class OC extends Cs{constructor(e,t,i){super(e);const n=this.locale.t;this.focusTracker=new Go,this.keystrokes=new Ko,this.unit=t,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(n("Save"),Hu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Hu.cancel,"ck-button-cancel","cancel"),this._focusables=new ts,this._validators=i,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Es({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const o=new Yu(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new fm(this.locale,Km);return t.label=e("Resize image (in %0)",this.unit),t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(null===e)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return null===e?null:`${e}${t}`}}class BC extends Ss{static get requires(){return[Of]}static get pluginName(){return"ImageCustomResizeUI"}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(xs(OC))(t.locale,e,function(e){const t=e.t;return[e=>""===e.rawSize.trim()?t("The value must not be empty."):null===e.parsedSize?t("The value should be a plain number."):void 0]}(t)),this._form.render(),this.listenTo(this._form,"submit",(()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))})),this.listenTo(this._form.labeledInput,"change:errorText",(()=>{t.ui.update()})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),As({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:Ok(t)});const n=function(e,t){const i=RC(e);if(!i)return null;const n=IC(i.model.getAttribute("resizedWidth")||null);return n?n.unit===t?n:VC(Jw(i.dom),{unit:"px",value:new Nn(i.dom).width},t):null}(t,e),o=n?n.value.toFixed(1):"",s=function(e,t){const i=RC(e);if(!i)return null;const n=Jw(i.dom),o=IC(window.getComputedStyle(i.dom).minWidth)||{value:1,unit:"px"};return{unit:t,lower:Math.max(.1,VC(n,o,t).value),upper:"px"===t?n:100}}(t,e);i.fieldView.value=i.fieldView.element.value=o,s&&Object.assign(i.fieldView,{min:s.lower.toFixed(1),max:Math.ceil(s.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class MC extends Is{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const o=e.value,{setImageSizes:s=!0}=e;let r=n.getClosestSelectedImageElement(i.document.selection);o&&this.shouldConvertImageType(o,r)&&(this.editor.execute(n.isBlockImage(r)?"imageTypeInline":"imageTypeBlock",{setImageSizes:s}),r=n.getClosestSelectedImageElement(i.document.selection)),!o||this._styles.get(o).isDefault?t.removeAttribute("imageStyle",r):t.setAttribute("imageStyle",o,r),s&&n.setImageNaturalSizeAttributes(r)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const{objectFullWidth:FC,objectInline:NC,objectLeft:DC,objectRight:LC,objectCenter:zC,objectBlockLeft:HC,objectBlockRight:$C}=Hu,WC={get inline(){return{name:"inline",title:"In line",icon:NC,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:DC,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:HC,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:zC,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:LC,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:$C,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:zC,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:LC,modelElements:["imageBlock"],className:"image-style-side"}}},jC={full:FC,left:HC,right:$C,center:zC,inlineLeft:DC,inlineRight:LC,inline:NC},UC=[{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 qC(e){v("image-style-configuration-definition-invalid",e)}const GC={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>function(e){e="string"==typeof e?WC[e]?{...WC[e]}:{name:e}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(WC[e.name],e);"string"==typeof e.icon&&(e.icon=jC[e.icon]||e.icon);return e}(e))).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:o}=e;if(!(n&&n.length&&o))return qC({style:e}),!1;{const o=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>o.includes(e))))return v("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...UC]:[]},warnInvalidStyle:qC,DEFAULT_OPTIONS:WC,DEFAULT_ICONS:jC,DEFAULT_DROPDOWN_DEFINITIONS:UC};function KC(e,t){for(const i of t)if(i.name===e)return i}class ZC extends Ss{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[Sk]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=GC,i=this.editor,n=i.plugins.has("ImageBlockEditing"),o=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(n,o)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:n,isInlinePluginLoaded:o}),this._setupConversion(n,o),this._setupPostFixer(),i.commands.add("imageStyle",new MC(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,o=(s=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=KC(t.attributeNewValue,s),o=KC(t.attributeOldValue,s),r=i.mapper.toViewElement(t.item),a=i.writer;o&&a.removeClass(o.className,r),n&&a.addClass(n.className,r)});var s;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=qo(i.modelRange.getItems());if(s&&n.schema.checkAttribute(s,"imageStyle"))for(const e of t[s.name])n.consumable.consume(o,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,s)}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",o),i.data.downcastDispatcher.on("attribute:imageStyle",o),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(Sk),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let o=!1;for(const s of t.differ.getChanges())if("insert"==s.type||"attribute"==s.type&&"imageStyle"==s.attributeKey){let t="insert"==s.type?s.position.nodeAfter:s.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),o=!0)}return o}))}}class JC extends Ss{static get requires(){return[ZC]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=YC(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=YC([...t.filter(N),...GC.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let o;const{defaultItem:s,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>QC(t)===e)))).map((e=>{const t=i.create(e);return e===s&&(o=t),t}));r.length!==l.length&&GC.warnInvalidStyle({dropdown:e});const c=zm(n,Lm),d=c.buttonView,h=d.arrowView;return Hm(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:XC(a,o.label),class:null,tooltip:!0}),h.unbind("label"),h.set({label:a}),d.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(So);return t<0?o.icon:l[t].icon})),d.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(So);return XC(a,t<0?o.label:l[t].label)})),d.bind("isOn").toMany(l,"isOn",((...e)=>e.some(So))),d.bind("class").toMany(l,"isOn",((...e)=>e.some(So)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:o.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(So))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(QC(t),(i=>{const n=this.editor.commands.get("imageStyle"),o=new Yu(i);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>e===t)),o.on("execute",this._executeCommand.bind(this,t)),o}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function YC(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function QC(e){return`imageStyle:${e}`}function XC(e,t){return(e?e+": ":"")+t}class eA extends Ss{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new Rs(e)),e.commands.add("outdent",new Rs(e))}}class tA extends Ss{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Hu.indent:Hu.outdent,o="ltr"==t.uiLanguageDirection?Hu.outdent:Hu.indent;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),o)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(()=>{const n=this._createButton(Yu,e,t,i);return n.set({tooltip:!0}),n})),n.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(pp,e,t,i)))}_createButton(e,t,i,n){const o=this.editor,s=o.commands.get(t),r=new e(o.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(s,"isEnabled"),this.listenTo(r,"execute",(()=>{o.execute(t),o.editing.view.focus()})),r}}class iA extends Is{constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=qo(this.editor.model.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter((e=>this._isIndentationChangeAllowed(e)))}_isIndentationChangeAllowed(e){const t=this.editor;if(!t.model.schema.checkAttribute(e,"blockIndent"))return!1;if(!t.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!t.plugins.get("ListUtils").isListItemBlock(e)}}class nA{constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class oA{constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const sA=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class rA{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const s=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,s);for(const t in e.styles)n.setStyle(t,e.styles[t],s);n.setCustomProperty("link",!0,s),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),s):n.wrap(i.mapper.toViewRange(t.range),s):n.unwrap(i.mapper.toViewRange(t.range),s)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const o=n.toViewElement(t.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));for(const e of this._definitions){const n=Zo(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,s):i.setAttribute(e,t,s);e.classes&&i.addClass(e.classes,s);for(const t in e.styles)i.setStyle(t,e.styles[t],s)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,s):i.removeAttribute(e,s);e.classes&&i.removeClass(e.classes,s);for(const t in e.styles)i.removeStyle(t,s)}}}))}}}const aA=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,lA=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,cA=/^((\w+:(\/{2,})?)|(\W))/i,dA=["https?","ftps?","mailto"],hA="Ctrl+K";function uA(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function mA(e,t=dA){const i=String(e),n=t.join("|");return function(e,t){const i=e.replace(aA,"");return!!i.match(t)}(i,new RegExp(`${"^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("",n)}`,"i"))?i:"#"}function gA(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function fA(e,t){const i=(n=e,lA.test(n)?"mailto:":t);var n;const o=!!i&&!pA(e);return e&&o?i+e:e}function pA(e){return cA.test(e)}function bA(e){window.open(e,"_blank","noopener")}class wA extends Is{constructor(){super(...arguments),this.manualDecorators=new Uo,this.automaticDecorators=new rA}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||qo(t.getSelectedBlocks());gA(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,o=[],s=[];for(const e in t)t[e]?o.push(e):s.push(e);i.change((t=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=_A(n);let l=vb(r,"linkHref",n.getAttribute("linkHref"),i);n.getAttribute("linkHref")===a&&(l=this._updateLinkContent(i,t,l,e)),t.setAttribute("linkHref",e,l),o.forEach((e=>{t.setAttribute(e,!0,l)})),s.forEach((e=>{t.removeAttribute(e,l)})),t.setSelection(t.createPositionAfter(l.end.nodeBefore))}else if(""!==e){const s=Zo(n.getAttributes());s.set("linkHref",e),o.forEach((e=>{s.set(e,!0)}));const{end:a}=i.insertContent(t.createText(e,s),r);t.setSelection(a)}["linkHref",...o,...s].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const r=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of r)this._isRangeToUpdate(e,a)&&l.push(e);for(const r of l){let a=r;if(1===l.length){const o=_A(n);n.getAttribute("linkHref")===o&&(a=this._updateLinkContent(i,t,r,e),t.setSelection(t.createSelection(a)))}t.setAttribute("linkHref",e,a),o.forEach((e=>{t.setAttribute(e,!0,a)})),s.forEach((e=>{t.removeAttribute(e,a)}))}}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return gA(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}_updateLinkContent(e,t,i,n){const o=t.createText(n,{linkHref:n});return e.insertContent(o,i)}}function _A(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const i=t[0];return i.is("$text")||i.is("$textProxy")?i.data:null}}class vA extends Is{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();gA(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const o=i.isCollapsed?[vb(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class yA extends(U()){constructor({id:e,label:t,attributes:i,classes:n,styles:o,defaultValue:s}){super(),this.id=e,this.set("value",void 0),this.defaultValue=s,this.label=t,this.attributes=i,this.classes=n,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const kA="automatic",CA=/^(https?:)?\/\//;class AA extends Ss{static get pluginName(){return"LinkEditing"}static get requires(){return[ub,Xp,Bw]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:uA}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>uA(mA(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new wA(e)),e.commands.add("unlink",new vA(e));const i=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${Dy(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter((e=>e.mode===kA))),this._enableManualDecorators(i.filter((e=>"manual"===e.mode)));e.plugins.get(ub).registerAttribute("linkHref"),function(e,t,i,n){const o=e.editing.view,s=new Set;o.document.registerPostFixer((o=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=vb(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(o.addClass(n,e),s.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of s.values())e.removeClass(n,t),s.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:kA,callback:e=>!!e&&CA.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new yA(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:o})=>{if((o.is("selection")||i.isInline(o))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((e,t)=>{if(!(r.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let i=t.domTarget;if("a"!=i.tagName.toLowerCase()&&(i=i.closest("a")),!i)return;const n=i.getAttribute("href");n&&(e.stop(),t.preventDefault(),bA(n))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,i)=>{const n=e.commands.get("link").value;!!n&&i.keyCode===go.enter&&i.altKey&&(t.stop(),bA(n))}))}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{n.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change((t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))))}))}))}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,n)=>{t.change((e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=fA(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}}))}))}}class xA extends Cs{constructor(e,t,i){super(e),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts;const n=e.t;this._validators=i,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Hu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Hu.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),Es({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createUrlInput(){const e=this.locale.t,t=new fm(this.locale,Gm);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const o=new Yu(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new Qu(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",((e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e)),n.on("execute",(()=>{i.set("value",!n.isOn)})),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Cs;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class EA extends Cs{constructor(e,t={}){super(e),this.focusTracker=new Go,this.keystrokes=new Ko,this._focusables=new ts;const i=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(i("Unlink"),'',"unlink"),this.editButtonView=this._createButton(i("Edit link"),Hu.pencil,"edit"),this.set("href",void 0),this._linkConfig=t,this._focusCycler=new Am({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new Yu(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new Yu(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&mA(e,this._linkConfig.allowedProtocols))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||i("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}const TA="link-ui";class SA extends Ss{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[Of]}static get pluginName(){return"LinkUI"}init(){const e=this.editor,t=this.editor.t;e.editing.view.addObserver(jh),this._balloon=e.plugins.get(Of),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:TA,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:TA,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:hA},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new EA(e.locale,e.config.get("link")),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(hA,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new(xs(xA))(e.locale,t,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isEnabled").to(t,"isEnabled"),n.saveButtonView.bind("isEnabled").to(t,"isEnabled"),this.listenTo(n,"submit",(()=>{if(n.isValid()){const{value:t}=n.urlInputView.fieldView.element,o=fA(t,i);e.execute("link",o,n.getDecoratorSwitchesState()),this._closeFormView()}})),this.listenTo(n.urlInputView,"change:errorText",(()=>{e.ui.update()})),this.listenTo(n,"cancel",(()=>{this._closeFormView()})),n.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link");e.ui.componentFactory.add("link",(()=>{const e=this._createButton(Yu);return e.set({tooltip:!0,isToggleable:!0}),e.bind("isOn").to(t,"value",(e=>!!e)),e})),e.ui.componentFactory.add("menuBar:link",(()=>this._createButton(pp)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),o=new e(t.locale),s=i.t;return o.set({label:s("Link"),icon:'',keystroke:hA}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>this._showUI(!0))),o}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(hA,((t,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),As({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=s();const o=()=>{const e=this._getSelectedLinkElement(),t=s();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function s(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n;if(t.markers.has(TA)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(TA)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&$w(i))return PA(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=PA(i.start),o=PA(i.end);return n&&n==o&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(TA))t.updateMarker(TA,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(TA,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(TA,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(TA)&&e.change((e=>{e.removeMarker(TA)}))}}function PA(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const IA=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 VA extends Ss{static get requires(){return[lb,AA]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?vb(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,o=n.getFirstPosition(),s=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,o)||t);r&&(r=r.getJoined(this._expandLinkRange(i,s)||t)),r&&(r.start.isBefore(o)||r.end.isAfter(s))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),o=e.commands.get("link");n.on("inputTransformation",((e,n)=>{if(!this.isEnabled||!o.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const s=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(IA);a&&a[2]===r&&(t.change((e=>{this._selectEntireLinks(e,s),o.execute(r)})),e.stop())}),{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new hb(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=RA(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:o,url:s}=i;if(!n.isTyping)return;const r=o.end.getShiftedBy(-1),a=r.getShiftedBy(-s.length),l=e.model.createRange(a,r);this._applyAutoLink(s,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=db(e,t),o=RA(i);if(o){const e=t.createRange(n.end.getShiftedBy(-o.length),n.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=fA(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&pA(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange((o=>{o.setAttribute("linkHref",e,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function RA(e){const t=IA.exec(e);return t?t[2]:null}class OA{constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=vo(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){return qo(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of BA(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some((e=>t.getAttribute(e)!==this._startElement.getAttribute(e))))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}function*BA(e,t="forward"){const i="forward"==t,n=[];let o=null;for(;NA(e);){let t=null;if(o){const i=e.getAttribute("listIndent"),s=o.getAttribute("listIndent");i>s?n[s]=o:ie.getAttribute("listItemId")!=t))}function JA(e){return Array.from(e).filter((e=>"$graveyard"!==e.root.rootName)).sort(((e,t)=>e.index-t.index))}function YA(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function QA(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function XA(e){return"numbered"==e||"customNumbered"==e}function ex(e,t,i){return LA(t,{direction:"forward"}).pop().index>e.index?qA(e,t,i):[]}class tx extends Is{constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=ix(e.document.selection);e.change((e=>{const i=[];ZA(t)&&!HA(t[0])?("forward"==this._direction&&i.push(...GA(t,e)),i.push(...UA(t[0],e))):"forward"==this._direction?i.push(...GA(t,e,{expand:!0})):i.push(...function(e,t){const i=WA(e=vo(e)),n=new Set,o=Math.min(...i.map((e=>e.getAttribute("listIndent")))),s=new Map;for(const e of i)s.set(e,OA.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)KA(e,t);else{if(e.getAttribute("listIndent")==o){const i=ex(e,s.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return JA(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=OA.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)}))}_fireAfterExecute(e){this.fire("afterExecute",JA(new Set(e)))}_checkEnabled(){let e=ix(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(ZA(e)&&!HA(e[0]))return!0;e=WA(e),t=e[0];const i=OA.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function ix(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex((e=>!NA(e)));return-1!=i&&(t.length=i),t}class nx extends Is{constructor(e,t,i={}){super(e),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=YA(t),o=Array.from(i.selection.getSelectedBlocks()).filter((e=>t.schema.checkAttribute(e,"listType")||QA(e,t.schema))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((r=>{if(s){const e=o[o.length-1],t=LA(e,{direction:"forward"}),i=[];t.length>1&&i.push(...UA(t[1],r)),i.push(...KA(o,r)),i.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:o}of BA(e.nextSibling,"forward")){const e=o.getAttribute("listIndent");if(0==e)break;e{const{firstElement:s,lastElement:r}=this._getMergeSubjectElements(i,e),a=s.getAttribute("listIndent")||0,l=r.getAttribute("listIndent"),c=r.getAttribute("listItemId");if(a!=l){const e=(d=r,Array.from(new OA(d,{direction:"forward",higherIndent:!0})));n.push(...GA([r,...e],o,{indentBy:a-l,expand:a{const t=UA(this._getStartBlock(),e);this._fireAfterExecute(t)}))}_fireAfterExecute(e){this.fire("afterExecute",JA(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&NA(t)&&!HA(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class rx extends Ss{static get pluginName(){return"ListUtils"}expandListBlocksToCompleteList(e){return jA(e)}isFirstBlockOfListItem(e){return HA(e)}isListItemBlock(e){return NA(e)}expandListBlocksToCompleteItems(e,t={}){return WA(e,t)}isNumberedListType(e){return XA(e)}}function ax(e){return e.is("element","ol")||e.is("element","ul")}function lx(e){return e.is("element","li")}function cx(e,t,i,n=ux(i,t)){return e.createAttributeElement(hx(i),null,{priority:2*t/100-100,id:n})}function dx(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function hx(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function ux(e,t){return`list-${e}-${t}`}function mx(e,t){const i=e.nodeBefore;if(NA(i)){let e=i;for(const{node:i}of BA(e,"backward"))if(e=i,t.has(e))return;t.set(i,e)}else{const i=e.nodeAfter;NA(i)&&t.set(i,i)}}function gx(){return(e,t,i)=>{const{writer:n,schema:o}=i;if(!t.modelRange)return;const s=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>o.checkAttribute(e,"listItemId")));if(!s.length)return;const r=FA.next(),a=function(e){let t=0,i=e.parent;for(;i;){if(lx(i))t++;else{const e=i.previousSibling;e&&lx(e)&&t++}i=i.parent}return t}(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=s[0].getAttribute("listType");c&&(l=c);const d={listItemId:r,listIndent:a,listType:l};for(const e of s)e.hasAttribute("listItemId")||n.setAttributes(d,e);s.length>1&&s[1].getAttribute("listItemId")!=d.listItemId&&i.keepEmptyElement(s[0])}}function fx(){return(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0}))return;const n=new qh(t.viewItem.document);for(const e of Array.from(t.viewItem.getChildren()))lx(e)||ax(e)||n.remove(e)}}function px(e,t,i,{dataPipeline:n}={}){const o=function(e){return(t,i)=>{const n=[];for(const i of e)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every((e=>!1!==i.test(t,e)))&&(n.forEach((e=>i.consume(t,e))),!0)}}(e);return(s,r,a)=>{const{writer:l,mapper:c,consumable:d}=a,h=r.item;if(!e.includes(r.attributeKey))return;if(!o(h,d))return;const u=function(e,t,i){const n=i.createRangeOn(e),o=t.toViewRange(n).getTrimmed();return o.end.nodeBefore}(h,c,i);wx(u,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(u,l);const m=function(e,t,i,n,{dataPipeline:o}){let s=n.createRangeOn(t);if(!HA(e))return s;for(const r of i){if("itemMarker"!=r.scope)continue;const i=r.createElement(n,e,{dataPipeline:o});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(s.start,i),s=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!r.createWrapperElement||!r.canWrapElement)continue;const a=r.createWrapperElement(n,e,{dataPipeline:o});n.setCustomProperty("listItemWrapper",!0,a),r.canWrapElement(e)?s=n.wrap(s,a):(s=n.wrap(n.createRangeOn(i),a),s=n.createRange(s.start,n.createPositionAfter(t)))}return s}(h,u,t,l,{dataPipeline:n});!function(e,t,i,n){if(!e.hasAttribute("listIndent"))return;const o=e.getAttribute("listIndent");let s=e;for(let e=o;e>=0;e--){const o=dx(n,e,s.getAttribute("listItemId")),r=cx(n,e,s.getAttribute("listType"));for(const e of i)"list"!=e.scope&&"item"!=e.scope||!s.hasAttribute(e.attributeName)||e.setAttributeOnDowncast(n,s.getAttribute(e.attributeName),"list"==e.scope?r:o);if(t=n.wrap(t,o),t=n.wrap(t,r),0==e)break;if(s=OA.first(s,{lowerIndent:!0}),!s)break}}(h,m,t,l)}}function bx(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!_x(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function wx(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];o(t.createPositionBefore(e).getWalker({direction:"backward"})),o(t.createRangeIn(e).getWalker());for(const e of n)t.remove(e);function o(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function _x(e,t,i=DA(e)){if(!NA(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return i.length<2}const vx=["listType","listIndent","listItemId"];class yx extends Ss{static get pluginName(){return"ListEditing"}static get requires(){return[Lb,lb,rx,Bw]}constructor(e){super(e),this._downcastStrategies=[],e.config.define("list.multiBlock",!0)}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new _("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:vx}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const e of vx)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new nx(e,"numbered")),e.commands.add("bulletedList",new nx(e,"bulleted")),e.commands.add("customNumberedList",new nx(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new nx(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new tx(e,"forward")),e.commands.add("outdentList",new tx(e,"backward")),e.commands.add("splitListItemBefore",new sx(e,"before")),e.commands.add("splitListItemAfter",new sx(e,"after")),i&&(e.commands.add("mergeListItemBackward",new ox(e,"backward")),e.commands.add("mergeListItemForward",new ox(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...vx,...this._downcastStrategies.map((e=>e.attributeName))]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",((n,o)=>{const s=e.model.document.selection;YA(e.model)||e.model.change((()=>{const r=s.getFirstPosition();if(s.isCollapsed&&"backward"==o.direction){if(!r.isAtStart)return;const i=r.parent;if(!NA(i))return;if(OA.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:kx(e.model,"backward")})}else $A(i)||e.execute("splitListItemAfter"),e.execute("outdentList");o.preventDefault(),n.stop()}else{if(s.isCollapsed&&!s.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:kx(e.model,"forward")}),o.preventDefault(),n.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",((i,n)=>{const o=t.document,s=o.selection.getFirstPosition().parent;if(o.selection.isCollapsed&&NA(s)&&s.isEmpty&&!n.isSoft){const t=HA(s),o=$A(s);t&&o?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!o?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):o&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}}),{context:"li"}),this.listenTo(n,"afterExecute",(()=>{const t=i.get("splitListItemBefore");if(t.refresh(),!t.isEnabled)return;2===DA(e.model.document.selection.getLastPosition().parent).length&&t.execute()}))}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),o=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,{writer:t})=>t.createElement(o,{listType:""})}).elementToElement({view:"p",model:(e,{writer:t})=>e.parent&&e.parent.is("element","li")?t.createElement(o,{listType:""}):null,converterPriority:"high"}).add((e=>{e.on("element:li",gx()),e.on("element:ul",fx(),{priority:"high"}),e.on("element:ol",fx(),{priority:"high"})})),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:o,view:bx(i),converterPriority:"high"}).add((e=>{var n;e.on("attribute",px(i,this._downcastStrategies,t)),e.on("remove",(n=t.schema,(e,t,i)=>{const{writer:o,mapper:s}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=s.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=s.toViewPosition(l,{isPhantom:!0}),d=o.createRange(a,c).getTrimmed().end.nodeBefore;d&&wx(d,o,s)}))})),e.conversion.for("dataDowncast").elementToElement({model:o,view:bx(i,{dataPipeline:!0}),converterPriority:"high"}).add((e=>{e.on("attribute",px(i,this._downcastStrategies,t,{dataPipeline:!0}))}));const s=(r=this._downcastStrategies,a=e.editing.view,(e,t)=>{if(t.modelPosition.offset>0)return;const i=t.modelPosition.parent;if(!NA(i))return;if(!r.some((e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(i))))return;const n=t.mapper.toViewElement(i),o=a.createRangeIn(n),s=o.getWalker();let l=o.start;for(const{item:e}of s){if(e.is("element")&&t.mapper.toModelElement(e)||e.is("$textProxy"))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(e),s.skip((({previousPosition:e})=>!e.isEqual(l))))}t.viewPosition=l});var r,a;e.editing.mapper.on("modelToViewPosition",s),e.data.mapper.on("modelToViewPosition",s),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Map,l=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)mx(e.position,a),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):mx(e.position.getShiftedBy(e.length),a);else if("remove"==e.type&&e.attributes.has("listItemId"))mx(e.position,a);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(mx(e.range.start,a),null===e.attributeNewValue?(mx(e.range.start.getShiftedBy(1),a),s(t)&&r.push(t)):l.add(t)):NA(t)&&s(t)&&r.push(t)}for(const e of a.values())r.push(...o(e,l));for(const e of new Set(r))t.reconvertItem(e)};function o(e,t){const n=[],o=new Set,a=[];for(const{node:l,previous:c}of BA(e,"forward")){if(o.has(l))continue;const e=l.getAttribute("listIndent");c&&ei.includes(e))));const d=LA(l,{direction:"forward"});for(const e of d)o.add(e),(s(e,d)||r(e,a,t))&&n.push(e)}return n}function s(e,o){const s=t.mapper.toViewElement(e);if(!s)return!1;if(n.fire("checkElement",{modelElement:e,viewElement:s}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=_x(e,i,o);return!(!r||!s.is("element","p"))||!(r||!s.is("element","span"))}function r(e,i,o){if(o.has(e))return!1;const s=t.mapper.toViewElement(e);let r=i.length-1;for(let e=s.parent;!e.is("editableElement");e=e.parent){const t=lx(e),o=ax(e);if(!o&&!t)continue;const s="checkAttributes:"+(t?"item":"list");if(n.fire(s,{viewElement:e,modelAttributes:i[r]}))break;if(o&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",((e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())})),this.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{t.name==hx(i.listType)&&t.id==ux(i.listType,i.listIndent)||(e.return=!0,e.stop())}))}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer((i=>function(e,t,i,n){const o=e.document.differ.getChanges(),s=new Map,r=n.editor.config.get("list.multiBlock");let a=!1;for(const n of o){if("insert"==n.type&&"$text"!=n.name){const o=n.position.nodeAfter;if(!e.schema.checkAttribute(o,"listItemId"))for(const e of Array.from(o.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,o),a=!0);mx(n.position,s),n.attributes.has("listItemId")||mx(n.position.getShiftedBy(n.length),s);for(const{item:t,previousPosition:i}of e.createRangeIn(o))NA(t)&&mx(i,s)}else"remove"==n.type?mx(n.position,s):"attribute"==n.type&&i.includes(n.attributeKey)&&(mx(n.range.start,s),null===n.attributeNewValue&&mx(n.range.start.getShiftedBy(1),s));if(!r&&"attribute"==n.type&&vx.includes(n.attributeKey)){const e=n.range.start.nodeAfter;null===n.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),a=!0):null===n.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),a=!0)}}const l=new Set;for(const e of s.values())a=n.fire("postFixer",{listNodes:new MA(e),listHead:e,writer:t,seenIds:l})||a;return a}(e,i,t,this))),this.on("postFixer",((e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,o=null,s=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===o?(o=e-i,a=i):(o>e&&(o=e),a=e-o),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),s=!0,n=a}else o=null,i=e+1,n=e}return s}(t,i)||e.return}),{priority:"high"}),this.on("postFixer",((e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let o=!1;for(const{node:s}of e){if(n.has(s))continue;let e=s.getAttribute("listType"),r=s.getAttribute("listItemId");if(t.has(r)&&(r=FA.next()),t.add(r),s.is("element","listItem"))s.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,s),o=!0);else for(const t of LA(s,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=FA.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),o=!0)}return o}(t,n,i)||e.return}),{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const o=i.is("documentFragment")?Array.from(i.getChildren()):[i];if(!o.length)return;const s=(n?e.createSelection(n):e.document.selection).getFirstPosition();let r;if(NA(s.parent))r=s.parent;else{if(!NA(s.nodeBefore))return;r=s.nodeBefore}e.change((e=>{const t=r.getAttribute("listType"),i=r.getAttribute("listIndent"),n=o[0].getAttribute("listIndent")||0,s=Math.max(i-n,0);for(const i of o){const n=NA(i);r.is("element","listItem")&&i.is("element","paragraph")&&e.rename(i,"listItem"),e.setAttributes({listIndent:(n?i.getAttribute("listIndent"):0)+s,listItemId:n?i.getAttribute("listItemId"):FA.next(),listType:t},i)}}))}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",((t,i)=>{e.change((e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty){t.slice(0,-1).every(NA)&&e.remove(n)}if("copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());ZA(t)&&KA(t,e)}}))}))}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function kx(e,t){const i=e.document.selection;if(!i.isCollapsed)return!YA(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,o=n.previousSibling;return!e.schema.isObject(o)&&(!!o.isEmpty||ZA([n,o]))}function Cx(e,t,i,n){e.ui.componentFactory.add(t,(()=>{const o=Ax(Yu,e,t,i,n);return o.set({tooltip:!0,isToggleable:!0}),o})),e.ui.componentFactory.add(`menuBar:${t}`,(()=>Ax(pp,e,t,i,n)))}function Ax(e,t,i,n,o){const s=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:o}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",(()=>{t.execute(i),t.editing.view.focus()})),r}class xx extends Ss{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||Cx(this.editor,"numberedList",e("Numbered List"),Hu.numberedList),this.editor.ui.componentFactory.has("bulletedList")||Cx(this.editor,"bulletedList",e("Bulleted List"),Hu.bulletedList)}}class Ex extends Ss{static get requires(){return[yx,xx]}static get pluginName(){return"List"}}const Tx={},Sx={},Px={},Ix=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of Ix)Tx[e]=i,Sx[e]=t,t&&(Px[t]=e);bo("Ctrl+Enter");bo("Ctrl+Enter");const Vx={"(":")","[":"]","{":"}"};class Rx extends Is{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,o=n.id,s=e.range||i.getFirstRange();if(!t.canEditAt(s))return;const r=e.text||o,a=Bx({_text:r,id:o},n);if(1!=e.marker.length)throw new _("mentioncommand-incorrect-marker",this);if(o.charAt(0)!=e.marker)throw new _("mentioncommand-incorrect-id",this);t.change((e=>{const n=Zo(i.getAttributes()),o=new Map(n.entries());o.set("mention",a);const l=t.insertContent(e.createText(r,o),s),c=l.start.nodeBefore,d=l.end.nodeAfter,h=d&&d.is("$text")&&d.data.startsWith(" ");let u=!1;if(c&&d&&c.is("$text")&&d.is("$text")){const e=c.data.slice(-1),t=e in Vx,i=t&&d.data.startsWith(Vx[e]);u=t&&i}u||h||t.insertContent(e.createText(" ",n),s.start.getShiftedBy(r.length))}))}}class Ox extends Ss{static get pluginName(){return"MentionEditing"}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",key:"data-mention",classes:"mention"},model:{key:"mention",value:e=>Mx(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:Nx}),e.conversion.for("downcast").add(Fx),i.registerPostFixer((e=>function(e,t,i){const n=t.differ.getChanges();let o=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;o=Lx(n.textNode,e)||o,o=Lx(t,e)||o,o=Lx(n.nodeBefore,e)||o,o=Lx(n.nodeAfter,e)||o}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())o=Lx(i,e)||o}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;o=Lx(n.nodeBefore,e)||o,o=Lx(t,e)||o}}return o}(e,i,t.schema))),i.registerPostFixer((e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,o=t.range.end.nodeAfter;for(const s of[i,o])Dx(s)&&s.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,s),n=!0)}return n}(e,i))),i.registerPostFixer((e=>function(e,t){const i=t.selection,n=i.focus;if(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))return e.removeSelectionAttribute("mention"),!0;return!1}(e,i))),e.commands.add("mention",new Rx(e))}}function Bx(e,t){return Object.assign({uid:f()},e,t||{})}function Mx(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(!n)return;return Bx({id:i,_text:n.data},t)}function Fx(e){e.on("attribute:mention",((e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const o=t.range.start;(o.textNode||o.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)}),{priority:"highest"})}function Nx(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function Dx(e){if(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))return!1;return e.data!=e.getAttribute("mention")._text}function Lx(e,t){return!!Dx(e)&&(t.removeAttribute("mention",e),!0)}class zx extends Dm{constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))})),this.listenTo(this.domElement,"click",(()=>{this.fire("execute")}))}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class $x extends Mm{highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const Wx=[go.arrowup,go.arrowdown,go.esc],jx=[go.enter,go.tab];class Ux extends Ss{static get pluginName(){return"MentionUI"}static get requires(){return[Of]}constructor(e){super(e),this._items=new Uo,this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=ll(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||jx,i=Wx.concat(t);this._balloon=e.plugins.get(Of),e.editing.view.document.on("keydown",((e,n)=>{var o;o=n.keyCode,i.includes(o)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==go.arrowdown&&this._mentionsView.selectNext(),n.keyCode==go.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==go.esc&&this._hideUIAndRemoveMarker())}),{priority:"highest"}),As({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!Jx(i))throw new _("mentionconfig-incorrect-marker",null,{marker:i});const o={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):Zx(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,o)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",(()=>{this._hideUIAndRemoveMarker()})),this.on("requestFeed:response",((e,t)=>this._handleFeedResponse(t))),this.on("requestFeed:error",(()=>this._hideUIAndRemoveMarker()))}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new zx(e);return t.items.bindTo(this._items).using((i=>{const{item:n,marker:o}=i,{dropdownLimit:s}=this._mentionsConfigurations.get(o),r=s||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new $x(e),l=this._renderItem(n,o);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=o,a.on("execute",(()=>{t.fire("execute",{item:n,marker:o})})),a})),t.on("execute",((e,t)=>{const i=this.editor,n=i.model,o=t.item,s=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:o,text:o.text,marker:s,range:c}),i.editing.view.focus()})),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then((i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})})).catch((t=>{this.fire("requestFeed:error",{error:t}),v("mention-feed-callback-error",{marker:e})})):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map((e=>({...e,pattern:Kx(e.marker,e.minimumCharacters||0)}))),n=new hb(t.model,function(e){const t=t=>{const i=Gx(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const o=t.substring(n);return i.pattern.test(o)};return t}(i));n.on("matched",((e,n)=>{const o=Gx(i,n.text),s=t.model.document.selection.focus,r=t.model.createPositionAt(s.parent,o.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(s)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=Kx(e.marker,0),o=t.substring(i);return o.match(n)[2]}(o,n.text),l=o.marker.length+a.length,c=s.getShiftedBy(-l),d=s.getShiftedBy(-a.length),h=t.model.createRange(c,d);if(Yx(t)){const e=t.model.markers.get("mention");t.model.change((t=>{t.updateMarker(e,{range:h})}))}else t.model.change((e=>{e.addMarker("mention",{range:h,usingOperation:!1,affectsData:!1})}));this._requestFeedDebounced(o.marker,a)})),n.on("unmatched",(()=>{this._hideUIAndRemoveMarker()}));const o=t.commands.get("mention");return n.bind("isEnabled").to(o),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!Yx(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),Yx(this.editor)&&this.editor.model.change((e=>e.removeMarker("mention"))),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,o=e.id;const s=this._getItemRenderer(t);if(s){const t=s(e);"string"!=typeof t?n=new Hx(i.locale,t):o=t}if(!n){const e=new Yu(i.locale);e.label=o,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,o=n.view.domConverter,s=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=s.toViewRange(t);return Nn.getDomRangeRects(o.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:qx(t,i.locale.uiLanguageDirection)}}}function qx(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function Gx(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function Kx(e,t){const i=0==t?"*":`{${t},}`,n=r.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";return new RegExp(`(?:^|[ ${n}])([${e}])(.${i})$`,"u")}function Zx(e){return t=>e.filter((e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase())))}function Jx(e){return e&&1==e.length}function Yx(e){return e.model.markers.has("mention")}function Qx(e){return void 0!==e&&e.endsWith("px")}function Xx(e){return e.toFixed(2).replace(/\.?0+$/,"")+"px"}function eE(e,t,i){if(!e.childCount)return;const n=new qh(e.document),o=function(e,t){const i=t.createRangeIn(e),n=[],o=new Set;for(const e of i.getItems()){if(!e.is("element")||!e.name.match(/^(p|h\d+|li|div)$/))continue;let t=lE(e);if(void 0===t||0!=parseFloat(t)||Array.from(e.getClassNames()).find((e=>e.startsWith("MsoList")))||(t=void 0),e.hasStyle("mso-list")||void 0!==t&&o.has(t)){const i=rE(e);n.push({element:e,id:i.id,order:i.order,indent:i.indent,marginLeft:t}),void 0!==t&&o.add(t)}else o.clear()}return n}(e,n);if(!o.length)return;const s={},r=[];for(const e of o)if(void 0!==e.indent){tE(e)||(r.length=0);const o=`${e.id}:${e.indent}`,a=Math.min(e.indent-1,r.length);if(ar.length-1||r[a].listElement.name!=l.type){0==a&&"ol"==l.type&&void 0!==e.id&&s[o]&&(l.startIndex=s[o]);const t=sE(l,n,i);if(Qx(e.marginLeft)&&(0==a||Qx(r[a-1].marginLeft))){let i=e.marginLeft;a>0&&(i=Xx(parseFloat(i)-parseFloat(r[a-1].marginLeft))),n.setStyle("padding-left",i,t)}if(0==r.length){const i=e.element.parent,o=i.getChildIndex(e.element)+1;n.insertChild(o,t,i)}else{const e=r[a-1].listItemElements;n.appendChild(t,e[e.length-1])}r[a]={...e,listElement:t,listItemElements:[]},0==a&&void 0!==e.id&&(s[o]=l.startIndex||1)}}const l="li"==e.element.name?e.element:n.createElement("li");n.appendChild(l,r[a].listElement),r[a].listItemElements.push(l),0==a&&void 0!==e.id&&s[o]++,e.element!=l&&n.appendChild(e.element,l),aE(e.element,n),n.removeStyle("text-indent",e.element),n.removeStyle("margin-left",e.element)}else{const t=r.find((t=>t.marginLeft==e.marginLeft));if(t){const i=t.listItemElements;n.appendChild(e.element,i[i.length-1]),n.removeStyle("margin-left",e.element)}else r.length=0}}function tE(e){const t=e.element.previousSibling;return iE(t||e.element.parent)}function iE(e){return e.is("element","ol")||e.is("element","ul")}function nE(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,s=new RegExp(`@list\\s+l${e.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${e.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=s.exec(t),l=r.exec(t),c=a&&!l,d=i.exec(t);let h="decimal",u="ol",m=null;if(d&&d[1]){const t=n.exec(d[1]);if(t&&t[1]&&(h=t[1].trim(),u="bullet"!==h&&"image"!==h?"ol":"ul"),"bullet"===h){const t=function(e){if("li"==e.name&&"ul"==e.parent.name&&e.parent.hasAttribute("type"))return e.parent.getAttribute("type");const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(h=t)}else{const e=o.exec(d[1]);e&&e[1]&&(m=parseInt(e[1]))}c&&(u="ol")}return{type:u,startIndex:m,style:oE(h),isLegalStyleList:c}}function oE(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function sE(e,t,i){const n=t.createElement(e.type);return e.style&&t.setStyle("list-style-type",e.style,n),e.startIndex&&e.startIndex>1&&t.setAttribute("start",e.startIndex,n),e.isLegalStyleList&&i&&t.addClass("legal-list",n),n}function rE(e){const t=e.getStyle("mso-list");if(void 0===t)return{};const i=t.match(/(^|\s{1,100})l(\d+)/i),n=t.match(/\s{0,100}lfo(\d+)/i),o=t.match(/\s{0,100}level(\d+)/i);return i&&n&&o?{id:i[2],order:n[1],indent:parseInt(o[1])}:{indent:1}}function aE(e,t){const i=new Js({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}function lE(e){const t=e.getStyle("margin-left");return void 0===t||t.endsWith("px")?t:function(e){const t=parseFloat(e);return e.endsWith("pt")?Xx(96*t/72):e.endsWith("pc")?Xx(12*t*96/72):e.endsWith("in")?Xx(96*t):e.endsWith("cm")?Xx(96*t/2.54):e.endsWith("mm")?Xx(t/10*96/2.54):e}(t)}function cE(e,t){if(!e.childCount)return;const i=new qh(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Js({name:/v:(.+)/}),o=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,s=i&&i.is("element")?i.name:null,r=["Chart"],a=n.match(t),l=t.getAttribute("o:gfxdata"),c="v:shapetype"===s,d=l&&r.some((e=>t.getAttribute("id").includes(e)));a&&l&&!c&&!d&&o.push(e.item.getAttribute("id"))}return o}(e,i);!function(e,t,i){const n=i.createRangeIn(t),o=new Js({name:"img"}),s=[];for(const t of n)if(t.item.is("element")&&o.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every((t=>e.indexOf(t)>-1))?s.push(i):i.getAttribute("src")||s.push(i)}for(const e of s)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;s(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function s(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(s(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new Js({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new Js({name:"img"}),o=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,i);o.length&&function(e,t,i){if(e.length===t.length)for(let n=0;nString.fromCharCode(parseInt(e,16)))).join(""))}const hE=//i,uE=/xmlns:o="urn:schemas-microsoft-com/i;class mE{constructor(e,t=!1){this.document=e,this.hasMultiLevelListPlugin=t}isActive(e){return hE.test(e)||uE.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;eE(t,i,this.hasMultiLevelListPlugin),cE(t,e.dataTransfer.getData("text/rtf")),function(e){const t=[],i=new qh(e.document);for(const{item:n}of i.createRangeIn(e))if(n.is("element")){for(const e of n.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,n);for(const e of n.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,n);(n.is("element","w:sdt")||n.is("element","w:sdtpr")&&n.isEmpty||n.is("element","o:p")&&n.isEmpty)&&t.push(n)}for(const e of t){const t=e.parent,n=t.getChildIndex(e);i.insertChild(n,e.getChildren(),t),i.remove(e)}}(t),e.content=t}}function gE(e,t,i,{blockElements:n,inlineObjectElements:o}){let s=i.createPositionAt(e,"forward"==t?"after":"before");return s=s.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?s.nodeAfter:s.nodeBefore}function fE(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const pE=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class bE{constructor(e){this.document=e}isActive(e){return pE.test(e)}execute(e){const t=new qh(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new Jr(t.document.stylesProcessor),n=new za(i,{renderingMode:"data"}),o=n.blockElements,s=n.inlineObjectElements,r=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=gE(e,"forward",t,{blockElements:o,inlineObjectElements:s}),n=gE(e,"backward",t,{blockElements:o,inlineObjectElements:s}),a=fE(i,o);(fE(n,o)||a)&&r.push(e)}}for(const e of r)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const wE=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function yE(e,t){const i=new DOMParser,n=function(e){return vE(vE(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i="",n=e.indexOf(t);if(n<0)return e;const o=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(o>=0?e.substring(o):"")}(e=(e=e.replace(/

abc

\n //\n if (isAttribute && this._wrapAttributeElement(wrapElement, child)) {\n wrapPositions.push(new Position(parent, i));\n }\n //\n // Wrap the child if it is not an attribute element or if it is an attribute element that should be inside\n // `wrapElement` (due to priority).\n //\n //

abc

-->

abc

\n //

abc

-->

abc

\n else if (isText || !isAttribute || shouldABeOutsideB(wrapElement, child)) {\n // Clone attribute.\n const newAttribute = wrapElement._clone();\n // Wrap current node with new attribute.\n child._remove();\n newAttribute._appendChild(child);\n parent._insertChild(i, newAttribute);\n this._addToClonedElementsGroup(newAttribute);\n wrapPositions.push(new Position(parent, i));\n }\n //\n // If other nested attribute is found and it wasn't wrapped (see above), continue wrapping inside it.\n //\n //

abc

-->

abc

\n //\n else /* if ( isAttribute ) */ {\n this._wrapChildren(child, 0, child.childCount, wrapElement);\n }\n i++;\n }\n // Merge at each wrap.\n let offsetChange = 0;\n for (const position of wrapPositions) {\n position.offset -= offsetChange;\n // Do not merge with elements outside selected children.\n if (position.offset == startOffset) {\n continue;\n }\n const newPosition = this.mergeAttributes(position);\n // If nodes were merged - other merge offsets will change.\n if (!newPosition.isEqual(position)) {\n offsetChange++;\n endOffset--;\n }\n }\n return Range._createFromParentsAndOffsets(parent, startOffset, parent, endOffset);\n }\n /**\n * Unwraps children from provided `unwrapElement`. Only children contained in `parent` element between\n * `startOffset` and `endOffset` will be unwrapped.\n */\n _unwrapChildren(parent, startOffset, endOffset, unwrapElement) {\n let i = startOffset;\n const unwrapPositions = [];\n // Iterate over each element between provided offsets inside parent.\n // We don't use tree walker or range iterator because we will be removing and merging potentially multiple nodes,\n // so it could get messy. It is safer to it manually in this case.\n while (i < endOffset) {\n const child = parent.getChild(i);\n // Skip all text nodes. There should be no container element's here either.\n if (!child.is('attributeElement')) {\n i++;\n continue;\n }\n //\n // (In all examples, assume that `unwrapElement` is `` element.)\n //\n // If the child is similar to the given attribute element, unwrap it - it will be completely removed.\n //\n //

abcxyz

-->

abcxyz

\n //\n if (child.isSimilar(unwrapElement)) {\n const unwrapped = child.getChildren();\n const count = child.childCount;\n // Replace wrapper element with its children\n child._remove();\n parent._insertChild(i, unwrapped);\n this._removeFromClonedElementsGroup(child);\n // Save start and end position of moved items.\n unwrapPositions.push(new Position(parent, i), new Position(parent, i + count));\n // Skip elements that were unwrapped. Assuming there won't be another element to unwrap in child elements.\n i += count;\n endOffset += count - 1;\n continue;\n }\n //\n // If the child is not similar but is an attribute element, try partial unwrapping - remove the same attributes/styles/classes.\n // Partial unwrapping will happen only if the elements have the same name.\n //\n //

abcxyz

-->

abcxyz

\n //

abcxyz

-->

abcxyz

\n //\n if (this._unwrapAttributeElement(unwrapElement, child)) {\n unwrapPositions.push(new Position(parent, i), new Position(parent, i + 1));\n i++;\n continue;\n }\n //\n // If other nested attribute is found, look through it's children for elements to unwrap.\n //\n //

abc

-->

abc

\n //\n this._unwrapChildren(child, 0, child.childCount, unwrapElement);\n i++;\n }\n // Merge at each unwrap.\n let offsetChange = 0;\n for (const position of unwrapPositions) {\n position.offset -= offsetChange;\n // Do not merge with elements outside selected children.\n if (position.offset == startOffset || position.offset == endOffset) {\n continue;\n }\n const newPosition = this.mergeAttributes(position);\n // If nodes were merged - other merge offsets will change.\n if (!newPosition.isEqual(position)) {\n offsetChange++;\n endOffset--;\n }\n }\n return Range._createFromParentsAndOffsets(parent, startOffset, parent, endOffset);\n }\n /**\n * Helper function for `view.writer.wrap`. Wraps range with provided attribute element.\n * This method will also merge newly added attribute element with its siblings whenever possible.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n * an instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement}.\n *\n * @returns New range after wrapping, spanning over wrapping attribute element.\n */\n _wrapRange(range, attribute) {\n // Break attributes at range start and end.\n const { start: breakStart, end: breakEnd } = this._breakAttributesRange(range, true);\n const parentContainer = breakStart.parent;\n // Wrap all children with attribute.\n const newRange = this._wrapChildren(parentContainer, breakStart.offset, breakEnd.offset, attribute);\n // Merge attributes at the both ends and return a new range.\n const start = this.mergeAttributes(newRange.start);\n // If start position was merged - move end position back.\n if (!start.isEqual(newRange.start)) {\n newRange.end.offset--;\n }\n const end = this.mergeAttributes(newRange.end);\n return new Range(start, end);\n }\n /**\n * Helper function for {@link #wrap}. Wraps position with provided attribute element.\n * This method will also merge newly added attribute element with its siblings whenever possible.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n * an instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement}.\n *\n * @returns New position after wrapping.\n */\n _wrapPosition(position, attribute) {\n // Return same position when trying to wrap with attribute similar to position parent.\n if (attribute.isSimilar(position.parent)) {\n return movePositionToTextNode(position.clone());\n }\n // When position is inside text node - break it and place new position between two text nodes.\n if (position.parent.is('$text')) {\n position = breakTextNode(position);\n }\n // Create fake element that will represent position, and will not be merged with other attributes.\n const fakeElement = this.createAttributeElement('_wrapPosition-fake-element');\n fakeElement._priority = Number.POSITIVE_INFINITY;\n fakeElement.isSimilar = () => false;\n // Insert fake element in position location.\n position.parent._insertChild(position.offset, fakeElement);\n // Range around inserted fake attribute element.\n const wrapRange = new Range(position, position.getShiftedBy(1));\n // Wrap fake element with attribute (it will also merge if possible).\n this.wrap(wrapRange, attribute);\n // Remove fake element and place new position there.\n const newPosition = new Position(fakeElement.parent, fakeElement.index);\n fakeElement._remove();\n // If position is placed between text nodes - merge them and return position inside.\n const nodeBefore = newPosition.nodeBefore;\n const nodeAfter = newPosition.nodeAfter;\n if (nodeBefore instanceof Text && nodeAfter instanceof Text) {\n return mergeTextNodes(nodeBefore, nodeAfter);\n }\n // If position is next to text node - move position inside.\n return movePositionToTextNode(newPosition);\n }\n /**\n * Wraps one {@link module:engine/view/attributeelement~AttributeElement AttributeElement} into another by\n * merging them if possible. When merging is possible - all attributes, styles and classes are moved from wrapper\n * element to element being wrapped.\n *\n * @param wrapper Wrapper AttributeElement.\n * @param toWrap AttributeElement to wrap using wrapper element.\n * @returns Returns `true` if elements are merged.\n */\n _wrapAttributeElement(wrapper, toWrap) {\n if (!canBeJoined(wrapper, toWrap)) {\n return false;\n }\n // Can't merge if name or priority differs.\n if (wrapper.name !== toWrap.name || wrapper.priority !== toWrap.priority) {\n return false;\n }\n // Check if attributes can be merged.\n for (const key of wrapper.getAttributeKeys()) {\n // Classes and styles should be checked separately.\n if (key === 'class' || key === 'style') {\n continue;\n }\n // If some attributes are different we cannot wrap.\n if (toWrap.hasAttribute(key) && toWrap.getAttribute(key) !== wrapper.getAttribute(key)) {\n return false;\n }\n }\n // Check if styles can be merged.\n for (const key of wrapper.getStyleNames()) {\n if (toWrap.hasStyle(key) && toWrap.getStyle(key) !== wrapper.getStyle(key)) {\n return false;\n }\n }\n // Move all attributes/classes/styles from wrapper to wrapped AttributeElement.\n for (const key of wrapper.getAttributeKeys()) {\n // Classes and styles should be checked separately.\n if (key === 'class' || key === 'style') {\n continue;\n }\n // Move only these attributes that are not present - other are similar.\n if (!toWrap.hasAttribute(key)) {\n this.setAttribute(key, wrapper.getAttribute(key), toWrap);\n }\n }\n for (const key of wrapper.getStyleNames()) {\n if (!toWrap.hasStyle(key)) {\n this.setStyle(key, wrapper.getStyle(key), toWrap);\n }\n }\n for (const key of wrapper.getClassNames()) {\n if (!toWrap.hasClass(key)) {\n this.addClass(key, toWrap);\n }\n }\n return true;\n }\n /**\n * Unwraps {@link module:engine/view/attributeelement~AttributeElement AttributeElement} from another by removing\n * corresponding attributes, classes and styles. All attributes, classes and styles from wrapper should be present\n * inside element being unwrapped.\n *\n * @param wrapper Wrapper AttributeElement.\n * @param toUnwrap AttributeElement to unwrap using wrapper element.\n * @returns Returns `true` if elements are unwrapped.\n **/\n _unwrapAttributeElement(wrapper, toUnwrap) {\n if (!canBeJoined(wrapper, toUnwrap)) {\n return false;\n }\n // Can't unwrap if name or priority differs.\n if (wrapper.name !== toUnwrap.name || wrapper.priority !== toUnwrap.priority) {\n return false;\n }\n // Check if AttributeElement has all wrapper attributes.\n for (const key of wrapper.getAttributeKeys()) {\n // Classes and styles should be checked separately.\n if (key === 'class' || key === 'style') {\n continue;\n }\n // If some attributes are missing or different we cannot unwrap.\n if (!toUnwrap.hasAttribute(key) || toUnwrap.getAttribute(key) !== wrapper.getAttribute(key)) {\n return false;\n }\n }\n // Check if AttributeElement has all wrapper classes.\n if (!toUnwrap.hasClass(...wrapper.getClassNames())) {\n return false;\n }\n // Check if AttributeElement has all wrapper styles.\n for (const key of wrapper.getStyleNames()) {\n // If some styles are missing or different we cannot unwrap.\n if (!toUnwrap.hasStyle(key) || toUnwrap.getStyle(key) !== wrapper.getStyle(key)) {\n return false;\n }\n }\n // Remove all wrapper's attributes from unwrapped element.\n for (const key of wrapper.getAttributeKeys()) {\n // Classes and styles should be checked separately.\n if (key === 'class' || key === 'style') {\n continue;\n }\n this.removeAttribute(key, toUnwrap);\n }\n // Remove all wrapper's classes from unwrapped element.\n this.removeClass(Array.from(wrapper.getClassNames()), toUnwrap);\n // Remove all wrapper's styles from unwrapped element.\n this.removeStyle(Array.from(wrapper.getStyleNames()), toUnwrap);\n return true;\n }\n /**\n * Helper function used by other `DowncastWriter` methods. Breaks attribute elements at the boundaries of given range.\n *\n * @param range Range which `start` and `end` positions will be used to break attributes.\n * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.\n * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n * @returns New range with located at break positions.\n */\n _breakAttributesRange(range, forceSplitText = false) {\n const rangeStart = range.start;\n const rangeEnd = range.end;\n validateRangeContainer(range, this.document);\n // Break at the collapsed position. Return new collapsed range.\n if (range.isCollapsed) {\n const position = this._breakAttributes(range.start, forceSplitText);\n return new Range(position, position);\n }\n const breakEnd = this._breakAttributes(rangeEnd, forceSplitText);\n const count = breakEnd.parent.childCount;\n const breakStart = this._breakAttributes(rangeStart, forceSplitText);\n // Calculate new break end offset.\n breakEnd.offset += breakEnd.parent.childCount - count;\n return new Range(breakStart, breakEnd);\n }\n /**\n * Helper function used by other `DowncastWriter` methods. Breaks attribute elements at given position.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-empty-element` when break position\n * is placed inside {@link module:engine/view/emptyelement~EmptyElement EmptyElement}.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-ui-element` when break position\n * is placed inside {@link module:engine/view/uielement~UIElement UIElement}.\n *\n * @param position Position where to break attributes.\n * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.\n * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n * @returns New position after breaking the attributes.\n */\n _breakAttributes(position, forceSplitText = false) {\n const positionOffset = position.offset;\n const positionParent = position.parent;\n // If position is placed inside EmptyElement - throw an exception as we cannot break inside.\n if (position.parent.is('emptyElement')) {\n /**\n * Cannot break an `EmptyElement` instance.\n *\n * This error is thrown if\n * {@link module:engine/view/downcastwriter~DowncastWriter#breakAttributes `DowncastWriter#breakAttributes()`}\n * was executed in an incorrect position.\n *\n * @error view-writer-cannot-break-empty-element\n */\n throw new CKEditorError('view-writer-cannot-break-empty-element', this.document);\n }\n // If position is placed inside UIElement - throw an exception as we cannot break inside.\n if (position.parent.is('uiElement')) {\n /**\n * Cannot break a `UIElement` instance.\n *\n * This error is thrown if\n * {@link module:engine/view/downcastwriter~DowncastWriter#breakAttributes `DowncastWriter#breakAttributes()`}\n * was executed in an incorrect position.\n *\n * @error view-writer-cannot-break-ui-element\n */\n throw new CKEditorError('view-writer-cannot-break-ui-element', this.document);\n }\n // If position is placed inside RawElement - throw an exception as we cannot break inside.\n if (position.parent.is('rawElement')) {\n /**\n * Cannot break a `RawElement` instance.\n *\n * This error is thrown if\n * {@link module:engine/view/downcastwriter~DowncastWriter#breakAttributes `DowncastWriter#breakAttributes()`}\n * was executed in an incorrect position.\n *\n * @error view-writer-cannot-break-raw-element\n */\n throw new CKEditorError('view-writer-cannot-break-raw-element', this.document);\n }\n // There are no attributes to break and text nodes breaking is not forced.\n if (!forceSplitText && positionParent.is('$text') && isContainerOrFragment(positionParent.parent)) {\n return position.clone();\n }\n // Position's parent is container, so no attributes to break.\n if (isContainerOrFragment(positionParent)) {\n return position.clone();\n }\n // Break text and start again in new position.\n if (positionParent.is('$text')) {\n return this._breakAttributes(breakTextNode(position), forceSplitText);\n }\n const length = positionParent.childCount;\n //

foobar{}

\n //

foobar[]

\n //

foobar[]

\n if (positionOffset == length) {\n const newPosition = new Position(positionParent.parent, positionParent.index + 1);\n return this._breakAttributes(newPosition, forceSplitText);\n }\n else {\n //

foo{}bar

\n //

foo[]bar

\n //

foo{}bar

\n if (positionOffset === 0) {\n const newPosition = new Position(positionParent.parent, positionParent.index);\n return this._breakAttributes(newPosition, forceSplitText);\n }\n //

foob{}ar

\n //

foob[]ar

\n //

foob[]ar

\n //

foob[]ar

\n else {\n const offsetAfter = positionParent.index + 1;\n // Break element.\n const clonedNode = positionParent._clone();\n // Insert cloned node to position's parent node.\n positionParent.parent._insertChild(offsetAfter, clonedNode);\n this._addToClonedElementsGroup(clonedNode);\n // Get nodes to move.\n const count = positionParent.childCount - positionOffset;\n const nodesToMove = positionParent._removeChildren(positionOffset, count);\n // Move nodes to cloned node.\n clonedNode._appendChild(nodesToMove);\n // Create new position to work on.\n const newPosition = new Position(positionParent.parent, offsetAfter);\n return this._breakAttributes(newPosition, forceSplitText);\n }\n }\n }\n /**\n * Stores the information that an {@link module:engine/view/attributeelement~AttributeElement attribute element} was\n * added to the tree. Saves the reference to the group in the given element and updates the group, so other elements\n * from the group now keep a reference to the given attribute element.\n *\n * The clones group can be obtained using {@link module:engine/view/attributeelement~AttributeElement#getElementsWithSameId}.\n *\n * Does nothing if added element has no {@link module:engine/view/attributeelement~AttributeElement#id id}.\n *\n * @param element Attribute element to save.\n */\n _addToClonedElementsGroup(element) {\n // Add only if the element is in document tree.\n if (!element.root.is('rootElement')) {\n return;\n }\n // Traverse the element's children recursively to find other attribute elements that also might got inserted.\n // The loop is at the beginning so we can make fast returns later in the code.\n if (element.is('element')) {\n for (const child of element.getChildren()) {\n this._addToClonedElementsGroup(child);\n }\n }\n const id = element.id;\n if (!id) {\n return;\n }\n let group = this._cloneGroups.get(id);\n if (!group) {\n group = new Set();\n this._cloneGroups.set(id, group);\n }\n group.add(element);\n element._clonesGroup = group;\n }\n /**\n * Removes all the information about the given {@link module:engine/view/attributeelement~AttributeElement attribute element}\n * from its clones group.\n *\n * Keep in mind, that the element will still keep a reference to the group (but the group will not keep a reference to it).\n * This allows to reference the whole group even if the element was already removed from the tree.\n *\n * Does nothing if the element has no {@link module:engine/view/attributeelement~AttributeElement#id id}.\n *\n * @param element Attribute element to remove.\n */\n _removeFromClonedElementsGroup(element) {\n // Traverse the element's children recursively to find other attribute elements that also got removed.\n // The loop is at the beginning so we can make fast returns later in the code.\n if (element.is('element')) {\n for (const child of element.getChildren()) {\n this._removeFromClonedElementsGroup(child);\n }\n }\n const id = element.id;\n if (!id) {\n return;\n }\n const group = this._cloneGroups.get(id);\n if (!group) {\n return;\n }\n group.delete(element);\n // Not removing group from element on purpose!\n // If other parts of code have reference to this element, they will be able to get references to other elements from the group.\n }\n}\n// Helper function for `view.writer.wrap`. Checks if given element has any children that are not ui elements.\nfunction _hasNonUiChildren(parent) {\n return Array.from(parent.getChildren()).some(child => !child.is('uiElement'));\n}\n/**\n * The `attribute` passed to {@link module:engine/view/downcastwriter~DowncastWriter#wrap `DowncastWriter#wrap()`}\n * must be an instance of {@link module:engine/view/attributeelement~AttributeElement `AttributeElement`}.\n *\n * @error view-writer-wrap-invalid-attribute\n */\n/**\n * Returns first parent container of specified {@link module:engine/view/position~Position Position}.\n * Position's parent node is checked as first, then next parents are checked.\n * Note that {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment} is treated like a container.\n *\n * @param position Position used as a start point to locate parent container.\n * @returns Parent container element or `undefined` if container is not found.\n */\nfunction getParentContainer(position) {\n let parent = position.parent;\n while (!isContainerOrFragment(parent)) {\n if (!parent) {\n return undefined;\n }\n parent = parent.parent;\n }\n return parent;\n}\n/**\n * Checks if first {@link module:engine/view/attributeelement~AttributeElement AttributeElement} provided to the function\n * can be wrapped outside second element. It is done by comparing elements'\n * {@link module:engine/view/attributeelement~AttributeElement#priority priorities}, if both have same priority\n * {@link module:engine/view/element~Element#getIdentity identities} are compared.\n */\nfunction shouldABeOutsideB(a, b) {\n if (a.priority < b.priority) {\n return true;\n }\n else if (a.priority > b.priority) {\n return false;\n }\n // When priorities are equal and names are different - use identities.\n return a.getIdentity() < b.getIdentity();\n}\n/**\n * Returns new position that is moved to near text node. Returns same position if there is no text node before of after\n * specified position.\n *\n * ```html\n *

foo[]

->

foo{}

\n *

[]foo

->

{}foo

\n * ```\n *\n * @returns Position located inside text node or same position if there is no text nodes\n * before or after position location.\n */\nfunction movePositionToTextNode(position) {\n const nodeBefore = position.nodeBefore;\n if (nodeBefore && nodeBefore.is('$text')) {\n return new Position(nodeBefore, nodeBefore.data.length);\n }\n const nodeAfter = position.nodeAfter;\n if (nodeAfter && nodeAfter.is('$text')) {\n return new Position(nodeAfter, 0);\n }\n return position;\n}\n/**\n * Breaks text node into two text nodes when possible.\n *\n * ```html\n *

foo{}bar

->

foo[]bar

\n *

{}foobar

->

[]foobar

\n *

foobar{}

->

foobar[]

\n * ```\n *\n * @param position Position that need to be placed inside text node.\n * @returns New position after breaking text node.\n */\nfunction breakTextNode(position) {\n if (position.offset == position.parent.data.length) {\n return new Position(position.parent.parent, position.parent.index + 1);\n }\n if (position.offset === 0) {\n return new Position(position.parent.parent, position.parent.index);\n }\n // Get part of the text that need to be moved.\n const textToMove = position.parent.data.slice(position.offset);\n // Leave rest of the text in position's parent.\n position.parent._data = position.parent.data.slice(0, position.offset);\n // Insert new text node after position's parent text node.\n position.parent.parent._insertChild(position.parent.index + 1, new Text(position.root.document, textToMove));\n // Return new position between two newly created text nodes.\n return new Position(position.parent.parent, position.parent.index + 1);\n}\n/**\n * Merges two text nodes into first node. Removes second node and returns merge position.\n *\n * @param t1 First text node to merge. Data from second text node will be moved at the end of this text node.\n * @param t2 Second text node to merge. This node will be removed after merging.\n * @returns Position after merging text nodes.\n */\nfunction mergeTextNodes(t1, t2) {\n // Merge text data into first text node and remove second one.\n const nodeBeforeLength = t1.data.length;\n t1._data += t2.data;\n t2._remove();\n return new Position(t1, nodeBeforeLength);\n}\nconst validNodesToInsert = [Text, AttributeElement, ContainerElement, EmptyElement, RawElement, UIElement];\n/**\n * Checks if provided nodes are valid to insert.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert\n * contains instances that are not supported ones (see error description for valid ones.\n */\nfunction validateNodesToInsert(nodes, errorContext) {\n for (const node of nodes) {\n if (!validNodesToInsert.some((validNode => node instanceof validNode))) { // eslint-disable-line no-use-before-define\n /**\n * One of the nodes to be inserted is of an invalid type.\n *\n * Nodes to be inserted with {@link module:engine/view/downcastwriter~DowncastWriter#insert `DowncastWriter#insert()`} should be\n * of the following types:\n *\n * * {@link module:engine/view/attributeelement~AttributeElement AttributeElement},\n * * {@link module:engine/view/containerelement~ContainerElement ContainerElement},\n * * {@link module:engine/view/emptyelement~EmptyElement EmptyElement},\n * * {@link module:engine/view/uielement~UIElement UIElement},\n * * {@link module:engine/view/rawelement~RawElement RawElement},\n * * {@link module:engine/view/text~Text Text}.\n *\n * @error view-writer-insert-invalid-node-type\n */\n throw new CKEditorError('view-writer-insert-invalid-node-type', errorContext);\n }\n if (!node.is('$text')) {\n validateNodesToInsert(node.getChildren(), errorContext);\n }\n }\n}\n/**\n * Checks if node is ContainerElement or DocumentFragment, because in most cases they should be treated the same way.\n *\n * @returns Returns `true` if node is instance of ContainerElement or DocumentFragment.\n */\nfunction isContainerOrFragment(node) {\n return node && (node.is('containerElement') || node.is('documentFragment'));\n}\n/**\n * Checks if {@link module:engine/view/range~Range#start range start} and {@link module:engine/view/range~Range#end range end} are placed\n * inside same {@link module:engine/view/containerelement~ContainerElement container element}.\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when validation fails.\n */\nfunction validateRangeContainer(range, errorContext) {\n const startContainer = getParentContainer(range.start);\n const endContainer = getParentContainer(range.end);\n if (!startContainer || !endContainer || startContainer !== endContainer) {\n /**\n * The container of the given range is invalid.\n *\n * This may happen if {@link module:engine/view/range~Range#start range start} and\n * {@link module:engine/view/range~Range#end range end} positions are not placed inside the same container element or\n * a parent container for these positions cannot be found.\n *\n * Methods like {@link module:engine/view/downcastwriter~DowncastWriter#wrap `DowncastWriter#remove()`},\n * {@link module:engine/view/downcastwriter~DowncastWriter#wrap `DowncastWriter#clean()`},\n * {@link module:engine/view/downcastwriter~DowncastWriter#wrap `DowncastWriter#wrap()`},\n * {@link module:engine/view/downcastwriter~DowncastWriter#wrap `DowncastWriter#unwrap()`} need to be called\n * on a range that has its start and end positions located in the same container element. Both positions can be\n * nested within other elements (e.g. an attribute element) but the closest container ancestor must be the same.\n *\n * @error view-writer-invalid-range-container\n */\n throw new CKEditorError('view-writer-invalid-range-container', errorContext);\n }\n}\n/**\n * Checks if two attribute elements can be joined together. Elements can be joined together if, and only if\n * they do not have ids specified.\n */\nfunction canBeJoined(a, b) {\n return a.id === null && b.id === null;\n}\n","/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\nimport { keyCodes, isText } from '@ckeditor/ckeditor5-utils';\n/**\n * Set of utilities related to handling block and inline fillers.\n *\n * Browsers do not allow to put caret in elements which does not have height. Because of it, we need to fill all\n * empty elements which should be selectable with elements or characters called \"fillers\". Unfortunately there is no one\n * universal filler, this is why two types are uses:\n *\n * * Block filler is an element which fill block elements, like `

`. CKEditor uses `
` as a block filler during the editing,\n * as browsers do natively. So instead of an empty `

` there will be `


`. The advantage of block filler is that\n * it is transparent for the selection, so when the caret is before the `
` and user presses right arrow he will be\n * moved to the next paragraph, not after the `
`. The disadvantage is that it breaks a block, so it can not be used\n * in the middle of a line of text. The {@link module:engine/view/filler~BR_FILLER `
` filler} can be replaced with any other\n * character in the data output, for instance {@link module:engine/view/filler~NBSP_FILLER non-breaking space} or\n * {@link module:engine/view/filler~MARKED_NBSP_FILLER marked non-breaking space}.\n *\n * * Inline filler is a filler which does not break a line of text, so it can be used inside the text, for instance in the empty\n * `` surrendered by text: `foobar`, if we want to put the caret there. CKEditor uses a sequence of the zero-width\n * spaces as an {@link module:engine/view/filler~INLINE_FILLER inline filler} having the predetermined\n * {@link module:engine/view/filler~INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to\n * avoid treating random zero-width spaces as the inline filler. Disadvantage of the inline filler is that it is not\n * transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional\n * code is needed to handle the caret.\n *\n * Both inline and block fillers are handled by the {@link module:engine/view/renderer~Renderer renderer} and are not present in the\n * view.\n *\n * @module engine/view/filler\n */\n/**\n * Non-breaking space filler creator. This function creates the ` ` text node.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~MARKED_NBSP_FILLER\n * @see module:engine/view/filler~BR_FILLER\n */\nexport const NBSP_FILLER = (domDocument) => domDocument.createTextNode('\\u00A0');\n/**\n * Marked non-breaking space filler creator. This function creates the ` ` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @see module:engine/view/filler~BR_FILLER\n */\nexport const MARKED_NBSP_FILLER = (domDocument) => {\n const span = domDocument.createElement('span');\n span.dataset.ckeFiller = 'true';\n span.innerText = '\\u00A0';\n return span;\n};\n/**\n * `
` filler creator. This function creates the `
` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @see module:engine/view/filler~MARKED_NBSP_FILLER\n */\nexport const BR_FILLER = (domDocument) => {\n const fillerBr = domDocument.createElement('br');\n fillerBr.dataset.ckeFiller = 'true';\n return fillerBr;\n};\n/**\n * Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.\n */\nexport const INLINE_FILLER_LENGTH = 7;\n/**\n * Inline filler which is a sequence of the word joiners.\n */\nexport const INLINE_FILLER = '\\u2060'.repeat(INLINE_FILLER_LENGTH);\n/**\n * Checks if the node is a text node which starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n * ```ts\n * startsWithFiller( document.createTextNode( INLINE_FILLER ) ); // true\n * startsWithFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // true\n * startsWithFiller( document.createTextNode( 'foo' ) ); // false\n * startsWithFiller( document.createElement( 'p' ) ); // false\n * ```\n *\n * @param domNode DOM node.\n * @returns True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n */\nexport function startsWithFiller(domNode) {\n if (typeof domNode == 'string') {\n return domNode.substr(0, INLINE_FILLER_LENGTH) === INLINE_FILLER;\n }\n return isText(domNode) && (domNode.data.substr(0, INLINE_FILLER_LENGTH) === INLINE_FILLER);\n}\n/**\n * Checks if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n * ```ts\n * isInlineFiller( document.createTextNode( INLINE_FILLER ) ); // true\n * isInlineFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // false\n * ```\n *\n * @param domText DOM text node.\n * @returns True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n */\nexport function isInlineFiller(domText) {\n return domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller(domText);\n}\n/**\n * Get string data from the text node, removing an {@link module:engine/view/filler~INLINE_FILLER inline filler} from it,\n * if text node contains it.\n *\n * ```ts\n * getDataWithoutFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ) == 'foo' // true\n * getDataWithoutFiller( document.createTextNode( 'foo' ) ) == 'foo' // true\n * ```\n *\n * @param domText DOM text node, possible with inline filler.\n * @returns Data without filler.\n */\nexport function getDataWithoutFiller(domText) {\n const data = typeof domText == 'string' ? domText : domText.data;\n if (startsWithFiller(domText)) {\n return data.slice(INLINE_FILLER_LENGTH);\n }\n return data;\n}\n/**\n * Assign key observer which move cursor from the end of the inline filler to the beginning of it when\n * the left arrow is pressed, so the filler does not break navigation.\n *\n * @param view View controller instance we should inject quirks handling on.\n */\nexport function injectQuirksHandling(view) {\n view.document.on('arrowKey', jumpOverInlineFiller, { priority: 'low' });\n}\n/**\n * Move cursor from the end of the inline filler to the beginning of it when, so the filler does not break navigation.\n */\nfunction jumpOverInlineFiller(evt, data) {\n if (data.keyCode == keyCodes.arrowleft) {\n const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();\n if (domSelection.rangeCount == 1 && domSelection.getRangeAt(0).collapsed) {\n const domParent = domSelection.getRangeAt(0).startContainer;\n const domOffset = domSelection.getRangeAt(0).startOffset;\n if (startsWithFiller(domParent) && domOffset <= INLINE_FILLER_LENGTH) {\n domSelection.collapse(domParent, 0);\n }\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2024, 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 * @module engine/view/renderer\n */\nimport ViewText from './text.js';\nimport ViewPosition from './position.js';\nimport { INLINE_FILLER, INLINE_FILLER_LENGTH, startsWithFiller, isInlineFiller } from './filler.js';\nimport { CKEditorError, ObservableMixin, diff, env, fastDiff, insertAt, isComment, isNode, isText, remove, indexOf } from '@ckeditor/ckeditor5-utils';\nimport '../../theme/renderer.css';\n/**\n * Renderer is responsible for updating the DOM structure and the DOM selection based on\n * the {@link module:engine/view/renderer~Renderer#markToSync information about updated view nodes}.\n * In other words, it renders the view to the DOM.\n *\n * Its main responsibility is to make only the necessary, minimal changes to the DOM. However, unlike in many\n * virtual DOM implementations, the primary reason for doing minimal changes is not the performance but ensuring\n * that native editing features such as text composition, autocompletion, spell checking, selection's x-index are\n * affected as little as possible.\n *\n * Renderer uses {@link module:engine/view/domconverter~DomConverter} to transform view nodes and positions\n * to and from the DOM.\n */\nexport default class Renderer extends ObservableMixin() {\n /**\n * Creates a renderer instance.\n *\n * @param domConverter Converter instance.\n * @param selection View selection.\n */\n constructor(domConverter, selection) {\n super();\n /**\n * Set of DOM Documents instances.\n */\n this.domDocuments = new Set();\n /**\n * Set of nodes which attributes changed and may need to be rendered.\n */\n this.markedAttributes = new Set();\n /**\n * Set of elements which child lists changed and may need to be rendered.\n */\n this.markedChildren = new Set();\n /**\n * Set of text nodes which text data changed and may need to be rendered.\n */\n this.markedTexts = new Set();\n /**\n * The text node in which the inline filler was rendered.\n */\n this._inlineFiller = null;\n /**\n * DOM element containing fake selection.\n */\n this._fakeSelectionContainer = null;\n this.domConverter = domConverter;\n this.selection = selection;\n this.set('isFocused', false);\n this.set('isSelecting', false);\n // Rendering the selection and inline filler manipulation should be postponed in (non-Android) Blink until the user finishes\n // creating the selection in DOM to avoid accidental selection collapsing\n // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n // When the user stops selecting, all pending changes should be rendered ASAP, though.\n if (env.isBlink && !env.isAndroid) {\n this.on('change:isSelecting', () => {\n if (!this.isSelecting) {\n this.render();\n }\n });\n }\n this.set('isComposing', false);\n this.on('change:isComposing', () => {\n if (!this.isComposing) {\n this.render();\n }\n });\n }\n /**\n * Marks a view node to be updated in the DOM by {@link #render `render()`}.\n *\n * Note that only view nodes whose parents have corresponding DOM elements need to be marked to be synchronized.\n *\n * @see #markedAttributes\n * @see #markedChildren\n * @see #markedTexts\n *\n * @param type Type of the change.\n * @param node ViewNode to be marked.\n */\n markToSync(type, node) {\n if (type === 'text') {\n if (this.domConverter.mapViewToDom(node.parent)) {\n this.markedTexts.add(node);\n }\n }\n else {\n // If the node has no DOM element it is not rendered yet,\n // its children/attributes do not need to be marked to be sync.\n if (!this.domConverter.mapViewToDom(node)) {\n return;\n }\n if (type === 'attributes') {\n this.markedAttributes.add(node);\n }\n else if (type === 'children') {\n this.markedChildren.add(node);\n }\n else {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const unreachable = type;\n /**\n * Unknown type passed to Renderer.markToSync.\n *\n * @error view-renderer-unknown-type\n */\n throw new CKEditorError('view-renderer-unknown-type', this);\n }\n }\n }\n /**\n * Renders all buffered changes ({@link #markedAttributes}, {@link #markedChildren} and {@link #markedTexts}) and\n * the current view selection (if needed) to the DOM by applying a minimal set of changes to it.\n *\n * Renderer tries not to break the text composition (e.g. IME) and x-index of the selection,\n * so it does as little as it is needed to update the DOM.\n *\n * Renderer also handles {@link module:engine/view/filler fillers}. Especially, it checks if the inline filler is needed\n * at the selection position and adds or removes it. To prevent breaking text composition inline filler will not be\n * removed as long as the selection is in the text node which needed it at first.\n */\n render() {\n // Ignore rendering while in the composition mode. Composition events are not cancellable and browser will modify the DOM tree.\n // All marked elements, attributes, etc. will wait until next render after the composition ends.\n // On Android composition events are immediately applied to the model, so we don't need to skip rendering,\n // and we should not do it because the difference between view and DOM could lead to position mapping problems.\n if (this.isComposing && !env.isAndroid) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( '%c[Renderer]%c Rendering aborted while isComposing',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', ''\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( '%c[Renderer]%c Rendering',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', ''\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n let inlineFillerPosition = null;\n const isInlineFillerRenderingPossible = env.isBlink && !env.isAndroid ? !this.isSelecting : true;\n // Refresh mappings.\n for (const element of this.markedChildren) {\n this._updateChildrenMappings(element);\n }\n // Don't manipulate inline fillers while the selection is being made in (non-Android) Blink to prevent accidental\n // DOM selection collapsing\n // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n if (isInlineFillerRenderingPossible) {\n // There was inline filler rendered in the DOM but it's not\n // at the selection position any more, so we can remove it\n // (cause even if it's needed, it must be placed in another location).\n if (this._inlineFiller && !this._isSelectionInInlineFiller()) {\n this._removeInlineFiller();\n }\n // If we've got the filler, let's try to guess its position in the view.\n if (this._inlineFiller) {\n inlineFillerPosition = this._getInlineFillerPosition();\n }\n // Otherwise, if it's needed, create it at the selection position.\n else if (this._needsInlineFillerAtSelection()) {\n inlineFillerPosition = this.selection.getFirstPosition();\n // Do not use `markToSync` so it will be added even if the parent is already added.\n this.markedChildren.add(inlineFillerPosition.parent);\n }\n }\n // Make sure the inline filler has any parent, so it can be mapped to view position by DomConverter.\n else if (this._inlineFiller && this._inlineFiller.parentNode) {\n // While the user is making selection, preserve the inline filler at its original position.\n inlineFillerPosition = this.domConverter.domPositionToView(this._inlineFiller);\n // While down-casting the document selection attributes, all existing empty\n // attribute elements (for selection position) are removed from the view and DOM,\n // so make sure that we were able to map filler position.\n // https://github.com/ckeditor/ckeditor5/issues/12026\n if (inlineFillerPosition && inlineFillerPosition.parent.is('$text')) {\n // The inline filler position is expected to be before the text node.\n inlineFillerPosition = ViewPosition._createBefore(inlineFillerPosition.parent);\n }\n }\n for (const element of this.markedAttributes) {\n this._updateAttrs(element);\n }\n for (const element of this.markedChildren) {\n this._updateChildren(element, { inlineFillerPosition });\n }\n for (const node of this.markedTexts) {\n if (!this.markedChildren.has(node.parent) && this.domConverter.mapViewToDom(node.parent)) {\n this._updateText(node, { inlineFillerPosition });\n }\n }\n // * Check whether the inline filler is required and where it really is in the DOM.\n // At this point in most cases it will be in the DOM, but there are exceptions.\n // For example, if the inline filler was deep in the created DOM structure, it will not be created.\n // Similarly, if it was removed at the beginning of this function and then neither text nor children were updated,\n // it will not be present. Fix those and similar scenarios.\n // * Don't manipulate inline fillers while the selection is being made in (non-Android) Blink to prevent accidental\n // DOM selection collapsing\n // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n if (isInlineFillerRenderingPossible) {\n if (inlineFillerPosition) {\n const fillerDomPosition = this.domConverter.viewPositionToDom(inlineFillerPosition);\n const domDocument = fillerDomPosition.parent.ownerDocument;\n if (!startsWithFiller(fillerDomPosition.parent)) {\n // Filler has not been created at filler position. Create it now.\n this._inlineFiller = addInlineFiller(domDocument, fillerDomPosition.parent, fillerDomPosition.offset);\n }\n else {\n // Filler has been found, save it.\n this._inlineFiller = fillerDomPosition.parent;\n }\n }\n else {\n // There is no filler needed.\n this._inlineFiller = null;\n }\n }\n // First focus the new editing host, then update the selection.\n // Otherwise, FF may throw an error (https://github.com/ckeditor/ckeditor5/issues/721).\n this._updateFocus();\n this._updateSelection();\n this.domConverter._clearTemporaryCustomProperties();\n this.markedTexts.clear();\n this.markedAttributes.clear();\n this.markedChildren.clear();\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n /**\n * Updates mappings of view element's children.\n *\n * Children that were replaced in the view structure by similar elements (same tag name) are treated as 'replaced'.\n * This means that their mappings can be updated so the new view elements are mapped to the existing DOM elements.\n * Thanks to that these elements do not need to be re-rendered completely.\n *\n * @param viewElement The view element whose children mappings will be updated.\n */\n _updateChildrenMappings(viewElement) {\n const domElement = this.domConverter.mapViewToDom(viewElement);\n if (!domElement) {\n // If there is no `domElement` it means that it was already removed from DOM and there is no need to process it.\n return;\n }\n // Removing nodes from the DOM as we iterate can cause `actualDomChildren`\n // (which is a live-updating `NodeList`) to get out of sync with the\n // indices that we compute as we iterate over `actions`.\n // This would produce incorrect element mappings.\n //\n // Converting live list to an array to make the list static.\n const actualDomChildren = Array.from(domElement.childNodes);\n const expectedDomChildren = Array.from(this.domConverter.viewChildrenToDom(viewElement, { withChildren: false }));\n const diff = this._diffNodeLists(actualDomChildren, expectedDomChildren);\n const actions = this._findUpdateActions(diff, actualDomChildren, expectedDomChildren, areSimilarElements);\n if (actions.indexOf('update') !== -1) {\n const counter = { equal: 0, insert: 0, delete: 0 };\n for (const action of actions) {\n if (action === 'update') {\n const insertIndex = counter.equal + counter.insert;\n const deleteIndex = counter.equal + counter.delete;\n const viewChild = viewElement.getChild(insertIndex);\n // UIElement and RawElement are special cases. Their children are not stored in a view (#799)\n // so we cannot use them with replacing flow (since they use view children during rendering\n // which will always result in rendering empty elements).\n if (viewChild && !viewChild.is('uiElement') && !viewChild.is('rawElement')) {\n this._updateElementMappings(viewChild, actualDomChildren[deleteIndex]);\n }\n remove(expectedDomChildren[insertIndex]);\n counter.equal++;\n }\n else {\n counter[action]++;\n }\n }\n }\n }\n /**\n * Updates mappings of a given view element.\n *\n * @param viewElement The view element whose mappings will be updated.\n * @param domElement The DOM element representing the given view element.\n */\n _updateElementMappings(viewElement, domElement) {\n // Remap 'DomConverter' bindings.\n this.domConverter.unbindDomElement(domElement);\n this.domConverter.bindElements(domElement, viewElement);\n // View element may have children which needs to be updated, but are not marked, mark them to update.\n this.markedChildren.add(viewElement);\n // Because we replace new view element mapping with the existing one, the corresponding DOM element\n // will not be rerendered. The new view element may have different attributes than the previous one.\n // Since its corresponding DOM element will not be rerendered, new attributes will not be added\n // to the DOM, so we need to mark it here to make sure its attributes gets updated. See #1427 for more\n // detailed case study.\n // Also there are cases where replaced element is removed from the view structure and then has\n // its attributes changed or removed. In such cases the element will not be present in `markedAttributes`\n // and also may be the same (`element.isSimilar()`) as the reused element not having its attributes updated.\n // To prevent such situations we always mark reused element to have its attributes rerenderd (#1560).\n this.markedAttributes.add(viewElement);\n }\n /**\n * Gets the position of the inline filler based on the current selection.\n * Here, we assume that we know that the filler is needed and\n * {@link #_isSelectionInInlineFiller is at the selection position}, and, since it is needed,\n * it is somewhere at the selection position.\n *\n * Note: The filler position cannot be restored based on the filler's DOM text node, because\n * when this method is called (before rendering), the bindings will often be broken. View-to-DOM\n * bindings are only dependable after rendering.\n */\n _getInlineFillerPosition() {\n const firstPos = this.selection.getFirstPosition();\n if (firstPos.parent.is('$text')) {\n return ViewPosition._createBefore(firstPos.parent);\n }\n else {\n return firstPos;\n }\n }\n /**\n * Returns `true` if the selection has not left the inline filler's text node.\n * If it is `true`, it means that the filler had been added for a reason and the selection did not\n * leave the filler's text node. For example, the user can be in the middle of a composition so it should not be touched.\n *\n * @returns `true` if the inline filler and selection are in the same place.\n */\n _isSelectionInInlineFiller() {\n if (this.selection.rangeCount != 1 || !this.selection.isCollapsed) {\n return false;\n }\n // Note, we can't check if selection's position equals position of the\n // this._inlineFiller node, because of #663. We may not be able to calculate\n // the filler's position in the view at this stage.\n // Instead, we check it the other way – whether selection is anchored in\n // that text node or next to it.\n // Possible options are:\n // \"FILLER{}\"\n // \"FILLERadded-text{}\"\n const selectionPosition = this.selection.getFirstPosition();\n const position = this.domConverter.viewPositionToDom(selectionPosition);\n if (position && isText(position.parent) && startsWithFiller(position.parent)) {\n return true;\n }\n return false;\n }\n /**\n * Removes the inline filler.\n */\n _removeInlineFiller() {\n const domFillerNode = this._inlineFiller;\n // Something weird happened and the stored node doesn't contain the filler's text.\n if (!startsWithFiller(domFillerNode)) {\n /**\n * The inline filler node was lost. Most likely, something overwrote the filler text node\n * in the DOM.\n *\n * @error view-renderer-filler-was-lost\n */\n throw new CKEditorError('view-renderer-filler-was-lost', this);\n }\n if (isInlineFiller(domFillerNode)) {\n domFillerNode.remove();\n }\n else {\n domFillerNode.data = domFillerNode.data.substr(INLINE_FILLER_LENGTH);\n }\n this._inlineFiller = null;\n }\n /**\n * Checks if the inline {@link module:engine/view/filler filler} should be added.\n *\n * @returns `true` if the inline filler should be added.\n */\n _needsInlineFillerAtSelection() {\n if (this.selection.rangeCount != 1 || !this.selection.isCollapsed) {\n return false;\n }\n const selectionPosition = this.selection.getFirstPosition();\n const selectionParent = selectionPosition.parent;\n const selectionOffset = selectionPosition.offset;\n // If there is no DOM root we do not care about fillers.\n if (!this.domConverter.mapViewToDom(selectionParent.root)) {\n return false;\n }\n if (!(selectionParent.is('element'))) {\n return false;\n }\n // Prevent adding inline filler inside elements with contenteditable=false.\n // https://github.com/ckeditor/ckeditor5-engine/issues/1170\n if (!isEditable(selectionParent)) {\n return false;\n }\n const nodeBefore = selectionPosition.nodeBefore;\n const nodeAfter = selectionPosition.nodeAfter;\n if (nodeBefore instanceof ViewText || nodeAfter instanceof ViewText) {\n return false;\n }\n // We have block filler, we do not need inline one.\n if (selectionOffset === selectionParent.getFillerOffset() && (!nodeBefore || !nodeBefore.is('element', 'br'))) {\n return false;\n }\n // Do not use inline filler while typing outside inline elements on Android.\n // The deleteContentBackward would remove part of the inline filler instead of removing last letter in a link.\n if (env.isAndroid && (nodeBefore || nodeAfter)) {\n return false;\n }\n return true;\n }\n /**\n * Checks if text needs to be updated and possibly updates it.\n *\n * @param viewText View text to update.\n * @param options.inlineFillerPosition The position where the inline filler should be rendered.\n */\n _updateText(viewText, options) {\n const domText = this.domConverter.findCorrespondingDomText(viewText);\n const newDomText = this.domConverter.viewToDom(viewText);\n let expectedText = newDomText.data;\n const filler = options.inlineFillerPosition;\n if (filler && filler.parent == viewText.parent && filler.offset == viewText.index) {\n expectedText = INLINE_FILLER + expectedText;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( '%c[Renderer]%c Update text',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', ''\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n updateTextNode(domText, expectedText);\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n /**\n * Checks if attribute list needs to be updated and possibly updates it.\n *\n * @param viewElement The view element to update.\n */\n _updateAttrs(viewElement) {\n const domElement = this.domConverter.mapViewToDom(viewElement);\n if (!domElement) {\n // If there is no `domElement` it means that 'viewElement' is outdated as its mapping was updated\n // in 'this._updateChildrenMappings()'. There is no need to process it as new view element which\n // replaced old 'viewElement' mapping was also added to 'this.markedAttributes'\n // in 'this._updateChildrenMappings()' so it will be processed separately.\n return;\n }\n const domAttrKeys = Array.from(domElement.attributes).map(attr => attr.name);\n const viewAttrKeys = viewElement.getAttributeKeys();\n // Add or overwrite attributes.\n for (const key of viewAttrKeys) {\n this.domConverter.setDomElementAttribute(domElement, key, viewElement.getAttribute(key), viewElement);\n }\n // Remove from DOM attributes which do not exists in the view.\n for (const key of domAttrKeys) {\n // All other attributes not present in the DOM should be removed.\n if (!viewElement.hasAttribute(key)) {\n this.domConverter.removeDomElementAttribute(domElement, key);\n }\n }\n }\n /**\n * Checks if elements child list needs to be updated and possibly updates it.\n *\n * Note that on Android, to reduce the risk of composition breaks, it tries to update data of an existing\n * child text nodes instead of replacing them completely.\n *\n * @param viewElement View element to update.\n * @param options.inlineFillerPosition The position where the inline filler should be rendered.\n */\n _updateChildren(viewElement, options) {\n const domElement = this.domConverter.mapViewToDom(viewElement);\n if (!domElement) {\n // If there is no `domElement` it means that it was already removed from DOM.\n // There is no need to process it. It will be processed when re-inserted.\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( '%c[Renderer]%c Update children',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', ''\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n // IME on Android inserts a new text node while typing after a link\n // instead of updating an existing text node that follows the link.\n // We must normalize those text nodes so the diff won't get confused.\n // https://github.com/ckeditor/ckeditor5/issues/12574.\n if (env.isAndroid) {\n let previousDomNode = null;\n for (const domNode of Array.from(domElement.childNodes)) {\n if (previousDomNode && isText(previousDomNode) && isText(domNode)) {\n domElement.normalize();\n break;\n }\n previousDomNode = domNode;\n }\n }\n const inlineFillerPosition = options.inlineFillerPosition;\n const actualDomChildren = domElement.childNodes;\n const expectedDomChildren = Array.from(this.domConverter.viewChildrenToDom(viewElement, { bind: true }));\n // Inline filler element has to be created as it is present in the DOM, but not in the view. It is required\n // during diffing so text nodes could be compared correctly and also during rendering to maintain\n // proper order and indexes while updating the DOM.\n if (inlineFillerPosition && inlineFillerPosition.parent === viewElement) {\n addInlineFiller(domElement.ownerDocument, expectedDomChildren, inlineFillerPosition.offset);\n }\n const diff = this._diffNodeLists(actualDomChildren, expectedDomChildren);\n // We need to make sure that we update the existing text node and not replace it with another one.\n // The composition and different \"language\" browser extensions are fragile to text node being completely replaced.\n const actions = this._findUpdateActions(diff, actualDomChildren, expectedDomChildren, areTextNodes);\n let i = 0;\n const nodesToUnbind = new Set();\n // Handle deletions first.\n // This is to prevent a situation where an element that already exists in `actualDomChildren` is inserted at a different\n // index in `actualDomChildren`. Since `actualDomChildren` is a `NodeList`, this works like move, not like an insert,\n // and it disrupts the whole algorithm. See https://github.com/ckeditor/ckeditor5/issues/6367.\n //\n // It doesn't matter in what order we remove or add nodes, as long as we remove and add correct nodes at correct indexes.\n for (const action of actions) {\n if (action === 'delete') {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( '%c[Renderer]%c Remove node',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', '', actualDomChildren[ i ]\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n nodesToUnbind.add(actualDomChildren[i]);\n remove(actualDomChildren[i]);\n }\n else if (action === 'equal' || action === 'update') {\n i++;\n }\n }\n i = 0;\n for (const action of actions) {\n if (action === 'insert') {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( '%c[Renderer]%c Insert node',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', '', expectedDomChildren[ i ]\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n insertAt(domElement, i, expectedDomChildren[i]);\n i++;\n }\n // Update the existing text node data. Note that replace action is generated only for Android for now.\n else if (action === 'update') {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( '%c[Renderer]%c Update text node',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', ''\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n updateTextNode(actualDomChildren[i], expectedDomChildren[i].data);\n i++;\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n else if (action === 'equal') {\n // Force updating text nodes inside elements which did not change and do not need to be re-rendered (#1125).\n // Do it here (not in the loop above) because only after insertions the `i` index is correct.\n this._markDescendantTextToSync(this.domConverter.domToView(expectedDomChildren[i]));\n i++;\n }\n }\n // Unbind removed nodes. When node does not have a parent it means that it was removed from DOM tree during\n // comparison with the expected DOM. We don't need to check child nodes, because if child node was reinserted,\n // it was moved to DOM tree out of the removed node.\n for (const node of nodesToUnbind) {\n if (!node.parentNode) {\n this.domConverter.unbindDomElement(node);\n }\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n /**\n * Shorthand for diffing two arrays or node lists of DOM nodes.\n *\n * @param actualDomChildren Actual DOM children\n * @param expectedDomChildren Expected DOM children.\n * @returns The list of actions based on the {@link module:utils/diff~diff} function.\n */\n _diffNodeLists(actualDomChildren, expectedDomChildren) {\n actualDomChildren = filterOutFakeSelectionContainer(actualDomChildren, this._fakeSelectionContainer);\n return diff(actualDomChildren, expectedDomChildren, sameNodes.bind(null, this.domConverter));\n }\n /**\n * Finds DOM nodes that were replaced with the similar nodes (same tag name) in the view. All nodes are compared\n * within one `insert`/`delete` action group, for example:\n *\n * ```\n * Actual DOM:\t\t

FooBarBazBax

\n * Expected DOM:\t

Bar123Baz456

\n * Input actions:\t[ insert, insert, delete, delete, equal, insert, delete ]\n * Output actions:\t[ insert, replace, delete, equal, replace ]\n * ```\n *\n * @param actions Actions array which is a result of the {@link module:utils/diff~diff} function.\n * @param actualDom Actual DOM children\n * @param expectedDom Expected DOM children.\n * @param comparator A comparator function that should return `true` if the given node should be reused\n * (either by the update of a text node data or an element children list for similar elements).\n * @returns Actions array modified with the `update` actions.\n */\n _findUpdateActions(actions, actualDom, expectedDom, comparator) {\n // If there is no both 'insert' and 'delete' actions, no need to check for replaced elements.\n if (actions.indexOf('insert') === -1 || actions.indexOf('delete') === -1) {\n return actions;\n }\n let newActions = [];\n let actualSlice = [];\n let expectedSlice = [];\n const counter = { equal: 0, insert: 0, delete: 0 };\n for (const action of actions) {\n if (action === 'insert') {\n expectedSlice.push(expectedDom[counter.equal + counter.insert]);\n }\n else if (action === 'delete') {\n actualSlice.push(actualDom[counter.equal + counter.delete]);\n }\n else { // equal\n newActions = newActions.concat(diff(actualSlice, expectedSlice, comparator)\n .map(action => action === 'equal' ? 'update' : action));\n newActions.push('equal');\n // Reset stored elements on 'equal'.\n actualSlice = [];\n expectedSlice = [];\n }\n counter[action]++;\n }\n return newActions.concat(diff(actualSlice, expectedSlice, comparator)\n .map(action => action === 'equal' ? 'update' : action));\n }\n /**\n * Marks text nodes to be synchronized.\n *\n * If a text node is passed, it will be marked. If an element is passed, all descendant text nodes inside it will be marked.\n *\n * @param viewNode View node to sync.\n */\n _markDescendantTextToSync(viewNode) {\n if (!viewNode) {\n return;\n }\n if (viewNode.is('$text')) {\n this.markedTexts.add(viewNode);\n }\n else if (viewNode.is('element')) {\n for (const child of viewNode.getChildren()) {\n this._markDescendantTextToSync(child);\n }\n }\n }\n /**\n * Checks if the selection needs to be updated and possibly updates it.\n */\n _updateSelection() {\n // Block updating DOM selection in (non-Android) Blink while the user is selecting to prevent accidental selection collapsing.\n // Note: Structural changes in DOM must trigger selection rendering, though. Nodes the selection was anchored\n // to, may disappear in DOM which would break the selection (e.g. in real-time collaboration scenarios).\n // https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723\n if (env.isBlink && !env.isAndroid && this.isSelecting && !this.markedChildren.size) {\n return;\n }\n // If there is no selection - remove DOM and fake selections.\n if (this.selection.rangeCount === 0) {\n this._removeDomSelection();\n this._removeFakeSelection();\n return;\n }\n const domRoot = this.domConverter.mapViewToDom(this.selection.editableElement);\n // Do nothing if there is no focus, or there is no DOM element corresponding to selection's editable element.\n if (!this.isFocused || !domRoot) {\n return;\n }\n // Render fake selection - create the fake selection container (if needed) and move DOM selection to it.\n if (this.selection.isFake) {\n this._updateFakeSelection(domRoot);\n }\n // There was a fake selection so remove it and update the DOM selection.\n // This is especially important on Android because otherwise IME will try to compose over the fake selection container.\n else if (this._fakeSelectionContainer && this._fakeSelectionContainer.isConnected) {\n this._removeFakeSelection();\n this._updateDomSelection(domRoot);\n }\n // Update the DOM selection in case of a plain selection change (no fake selection is involved).\n // On non-Android the whole rendering is disabled in composition mode (including DOM selection update),\n // but updating DOM selection should be also disabled on Android if in the middle of the composition\n // (to not interrupt it).\n else if (!(this.isComposing && env.isAndroid)) {\n this._updateDomSelection(domRoot);\n }\n }\n /**\n * Updates the fake selection.\n *\n * @param domRoot A valid DOM root where the fake selection container should be added.\n */\n _updateFakeSelection(domRoot) {\n const domDocument = domRoot.ownerDocument;\n if (!this._fakeSelectionContainer) {\n this._fakeSelectionContainer = createFakeSelectionContainer(domDocument);\n }\n const container = this._fakeSelectionContainer;\n // Bind fake selection container with the current selection *position*.\n this.domConverter.bindFakeSelection(container, this.selection);\n if (!this._fakeSelectionNeedsUpdate(domRoot)) {\n return;\n }\n if (!container.parentElement || container.parentElement != domRoot) {\n domRoot.appendChild(container);\n }\n container.textContent = this.selection.fakeSelectionLabel || '\\u00A0';\n const domSelection = domDocument.getSelection();\n const domRange = domDocument.createRange();\n domSelection.removeAllRanges();\n domRange.selectNodeContents(container);\n domSelection.addRange(domRange);\n }\n /**\n * Updates the DOM selection.\n *\n * @param domRoot A valid DOM root where the DOM selection should be rendered.\n */\n _updateDomSelection(domRoot) {\n const domSelection = domRoot.ownerDocument.defaultView.getSelection();\n // Let's check whether DOM selection needs updating at all.\n if (!this._domSelectionNeedsUpdate(domSelection)) {\n return;\n }\n // Multi-range selection is not available in most browsers, and, at least in Chrome, trying to\n // set such selection, that is not continuous, throws an error. Because of that, we will just use anchor\n // and focus of view selection.\n // Since we are not supporting multi-range selection, we also do not need to check if proper editable is\n // selected. If there is any editable selected, it is okay (editable is taken from selection anchor).\n const anchor = this.domConverter.viewPositionToDom(this.selection.anchor);\n const focus = this.domConverter.viewPositionToDom(this.selection.focus);\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( '%c[Renderer]%c Update DOM selection:',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', '', anchor, focus\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n domSelection.setBaseAndExtent(anchor.parent, anchor.offset, focus.parent, focus.offset);\n // Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).\n if (env.isGecko) {\n fixGeckoSelectionAfterBr(focus, domSelection);\n }\n }\n /**\n * Checks whether a given DOM selection needs to be updated.\n *\n * @param domSelection The DOM selection to check.\n */\n _domSelectionNeedsUpdate(domSelection) {\n if (!this.domConverter.isDomSelectionCorrect(domSelection)) {\n // Current DOM selection is in incorrect position. We need to update it.\n return true;\n }\n const oldViewSelection = domSelection && this.domConverter.domSelectionToView(domSelection);\n if (oldViewSelection && this.selection.isEqual(oldViewSelection)) {\n return false;\n }\n // If selection is not collapsed, it does not need to be updated if it is similar.\n if (!this.selection.isCollapsed && this.selection.isSimilar(oldViewSelection)) {\n // Selection did not changed and is correct, do not update.\n return false;\n }\n // Selections are not similar.\n return true;\n }\n /**\n * Checks whether the fake selection needs to be updated.\n *\n * @param domRoot A valid DOM root where a new fake selection container should be added.\n */\n _fakeSelectionNeedsUpdate(domRoot) {\n const container = this._fakeSelectionContainer;\n const domSelection = domRoot.ownerDocument.getSelection();\n // Fake selection needs to be updated if there's no fake selection container, or the container currently sits\n // in a different root.\n if (!container || container.parentElement !== domRoot) {\n return true;\n }\n // Make sure that the selection actually is within the fake selection.\n if (domSelection.anchorNode !== container && !container.contains(domSelection.anchorNode)) {\n return true;\n }\n return container.textContent !== this.selection.fakeSelectionLabel;\n }\n /**\n * Removes the DOM selection.\n */\n _removeDomSelection() {\n for (const doc of this.domDocuments) {\n const domSelection = doc.getSelection();\n if (domSelection.rangeCount) {\n const activeDomElement = doc.activeElement;\n const viewElement = this.domConverter.mapDomToView(activeDomElement);\n if (activeDomElement && viewElement) {\n domSelection.removeAllRanges();\n }\n }\n }\n }\n /**\n * Removes the fake selection.\n */\n _removeFakeSelection() {\n const container = this._fakeSelectionContainer;\n if (container) {\n container.remove();\n }\n }\n /**\n * Checks if focus needs to be updated and possibly updates it.\n */\n _updateFocus() {\n if (this.isFocused) {\n const editable = this.selection.editableElement;\n if (editable) {\n this.domConverter.focus(editable);\n }\n }\n }\n}\n/**\n * Checks if provided element is editable.\n */\nfunction isEditable(element) {\n if (element.getAttribute('contenteditable') == 'false') {\n return false;\n }\n const parent = element.findAncestor(element => element.hasAttribute('contenteditable'));\n return !parent || parent.getAttribute('contenteditable') == 'true';\n}\n/**\n * Adds inline filler at a given position.\n *\n * The position can be given as an array of DOM nodes and an offset in that array,\n * or a DOM parent element and an offset in that element.\n *\n * @returns The DOM text node that contains an inline filler.\n */\nfunction addInlineFiller(domDocument, domParentOrArray, offset) {\n const childNodes = domParentOrArray instanceof Array ? domParentOrArray : domParentOrArray.childNodes;\n const nodeAfterFiller = childNodes[offset];\n if (isText(nodeAfterFiller)) {\n nodeAfterFiller.data = INLINE_FILLER + nodeAfterFiller.data;\n return nodeAfterFiller;\n }\n else {\n const fillerNode = domDocument.createTextNode(INLINE_FILLER);\n if (Array.isArray(domParentOrArray)) {\n childNodes.splice(offset, 0, fillerNode);\n }\n else {\n insertAt(domParentOrArray, offset, fillerNode);\n }\n return fillerNode;\n }\n}\n/**\n * Whether two DOM nodes should be considered as similar.\n * Nodes are considered similar if they have the same tag name.\n */\nfunction areSimilarElements(node1, node2) {\n return isNode(node1) && isNode(node2) &&\n !isText(node1) && !isText(node2) &&\n !isComment(node1) && !isComment(node2) &&\n node1.tagName.toLowerCase() === node2.tagName.toLowerCase();\n}\n/**\n * Whether two DOM nodes are text nodes.\n */\nfunction areTextNodes(node1, node2) {\n return isNode(node1) && isNode(node2) &&\n isText(node1) && isText(node2);\n}\n/**\n * Whether two dom nodes should be considered as the same.\n * Two nodes which are considered the same are:\n *\n * * Text nodes with the same text.\n * * Element nodes represented by the same object.\n * * Two block filler elements.\n *\n * @param blockFillerMode Block filler mode, see {@link module:engine/view/domconverter~DomConverter#blockFillerMode}.\n */\nfunction sameNodes(domConverter, actualDomChild, expectedDomChild) {\n // Elements.\n if (actualDomChild === expectedDomChild) {\n return true;\n }\n // Texts.\n else if (isText(actualDomChild) && isText(expectedDomChild)) {\n return actualDomChild.data === expectedDomChild.data;\n }\n // Block fillers.\n else if (domConverter.isBlockFiller(actualDomChild) &&\n domConverter.isBlockFiller(expectedDomChild)) {\n return true;\n }\n // Not matching types.\n return false;\n}\n/**\n * The following is a Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).\n * When the native DOM selection is at the end of the block and preceded by
e.g.\n *\n * ```html\n *

foo
[]

\n * ```\n *\n * which happens a lot when using the soft line break, the browser fails to (visually) move the\n * caret to the new line. A quick fix is as simple as force–refreshing the selection with the same range.\n */\nfunction fixGeckoSelectionAfterBr(focus, domSelection) {\n let parent = focus.parent;\n let offset = focus.offset;\n if (isText(parent) && isInlineFiller(parent)) {\n offset = indexOf(parent) + 1;\n parent = parent.parentNode;\n }\n // This fix works only when the focus point is at the very end of an element.\n // There is no point in running it in cases unrelated to the browser bug.\n if (parent.nodeType != Node.ELEMENT_NODE || offset != parent.childNodes.length - 1) {\n return;\n }\n const childAtOffset = parent.childNodes[offset];\n // To stay on the safe side, the fix being as specific as possible, it targets only the\n // selection which is at the very end of the element and preceded by
.\n if (childAtOffset && childAtOffset.tagName == 'BR') {\n domSelection.addRange(domSelection.getRangeAt(0));\n }\n}\nfunction filterOutFakeSelectionContainer(domChildList, fakeSelectionContainer) {\n const childList = Array.from(domChildList);\n if (childList.length == 0 || !fakeSelectionContainer) {\n return childList;\n }\n const last = childList[childList.length - 1];\n if (last == fakeSelectionContainer) {\n childList.pop();\n }\n return childList;\n}\n/**\n * Creates a fake selection container for a given document.\n */\nfunction createFakeSelectionContainer(domDocument) {\n const container = domDocument.createElement('div');\n container.className = 'ck-fake-selection-container';\n Object.assign(container.style, {\n position: 'fixed',\n top: 0,\n left: '-9999px',\n // See https://github.com/ckeditor/ckeditor5/issues/752.\n width: '42px'\n });\n // Fill it with a text node so we can update it later.\n container.textContent = '\\u00A0';\n return container;\n}\n/**\n * Checks if text needs to be updated and possibly updates it by removing and inserting only parts\n * of the data from the existing text node to reduce impact on the IME composition.\n *\n * @param domText DOM text node to update.\n * @param expectedText The expected data of a text node.\n */\nfunction updateTextNode(domText, expectedText) {\n const actualText = domText.data;\n if (actualText == expectedText) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( '%c[Renderer]%c Text node does not need update:',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', '',\n // @if CK_DEBUG_TYPING // \t\t`\"${ domText.data }\" (${ domText.data.length })`\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( '%c[Renderer]%c Update text node:',\n // @if CK_DEBUG_TYPING // \t\t'color: green;font-weight: bold', '',\n // @if CK_DEBUG_TYPING // \t\t`\"${ domText.data }\" (${ domText.data.length }) -> \"${ expectedText }\" (${ expectedText.length })`\n // @if CK_DEBUG_TYPING // \t);\n // @if CK_DEBUG_TYPING // }\n const actions = fastDiff(actualText, expectedText);\n for (const action of actions) {\n if (action.type === 'insert') {\n domText.insertData(action.index, action.values.join(''));\n }\n else { // 'delete'\n domText.deleteData(action.index, action.howMany);\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2024, 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 * @module engine/view/domconverter\n */\n/* globals Node, NodeFilter, DOMParser */\nimport ViewText from './text.js';\nimport ViewElement from './element.js';\nimport ViewUIElement from './uielement.js';\nimport ViewPosition from './position.js';\nimport ViewRange from './range.js';\nimport ViewSelection from './selection.js';\nimport ViewDocumentFragment from './documentfragment.js';\nimport ViewTreeWalker from './treewalker.js';\nimport { default as Matcher } from './matcher.js';\nimport { BR_FILLER, INLINE_FILLER_LENGTH, NBSP_FILLER, MARKED_NBSP_FILLER, getDataWithoutFiller, isInlineFiller, startsWithFiller } from './filler.js';\nimport { global, logWarning, indexOf, getAncestors, isText, isComment, isValidAttributeName, first, env } from '@ckeditor/ckeditor5-utils';\nconst BR_FILLER_REF = BR_FILLER(global.document); // eslint-disable-line new-cap\nconst NBSP_FILLER_REF = NBSP_FILLER(global.document); // eslint-disable-line new-cap\nconst MARKED_NBSP_FILLER_REF = MARKED_NBSP_FILLER(global.document); // eslint-disable-line new-cap\nconst UNSAFE_ATTRIBUTE_NAME_PREFIX = 'data-ck-unsafe-attribute-';\nconst UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE = 'data-ck-unsafe-element';\n/**\n * `DomConverter` is a set of tools to do transformations between DOM nodes and view nodes. It also handles\n * {@link module:engine/view/domconverter~DomConverter#bindElements bindings} between these nodes.\n *\n * An instance of the DOM converter is available under\n * {@link module:engine/view/view~View#domConverter `editor.editing.view.domConverter`}.\n *\n * The DOM converter does not check which nodes should be rendered (use {@link module:engine/view/renderer~Renderer}), does not keep the\n * state of a tree nor keeps the synchronization between the tree view and the DOM tree (use {@link module:engine/view/document~Document}).\n *\n * The DOM converter keeps DOM elements to view element bindings, so when the converter gets destroyed, the bindings are lost.\n * Two converters will keep separate binding maps, so one tree view can be bound with two DOM trees.\n */\nexport default class DomConverter {\n /**\n * Creates a DOM converter.\n *\n * @param document The view document instance.\n * @param options An object with configuration options.\n * @param options.blockFillerMode The type of the block filler to use.\n * Default value depends on the options.renderingMode:\n * 'nbsp' when options.renderingMode == 'data',\n * 'br' when options.renderingMode == 'editing'.\n * @param options.renderingMode Whether to leave the View-to-DOM conversion result unchanged\n * or improve editing experience by filtering out interactive data.\n */\n constructor(document, { blockFillerMode, renderingMode = 'editing' } = {}) {\n /**\n * The DOM-to-view mapping.\n */\n this._domToViewMapping = new WeakMap();\n /**\n * The view-to-DOM mapping.\n */\n this._viewToDomMapping = new WeakMap();\n /**\n * Holds the mapping between fake selection containers and corresponding view selections.\n */\n this._fakeSelectionMapping = new WeakMap();\n /**\n * Matcher for view elements whose content should be treated as raw data\n * and not processed during the conversion from DOM nodes to view elements.\n */\n this._rawContentElementMatcher = new Matcher();\n /**\n * Matcher for inline object view elements. This is an extension of a simple {@link #inlineObjectElements} array of element names.\n */\n this._inlineObjectElementMatcher = new Matcher();\n /**\n * Set of elements with temporary custom properties that require clearing after render.\n */\n this._elementsWithTemporaryCustomProperties = new Set();\n this.document = document;\n this.renderingMode = renderingMode;\n this.blockFillerMode = blockFillerMode || (renderingMode === 'editing' ? 'br' : 'nbsp');\n this.preElements = ['pre'];\n this.blockElements = [\n 'address', 'article', 'aside', 'blockquote', 'caption', 'center', 'dd', 'details', 'dir', 'div',\n 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header',\n 'hgroup', 'legend', 'li', 'main', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'summary', 'table', 'tbody',\n 'td', 'tfoot', 'th', 'thead', 'tr', 'ul'\n ];\n this.inlineObjectElements = [\n 'object', 'iframe', 'input', 'button', 'textarea', 'select', 'option', 'video', 'embed', 'audio', 'img', 'canvas'\n ];\n this.unsafeElements = ['script', 'style'];\n this._domDocument = this.renderingMode === 'editing' ? global.document : global.document.implementation.createHTMLDocument('');\n }\n /**\n * Binds a given DOM element that represents fake selection to a **position** of a\n * {@link module:engine/view/documentselection~DocumentSelection document selection}.\n * Document selection copy is stored and can be retrieved by the\n * {@link module:engine/view/domconverter~DomConverter#fakeSelectionToView} method.\n */\n bindFakeSelection(domElement, viewDocumentSelection) {\n this._fakeSelectionMapping.set(domElement, new ViewSelection(viewDocumentSelection));\n }\n /**\n * Returns a {@link module:engine/view/selection~Selection view selection} instance corresponding to a given\n * DOM element that represents fake selection. Returns `undefined` if binding to the given DOM element does not exist.\n */\n fakeSelectionToView(domElement) {\n return this._fakeSelectionMapping.get(domElement);\n }\n /**\n * Binds DOM and view elements, so it will be possible to get corresponding elements using\n * {@link module:engine/view/domconverter~DomConverter#mapDomToView} and\n * {@link module:engine/view/domconverter~DomConverter#mapViewToDom}.\n *\n * @param domElement The DOM element to bind.\n * @param viewElement The view element to bind.\n */\n bindElements(domElement, viewElement) {\n this._domToViewMapping.set(domElement, viewElement);\n this._viewToDomMapping.set(viewElement, domElement);\n }\n /**\n * Unbinds a given DOM element from the view element it was bound to. Unbinding is deep, meaning that all children of\n * the DOM element will be unbound too.\n *\n * @param domElement The DOM element to unbind.\n */\n unbindDomElement(domElement) {\n const viewElement = this._domToViewMapping.get(domElement);\n if (viewElement) {\n this._domToViewMapping.delete(domElement);\n this._viewToDomMapping.delete(viewElement);\n for (const child of Array.from(domElement.children)) {\n this.unbindDomElement(child);\n }\n }\n }\n /**\n * Binds DOM and view document fragments, so it will be possible to get corresponding document fragments using\n * {@link module:engine/view/domconverter~DomConverter#mapDomToView} and\n * {@link module:engine/view/domconverter~DomConverter#mapViewToDom}.\n *\n * @param domFragment The DOM document fragment to bind.\n * @param viewFragment The view document fragment to bind.\n */\n bindDocumentFragments(domFragment, viewFragment) {\n this._domToViewMapping.set(domFragment, viewFragment);\n this._viewToDomMapping.set(viewFragment, domFragment);\n }\n /**\n * Decides whether a given pair of attribute key and value should be passed further down the pipeline.\n *\n * @param elementName Element name in lower case.\n */\n shouldRenderAttribute(attributeKey, attributeValue, elementName) {\n if (this.renderingMode === 'data') {\n return true;\n }\n attributeKey = attributeKey.toLowerCase();\n if (attributeKey.startsWith('on')) {\n return false;\n }\n if (attributeKey === 'srcdoc' &&\n attributeValue.match(/\\bon\\S+\\s*=|javascript:|<\\s*\\/*script/i)) {\n return false;\n }\n if (elementName === 'img' &&\n (attributeKey === 'src' || attributeKey === 'srcset')) {\n return true;\n }\n if (elementName === 'source' && attributeKey === 'srcset') {\n return true;\n }\n if (attributeValue.match(/^\\s*(javascript:|data:(image\\/svg|text\\/x?html))/i)) {\n return false;\n }\n return true;\n }\n /**\n * Set `domElement`'s content using provided `html` argument. Apply necessary filtering for the editing pipeline.\n *\n * @param domElement DOM element that should have `html` set as its content.\n * @param html Textual representation of the HTML that will be set on `domElement`.\n */\n setContentOf(domElement, html) {\n // For data pipeline we pass the HTML as-is.\n if (this.renderingMode === 'data') {\n domElement.innerHTML = html;\n return;\n }\n const document = new DOMParser().parseFromString(html, 'text/html');\n const fragment = document.createDocumentFragment();\n const bodyChildNodes = document.body.childNodes;\n while (bodyChildNodes.length > 0) {\n fragment.appendChild(bodyChildNodes[0]);\n }\n const treeWalker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT);\n const nodes = [];\n let currentNode;\n // eslint-disable-next-line no-cond-assign\n while (currentNode = treeWalker.nextNode()) {\n nodes.push(currentNode);\n }\n for (const currentNode of nodes) {\n // Go through nodes to remove those that are prohibited in editing pipeline.\n for (const attributeName of currentNode.getAttributeNames()) {\n this.setDomElementAttribute(currentNode, attributeName, currentNode.getAttribute(attributeName));\n }\n const elementName = currentNode.tagName.toLowerCase();\n // There are certain nodes, that should be renamed to in editing pipeline.\n if (this._shouldRenameElement(elementName)) {\n _logUnsafeElement(elementName);\n currentNode.replaceWith(this._createReplacementDomElement(elementName, currentNode));\n }\n }\n // Empty the target element.\n while (domElement.firstChild) {\n domElement.firstChild.remove();\n }\n domElement.append(fragment);\n }\n /**\n * Converts the view to the DOM. For all text nodes, not bound elements and document fragments new items will\n * be created. For bound elements and document fragments the method will return corresponding items.\n *\n * @param viewNode View node or document fragment to transform.\n * @param options Conversion options.\n * @param options.bind Determines whether new elements will be bound.\n * @param options.withChildren If `false`, node's and document fragment's children will not be converted.\n * @returns Converted node or DocumentFragment.\n */\n viewToDom(viewNode, options = {}) {\n if (viewNode.is('$text')) {\n const textData = this._processDataFromViewText(viewNode);\n return this._domDocument.createTextNode(textData);\n }\n else {\n const viewElementOrFragment = viewNode;\n if (this.mapViewToDom(viewElementOrFragment)) {\n // Do not reuse element that is marked to not reuse (for example an IMG element\n // so it can immediately display a placeholder background instead of waiting for the new src to load).\n if (viewElementOrFragment.getCustomProperty('editingPipeline:doNotReuseOnce')) {\n this._elementsWithTemporaryCustomProperties.add(viewElementOrFragment);\n }\n else {\n return this.mapViewToDom(viewElementOrFragment);\n }\n }\n let domElement;\n if (viewElementOrFragment.is('documentFragment')) {\n // Create DOM document fragment.\n domElement = this._domDocument.createDocumentFragment();\n if (options.bind) {\n this.bindDocumentFragments(domElement, viewElementOrFragment);\n }\n }\n else if (viewElementOrFragment.is('uiElement')) {\n if (viewElementOrFragment.name === '$comment') {\n domElement = this._domDocument.createComment(viewElementOrFragment.getCustomProperty('$rawContent'));\n }\n else {\n // UIElement has its own render() method (see #799).\n domElement = viewElementOrFragment.render(this._domDocument, this);\n }\n if (options.bind) {\n this.bindElements(domElement, viewElementOrFragment);\n }\n return domElement;\n }\n else {\n // Create DOM element.\n if (this._shouldRenameElement(viewElementOrFragment.name)) {\n _logUnsafeElement(viewElementOrFragment.name);\n domElement = this._createReplacementDomElement(viewElementOrFragment.name);\n }\n else if (viewElementOrFragment.hasAttribute('xmlns')) {\n domElement = this._domDocument.createElementNS(viewElementOrFragment.getAttribute('xmlns'), viewElementOrFragment.name);\n }\n else {\n domElement = this._domDocument.createElement(viewElementOrFragment.name);\n }\n // RawElement take care of their children in RawElement#render() method which can be customized\n // (see https://github.com/ckeditor/ckeditor5/issues/4469).\n if (viewElementOrFragment.is('rawElement')) {\n viewElementOrFragment.render(domElement, this);\n }\n if (options.bind) {\n this.bindElements(domElement, viewElementOrFragment);\n }\n // Copy element's attributes.\n for (const key of viewElementOrFragment.getAttributeKeys()) {\n this.setDomElementAttribute(domElement, key, viewElementOrFragment.getAttribute(key), viewElementOrFragment);\n }\n }\n if (options.withChildren !== false) {\n for (const child of this.viewChildrenToDom(viewElementOrFragment, options)) {\n if (domElement instanceof HTMLTemplateElement) {\n domElement.content.appendChild(child);\n }\n else {\n domElement.appendChild(child);\n }\n }\n }\n return domElement;\n }\n }\n /**\n * Sets the attribute on a DOM element.\n *\n * **Note**: To remove the attribute, use {@link #removeDomElementAttribute}.\n *\n * @param domElement The DOM element the attribute should be set on.\n * @param key The name of the attribute.\n * @param value The value of the attribute.\n * @param relatedViewElement The view element related to the `domElement` (if there is any).\n * It helps decide whether the attribute set is unsafe. For instance, view elements created via the\n * {@link module:engine/view/downcastwriter~DowncastWriter} methods can allow certain attributes that would normally be filtered out.\n */\n setDomElementAttribute(domElement, key, value, relatedViewElement) {\n const shouldRenderAttribute = this.shouldRenderAttribute(key, value, domElement.tagName.toLowerCase()) ||\n relatedViewElement && relatedViewElement.shouldRenderUnsafeAttribute(key);\n if (!shouldRenderAttribute) {\n logWarning('domconverter-unsafe-attribute-detected', { domElement, key, value });\n }\n if (!isValidAttributeName(key)) {\n /**\n * Invalid attribute name was ignored during rendering.\n *\n * @error domconverter-invalid-attribute-detected\n */\n logWarning('domconverter-invalid-attribute-detected', { domElement, key, value });\n return;\n }\n // The old value was safe but the new value is unsafe.\n if (domElement.hasAttribute(key) && !shouldRenderAttribute) {\n domElement.removeAttribute(key);\n }\n // The old value was unsafe (but prefixed) but the new value will be safe (will be unprefixed).\n else if (domElement.hasAttribute(UNSAFE_ATTRIBUTE_NAME_PREFIX + key) && shouldRenderAttribute) {\n domElement.removeAttribute(UNSAFE_ATTRIBUTE_NAME_PREFIX + key);\n }\n // If the attribute should not be rendered, rename it (instead of removing) to give developers some idea of what\n // is going on (https://github.com/ckeditor/ckeditor5/issues/10801).\n domElement.setAttribute(shouldRenderAttribute ? key : UNSAFE_ATTRIBUTE_NAME_PREFIX + key, value);\n }\n /**\n * Removes an attribute from a DOM element.\n *\n * **Note**: To set the attribute, use {@link #setDomElementAttribute}.\n *\n * @param domElement The DOM element the attribute should be removed from.\n * @param key The name of the attribute.\n */\n removeDomElementAttribute(domElement, key) {\n // See #_createReplacementDomElement() to learn what this is.\n if (key == UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE) {\n return;\n }\n domElement.removeAttribute(key);\n // See setDomElementAttribute() to learn what this is.\n domElement.removeAttribute(UNSAFE_ATTRIBUTE_NAME_PREFIX + key);\n }\n /**\n * Converts children of the view element to DOM using the\n * {@link module:engine/view/domconverter~DomConverter#viewToDom} method.\n * Additionally, this method adds block {@link module:engine/view/filler filler} to the list of children, if needed.\n *\n * @param viewElement Parent view element.\n * @param options See {@link module:engine/view/domconverter~DomConverter#viewToDom} options parameter.\n * @returns DOM nodes.\n */\n *viewChildrenToDom(viewElement, options = {}) {\n const fillerPositionOffset = viewElement.getFillerOffset && viewElement.getFillerOffset();\n let offset = 0;\n for (const childView of viewElement.getChildren()) {\n if (fillerPositionOffset === offset) {\n yield this._getBlockFiller();\n }\n const transparentRendering = childView.is('element') &&\n !!childView.getCustomProperty('dataPipeline:transparentRendering') &&\n !first(childView.getAttributes());\n if (transparentRendering && this.renderingMode == 'data') {\n yield* this.viewChildrenToDom(childView, options);\n }\n else {\n if (transparentRendering) {\n /**\n * The `dataPipeline:transparentRendering` flag is supported only in the data pipeline.\n *\n * @error domconverter-transparent-rendering-unsupported-in-editing-pipeline\n */\n logWarning('domconverter-transparent-rendering-unsupported-in-editing-pipeline', { viewElement: childView });\n }\n yield this.viewToDom(childView, options);\n }\n offset++;\n }\n if (fillerPositionOffset === offset) {\n yield this._getBlockFiller();\n }\n }\n /**\n * Converts view {@link module:engine/view/range~Range} to DOM range.\n * Inline and block {@link module:engine/view/filler fillers} are handled during the conversion.\n *\n * @param viewRange View range.\n * @returns DOM range.\n */\n viewRangeToDom(viewRange) {\n const domStart = this.viewPositionToDom(viewRange.start);\n const domEnd = this.viewPositionToDom(viewRange.end);\n const domRange = this._domDocument.createRange();\n domRange.setStart(domStart.parent, domStart.offset);\n domRange.setEnd(domEnd.parent, domEnd.offset);\n return domRange;\n }\n /**\n * Converts view {@link module:engine/view/position~Position} to DOM parent and offset.\n *\n * Inline and block {@link module:engine/view/filler fillers} are handled during the conversion.\n * If the converted position is directly before inline filler it is moved inside the filler.\n *\n * @param viewPosition View position.\n * @returns DOM position or `null` if view position could not be converted to DOM.\n * DOM position has two properties:\n * * `parent` - DOM position parent.\n * * `offset` - DOM position offset.\n */\n viewPositionToDom(viewPosition) {\n const viewParent = viewPosition.parent;\n if (viewParent.is('$text')) {\n const domParent = this.findCorrespondingDomText(viewParent);\n if (!domParent) {\n // Position is in a view text node that has not been rendered to DOM yet.\n return null;\n }\n let offset = viewPosition.offset;\n if (startsWithFiller(domParent)) {\n offset += INLINE_FILLER_LENGTH;\n }\n return { parent: domParent, offset };\n }\n else {\n // viewParent is instance of ViewElement.\n let domParent, domBefore, domAfter;\n if (viewPosition.offset === 0) {\n domParent = this.mapViewToDom(viewParent);\n if (!domParent) {\n // Position is in a view element that has not been rendered to DOM yet.\n return null;\n }\n domAfter = domParent.childNodes[0];\n }\n else {\n const nodeBefore = viewPosition.nodeBefore;\n domBefore = nodeBefore.is('$text') ?\n this.findCorrespondingDomText(nodeBefore) :\n this.mapViewToDom(nodeBefore);\n if (!domBefore) {\n // Position is after a view element that has not been rendered to DOM yet.\n return null;\n }\n domParent = domBefore.parentNode;\n domAfter = domBefore.nextSibling;\n }\n // If there is an inline filler at position return position inside the filler. We should never return\n // the position before the inline filler.\n if (isText(domAfter) && startsWithFiller(domAfter)) {\n return { parent: domAfter, offset: INLINE_FILLER_LENGTH };\n }\n const offset = domBefore ? indexOf(domBefore) + 1 : 0;\n return { parent: domParent, offset };\n }\n }\n /**\n * Converts DOM to view. For all text nodes, not bound elements and document fragments new items will\n * be created. For bound elements and document fragments function will return corresponding items. For\n * {@link module:engine/view/filler fillers} `null` will be returned.\n * For all DOM elements rendered by {@link module:engine/view/uielement~UIElement} that UIElement will be returned.\n *\n * @param domNode DOM node or document fragment to transform.\n * @param options Conversion options.\n * @param options.bind Determines whether new elements will be bound. False by default.\n * @param options.withChildren If `true`, node's and document fragment's children will be converted too. True by default.\n * @param options.keepOriginalCase If `false`, node's tag name will be converted to lower case. False by default.\n * @param options.skipComments If `false`, comment nodes will be converted to `$comment`\n * {@link module:engine/view/uielement~UIElement view UI elements}. False by default.\n * @returns Converted node or document fragment or `null` if DOM node is a {@link module:engine/view/filler filler}\n * or the given node is an empty text node.\n */\n domToView(domNode, options = {}) {\n const inlineNodes = [];\n const generator = this._domToView(domNode, options, inlineNodes);\n // Get the first yielded value or a returned value.\n const node = generator.next().value;\n if (!node) {\n return null;\n }\n // Trigger children handling.\n generator.next();\n // Whitespace cleaning.\n this._processDomInlineNodes(null, inlineNodes, options);\n // Text not got trimmed to an empty string so there is no result node.\n if (node.is('$text') && node.data.length == 0) {\n return null;\n }\n return node;\n }\n /**\n * Converts children of the DOM element to view nodes using\n * the {@link module:engine/view/domconverter~DomConverter#domToView} method.\n * Additionally this method omits block {@link module:engine/view/filler filler}, if it exists in the DOM parent.\n *\n * @param domElement Parent DOM element.\n * @param options See {@link module:engine/view/domconverter~DomConverter#domToView} options parameter.\n * @param inlineNodes An array that will be populated with inline nodes. It's used internally for whitespace processing.\n * @returns View nodes.\n */\n *domChildrenToView(domElement, options = {}, inlineNodes = []) {\n // Get child nodes from content document fragment if element is template\n let childNodes = [];\n if (domElement instanceof HTMLTemplateElement) {\n childNodes = [...domElement.content.childNodes];\n }\n else {\n childNodes = [...domElement.childNodes];\n }\n for (let i = 0; i < childNodes.length; i++) {\n const domChild = childNodes[i];\n const generator = this._domToView(domChild, options, inlineNodes);\n // Get the first yielded value or a returned value.\n const viewChild = generator.next().value;\n if (viewChild !== null) {\n // Whitespace cleaning before entering a block element (between block elements).\n if (this._isBlockViewElement(viewChild)) {\n this._processDomInlineNodes(domElement, inlineNodes, options);\n }\n yield viewChild;\n // Trigger children handling.\n generator.next();\n }\n }\n // Whitespace cleaning before leaving a block element (content of block element).\n this._processDomInlineNodes(domElement, inlineNodes, options);\n }\n /**\n * Converts DOM selection to view {@link module:engine/view/selection~Selection}.\n * Ranges which cannot be converted will be omitted.\n *\n * @param domSelection DOM selection.\n * @returns View selection.\n */\n domSelectionToView(domSelection) {\n // See: https://github.com/ckeditor/ckeditor5/issues/9635.\n if (isGeckoRestrictedDomSelection(domSelection)) {\n return new ViewSelection([]);\n }\n // DOM selection might be placed in fake selection container.\n // If container contains fake selection - return corresponding view selection.\n if (domSelection.rangeCount === 1) {\n let container = domSelection.getRangeAt(0).startContainer;\n // The DOM selection might be moved to the text node inside the fake selection container.\n if (isText(container)) {\n container = container.parentNode;\n }\n const viewSelection = this.fakeSelectionToView(container);\n if (viewSelection) {\n return viewSelection;\n }\n }\n const isBackward = this.isDomSelectionBackward(domSelection);\n const viewRanges = [];\n for (let i = 0; i < domSelection.rangeCount; i++) {\n // DOM Range have correct start and end, no matter what is the DOM Selection direction. So we don't have to fix anything.\n const domRange = domSelection.getRangeAt(i);\n const viewRange = this.domRangeToView(domRange);\n if (viewRange) {\n viewRanges.push(viewRange);\n }\n }\n return new ViewSelection(viewRanges, { backward: isBackward });\n }\n /**\n * Converts DOM Range to view {@link module:engine/view/range~Range}.\n * If the start or end position can not be converted `null` is returned.\n *\n * @param domRange DOM range.\n * @returns View range.\n */\n domRangeToView(domRange) {\n const viewStart = this.domPositionToView(domRange.startContainer, domRange.startOffset);\n const viewEnd = this.domPositionToView(domRange.endContainer, domRange.endOffset);\n if (viewStart && viewEnd) {\n return new ViewRange(viewStart, viewEnd);\n }\n return null;\n }\n /**\n * Converts DOM parent and offset to view {@link module:engine/view/position~Position}.\n *\n * If the position is inside a {@link module:engine/view/filler filler} which has no corresponding view node,\n * position of the filler will be converted and returned.\n *\n * If the position is inside DOM element rendered by {@link module:engine/view/uielement~UIElement}\n * that position will be converted to view position before that UIElement.\n *\n * If structures are too different and it is not possible to find corresponding position then `null` will be returned.\n *\n * @param domParent DOM position parent.\n * @param domOffset DOM position offset. You can skip it when converting the inline filler node.\n * @returns View position.\n */\n domPositionToView(domParent, domOffset = 0) {\n if (this.isBlockFiller(domParent)) {\n return this.domPositionToView(domParent.parentNode, indexOf(domParent));\n }\n // If position is somewhere inside UIElement or a RawElement - return position before that element.\n const viewElement = this.mapDomToView(domParent);\n if (viewElement && (viewElement.is('uiElement') || viewElement.is('rawElement'))) {\n return ViewPosition._createBefore(viewElement);\n }\n if (isText(domParent)) {\n if (isInlineFiller(domParent)) {\n return this.domPositionToView(domParent.parentNode, indexOf(domParent));\n }\n const viewParent = this.findCorrespondingViewText(domParent);\n let offset = domOffset;\n if (!viewParent) {\n return null;\n }\n if (startsWithFiller(domParent)) {\n offset -= INLINE_FILLER_LENGTH;\n offset = offset < 0 ? 0 : offset;\n }\n return new ViewPosition(viewParent, offset);\n }\n // domParent instanceof HTMLElement.\n else {\n if (domOffset === 0) {\n const viewParent = this.mapDomToView(domParent);\n if (viewParent) {\n return new ViewPosition(viewParent, 0);\n }\n }\n else {\n const domBefore = domParent.childNodes[domOffset - 1];\n // Jump over an inline filler (and also on Firefox jump over a block filler while pressing backspace in an empty paragraph).\n if (isText(domBefore) && isInlineFiller(domBefore) || domBefore && this.isBlockFiller(domBefore)) {\n return this.domPositionToView(domBefore.parentNode, indexOf(domBefore));\n }\n const viewBefore = isText(domBefore) ?\n this.findCorrespondingViewText(domBefore) :\n this.mapDomToView(domBefore);\n // TODO #663\n if (viewBefore && viewBefore.parent) {\n return new ViewPosition(viewBefore.parent, viewBefore.index + 1);\n }\n }\n return null;\n }\n }\n /**\n * Returns corresponding view {@link module:engine/view/element~Element Element} or\n * {@link module:engine/view/documentfragment~DocumentFragment} for provided DOM element or\n * document fragment. If there is no view item {@link module:engine/view/domconverter~DomConverter#bindElements bound}\n * to the given DOM - `undefined` is returned.\n *\n * For all DOM elements rendered by a {@link module:engine/view/uielement~UIElement} or\n * a {@link module:engine/view/rawelement~RawElement}, the parent `UIElement` or `RawElement` will be returned.\n *\n * @param domElementOrDocumentFragment DOM element or document fragment.\n * @returns Corresponding view element, document fragment or `undefined` if no element was bound.\n */\n mapDomToView(domElementOrDocumentFragment) {\n const hostElement = this.getHostViewElement(domElementOrDocumentFragment);\n return hostElement || this._domToViewMapping.get(domElementOrDocumentFragment);\n }\n /**\n * Finds corresponding text node. Text nodes are not {@link module:engine/view/domconverter~DomConverter#bindElements bound},\n * corresponding text node is returned based on the sibling or parent.\n *\n * If the directly previous sibling is a {@link module:engine/view/domconverter~DomConverter#bindElements bound} element, it is used\n * to find the corresponding text node.\n *\n * If this is a first child in the parent and the parent is a {@link module:engine/view/domconverter~DomConverter#bindElements bound}\n * element, it is used to find the corresponding text node.\n *\n * For all text nodes rendered by a {@link module:engine/view/uielement~UIElement} or\n * a {@link module:engine/view/rawelement~RawElement}, the parent `UIElement` or `RawElement` will be returned.\n *\n * Otherwise `null` is returned.\n *\n * Note that for the block or inline {@link module:engine/view/filler filler} this method returns `null`.\n *\n * @param domText DOM text node.\n * @returns Corresponding view text node or `null`, if it was not possible to find a corresponding node.\n */\n findCorrespondingViewText(domText) {\n if (isInlineFiller(domText)) {\n return null;\n }\n // If DOM text was rendered by a UIElement or a RawElement - return this parent element.\n const hostElement = this.getHostViewElement(domText);\n if (hostElement) {\n return hostElement;\n }\n const previousSibling = domText.previousSibling;\n // Try to use previous sibling to find the corresponding text node.\n if (previousSibling) {\n if (!(this.isElement(previousSibling))) {\n // The previous is text or comment.\n return null;\n }\n const viewElement = this.mapDomToView(previousSibling);\n if (viewElement) {\n const nextSibling = viewElement.nextSibling;\n // It might be filler which has no corresponding view node.\n if (nextSibling instanceof ViewText) {\n return nextSibling;\n }\n else {\n return null;\n }\n }\n }\n // Try to use parent to find the corresponding text node.\n else {\n const viewElement = this.mapDomToView(domText.parentNode);\n if (viewElement) {\n const firstChild = viewElement.getChild(0);\n // It might be filler which has no corresponding view node.\n if (firstChild instanceof ViewText) {\n return firstChild;\n }\n else {\n return null;\n }\n }\n }\n return null;\n }\n mapViewToDom(documentFragmentOrElement) {\n return this._viewToDomMapping.get(documentFragmentOrElement);\n }\n /**\n * Finds corresponding text node. Text nodes are not {@link module:engine/view/domconverter~DomConverter#bindElements bound},\n * corresponding text node is returned based on the sibling or parent.\n *\n * If the directly previous sibling is a {@link module:engine/view/domconverter~DomConverter#bindElements bound} element, it is used\n * to find the corresponding text node.\n *\n * If this is a first child in the parent and the parent is a {@link module:engine/view/domconverter~DomConverter#bindElements bound}\n * element, it is used to find the corresponding text node.\n *\n * Otherwise `null` is returned.\n *\n * @param viewText View text node.\n * @returns Corresponding DOM text node or `null`, if it was not possible to find a corresponding node.\n */\n findCorrespondingDomText(viewText) {\n const previousSibling = viewText.previousSibling;\n // Try to use previous sibling to find the corresponding text node.\n if (previousSibling && this.mapViewToDom(previousSibling)) {\n return this.mapViewToDom(previousSibling).nextSibling;\n }\n // If this is a first node, try to use parent to find the corresponding text node.\n if (!previousSibling && viewText.parent && this.mapViewToDom(viewText.parent)) {\n return this.mapViewToDom(viewText.parent).childNodes[0];\n }\n return null;\n }\n /**\n * Focuses DOM editable that is corresponding to provided {@link module:engine/view/editableelement~EditableElement}.\n */\n focus(viewEditable) {\n const domEditable = this.mapViewToDom(viewEditable);\n if (domEditable && domEditable.ownerDocument.activeElement !== domEditable) {\n // Save the scrollX and scrollY positions before the focus.\n const { scrollX, scrollY } = global.window;\n const scrollPositions = [];\n // Save all scrollLeft and scrollTop values starting from domEditable up to\n // document#documentElement.\n forEachDomElementAncestor(domEditable, node => {\n const { scrollLeft, scrollTop } = node;\n scrollPositions.push([scrollLeft, scrollTop]);\n });\n domEditable.focus();\n // Restore scrollLeft and scrollTop values starting from domEditable up to\n // document#documentElement.\n // https://github.com/ckeditor/ckeditor5-engine/issues/951\n // https://github.com/ckeditor/ckeditor5-engine/issues/957\n forEachDomElementAncestor(domEditable, node => {\n const [scrollLeft, scrollTop] = scrollPositions.shift();\n node.scrollLeft = scrollLeft;\n node.scrollTop = scrollTop;\n });\n // Restore the scrollX and scrollY positions after the focus.\n // https://github.com/ckeditor/ckeditor5-engine/issues/951\n global.window.scrollTo(scrollX, scrollY);\n }\n }\n /**\n * Remove DOM selection from blurred editable, so it won't interfere with clicking on dropdowns (especially on iOS).\n *\n * @internal\n */\n _clearDomSelection() {\n const domEditable = this.mapViewToDom(this.document.selection.editableElement);\n if (!domEditable) {\n return;\n }\n // Check if DOM selection is inside editor editable element.\n const domSelection = domEditable.ownerDocument.defaultView.getSelection();\n const newViewSelection = this.domSelectionToView(domSelection);\n const selectionInEditable = newViewSelection && newViewSelection.rangeCount > 0;\n if (selectionInEditable) {\n domSelection.removeAllRanges();\n }\n }\n /**\n * Returns `true` when `node.nodeType` equals `Node.ELEMENT_NODE`.\n *\n * @param node Node to check.\n */\n isElement(node) {\n return node && node.nodeType == Node.ELEMENT_NODE;\n }\n /**\n * Returns `true` when `node.nodeType` equals `Node.DOCUMENT_FRAGMENT_NODE`.\n *\n * @param node Node to check.\n */\n isDocumentFragment(node) {\n return node && node.nodeType == Node.DOCUMENT_FRAGMENT_NODE;\n }\n /**\n * Checks if the node is an instance of the block filler for this DOM converter.\n *\n * ```ts\n * const converter = new DomConverter( viewDocument, { blockFillerMode: 'br' } );\n *\n * converter.isBlockFiller( BR_FILLER( document ) ); // true\n * converter.isBlockFiller( NBSP_FILLER( document ) ); // false\n * ```\n *\n * **Note:**: For the `'nbsp'` mode the method also checks context of a node so it cannot be a detached node.\n *\n * **Note:** A special case in the `'nbsp'` mode exists where the `
` in `


` is treated as a block filler.\n *\n * @param domNode DOM node to check.\n * @returns True if a node is considered a block filler for given mode.\n */\n isBlockFiller(domNode) {\n if (this.blockFillerMode == 'br') {\n return domNode.isEqualNode(BR_FILLER_REF);\n }\n // Special case for


in which
should be treated as filler even when we are not in the 'br' mode. See ckeditor5#5564.\n if (domNode.tagName === 'BR' &&\n hasBlockParent(domNode, this.blockElements) &&\n domNode.parentNode.childNodes.length === 1) {\n return true;\n }\n // If not in 'br' mode, try recognizing both marked and regular nbsp block fillers.\n return domNode.isEqualNode(MARKED_NBSP_FILLER_REF) || isNbspBlockFiller(domNode, this.blockElements);\n }\n /**\n * Returns `true` if given selection is a backward selection, that is, if it's `focus` is before `anchor`.\n *\n * @param DOM Selection instance to check.\n */\n isDomSelectionBackward(selection) {\n if (selection.isCollapsed) {\n return false;\n }\n // Since it takes multiple lines of code to check whether a \"DOM Position\" is before/after another \"DOM Position\",\n // we will use the fact that range will collapse if it's end is before it's start.\n const range = this._domDocument.createRange();\n try {\n range.setStart(selection.anchorNode, selection.anchorOffset);\n range.setEnd(selection.focusNode, selection.focusOffset);\n }\n catch (e) {\n // Safari sometimes gives us a selection that makes Range.set{Start,End} throw.\n // See https://github.com/ckeditor/ckeditor5/issues/12375.\n return false;\n }\n const backward = range.collapsed;\n range.detach();\n return backward;\n }\n /**\n * Returns a parent {@link module:engine/view/uielement~UIElement} or {@link module:engine/view/rawelement~RawElement}\n * that hosts the provided DOM node. Returns `null` if there is no such parent.\n */\n getHostViewElement(domNode) {\n const ancestors = getAncestors(domNode);\n // Remove domNode from the list.\n ancestors.pop();\n while (ancestors.length) {\n const domNode = ancestors.pop();\n const viewNode = this._domToViewMapping.get(domNode);\n if (viewNode && (viewNode.is('uiElement') || viewNode.is('rawElement'))) {\n return viewNode;\n }\n }\n return null;\n }\n /**\n * Checks if the given selection's boundaries are at correct places.\n *\n * The following places are considered as incorrect for selection boundaries:\n *\n * * before or in the middle of an inline filler sequence,\n * * inside a DOM element which represents {@link module:engine/view/uielement~UIElement a view UI element},\n * * inside a DOM element which represents {@link module:engine/view/rawelement~RawElement a view raw element}.\n *\n * @param domSelection The DOM selection object to be checked.\n * @returns `true` if the given selection is at a correct place, `false` otherwise.\n */\n isDomSelectionCorrect(domSelection) {\n return this._isDomSelectionPositionCorrect(domSelection.anchorNode, domSelection.anchorOffset) &&\n this._isDomSelectionPositionCorrect(domSelection.focusNode, domSelection.focusOffset);\n }\n /**\n * Registers a {@link module:engine/view/matcher~MatcherPattern} for view elements whose content should be treated as raw data\n * and not processed during the conversion from DOM nodes to view elements.\n *\n * This is affecting how {@link module:engine/view/domconverter~DomConverter#domToView} and\n * {@link module:engine/view/domconverter~DomConverter#domChildrenToView} process DOM nodes.\n *\n * The raw data can be later accessed by a\n * {@link module:engine/view/element~Element#getCustomProperty custom property of a view element} called `\"$rawContent\"`.\n *\n * @param pattern Pattern matching a view element whose content should\n * be treated as raw data.\n */\n registerRawContentMatcher(pattern) {\n this._rawContentElementMatcher.add(pattern);\n }\n /**\n * Registers a {@link module:engine/view/matcher~MatcherPattern} for inline object view elements.\n *\n * This is affecting how {@link module:engine/view/domconverter~DomConverter#domToView} and\n * {@link module:engine/view/domconverter~DomConverter#domChildrenToView} process DOM nodes.\n *\n * This is an extension of a simple {@link #inlineObjectElements} array of element names.\n *\n * @param pattern Pattern matching a view element which should be treated as an inline object.\n */\n registerInlineObjectMatcher(pattern) {\n this._inlineObjectElementMatcher.add(pattern);\n }\n /**\n * Clear temporary custom properties.\n *\n * @internal\n */\n _clearTemporaryCustomProperties() {\n for (const element of this._elementsWithTemporaryCustomProperties) {\n element._removeCustomProperty('editingPipeline:doNotReuseOnce');\n }\n this._elementsWithTemporaryCustomProperties.clear();\n }\n /**\n * Returns the block {@link module:engine/view/filler filler} node based on the current {@link #blockFillerMode} setting.\n */\n _getBlockFiller() {\n switch (this.blockFillerMode) {\n case 'nbsp':\n return NBSP_FILLER(this._domDocument); // eslint-disable-line new-cap\n case 'markedNbsp':\n return MARKED_NBSP_FILLER(this._domDocument); // eslint-disable-line new-cap\n case 'br':\n return BR_FILLER(this._domDocument); // eslint-disable-line new-cap\n }\n }\n /**\n * Checks if the given DOM position is a correct place for selection boundary. See {@link #isDomSelectionCorrect}.\n *\n * @param domParent Position parent.\n * @param offset Position offset.\n * @returns `true` if given position is at a correct place for selection boundary, `false` otherwise.\n */\n _isDomSelectionPositionCorrect(domParent, offset) {\n // If selection is before or in the middle of inline filler string, it is incorrect.\n if (isText(domParent) && startsWithFiller(domParent) && offset < INLINE_FILLER_LENGTH) {\n // Selection in a text node, at wrong position (before or in the middle of filler).\n return false;\n }\n if (this.isElement(domParent) && startsWithFiller(domParent.childNodes[offset])) {\n // Selection in an element node, before filler text node.\n return false;\n }\n const viewParent = this.mapDomToView(domParent);\n // The position is incorrect when anchored inside a UIElement or a RawElement.\n // Note: In case of UIElement and RawElement, mapDomToView() returns a parent element for any DOM child\n // so there's no need to perform any additional checks.\n if (viewParent && (viewParent.is('uiElement') || viewParent.is('rawElement'))) {\n return false;\n }\n return true;\n }\n /**\n * Internal generator for {@link #domToView}. Also used by {@link #domChildrenToView}.\n * Separates DOM nodes conversion from whitespaces processing.\n *\n * @param domNode DOM node or document fragment to transform.\n * @param inlineNodes An array of recently encountered inline nodes truncated to the block element boundaries.\n * Used later to process whitespaces.\n */\n *_domToView(domNode, options, inlineNodes) {\n if (this.isBlockFiller(domNode)) {\n return null;\n }\n // When node is inside a UIElement or a RawElement return that parent as it's view representation.\n const hostElement = this.getHostViewElement(domNode);\n if (hostElement) {\n return hostElement;\n }\n if (isComment(domNode) && options.skipComments) {\n return null;\n }\n if (isText(domNode)) {\n if (isInlineFiller(domNode)) {\n return null;\n }\n else {\n const textData = domNode.data;\n if (textData === '') {\n return null;\n }\n const textNode = new ViewText(this.document, textData);\n inlineNodes.push(textNode);\n return textNode;\n }\n }\n else {\n let viewElement = this.mapDomToView(domNode);\n if (viewElement) {\n if (this._isInlineObjectElement(viewElement)) {\n inlineNodes.push(viewElement);\n }\n return viewElement;\n }\n if (this.isDocumentFragment(domNode)) {\n // Create view document fragment.\n viewElement = new ViewDocumentFragment(this.document);\n if (options.bind) {\n this.bindDocumentFragments(domNode, viewElement);\n }\n }\n else {\n // Create view element.\n viewElement = this._createViewElement(domNode, options);\n if (options.bind) {\n this.bindElements(domNode, viewElement);\n }\n // Copy element's attributes.\n const attrs = domNode.attributes;\n if (attrs) {\n for (let l = attrs.length, i = 0; i < l; i++) {\n viewElement._setAttribute(attrs[i].name, attrs[i].value);\n }\n }\n // Treat this element's content as a raw data if it was registered as such.\n if (this._isViewElementWithRawContent(viewElement, options)) {\n viewElement._setCustomProperty('$rawContent', domNode.innerHTML);\n if (!this._isBlockViewElement(viewElement)) {\n inlineNodes.push(viewElement);\n }\n return viewElement;\n }\n // Comment node is also treated as an element with raw data.\n if (isComment(domNode)) {\n viewElement._setCustomProperty('$rawContent', domNode.data);\n return viewElement;\n }\n }\n // Yield the element first so the flow of nested inline nodes is not reversed inside elements.\n yield viewElement;\n const nestedInlineNodes = [];\n if (options.withChildren !== false) {\n for (const child of this.domChildrenToView(domNode, options, nestedInlineNodes)) {\n viewElement._appendChild(child);\n }\n }\n // Check if this is an inline object after processing child nodes so matcher\n // for inline objects can verify if the element is empty.\n if (this._isInlineObjectElement(viewElement)) {\n inlineNodes.push(viewElement);\n }\n else {\n // It's an inline element that is not an object (like , ) or a block element.\n for (const inlineNode of nestedInlineNodes) {\n inlineNodes.push(inlineNode);\n }\n }\n }\n }\n /**\n * Internal helper that walks the list of inline view nodes already generated from DOM nodes\n * and handles whitespaces and NBSPs.\n *\n * @param domParent The DOM parent of the given inline nodes. This should be a document fragment or\n * a block element to whitespace processing start cleaning.\n * @param inlineNodes An array of recently encountered inline nodes truncated to the block element boundaries.\n */\n _processDomInlineNodes(domParent, inlineNodes, options) {\n if (!inlineNodes.length) {\n return;\n }\n // Process text nodes only after reaching a block or document fragment,\n // do not alter whitespaces while processing an inline element like or .\n if (domParent && !this.isDocumentFragment(domParent) && !this._isBlockDomElement(domParent)) {\n return;\n }\n let prevNodeEndsWithSpace = false;\n for (let i = 0; i < inlineNodes.length; i++) {\n const node = inlineNodes[i];\n if (!node.is('$text')) {\n prevNodeEndsWithSpace = false;\n continue;\n }\n let data;\n let nodeEndsWithSpace = false;\n if (_hasViewParentOfType(node, this.preElements)) {\n data = getDataWithoutFiller(node.data);\n }\n else {\n // Change all consecutive whitespace characters (from the [ \\n\\t\\r] set –\n // see https://github.com/ckeditor/ckeditor5-engine/issues/822#issuecomment-311670249) to a single space character.\n // That's how multiple whitespaces are treated when rendered, so we normalize those whitespaces.\n // We're replacing 1+ (and not 2+) to also normalize singular \\n\\t\\r characters (#822).\n data = node.data.replace(/[ \\n\\t\\r]{1,}/g, ' ');\n nodeEndsWithSpace = /[^\\S\\u00A0]/.test(data.charAt(data.length - 1));\n const prevNode = i > 0 ? inlineNodes[i - 1] : null;\n const nextNode = i + 1 < inlineNodes.length ? inlineNodes[i + 1] : null;\n const shouldLeftTrim = !prevNode || prevNode.is('element') && prevNode.name == 'br' || prevNodeEndsWithSpace;\n const shouldRightTrim = nextNode ? false : !startsWithFiller(node.data);\n // Do not try to clear whitespaces if this is flat mapping for the purpose of mutation observer and differ in rendering.\n if (options.withChildren !== false) {\n // If the previous dom text node does not exist or it ends by whitespace character, remove space character from the\n // beginning of this text node. Such space character is treated as a whitespace.\n if (shouldLeftTrim) {\n data = data.replace(/^ /, '');\n }\n // If the next text node does not exist remove space character from the end of this text node.\n if (shouldRightTrim) {\n data = data.replace(/ $/, '');\n }\n }\n // At the beginning and end of a block element, Firefox inserts normal space +
instead of non-breaking space.\n // This means that the text node starts/end with normal space instead of non-breaking space.\n // This causes a problem because the normal space would be removed in `.replace` calls above. To prevent that,\n // the inline filler is removed only after the data is initially processed (by the `.replace` above). See ckeditor5#692.\n data = getDataWithoutFiller(data);\n // At this point we should have removed all whitespaces from DOM text data.\n //\n // Now, We will reverse the process that happens in `_processDataFromViewText`.\n //\n // We have to change   chars, that were in DOM text data because of rendering reasons, to spaces.\n // First, change all ` \\u00A0` pairs (space +  ) to two spaces. DOM converter changes two spaces from model/view to\n // ` \\u00A0` to ensure proper rendering. Since here we convert back, we recognize those pairs and change them back to ` `.\n data = data.replace(/ \\u00A0/g, ' ');\n const isNextNodeInlineObjectElement = nextNode && nextNode.is('element') && nextNode.name != 'br';\n const isNextNodeStartingWithSpace = nextNode && nextNode.is('$text') && nextNode.data.charAt(0) == ' ';\n // Then, let's change the last nbsp to a space.\n if (/[ \\u00A0]\\u00A0$/.test(data) || !nextNode || isNextNodeInlineObjectElement || isNextNodeStartingWithSpace) {\n data = data.replace(/\\u00A0$/, ' ');\n }\n // Then, change   character that is at the beginning of the text node to space character.\n // We do that replacement only if this is the first node or the previous node ends on whitespace character.\n if (shouldLeftTrim || prevNode && prevNode.is('element') && prevNode.name != 'br') {\n data = data.replace(/^\\u00A0/, ' ');\n }\n }\n // At this point, all whitespaces should be removed and all   created for rendering reasons should be\n // changed to normal space. All left   are   inserted intentionally.\n if (data.length == 0 && node.parent) {\n node._remove();\n inlineNodes.splice(i, 1);\n i--;\n }\n else {\n node._data = data;\n prevNodeEndsWithSpace = nodeEndsWithSpace;\n }\n }\n inlineNodes.length = 0;\n }\n /**\n * Takes text data from a given {@link module:engine/view/text~Text#data} and processes it so\n * it is correctly displayed in the DOM.\n *\n * Following changes are done:\n *\n * * a space at the beginning is changed to ` ` if this is the first text node in its container\n * element or if a previous text node ends with a space character,\n * * space at the end of the text node is changed to ` ` if there are two spaces at the end of a node or if next node\n * starts with a space or if it is the last text node in its container,\n * * remaining spaces are replaced to a chain of spaces and ` ` (e.g. `'x x'` becomes `'x   x'`).\n *\n * Content of {@link #preElements} is not processed.\n *\n * @param node View text node to process.\n * @returns Processed text data.\n */\n _processDataFromViewText(node) {\n let data = node.data;\n // If any of node ancestors has a name which is in `preElements` array, then currently processed\n // view text node is (will be) in preformatted element. We should not change whitespaces then.\n if (node.getAncestors().some(parent => this.preElements.includes(parent.name))) {\n return data;\n }\n // 1. Replace the first space with a nbsp if the previous node ends with a space or there is no previous node\n // (container element boundary).\n if (data.charAt(0) == ' ') {\n const prevNode = this._getTouchingInlineViewNode(node, false);\n const prevEndsWithSpace = prevNode && prevNode.is('$textProxy') && this._nodeEndsWithSpace(prevNode);\n if (prevEndsWithSpace || !prevNode) {\n data = '\\u00A0' + data.substr(1);\n }\n }\n // 2. Replace the last space with nbsp if there are two spaces at the end or if the next node starts with space or there is no\n // next node (container element boundary).\n //\n // Keep in mind that Firefox prefers $nbsp; before tag, not inside it:\n //\n // Foo  bar <-- bad.\n // Foo  bar <-- good.\n //\n // More here: https://github.com/ckeditor/ckeditor5-engine/issues/1747.\n if (data.charAt(data.length - 1) == ' ') {\n const nextNode = this._getTouchingInlineViewNode(node, true);\n const nextStartsWithSpace = nextNode && nextNode.is('$textProxy') && nextNode.data.charAt(0) == ' ';\n if (data.charAt(data.length - 2) == ' ' || !nextNode || nextStartsWithSpace) {\n data = data.substr(0, data.length - 1) + '\\u00A0';\n }\n }\n // 3. Create space+nbsp pairs.\n return data.replace(/ {2}/g, ' \\u00A0');\n }\n /**\n * Checks whether given node ends with a space character after changing appropriate space characters to ` `s.\n *\n * @param node Node to check.\n * @returns `true` if given `node` ends with space, `false` otherwise.\n */\n _nodeEndsWithSpace(node) {\n if (node.getAncestors().some(parent => this.preElements.includes(parent.name))) {\n return false;\n }\n const data = this._processDataFromViewText(node);\n return data.charAt(data.length - 1) == ' ';\n }\n /**\n * Helper function. For given {@link module:engine/view/text~Text view text node}, it finds previous or next sibling\n * that is contained in the same container element. If there is no such sibling, `null` is returned.\n *\n * @param node Reference node.\n * @returns Touching text node, an inline object\n * or `null` if there is no next or previous touching text node.\n */\n _getTouchingInlineViewNode(node, getNext) {\n const treeWalker = new ViewTreeWalker({\n startPosition: getNext ? ViewPosition._createAfter(node) : ViewPosition._createBefore(node),\n direction: getNext ? 'forward' : 'backward'\n });\n for (const value of treeWalker) {\n //
found – it works like a block boundary, so do not scan further.\n if (value.item.is('element', 'br')) {\n return null;\n }\n // Found an inline object (for example an image).\n else if (this._isInlineObjectElement(value.item)) {\n return value.item;\n }\n // ViewContainerElement is found on a way to next ViewText node, so given `node` was first/last\n // text node in its container element.\n else if (value.item.is('containerElement')) {\n return null;\n }\n // Found a text node in the same container element.\n else if (value.item.is('$textProxy')) {\n return value.item;\n }\n }\n return null;\n }\n /**\n * Returns `true` if a DOM node belongs to {@link #blockElements}. `false` otherwise.\n */\n _isBlockDomElement(node) {\n return this.isElement(node) && this.blockElements.includes(node.tagName.toLowerCase());\n }\n /**\n * Returns `true` if a view node belongs to {@link #blockElements}. `false` otherwise.\n */\n _isBlockViewElement(node) {\n return node.is('element') && this.blockElements.includes(node.name);\n }\n /**\n * Returns `true` if a DOM node belongs to {@link #inlineObjectElements}. `false` otherwise.\n */\n _isInlineObjectElement(node) {\n if (!node.is('element')) {\n return false;\n }\n return node.name == 'br' ||\n this.inlineObjectElements.includes(node.name) ||\n !!this._inlineObjectElementMatcher.match(node);\n }\n /**\n * Creates view element basing on the node type.\n *\n * @param node DOM node to check.\n * @param options Conversion options. See {@link module:engine/view/domconverter~DomConverter#domToView} options parameter.\n */\n _createViewElement(node, options) {\n if (isComment(node)) {\n return new ViewUIElement(this.document, '$comment');\n }\n const viewName = options.keepOriginalCase ? node.tagName : node.tagName.toLowerCase();\n return new ViewElement(this.document, viewName);\n }\n /**\n * Checks if view element's content should be treated as a raw data.\n *\n * @param viewElement View element to check.\n * @param options Conversion options. See {@link module:engine/view/domconverter~DomConverter#domToView} options parameter.\n */\n _isViewElementWithRawContent(viewElement, options) {\n return options.withChildren !== false && viewElement.is('element') && !!this._rawContentElementMatcher.match(viewElement);\n }\n /**\n * Checks whether a given element name should be renamed in a current rendering mode.\n *\n * @param elementName The name of view element.\n */\n _shouldRenameElement(elementName) {\n const name = elementName.toLowerCase();\n return this.renderingMode === 'editing' && this.unsafeElements.includes(name);\n }\n /**\n * Return a element with a special attribute holding the name of the original element.\n * Optionally, copy all the attributes of the original element if that element is provided.\n *\n * @param elementName The name of view element.\n * @param originalDomElement The original DOM element to copy attributes and content from.\n */\n _createReplacementDomElement(elementName, originalDomElement) {\n const newDomElement = this._domDocument.createElement('span');\n // Mark the span replacing a script as hidden.\n newDomElement.setAttribute(UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE, elementName);\n if (originalDomElement) {\n while (originalDomElement.firstChild) {\n newDomElement.appendChild(originalDomElement.firstChild);\n }\n for (const attributeName of originalDomElement.getAttributeNames()) {\n newDomElement.setAttribute(attributeName, originalDomElement.getAttribute(attributeName));\n }\n }\n return newDomElement;\n }\n}\n/**\n * Helper function.\n * Used to check if given native `Element` or `Text` node has parent with tag name from `types` array.\n *\n * @returns`true` if such parent exists or `false` if it does not.\n */\nfunction _hasViewParentOfType(node, types) {\n return node.getAncestors().some(parent => parent.is('element') && types.includes(parent.name));\n}\n/**\n * A helper that executes given callback for each DOM node's ancestor, starting from the given node\n * and ending in document#documentElement.\n *\n * @param callback A callback to be executed for each ancestor.\n */\nfunction forEachDomElementAncestor(element, callback) {\n let node = element;\n while (node) {\n callback(node);\n node = node.parentElement;\n }\n}\n/**\n * Checks if given node is a nbsp block filler.\n *\n * A   is a block filler only if it is a single child of a block element.\n *\n * @param domNode DOM node.\n */\nfunction isNbspBlockFiller(domNode, blockElements) {\n const isNBSP = domNode.isEqualNode(NBSP_FILLER_REF);\n return isNBSP && hasBlockParent(domNode, blockElements) && domNode.parentNode.childNodes.length === 1;\n}\n/**\n * Checks if domNode has block parent.\n *\n * @param domNode DOM node.\n */\nfunction hasBlockParent(domNode, blockElements) {\n const parent = domNode.parentNode;\n return !!parent && !!parent.tagName && blockElements.includes(parent.tagName.toLowerCase());\n}\n/**\n * Log to console the information about element that was replaced.\n * Check UNSAFE_ELEMENTS for all recognized unsafe elements.\n *\n * @param elementName The name of the view element.\n */\nfunction _logUnsafeElement(elementName) {\n if (elementName === 'script') {\n logWarning('domconverter-unsafe-script-element-detected');\n }\n if (elementName === 'style') {\n logWarning('domconverter-unsafe-style-element-detected');\n }\n}\n/**\n * In certain cases, Firefox mysteriously assigns so called \"restricted objects\" to native DOM Range properties.\n * Any attempt at accessing restricted object's properties causes errors.\n * See: https://github.com/ckeditor/ckeditor5/issues/9635.\n */\nfunction isGeckoRestrictedDomSelection(domSelection) {\n if (!env.isGecko) {\n return false;\n }\n if (!domSelection.rangeCount) {\n return false;\n }\n const container = domSelection.getRangeAt(0).startContainer;\n try {\n Object.prototype.toString.call(container);\n }\n catch (error) {\n return true;\n }\n return false;\n}\n/**\n * While rendering the editor content, the {@link module:engine/view/domconverter~DomConverter} detected a `