@ncino/web-components 5.0.0-preview.2 → 5.0.0-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +1 -1
- package/dist/_virtual/index_html.js +1 -1
- package/dist/_virtual/index_react.js +1 -1
- package/dist/_virtual/preload-helper.js +1 -1
- package/dist/assets/node_modules/.pnpm/ckeditor5@45.2.1/node_modules/ckeditor5/dist/ckeditor5.css +1 -1
- package/dist/components/accordion/gator/base/accordion.gator.js +6 -6
- package/dist/components/avatar/gator/avatar.gator.js +2 -2
- package/dist/components/badge/gator/badge.gator.js +2 -2
- package/dist/components/boolean/boolean.gator.js +6 -6
- package/dist/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.js +2 -2
- package/dist/components/button/gator/button.gator.js +4 -4
- package/dist/components/button-group/gator/button-group.gator.js +2 -2
- package/dist/components/checkbox/checkbox.gator.js +5 -5
- package/dist/components/checkbox-group/checkbox-group.gator.js +8 -8
- package/dist/components/combobox/base/combobox.js +1 -1
- package/dist/components/combobox/base/combobox.slds.js +13 -13
- package/dist/components/date-picker/base/gator/datepicker.gator.js +18 -18
- package/dist/components/date-picker/year-month-selector/year-month-selector.gator.js +2 -2
- package/dist/components/headline-card/gator/headline-card.gator.js +2 -2
- package/dist/components/icon/gator/icon.gator.js +2 -2
- package/dist/components/illustration/gator/illustration.gator.js +2 -2
- package/dist/components/input/base/input-base.gator.js +1 -1
- package/dist/components/input/gator/dropdown/input-dropdown.gator.js +11 -11
- package/dist/components/input/gator/input-currency/input-currency.gator.js +2 -2
- package/dist/components/input/gator/input-date/input-date.gator.js +15 -15
- package/dist/components/input/gator/input-file/input-file.gator.js +3 -3
- package/dist/components/input/gator/input-masked/input-masked.gator.js +1 -1
- package/dist/components/input/gator/input-phone/input-phone.gator.js +2 -2
- package/dist/components/input/gator/input-search/input-search.gator.js +2 -2
- package/dist/components/input/gator/input-text/input-text.gator.js +1 -1
- package/dist/components/input/gator/input-time/input-time.gator.js +2 -2
- package/dist/components/list/gator/list/list.gator.js +2 -2
- package/dist/components/list/gator/list-item/list-item.gator.js +6 -6
- package/dist/components/menu/base/gator/menu.gator.js +3 -3
- package/dist/components/menu/base/slds/menu.slds.js +2 -2
- package/dist/components/menu/menu-item/gator/menu-item.gator.js +2 -2
- package/dist/components/menu/menu-submenu/menu-submenu.js +1 -1
- package/dist/components/modal/gator/modal.gator.js +38 -39
- package/dist/components/page-header/gator/page-header.gator.js +2 -2
- package/dist/components/panel/gator/panel.gator.js +13 -13
- package/dist/components/panel/gator/panel.storybook-test.js +1 -1
- package/dist/components/pill/pill.slds.js +3 -3
- package/dist/components/popover/gator/popover.gator.js +10 -10
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/radio/radio.gator.js +2 -2
- package/dist/components/radio-group/radio-group.gator.js +2 -2
- package/dist/components/selection-box-group/selection-box-group.gator.js +5 -5
- package/dist/components/selector/gator/selector.gator.js +2 -2
- package/dist/components/switch/gator/switch.gator.js +2 -2
- package/dist/components/tabs/gator/tabset/tabset.gator.js +3 -3
- package/dist/components/text-detail/gator/text-detail.gator.js +17 -18
- package/dist/components/time-picker/gator/time-picker.gator.js +19 -19
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-autosave@45.2.1/node_modules/@ckeditor/ckeditor5-autosave/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-basic-styles@45.2.1/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-clipboard@45.2.1/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +10 -10
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-cloud-services@45.2.1/node_modules/@ckeditor/ckeditor5-cloud-services/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-code-block@45.2.1/node_modules/@ckeditor/ckeditor5-code-block/dist/index.js +5 -5
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-editor-classic@45.2.1/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +12 -12
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-find-and-replace@45.2.1/node_modules/@ckeditor/ckeditor5-find-and-replace/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-font@45.2.1/node_modules/@ckeditor/ckeditor5-font/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-heading@45.2.1/node_modules/@ckeditor/ckeditor5-heading/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-embed@45.2.1/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@45.2.1/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +6 -6
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-image@45.2.1/node_modules/@ckeditor/ckeditor5-image/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@45.2.1/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@45.2.1/node_modules/@ckeditor/ckeditor5-link/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@45.2.1/node_modules/@ckeditor/ckeditor5-list/dist/index.js +5 -5
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-markdown-gfm@45.2.1/node_modules/@ckeditor/ckeditor5-markdown-gfm/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-media-embed@45.2.1/node_modules/@ckeditor/ckeditor5-media-embed/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paragraph@45.2.1/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@45.2.1/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +9 -9
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-source-editing@45.2.1/node_modules/@ckeditor/ckeditor5-source-editing/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-special-characters@45.2.1/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-style@45.2.1/node_modules/@ckeditor/ckeditor5-style/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@45.2.1/node_modules/@ckeditor/ckeditor5-table/dist/index.js +6 -6
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-typing@45.2.1/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +10 -10
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-undo@45.2.1/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-upload@45.2.1/node_modules/@ckeditor/ckeditor5-upload/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +38 -38
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-watchdog@45.2.1/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-widget@45.2.1/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@deltablot_dropzone@7.3.1/node_modules/@deltablot/dropzone/dist/dropzone.js +1 -1
- package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/main.js +1 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/dist/common/fetch.js +1 -0
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +1 -0
- package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/helpers.js +1 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/package.json.js +1 -0
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.2/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
- package/dist/node_modules/.pnpm/@lit_reactive-element@2.1.0/node_modules/@lit/reactive-element/reactive-element.js +2 -2
- package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/channels/index.js +9 -9
- package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/csf/index.js +1 -1
- package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/preview-api/index.js +22 -22
- package/dist/node_modules/.pnpm/@storybook_instrumenter@8.6.14_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/instrumenter/dist/index.js +36 -36
- package/dist/node_modules/.pnpm/@storybook_test@8.6.14_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/test/dist/index.js +111 -111
- package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.10_typescript@5.8.3__playwright@1.53.2_77c47ac19cbe97978028e1e5ac862536/node_modules/@vitest/browser/context.js +1 -0
- package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js +8 -8
- package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js +5 -5
- package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js +11 -11
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.js +21 -21
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js +2 -2
- package/dist/node_modules/.pnpm/axe-core@4.10.3/node_modules/axe-core/axe.js +4 -4
- package/dist/node_modules/.pnpm/chai@5.2.0/node_modules/chai/chai.js +3 -3
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/_internal/isPrototype.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/get.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/unset.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/function/debounce.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/object/cloneDeepWith.js +1 -1
- package/dist/node_modules/.pnpm/lit-element@4.2.0/node_modules/lit-element/lit-element.js +2 -2
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/async-directive.js +1 -1
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/class-map.js +2 -2
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/ref.js +2 -2
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/lit-html.js +3 -3
- package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cache.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cachestorage.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/parse.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/constants.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/headers.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/index.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/request.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/response.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/util.js +2 -2
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/webidl.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/connection.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/events.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/frame.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/receiver.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/util.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/websocket.js +1 -1
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.10_@vitest_browser@3.2.4_@vitest_ui@3_8c34ee540b1f52c214debce201d1e515/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +1 -1
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.10_@vitest_browser@3.2.4_@vitest_ui@3_8c34ee540b1f52c214debce201d1e515/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +8 -8
- package/dist/packages/web-components/src/components/button/gator/button.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/modal/gator/modal.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/switch/gator/switch.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/text-detail/gator/text-detail.gator.scss.js +1 -1
- package/dist/packages/web-components/src/index.slds.scss.js +1 -1
- package/dist/types/components/modal/gator/modal.gator.d.ts +1 -1
- package/dist/types/components/text-detail/gator/text-detail.gator.d.ts +4 -2
- package/dist/utils/accessibility-utils.js +1 -1
- package/dist/utils/datatestid-utils.js +1 -1
- package/dist/utils/lightdom-utils.js +1 -1
- package/dist/utils/vitest-a11y-utils.js +1 -1
- package/dist/utils/vitest-utils.js +1 -1
- package/package.json +10 -10
- package/web-types.json +2 -3
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/dist/common/fetch.js +0 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +0 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/package.json.js +0 -1
- package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.10_typescript@5.8.3__playwright@1.53.1_5fd2997ee9a97429a51e07bc2023c338/node_modules/@vitest/browser/context.js +0 -1
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/client/external.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/client/figma_client.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/common/logging.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/common/updates.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/external_types.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/index_common.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/external.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/index_html.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/template_literal.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/react/external.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/react/index_react.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import{throttle as E}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/throttle.js";import{isElement as _}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isElement.js";import{cloneDeepWith as b}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*//**
|
|
5
5
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
6
6
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
7
|
-
*/class
|
|
7
|
+
*/class m{crashes=[];state="initializing";_crashNumberLimit;_now=Date.now;_minimumNonErrorTimePeriod;_boundErrorHandler;_listeners;constructor(t){if(this.crashes=[],this._crashNumberLimit=typeof t.crashNumberLimit=="number"?t.crashNumberLimit:3,this._minimumNonErrorTimePeriod=typeof t.minimumNonErrorTimePeriod=="number"?t.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const s="error"in e?e.error:e.reason;s instanceof Error&&this._handleError(s,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(t,e){this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e)}off(t,e){this._listeners[t]=this._listeners[t].filter(s=>s!==e)}_fire(t,...e){const s=this._listeners[t]||[];for(const r of s)r.apply(this,[null,...e])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(t,e){if(this._shouldReactToError(t)){this.crashes.push({message:t.message,stack:t.stack,filename:e instanceof ErrorEvent?e.filename:void 0,lineno:e instanceof ErrorEvent?e.lineno:void 0,colno:e instanceof ErrorEvent?e.colno:void 0,date:this._now()});const s=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:t,causesRestart:s}),s?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(t){return t.is&&t.is("CKEditorError")&&t.context!==void 0&&t.context!==null&&this.state==="ready"&&this._isErrorComingFromThisItem(t)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;const t=this.crashes[this.crashes.length-1].date,e=this.crashes[this.crashes.length-1-this._crashNumberLimit].date;return(t-e)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}/**
|
|
8
8
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
9
9
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
10
|
-
*/function _(o,e=new Set){const t=[o],s=new Set;let r=0;for(;t.length>r;){const i=t[r++];if(!(s.has(i)||!C(i)||e.has(i)))if(s.add(i),Symbol.iterator in i)try{for(const a of i)t.push(a)}catch{}else for(const a in i)a!=="defaultValue"&&t.push(i[a])}return s}function C(o){const e=Object.prototype.toString.call(o),t=typeof o;return!(t==="number"||t==="boolean"||t==="string"||t==="symbol"||t==="function"||e==="[object Date]"||e==="[object RegExp]"||e==="[object Module]"||o===void 0||o===null||o._watchdogExcluded||o instanceof EventTarget||o instanceof Event)}function p(o,e,t=new Set){if(o===e&&v(o))return!0;const s=_(o,t),r=_(e,t);for(const i of s)if(r.has(i))return!0;return!1}function v(o){return typeof o=="object"&&o!==null}class N extends f{constructor(t,s={}){super(s);n(this,"_editor",null);n(this,"_lifecyclePromise",null);n(this,"_throttledSave");n(this,"_data");n(this,"_lastDocumentVersion");n(this,"_elementOrData");n(this,"_initUsingData",!0);n(this,"_editables",{});n(this,"_config");n(this,"_excludedProps");this._throttledSave=P(this._save.bind(this),typeof s.saveInterval=="number"?s.saveInterval:5e3),t&&(this._creator=(r,i)=>t.create(r,i)),this._destructor=r=>r.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}_restart(){return Promise.resolve().then(()=>(this.state="initializing",this._fire("stateChange"),this._destroy())).catch(t=>{console.error("An error happened during the editor destroying.",t)}).then(()=>{const t={},s=[],r=this._config.rootsAttributes||{},i={};for(const[c,h]of Object.entries(this._data.roots))h.isLoaded?(t[c]="",i[c]=r[c]||{}):s.push(c);const a={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:s,rootsAttributes:i,_watchdogInitialData:this._data};return delete a.initialData,a.extraPlugins.push(S),this._initUsingData?this.create(t,a,a.context):g(this._elementOrData)?this.create(this._elementOrData,a,a.context):this.create(this._editables,a,a.context)}).then(()=>{this._fire("restart")})}create(t=this._elementOrData,s=this._config,r){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(super._startErrorHandling(),this._elementOrData=t,this._initUsingData=typeof t=="string"||Object.keys(t).length>0&&typeof Object.values(t)[0]=="string",this._config=this._cloneEditorConfiguration(s)||{},this._config.context=r,this._creator(t,this._config))).then(i=>{this._editor=i,i.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=i.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 t=this._editor;return this._editor=null,t.model.document.off("change:data",this._throttledSave),this._destructor(t)})}_save(){const t=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=t}catch(s){console.error(s,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(t){this._excludedProps=t}_getData(){const t=this._editor,s=t.model.document.roots.filter(h=>h.isAttached()&&h.rootName!="$graveyard"),{plugins:r}=t,i=r.has("CommentsRepository")&&r.get("CommentsRepository"),a=r.has("TrackChanges")&&r.get("TrackChanges"),c={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};s.forEach(h=>{c.roots[h.rootName]={content:JSON.stringify(Array.from(h.getChildren())),attributes:JSON.stringify(Array.from(h.getAttributes())),isLoaded:h._isLoaded}});for(const h of t.model.markers)h._affectsData&&(c.markers[h.name]={rangeJSON:h.getRange().toJSON(),usingOperation:h._managedUsingOperations,affectsData:h._affectsData});return i&&(c.commentThreads=JSON.stringify(i.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),a&&(c.suggestions=JSON.stringify(a.getSuggestions({toJSON:!0,skipNotAttached:!0}))),c}_getEditables(){const t={};for(const s of this.editor.model.document.getRootNames()){const r=this.editor.ui.getEditableElement(s);r&&(t[s]=r)}return t}_isErrorComingFromThisItem(t){return p(this._editor,t.context,this._excludedProps)}_cloneEditorConfiguration(t){return x(t,(s,r)=>{if(g(s)||r==="context")return s})}}class S{constructor(e){n(this,"editor");n(this,"_data");this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},t=>{this._restoreCollaborationData(),this._restoreEditorData(t)}),this.editor.data.fire("ready")},{priority:999})}_createNode(e,t){if("name"in t){const s=e.createElement(t.name,t.attributes);if(t.children)for(const r of t.children)s._appendChild(this._createNode(e,r));return s}else return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach(([s,{content:r,attributes:i}])=>{const a=JSON.parse(r),c=JSON.parse(i),h=t.model.document.getRoot(s);for(const[d,u]of c)e.setAttribute(d,u,h);for(const d of a){const u=this._createNode(e,d);e.insert(u,h,"end")}}),Object.entries(this._data.markers).forEach(([s,r])=>{const{document:i}=t.model,{rangeJSON:{start:a,end:c},...h}=r,d=i.getRoot(a.root),u=e.createPositionFromPath(d,a.path,a.stickiness),y=e.createPositionFromPath(d,c.path,c.stickiness),E=e.createRange(u,y);e.addMarker(s,{range:E,...h})})}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach(s=>{const r=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");i.hasCommentThread(s.threadId)&&i.getCommentThread(s.threadId).remove(),i.addCommentThread({channelId:r,...s})}),t.forEach(s=>{const r=this.editor.plugins.get("TrackChangesEditing");if(r.hasSuggestion(s.id)){const i=r.getSuggestion(s.id);i.attributes=s.attributes}else r.addSuggestionData(s)})}}const l=Symbol("MainQueueId");class R extends f{constructor(t,s={}){super(s);n(this,"_watchdogs",new Map);n(this,"_watchdogConfig");n(this,"_context",null);n(this,"_contextProps",new Set);n(this,"_actionQueues",new T);n(this,"_contextConfig");n(this,"_item");this._watchdogConfig=s,this._creator=r=>t.create(r),this._destructor=r=>r.destroy(),this._actionQueues.onEmpty(()=>{this.state==="initializing"&&(this.state="ready",this._fire("stateChange"))})}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}get context(){return this._context}create(t={}){return this._actionQueues.enqueue(l,()=>(this._contextConfig=t,this._create()))}getItem(t){return this._getWatchdog(t)._item}getItemState(t){return this._getWatchdog(t).state}add(t){const s=m(t);return Promise.all(s.map(r=>this._actionQueues.enqueue(r.id,()=>{if(this.state==="destroyed")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 i;if(this._watchdogs.has(r.id))throw new Error(`Item with the given id is already added: '${r.id}'.`);if(r.type==="editor")return i=new N(null,this._watchdogConfig),i.setCreator(r.creator),i._setExcludedProperties(this._contextProps),r.destructor&&i.setDestructor(r.destructor),this._watchdogs.set(r.id,i),i.on("error",(a,{error:c,causesRestart:h})=>{this._fire("itemError",{itemId:r.id,error:c}),h&&this._actionQueues.enqueue(r.id,()=>new Promise(d=>{const u=()=>{i.off("restart",u),this._fire("itemRestart",{itemId:r.id}),d()};i.on("restart",u)}))}),i.create(r.sourceElementOrData,r.config,this._context);throw new Error(`Not supported item type: '${r.type}'.`)})))}remove(t){const s=m(t);return Promise.all(s.map(r=>this._actionQueues.enqueue(r,()=>{const i=this._getWatchdog(r);return this._watchdogs.delete(r),i.destroy()})))}destroy(){return this._actionQueues.enqueue(l,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(l,()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch(t=>{console.error("An error happened during destroying the context or items.",t)}).then(()=>this._create()).then(()=>this._fire("restart"))))}_create(){return Promise.resolve().then(()=>(this._startErrorHandling(),this._creator(this._contextConfig))).then(t=>(this._context=t,this._contextProps=_(this._context),Promise.all(Array.from(this._watchdogs.values()).map(s=>(s._setExcludedProperties(this._contextProps),s.create(void 0,void 0,this._context))))))}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling();const t=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map(s=>s.destroy())).then(()=>this._destructor(t))})}_getWatchdog(t){const s=this._watchdogs.get(t);if(!s)throw new Error(`Item with the given id was not registered: ${t}.`);return s}_isErrorComingFromThisItem(t){for(const s of this._watchdogs.values())if(s._isErrorComingFromThisItem(t))return!1;return p(this._context,t.context)}}class T{constructor(){n(this,"_onEmptyCallbacks",[]);n(this,"_queues",new Map);n(this,"_activeActions",0)}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const s=e===l;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const i=(s?Promise.all(this._queues.values()):Promise.all([this._queues.get(l),this._queues.get(e)])).then(t),a=i.catch(()=>{});return this._queues.set(e,a),i.finally(()=>{this._activeActions--,this._queues.get(e)===a&&this._activeActions===0&&this._onEmptyCallbacks.forEach(c=>c())})}}function m(o){return Array.isArray(o)?o:[o]}export{R as ContextWatchdog,N as EditorWatchdog,f as Watchdog};
|
|
10
|
+
*/function l(n,t=new Set){const e=[n],s=new Set;let r=0;for(;e.length>r;){const i=e[r++];if(!(s.has(i)||!w(i)||t.has(i)))if(s.add(i),Symbol.iterator in i)try{for(const o of i)e.push(o)}catch{}else for(const o in i)o!=="defaultValue"&&e.push(i[o])}return s}function w(n){const t=Object.prototype.toString.call(n),e=typeof n;return!(e==="number"||e==="boolean"||e==="string"||e==="symbol"||e==="function"||t==="[object Date]"||t==="[object RegExp]"||t==="[object Module]"||n===void 0||n===null||n._watchdogExcluded||n instanceof EventTarget||n instanceof Event)}function f(n,t,e=new Set){if(n===t&&P(n))return!0;const s=l(n,e),r=l(t,e);for(const i of s)if(r.has(i))return!0;return!1}function P(n){return typeof n=="object"&&n!==null}class x extends m{_editor=null;_lifecyclePromise=null;_throttledSave;_data;_lastDocumentVersion;_elementOrData;_initUsingData=!0;_editables={};_config;_excludedProps;constructor(t,e={}){super(e),this._throttledSave=E(this._save.bind(this),typeof e.saveInterval=="number"?e.saveInterval:5e3),t&&(this._creator=(s,r)=>t.create(s,r)),this._destructor=s=>s.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}_restart(){return Promise.resolve().then(()=>(this.state="initializing",this._fire("stateChange"),this._destroy())).catch(t=>{console.error("An error happened during the editor destroying.",t)}).then(()=>{const t={},e=[],s=this._config.rootsAttributes||{},r={};for(const[o,a]of Object.entries(this._data.roots))a.isLoaded?(t[o]="",r[o]=s[o]||{}):e.push(o);const i={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:e,rootsAttributes:r,_watchdogInitialData:this._data};return delete i.initialData,i.extraPlugins.push(C),this._initUsingData?this.create(t,i,i.context):_(this._elementOrData)?this.create(this._elementOrData,i,i.context):this.create(this._editables,i,i.context)}).then(()=>{this._fire("restart")})}create(t=this._elementOrData,e=this._config,s){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(super._startErrorHandling(),this._elementOrData=t,this._initUsingData=typeof t=="string"||Object.keys(t).length>0&&typeof Object.values(t)[0]=="string",this._config=this._cloneEditorConfiguration(e)||{},this._config.context=s,this._creator(t,this._config))).then(r=>{this._editor=r,r.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=r.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 t=this._editor;return this._editor=null,t.model.document.off("change:data",this._throttledSave),this._destructor(t)})}_save(){const t=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=t}catch(e){console.error(e,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(t){this._excludedProps=t}_getData(){const t=this._editor,e=t.model.document.roots.filter(a=>a.isAttached()&&a.rootName!="$graveyard"),{plugins:s}=t,r=s.has("CommentsRepository")&&s.get("CommentsRepository"),i=s.has("TrackChanges")&&s.get("TrackChanges"),o={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};e.forEach(a=>{o.roots[a.rootName]={content:JSON.stringify(Array.from(a.getChildren())),attributes:JSON.stringify(Array.from(a.getAttributes())),isLoaded:a._isLoaded}});for(const a of t.model.markers)a._affectsData&&(o.markers[a.name]={rangeJSON:a.getRange().toJSON(),usingOperation:a._managedUsingOperations,affectsData:a._affectsData});return r&&(o.commentThreads=JSON.stringify(r.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),i&&(o.suggestions=JSON.stringify(i.getSuggestions({toJSON:!0,skipNotAttached:!0}))),o}_getEditables(){const t={};for(const e of this.editor.model.document.getRootNames()){const s=this.editor.ui.getEditableElement(e);s&&(t[e]=s)}return t}_isErrorComingFromThisItem(t){return f(this._editor,t.context,this._excludedProps)}_cloneEditorConfiguration(t){return b(t,(e,s)=>{if(_(e)||s==="context")return e})}}class C{editor;_data;constructor(t){this.editor=t,this._data=t.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",t=>{t.stop(),this.editor.model.enqueueChange({isUndoable:!1},e=>{this._restoreCollaborationData(),this._restoreEditorData(e)}),this.editor.data.fire("ready")},{priority:999})}_createNode(t,e){if("name"in e){const s=t.createElement(e.name,e.attributes);if(e.children)for(const r of e.children)s._appendChild(this._createNode(t,r));return s}else return t.createText(e.data,e.attributes)}_restoreEditorData(t){const e=this.editor;Object.entries(this._data.roots).forEach(([s,{content:r,attributes:i}])=>{const o=JSON.parse(r),a=JSON.parse(i),c=e.model.document.getRoot(s);for(const[h,d]of a)t.setAttribute(h,d,c);for(const h of o){const d=this._createNode(t,h);t.insert(d,c,"end")}}),Object.entries(this._data.markers).forEach(([s,r])=>{const{document:i}=e.model,{rangeJSON:{start:o,end:a},...c}=r,h=i.getRoot(o.root),d=t.createPositionFromPath(h,o.path,o.stickiness),p=t.createPositionFromPath(h,a.path,a.stickiness),y=t.createRange(d,p);t.addMarker(s,{range:y,...c})})}_restoreCollaborationData(){const t=JSON.parse(this._data.commentThreads),e=JSON.parse(this._data.suggestions);t.forEach(s=>{const r=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");i.hasCommentThread(s.threadId)&&i.getCommentThread(s.threadId).remove(),i.addCommentThread({channelId:r,...s})}),e.forEach(s=>{const r=this.editor.plugins.get("TrackChangesEditing");if(r.hasSuggestion(s.id)){const i=r.getSuggestion(s.id);i.attributes=s.attributes}else r.addSuggestionData(s)})}}const u=Symbol("MainQueueId");class A extends m{_watchdogs=new Map;_watchdogConfig;_context=null;_contextProps=new Set;_actionQueues=new v;_contextConfig;_item;constructor(t,e={}){super(e),this._watchdogConfig=e,this._creator=s=>t.create(s),this._destructor=s=>s.destroy(),this._actionQueues.onEmpty(()=>{this.state==="initializing"&&(this.state="ready",this._fire("stateChange"))})}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}get context(){return this._context}create(t={}){return this._actionQueues.enqueue(u,()=>(this._contextConfig=t,this._create()))}getItem(t){return this._getWatchdog(t)._item}getItemState(t){return this._getWatchdog(t).state}add(t){const e=g(t);return Promise.all(e.map(s=>this._actionQueues.enqueue(s.id,()=>{if(this.state==="destroyed")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 r;if(this._watchdogs.has(s.id))throw new Error(`Item with the given id is already added: '${s.id}'.`);if(s.type==="editor")return r=new x(null,this._watchdogConfig),r.setCreator(s.creator),r._setExcludedProperties(this._contextProps),s.destructor&&r.setDestructor(s.destructor),this._watchdogs.set(s.id,r),r.on("error",(i,{error:o,causesRestart:a})=>{this._fire("itemError",{itemId:s.id,error:o}),a&&this._actionQueues.enqueue(s.id,()=>new Promise(c=>{const h=()=>{r.off("restart",h),this._fire("itemRestart",{itemId:s.id}),c()};r.on("restart",h)}))}),r.create(s.sourceElementOrData,s.config,this._context);throw new Error(`Not supported item type: '${s.type}'.`)})))}remove(t){const e=g(t);return Promise.all(e.map(s=>this._actionQueues.enqueue(s,()=>{const r=this._getWatchdog(s);return this._watchdogs.delete(s),r.destroy()})))}destroy(){return this._actionQueues.enqueue(u,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(u,()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch(t=>{console.error("An error happened during destroying the context or items.",t)}).then(()=>this._create()).then(()=>this._fire("restart"))))}_create(){return Promise.resolve().then(()=>(this._startErrorHandling(),this._creator(this._contextConfig))).then(t=>(this._context=t,this._contextProps=l(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 t=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map(e=>e.destroy())).then(()=>this._destructor(t))})}_getWatchdog(t){const e=this._watchdogs.get(t);if(!e)throw new Error(`Item with the given id was not registered: ${t}.`);return e}_isErrorComingFromThisItem(t){for(const e of this._watchdogs.values())if(e._isErrorComingFromThisItem(t))return!1;return f(this._context,t.context)}}class v{_onEmptyCallbacks=[];_queues=new Map;_activeActions=0;onEmpty(t){this._onEmptyCallbacks.push(t)}enqueue(t,e){const s=t===u;this._activeActions++,this._queues.get(t)||this._queues.set(t,Promise.resolve());const i=(s?Promise.all(this._queues.values()):Promise.all([this._queues.get(u),this._queues.get(t)])).then(e),o=i.catch(()=>{});return this._queues.set(t,o),i.finally(()=>{this._activeActions--,this._queues.get(t)===o&&this._activeActions===0&&this._onEmptyCallbacks.forEach(a=>a())})}}function g(n){return Array.isArray(n)?n:[n]}export{A as ContextWatchdog,x as EditorWatchdog,m as Watchdog};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{Plugin as E}from"../../../../../@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{MouseObserver as H,TreeWalker as K}from"../../../../../@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{Delete as V}from"../../../../../@ckeditor_ckeditor5-typing@45.2.1/node_modules/@ckeditor/ckeditor5-typing/dist/index.js";import{keyCodes as P,env as D,getLocalizedArrowKeyCodeDirection as j,logWarning as $,CKEditorError as I,isForwardArrowKeyCode as U,getRangeFromMouseEvent as q,global as T,DomEmitterMixin as G,toArray as O,Rect as b,ObservableMixin as F,compareArrays as Y,EmitterMixin as X}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{IconReturnArrow as J,IconDragHandle as Q}from"../../../../../@ckeditor_ckeditor5-icons@45.2.1/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{ContextualBalloon as Z,ToolbarView as ee,BalloonPanelView as te,IconView as ie,Template as C,View as oe}from"../../../../../@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{Enter as ne}from"../../../../../@ckeditor_ckeditor5-enter@45.2.1/node_modules/@ckeditor/ckeditor5-enter/dist/index.js";import{throttle as se}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/throttle.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/class de extends ee(){constructor(){super(...arguments);p(this,"_stack",[])}add(e,t){const i=this._stack,o=i[0];this._insertDescriptor(e);const r=i[0];o!==r&&!C(o,r)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:r,writer:t})}remove(e,t){const i=this._stack,o=i[0];this._removeDescriptor(e);const r=i[0];o!==r&&!C(o,r)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:r,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex(r=>r.id===e.id);if(C(e,t[i]))return;i>-1&&t.splice(i,1);let o=0;for(;t[o]&&he(t[o],e);)o++;t.splice(o,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex(o=>o.id===e);i>-1&&t.splice(i,1)}}function C(n,s){return n&&s&&n.priority==s.priority&&S(n.classes)==S(s.classes)}function he(n,s){return n.priority>s.priority?!0:n.priority<s.priority?!1:S(n.classes)>S(s.classes)}function S(n){return Array.isArray(n)?n.sort().join(","):n}const ue="ck-widget",R="ck-widget_selected";function m(n){return n.is("element")?!!n.getCustomProperty("widget"):!1}function nt(n,s,e={}){if(!n.is("containerElement"))throw new F("widget-to-widget-wrong-element-type",null,{element:n});return s.setAttribute("contenteditable","false",n),s.addClass(ue,n),s.setCustomProperty("widget",!0,n),n.getFillerOffset=we,s.setCustomProperty("widgetLabel",[],n),e.label&&fe(n,e.label),e.hasSelectionHandle&&_e(n,s),L(n,s),n}function ge(n,s,e){if(s.classes&&e.addClass(N(s.classes),n),s.attributes)for(const t in s.attributes)e.setAttribute(t,s.attributes[t],n)}function pe(n,s,e){if(s.classes&&e.removeClass(N(s.classes),n),s.attributes)for(const t in s.attributes)e.removeAttribute(t,n)}function L(n,s,e=ge,t=pe){const i=new de;i.on("change:top",(l,c)=>{c.oldDescriptor&&t(n,c.oldDescriptor,c.writer),c.newDescriptor&&e(n,c.newDescriptor,c.writer)});const o=(l,c,a)=>i.add(c,a),r=(l,c,a)=>i.remove(c,a);s.setCustomProperty("addHighlight",o,n),s.setCustomProperty("removeHighlight",r,n)}function fe(n,s){n.getCustomProperty("widgetLabel").push(s)}function me(n){return n.getCustomProperty("widgetLabel").reduce((e,t)=>typeof t=="function"?e?e+". "+t():t():e?e+". "+t:t,"")}function st(n,s,e={}){return s.addClass(["ck-editor__editable","ck-editor__nested-editable"],n),e.withAriaRole!==!1&&s.setAttribute("role","textbox",n),s.setAttribute("tabindex","-1",n),e.label&&s.setAttribute("aria-label",e.label,n),s.setAttribute("contenteditable",n.isReadOnly?"false":"true",n),n.on("change:isReadOnly",(t,i,o)=>{s.setAttribute("contenteditable",o?"false":"true",n)}),n.on("change:isFocused",(t,i,o)=>{o?s.addClass("ck-editor__nested-editable_focused",n):s.removeClass("ck-editor__nested-editable_focused",n)}),L(n,s),n}function rt(n,s){const e=n.getSelectedElement();if(e){const t=b(n);if(t)return s.createRange(s.createPositionAt(e,t))}return s.schema.findOptimalInsertionRange(n)}function we(){return null}function _e(n,s){const e=s.createUIElement("div",{class:"ck ck-widget__selection-handle"},function(t){const i=this.toDomElement(t),o=new re;return o.set("content",ie),o.render(),i.appendChild(o.element),i});s.insert(s.createPositionAt(n,0),e),s.addClass(["ck-widget_with-selection-handle"],n)}function be(n){const s=l=>{const{width:c,paddingLeft:a,paddingRight:d}=l.ownerDocument.defaultView.getComputedStyle(l);return parseFloat(c)-(parseFloat(a)||0)-(parseFloat(d)||0)},e=n.parentElement;if(!e)return 0;let t=s(e);const i=5;let o=0,r=e;for(;isNaN(t);){if(r=r.parentElement,++o>i)return 0;t=s(r)}return t}function ye(n,s=new v(n)){const e=be(n);return e?s.width/e*100:0}const _="widget-type-around";function y(n,s,e){return!!n&&m(n)&&!e.isInline(s)}function ve(n){return n.closest(".ck-widget__type-around__button")}function Ee(n){return n.classList.contains("ck-widget__type-around__button_before")?"before":"after"}function Se(n,s){const e=n.closest(".ck-widget");return s.mapDomToView(e)}function b(n){return n.getAttribute(_)}const B=["before","after"],Pe=new DOMParser().parseFromString(te,"image/svg+xml").firstChild,W="ck-widget__type-around_disabled";class Ce extends P{constructor(){super(...arguments);p(this,"_currentFakeCaretModelElement",null)}static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[ce,I]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(i,o,r)=>{t.change(l=>{for(const c of t.document.roots)r?l.removeClass(W,c):l.addClass(W,c)}),r||e.model.change(l=>{l.removeSelectionAttribute(_)})}),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,o=i.editing.view,r=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:r}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(e,t,i,o){this.listenTo(e,t,(...r)=>{this.isEnabled&&i(...r)},o)}_insertParagraphAccordingToFakeCaretPosition(){const i=this.editor.model.document.selection,o=b(i);if(!o)return!1;const r=i.getSelectedElement();return this._insertParagraph(r,o),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,o={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(r,l,c)=>{const a=c.mapper.toViewElement(l.item);a&&y(a,l.item,t)&&(Te(c.writer,o,a),a.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,o=t.schema,r=e.editing.view;this._listenToIfEnabled(r.document,"arrowKey",(c,a)=>{this._handleArrowKeyPress(c,a)},{context:[m,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(c,a)=>{a.directChange&&e.model.change(d=>{d.removeSelectionAttribute(_)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const c=i.getSelectedElement();if(c){const a=e.editing.mapper.toViewElement(c);if(y(a,c,o))return}e.model.change(a=>{a.removeSelectionAttribute(_)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(c,a,d)=>{const u=d.writer;if(this._currentFakeCaretModelElement){const w=d.mapper.toViewElement(this._currentFakeCaretModelElement);w&&(u.removeClass(B.map(l),w),this._currentFakeCaretModelElement=null)}const h=a.selection.getSelectedElement();if(!h)return;const f=d.mapper.toViewElement(h);if(!y(f,h,o))return;const g=b(a.selection);g&&(u.addClass(l(g),f),this._currentFakeCaretModelElement=h)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(c,a,d)=>{d||e.model.change(u=>{u.removeSelectionAttribute(_)})});function l(c){return`ck-widget_type-around_show-fake-caret_${c}`}}_handleArrowKeyPress(e,t){const i=this.editor,o=i.model,r=o.document.selection,l=o.schema,c=i.editing.view,a=t.keyCode,d=X(a,i.locale.contentLanguageDirection),u=c.document.selection.getSelectedElement(),h=i.editing.mapper.toModelElement(u);let f;y(u,h,l)?f=this._handleArrowKeyPressOnSelectedWidget(d):r.isCollapsed?f=this._handleArrowKeyPressWhenSelectionNextToAWidget(d):t.shiftKey||(f=this._handleArrowKeyPressWhenNonCollapsedSelection(d)),f&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const i=this.editor.model,o=i.document.selection,r=b(o);return i.change(l=>{if(r){if(!(r===(e?"after":"before")))return l.removeSelectionAttribute(_),!0}else return l.setSelectionAttribute(_,e?"after":"before"),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,o=i.schema,r=t.plugins.get("Widget"),l=r._getObjectElementNextToSelection(e),c=t.editing.mapper.toViewElement(l);return y(c,l,o)?(i.change(a=>{r._setSelectionOverElement(l),a.setSelectionAttribute(_,e?"before":"after")}),!0):!1}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,o=i.schema,r=t.editing.mapper,l=i.document.selection,c=e?l.getLastPosition().nodeBefore:l.getFirstPosition().nodeAfter,a=r.toViewElement(c);return y(a,c,o)?(i.change(d=>{d.setSelection(c,"on"),d.setSelectionAttribute(_,e?"after":"before")}),!0):!1}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(i,o)=>{const r=ve(o.domTarget);if(!r)return;const l=Ee(r),c=Se(r,t.domConverter),a=e.editing.mapper.toModelElement(c);this._insertParagraph(a,l),o.preventDefault(),i.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",(o,r)=>{if(o.eventPhase!="atTarget")return;const l=t.getSelectedElement(),c=e.editing.mapper.toViewElement(l),a=e.model.schema;let d;this._insertParagraphAccordingToFakeCaretPosition()?d=!0:y(c,l,a)&&(this._insertParagraph(l,r.isSoft?"before":"after"),d=!0),d&&(r.preventDefault(),o.stop())},{context:m})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view.document;this._listenToIfEnabled(t,"insertText",(i,o)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(o.selection=t.selection)},{priority:"high"}),O.isAndroid?this._listenToIfEnabled(t,"keydown",(i,o)=>{o.keyCode==229&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(t,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"highest"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,o=i.schema;this._listenToIfEnabled(t.document,"delete",(r,l)=>{if(r.eventPhase!="atTarget")return;const c=b(i.document.selection);if(!c)return;const a=l.direction,d=i.document.selection.getSelectedElement(),u=c==="before",h=a=="forward";if(u===h)e.execute("delete",{selection:i.createSelection(d,"on")});else{const g=o.getNearestSelectionRange(i.createPositionAt(d,c),a);if(g)if(!g.isCollapsed)i.change(w=>{w.setSelection(g),e.execute(h?"deleteForward":"delete")});else{const w=i.createSelection(g.start);if(i.modifySelection(w,{direction:a}),!w.focus.isEqual(g.start))i.change(E=>{E.setSelection(g),e.execute(h?"deleteForward":"delete")});else{const E=Re(o,g.start.parent);i.deleteContent(i.createSelection(E,"on"),{doNotAutoparagraph:!0})}}}l.preventDefault(),r.stop()},{context:m})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(o,[r,l])=>{if(l&&!l.is("documentSelection"))return;const c=b(i);if(c)return o.stop(),t.change(a=>{const d=i.getSelectedElement(),u=t.createPositionAt(d,c),h=a.createSelection(u),f=t.insertContent(r,h);return a.setSelection(h),f})},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,i=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(o,r)=>{const[,l,c={}]=r;if(l&&!l.is("documentSelection"))return;const a=b(i);a&&(c.findOptimalPosition=a,r[3]=c)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,i=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(o,[r])=>{if(r&&!r.is("documentSelection"))return;b(i)&&o.stop()},{priority:"high"})}}function Te(n,s,e){const t=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},function(i){const o=this.toDomElement(i);return ke(o,s),Ae(o),o});n.insert(n.createPositionAt(e,"end"),t)}function ke(n,s){for(const e of B){const t=new k({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${e}`],title:s[e],"aria-hidden":"true"},children:[n.ownerDocument.importNode(Pe,!0)]});n.appendChild(t.render())}}function Ae(n){const s=new k({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});n.appendChild(s.render())}function Re(n,s){let e=s;for(const t of s.getAncestors({parentFirst:!0})){if(t.childCount>1||n.isLimit(t))break;e=t}return e}function We(n){const s=n.model;return(e,t)=>{const i=t.keyCode==T.arrowup,o=t.keyCode==T.arrowdown,r=t.shiftKey,l=s.document.selection;if(!i&&!o)return;const c=o;if(r&&He(l,c))return;const a=ze(n,l,c);if(a){if(a.isCollapsed){if(l.isCollapsed)return;if(r)return}(a.isCollapsed||xe(n,a,c))&&(s.change(d=>{const u=c?a.end:a.start;if(r){const h=s.createSelection(l.anchor);h.setFocus(u),d.setSelection(h)}else d.setSelection(u)}),e.stop(),t.preventDefault(),t.stopPropagation())}}}function ze(n,s,e){const t=n.model;if(e){const i=s.isCollapsed?s.focus:s.getLastPosition(),o=z(t,i,"forward");if(!o)return null;const r=t.createRange(i,o),l=x(t.schema,r,"backward");return l?t.createRange(i,l):null}else{const i=s.isCollapsed?s.focus:s.getFirstPosition(),o=z(t,i,"backward");if(!o)return null;const r=t.createRange(o,i),l=x(t.schema,r,"forward");return l?t.createRange(l,i):null}}function z(n,s,e){const t=n.schema,i=n.createRangeIn(s.root),o=e=="forward"?"elementStart":"elementEnd";for(const{previousPosition:r,item:l,type:c}of i.getWalker({startPosition:s,direction:e})){if(t.isLimit(l)&&!t.isInline(l))return r;if(c==o&&t.isBlock(l))return null}return null}function x(n,s,e){const t=e=="backward"?s.end:s.start;if(n.checkChild(t,"$text"))return t;for(const{nextPosition:i}of s.getWalker({direction:e}))if(n.checkChild(i,"$text"))return i;return null}function xe(n,s,e){const t=n.model,i=n.view.domConverter;if(e){const a=t.createSelection(s.start);t.modifySelection(a),!a.focus.isAtEnd&&!s.start.isEqual(a.focus)&&(s=t.createRange(a.focus,s.end))}const o=n.mapper.toViewRange(s),r=i.viewRangeToDom(o),l=v.getDomRangeRects(r);let c;for(const a of l){if(c===void 0){c=Math.round(a.bottom);continue}if(Math.round(a.top)>=c)return!1;c=Math.max(c,Math.round(a.bottom))}return!0}function He(n,s){return!n.isCollapsed&&n.isBackward==s}class lt extends P{constructor(){super(...arguments);p(this,"_previouslySelected",new Set)}static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[Ce,I]}init(){const e=this.editor,t=e.editing.view,i=t.document,o=e.t;this.editor.editing.downcastDispatcher.on("selection",(r,l,c)=>{const a=c.writer,d=l.selection;if(d.isCollapsed)return;const u=d.getSelectedElement();if(!u)return;const h=e.editing.mapper.toViewElement(u);m(h)&&c.consumable.consume(d,"selection")&&a.setSelection(a.createRangeOn(h),{fake:!0,label:me(h)})}),this.editor.editing.downcastDispatcher.on("selection",(r,l,c)=>{this._clearPreviouslySelectedWidgets(c.writer);const a=c.writer,d=a.document.selection;let u=null;for(const h of d.getRanges())for(const f of h){const g=f.item;m(g)&&!Ie(g,u)&&(a.addClass(R,g),this._previouslySelected.add(g),u=g)}},{priority:"low"}),t.addObserver(D),this.listenTo(i,"mousedown",(...r)=>this._onMousedown(...r)),this.listenTo(i,"arrowKey",(...r)=>{this._handleSelectionChangeOnArrowKeyPress(...r)},{context:[m,"$text"]}),this.listenTo(i,"arrowKey",(...r)=>{this._preventDefaultOnArrowKeyPress(...r)},{context:"$root"}),this.listenTo(i,"arrowKey",We(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",(r,l)=>{this._handleDelete(l.direction=="forward")&&(l.preventDefault(),r.stop())},{context:"$root"}),this.listenTo(i,"tab",(r,l)=>{r.eventPhase=="atTarget"&&(l.shiftKey||this._selectFirstNestedEditable()&&(l.preventDefault(),r.stop()))},{context:m,priority:"low"}),this.listenTo(i,"tab",(r,l)=>{l.shiftKey&&this._selectAncestorWidget()&&(l.preventDefault(),r.stop())},{priority:"low"}),this.listenTo(i,"keydown",(r,l)=>{l.keystroke==T.esc&&this._selectAncestorWidget()&&(l.preventDefault(),r.stop())},{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:o("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:o("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:o("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:o("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:o("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:o("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,o=i.editing.view,r=o.document;let l=t.target;if(!l)return;if(t.domEvent.detail>=3){this._selectBlockContent(l)&&t.preventDefault();return}if(!m(l)){const a=Ve(l);if(!a)return;if(m(a))l=a;else{const d=De(o,t);if(d&&m(d))l=d;else return}}O.isAndroid&&t.preventDefault(),r.isFocused||o.focus();const c=i.editing.mapper.toModelElement(l);this._setSelectionOverElement(c)}_selectBlockContent(e){const t=this.editor,i=t.model,o=t.editing.mapper,r=i.schema,l=o.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),c=Oe(o.toModelElement(l),i.schema);return c?(i.change(a=>{const d=r.isLimit(c)?null:Fe(a.createPositionAfter(c),r),u=a.createPositionAt(c,0),h=d?a.createPositionAt(d,0):a.createPositionAt(c,"end");a.setSelection(a.createRange(u,h))}),!0):!1}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,o=this.editor.model,r=o.schema,l=o.document.selection,c=l.getSelectedElement(),a=G(i,this.editor.locale.contentLanguageDirection),d=a=="down"||a=="right",u=a=="up"||a=="down";if(c&&r.isObject(c)){const f=d?l.getLastPosition():l.getFirstPosition(),g=r.getNearestSelectionRange(f,d?"forward":"backward");g&&(o.change(w=>{w.setSelection(g)}),t.preventDefault(),e.stop());return}if(!l.isCollapsed&&!t.shiftKey){const f=l.getFirstPosition(),g=l.getLastPosition(),w=f.nodeAfter,E=g.nodeBefore;(w&&r.isObject(w)||E&&r.isObject(E))&&(o.change(j=>{j.setSelection(d?g:f)}),t.preventDefault(),e.stop());return}if(!l.isCollapsed)return;const h=this._getObjectElementNextToSelection(d);if(h&&r.isObject(h)){if(r.isInline(h)&&u)return;this._setSelectionOverElement(h),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,o=i.schema,r=i.document.selection.getSelectedElement();r&&o.isObject(r)&&(t.preventDefault(),e.stop())}_handleDelete(e){const i=this.editor.model.document.selection;if(!this.editor.model.canEditAt(i)||!i.isCollapsed)return;const o=this._getObjectElementNextToSelection(e);if(o)return this.editor.model.change(r=>{let l=i.anchor.parent;for(;l.isEmpty;){const c=l;l=c.parent,r.remove(c)}this._setSelectionOverElement(o)}),!0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,o=t.document.selection,r=t.createSelection(o);if(t.modifySelection(r,{direction:e?"forward":"backward"}),r.isEqual(o))return null;const l=e?r.focus.nodeBefore:r.focus.nodeAfter;return l&&i.isObject(l)?l:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(R,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,i=this.editor.editing.view.document;for(const o of i.selection.getFirstRange().getItems())if(o.is("editableElement")){const r=e.editing.mapper.toModelElement(o);/* istanbul ignore next -- @preserve */if(!r)continue;const l=e.model.createPositionAt(r,0),c=e.model.schema.getNearestSelectionRange(l,"forward");return e.model.change(a=>{a.setSelection(c)}),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,o=e.editing.view.document.selection.getFirstPosition().parent,l=(o.is("$text")?o.parent:o).findAncestor(m);if(!l)return!1;const c=t.toModelElement(l);/* istanbul ignore next -- @preserve */return c?(e.model.change(a=>{a.setSelection(c,"on")}),!0):!1}}function Ve(n){let s=n;for(;s;){if(s.is("editableElement")||m(s))return s;s=s.parent}return null}function De(n,s){const e=J(s.domEvent);let t=null;if(e?t=n.domConverter.domRangeToView(e):t=n.createRange(n.createPositionAt(s.target,0)),!t)return null;const i=t.start;if(!i.parent)return null;let o=i.parent;return i.parent.is("editableElement")&&(i.isAtEnd&&i.nodeBefore?o=i.nodeBefore:i.isAtStart&&i.nodeAfter&&(o=i.nodeAfter)),o.is("$text")?o.parent:o}function Ie(n,s){return s?Array.from(n.getAncestors()).includes(s):!1}function Oe(n,s){for(const e of n.getAncestors({includeSelf:!0,parentFirst:!0})){if(s.checkChild(e,"$text"))return e;if(s.isLimit(e)&&!s.isObject(e))break}return null}function Fe(n,s){const e=new q({startPosition:n});for(const{item:t}of e){if(s.isLimit(t)||!t.is("element"))return null;if(s.checkChild(t,"$text"))return t}return null}class ct extends P{constructor(){super(...arguments);p(this,"_toolbarDefinitions",new Map);p(this,"_balloon")}static get requires(){return[oe]}static get pluginName(){return"WidgetToolbarRepository"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",i=>{Ne(e.editing.view.document.selection)&&i.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:o,balloonClassName:r="ck-toolbar-container",positions:l}){if(!i.length){Y("widget-toolbar-no-items",{toolbarId:e});return}const c=this.editor,a=c.t,d=new ne(c.locale);if(d.ariaLabel=t||a("Widget toolbar"),this._toolbarDefinitions.has(e))throw new F("widget-toolbar-duplicated",this,{toolbarId:e});const u={view:d,getRelatedElement:o,balloonClassName:r,itemsConfig:i,positions:l,initialized:!1};c.ui.addToolbar(d,{isContextual:!0,beforeFocus:()=>{const h=o(c.editing.view.document.selection);h&&this._showToolbar(u,h)},afterBlur:()=>{this._hideToolbar(u)}}),this._toolbarDefinitions.set(e,u)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const o of this._toolbarDefinitions.values()){const r=o.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!r)this._isToolbarInBalloon(o)&&this._hideToolbar(o);else if(!this.editor.ui.focusTracker.isFocused)this._isToolbarVisible(o)&&this._hideToolbar(o);else{const l=r.getAncestors().length;l>e&&(e=l,t=r,i=o)}}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?H(this.editor,t,e.positions):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:K(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const i of this._toolbarDefinitions.values())if(this._isToolbarVisible(i)){const o=i.getRelatedElement(this.editor.editing.view.document.selection);H(this.editor,o,e.positions)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function H(n,s,e){const t=n.plugins.get("ContextualBalloon"),i=K(n,s,e);t.updatePosition(i)}function K(n,s,e){const t=n.editing.view,i=se.defaultPositions;return{target:t.domConverter.mapViewToDom(s),positions:e||[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}function Ne(n){const s=n.getSelectedElement();return!!(s&&m(s))}class Me extends M(){constructor(e){super();p(this,"_referenceCoordinates");p(this,"_options");p(this,"_originalWidth");p(this,"_originalHeight");p(this,"_originalWidthPercents");p(this,"_aspectRatio");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 o=new v(t);this.activeHandlePosition=Ke(e),this._referenceCoordinates=Le(t,je(this.activeHandlePosition)),this._originalWidth=o.width,this._originalHeight=o.height,this._aspectRatio=o.width/o.height;const r=i.style.width;r&&r.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(r):this._originalWidthPercents=ye(i,o)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function Le(n,s){const e=new v(n),t=s.split("-"),i={x:t[1]=="right"?e.right:e.left,y:t[0]=="bottom"?e.bottom:e.top};return i.x+=n.ownerDocument.defaultView.scrollX,i.y+=n.ownerDocument.defaultView.scrollY,i}function Be(n){return`ck-widget__resizer__handle-${n}`}function Ke(n){const s=["top-left","top-right","bottom-right","bottom-left"];for(const e of s)if(n.classList.contains(Be(e)))return e}function je(n){const s=n.split("-"),e={top:"bottom",bottom:"top",left:"right",right:"left"};return`${e[s[0]]}-${e[s[1]]}`}class $e extends le{constructor(){super();const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",s.to("_viewPosition",e=>e?`ck-orientation-${e}`:"")],style:{display:s.if("_isVisible","none",e=>!e)}},children:[{text:s.to("_label")}]})}_bindToState(s,e){this.bind("_isVisible").to(e,"proposedWidth",e,"proposedHeight",(t,i)=>t!==null&&i!==null),this.bind("_label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",(t,i,o)=>s.unit==="px"?`${t}×${i}`:`${o}%`),this.bind("_viewPosition").to(e,"activeHandlePosition",e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",(t,i,o)=>i<50||o<50?"above-center":t)}_dismiss(){this.unbind(),this._isVisible=!1}}class V extends M(){constructor(e){super();p(this,"_state");p(this,"_sizeView");p(this,"_options");p(this,"_viewResizerWrapper",null);p(this,"_initialViewWidth");this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",(t,i)=>t&&i),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",t=>{!this.state.proposedWidth&&!this.state.proposedWidthPercents&&(this._cleanup(),t.stop())},{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change(t=>{t.removeClass("ck-hidden",this._viewResizerWrapper)})}hide(){this._options.editor.editing.view.change(t=>{t.addClass("ck-hidden",this._viewResizerWrapper)})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(o=>{const r=o.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},function(l){const c=this.toDomElement(l);return e._appendHandles(c),e._appendSizeUI(c),c});o.insert(o.createPositionAt(t,"end"),r),o.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=r,this.isVisible||this.hide()}),this.on("change:isVisible",()=>{this.isVisible?(this.show(),this.redraw()):this.hide()})}begin(e){this._state=new Me(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(d=>{const u=this._options.unit||"%",h=(u==="%"?t.widthPercents:t.width)+u;d.setStyle("width",h,this._options.viewElement)});const o=this._getHandleHost(),r=new v(o),l=Math.round(r.width),c=Math.round(r.height),a=new v(o);t.width=Math.round(a.width),t.height=Math.round(a.height),this.redraw(r),this.state.update({...t,handleHostWidth:l,handleHostHeight:c})}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(!Ge(t))return;const i=t.parentElement,o=this._getHandleHost(),r=this._viewResizerWrapper,l=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let c;if(i.isSameNode(o)){const a=e||new v(o);c=[a.width+"px",a.height+"px",void 0,void 0]}else c=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];Z(l,c)!=="same"&&this._options.editor.editing.view.change(a=>{a.setStyle({width:c[0],height:c[1],left:c[2],top:c[3]},r)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss(),this._options.editor.editing.view.change(t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,i=qe(e),o=this._options.isCentered?this._options.isCentered(this):!0,r={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(r.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(r.x*=2);let l=Math.abs(t.originalWidth+r.x),c=Math.abs(t.originalHeight+r.y);return(l/t.aspectRatio>c?"width":"height")=="width"?c=l/t.aspectRatio:l=c*t.aspectRatio,{width:Math.round(l),height:Math.round(c),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*l*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 i of t)e.appendChild(new k({tag:"div",attributes:{class:`ck-widget__resizer__handle ${Ue(i)}`}}).render())}_appendSizeUI(e){this._sizeView=new $e,this._sizeView.render(),e.appendChild(this._sizeView.element)}}function Ue(n){return`ck-widget__resizer__handle-${n}`}function qe(n){return{x:n.pageX,y:n.pageY}}function Ge(n){return n&&n.ownerDocument&&n.ownerDocument.contains(n)}class at extends P{constructor(){super(...arguments);p(this,"_resizers",new Map);p(this,"_observer");p(this,"_redrawSelectedResizerThrottled")}static get pluginName(){return"WidgetResize"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.editing,t=A.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(D),this._observer=new(Q()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=ae(()=>this.redrawSelectedResizer(),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",()=>{for(const[o,r]of this._resizers)o.isAttached()||(this._resizers.delete(o),r.destroy())},{priority:"lowest"}),this._observer.listenTo(A.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",()=>{const o=i.getSelectedElement(),r=this.getResizerByViewElement(o)||null;r?this.select(r):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 V(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const l=i.get("WidgetToolbarRepository");t.on("begin",()=>{l.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{l.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{l.clearForceDisabled("resize")},{priority:"highest"})}this._resizers.set(e.viewElement,t);const r=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(r)==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;V.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)}}export{ue as WIDGET_CLASS_NAME,R as WIDGET_SELECTED_CLASS_NAME,lt as Widget,at as WidgetResize,ct as WidgetToolbarRepository,Ce as WidgetTypeAround,be as calculateResizeHostAncestorWidth,ye as calculateResizeHostPercentageWidth,rt as findOptimalInsertionRange,me as getLabel,m as isWidget,L as setHighlightHandling,fe as setLabel,nt as toWidget,st as toWidgetEditable};
|
|
4
|
+
*/class re extends X(){_stack=[];add(e,t){const i=this._stack,o=i[0];this._insertDescriptor(e);const n=i[0];o!==n&&!S(o,n)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:n,writer:t})}remove(e,t){const i=this._stack,o=i[0];this._removeDescriptor(e);const n=i[0];o!==n&&!S(o,n)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:n,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex(n=>n.id===e.id);if(S(e,t[i]))return;i>-1&&t.splice(i,1);let o=0;for(;t[o]&&le(t[o],e);)o++;t.splice(o,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex(o=>o.id===e);i>-1&&t.splice(i,1)}}function S(s,e){return s&&e&&s.priority==e.priority&&v(s.classes)==v(e.classes)}function le(s,e){return s.priority>e.priority?!0:s.priority<e.priority?!1:v(s.classes)>v(e.classes)}function v(s){return Array.isArray(s)?s.sort().join(","):s}const ce="ck-widget",k="ck-widget_selected";function p(s){return s.is("element")?!!s.getCustomProperty("widget"):!1}function Ze(s,e,t={}){if(!s.is("containerElement"))throw new I("widget-to-widget-wrong-element-type",null,{element:s});return e.setAttribute("contenteditable","false",s),e.addClass(ce,s),e.setCustomProperty("widget",!0,s),s.getFillerOffset=ge,e.setCustomProperty("widgetLabel",[],s),t.label&&he(s,t.label),t.hasSelectionHandle&&pe(s,e),N(s,e),s}function ae(s,e,t){if(e.classes&&t.addClass(O(e.classes),s),e.attributes)for(const i in e.attributes)t.setAttribute(i,e.attributes[i],s)}function de(s,e,t){if(e.classes&&t.removeClass(O(e.classes),s),e.attributes)for(const i in e.attributes)t.removeAttribute(i,s)}function N(s,e,t=ae,i=de){const o=new re;o.on("change:top",(l,c)=>{c.oldDescriptor&&i(s,c.oldDescriptor,c.writer),c.newDescriptor&&t(s,c.newDescriptor,c.writer)});const n=(l,c,a)=>o.add(c,a),r=(l,c,a)=>o.remove(c,a);e.setCustomProperty("addHighlight",n,s),e.setCustomProperty("removeHighlight",r,s)}function he(s,e){s.getCustomProperty("widgetLabel").push(e)}function ue(s){return s.getCustomProperty("widgetLabel").reduce((t,i)=>typeof i=="function"?t?t+". "+i():i():t?t+". "+i:i,"")}function et(s,e,t={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],s),t.withAriaRole!==!1&&e.setAttribute("role","textbox",s),e.setAttribute("tabindex","-1",s),t.label&&e.setAttribute("aria-label",t.label,s),e.setAttribute("contenteditable",s.isReadOnly?"false":"true",s),s.on("change:isReadOnly",(i,o,n)=>{e.setAttribute("contenteditable",n?"false":"true",s)}),s.on("change:isFocused",(i,o,n)=>{n?e.addClass("ck-editor__nested-editable_focused",s):e.removeClass("ck-editor__nested-editable_focused",s)}),N(s,e),s}function tt(s,e){const t=s.getSelectedElement();if(t){const i=w(s);if(i)return e.createRange(e.createPositionAt(t,i))}return e.schema.findOptimalInsertionRange(s)}function ge(){return null}function pe(s,e){const t=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},function(i){const o=this.toDomElement(i),n=new ie;return n.set("content",Q),n.render(),o.appendChild(n.element),o});e.insert(e.createPositionAt(s,0),t),e.addClass(["ck-widget_with-selection-handle"],s)}function fe(s){const e=l=>{const{width:c,paddingLeft:a,paddingRight:h}=l.ownerDocument.defaultView.getComputedStyle(l);return parseFloat(c)-(parseFloat(a)||0)-(parseFloat(h)||0)},t=s.parentElement;if(!t)return 0;let i=e(t);const o=5;let n=0,r=t;for(;isNaN(i);){if(r=r.parentElement,++n>o)return 0;i=e(r)}return i}function me(s,e=new b(s)){const t=fe(s);return t?e.width/t*100:0}const m="widget-type-around";function _(s,e,t){return!!s&&p(s)&&!t.isInline(e)}function we(s){return s.closest(".ck-widget__type-around__button")}function _e(s){return s.classList.contains("ck-widget__type-around__button_before")?"before":"after"}function be(s,e){const t=s.closest(".ck-widget");return e.mapDomToView(t)}function w(s){return s.getAttribute(m)}const M=["before","after"],ye=new DOMParser().parseFromString(J,"image/svg+xml").firstChild,A="ck-widget__type-around_disabled";class ve extends E{_currentFakeCaretModelElement=null;static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[ne,V]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(i,o,n)=>{t.change(r=>{for(const l of t.document.roots)n?r.removeClass(A,l):r.addClass(A,l)}),n||e.model.change(r=>{r.removeSelectionAttribute(m)})}),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,o=i.editing.view,n=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:n}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(e,t,i,o){this.listenTo(e,t,(...n)=>{this.isEnabled&&i(...n)},o)}_insertParagraphAccordingToFakeCaretPosition(){const i=this.editor.model.document.selection,o=w(i);if(!o)return!1;const n=i.getSelectedElement();return this._insertParagraph(n,o),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,o={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(n,r,l)=>{const c=l.mapper.toViewElement(r.item);c&&_(c,r.item,t)&&(Ee(l.writer,o,c),c.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,o=t.schema,n=e.editing.view;this._listenToIfEnabled(n.document,"arrowKey",(l,c)=>{this._handleArrowKeyPress(l,c)},{context:[p,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(l,c)=>{c.directChange&&e.model.change(a=>{a.removeSelectionAttribute(m)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const l=i.getSelectedElement();if(l){const c=e.editing.mapper.toViewElement(l);if(_(c,l,o))return}e.model.change(c=>{c.removeSelectionAttribute(m)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(l,c,a)=>{const h=a.writer;if(this._currentFakeCaretModelElement){const f=a.mapper.toViewElement(this._currentFakeCaretModelElement);f&&(h.removeClass(M.map(r),f),this._currentFakeCaretModelElement=null)}const d=c.selection.getSelectedElement();if(!d)return;const g=a.mapper.toViewElement(d);if(!_(g,d,o))return;const u=w(c.selection);u&&(h.addClass(r(u),g),this._currentFakeCaretModelElement=d)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(l,c,a)=>{a||e.model.change(h=>{h.removeSelectionAttribute(m)})});function r(l){return`ck-widget_type-around_show-fake-caret_${l}`}}_handleArrowKeyPress(e,t){const i=this.editor,o=i.model,n=o.document.selection,r=o.schema,l=i.editing.view,c=t.keyCode,a=U(c,i.locale.contentLanguageDirection),h=l.document.selection.getSelectedElement(),d=i.editing.mapper.toModelElement(h);let g;_(h,d,r)?g=this._handleArrowKeyPressOnSelectedWidget(a):n.isCollapsed?g=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(g=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),g&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const i=this.editor.model,o=i.document.selection,n=w(o);return i.change(r=>{if(n){if(!(n===(e?"after":"before")))return r.removeSelectionAttribute(m),!0}else return r.setSelectionAttribute(m,e?"after":"before"),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,o=i.schema,n=t.plugins.get("Widget"),r=n._getObjectElementNextToSelection(e),l=t.editing.mapper.toViewElement(r);return _(l,r,o)?(i.change(c=>{n._setSelectionOverElement(r),c.setSelectionAttribute(m,e?"before":"after")}),!0):!1}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,o=i.schema,n=t.editing.mapper,r=i.document.selection,l=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter,c=n.toViewElement(l);return _(c,l,o)?(i.change(a=>{a.setSelection(l,"on"),a.setSelectionAttribute(m,e?"after":"before")}),!0):!1}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(i,o)=>{const n=we(o.domTarget);if(!n)return;const r=_e(n),l=be(n,t.domConverter),c=e.editing.mapper.toModelElement(l);this._insertParagraph(c,r),o.preventDefault(),i.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",(o,n)=>{if(o.eventPhase!="atTarget")return;const r=t.getSelectedElement(),l=e.editing.mapper.toViewElement(r),c=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:_(l,r,c)&&(this._insertParagraph(r,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),o.stop())},{context:p})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view.document;this._listenToIfEnabled(t,"insertText",(i,o)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(o.selection=t.selection)},{priority:"high"}),D.isAndroid?this._listenToIfEnabled(t,"keydown",(i,o)=>{o.keyCode==229&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(t,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"highest"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,o=i.schema;this._listenToIfEnabled(t.document,"delete",(n,r)=>{if(n.eventPhase!="atTarget")return;const l=w(i.document.selection);if(!l)return;const c=r.direction,a=i.document.selection.getSelectedElement(),h=l==="before",d=c=="forward";if(h===d)e.execute("delete",{selection:i.createSelection(a,"on")});else{const u=o.getNearestSelectionRange(i.createPositionAt(a,l),c);if(u)if(!u.isCollapsed)i.change(f=>{f.setSelection(u),e.execute(d?"deleteForward":"delete")});else{const f=i.createSelection(u.start);if(i.modifySelection(f,{direction:c}),!f.focus.isEqual(u.start))i.change(y=>{y.setSelection(u),e.execute(d?"deleteForward":"delete")});else{const y=Ce(o,u.start.parent);i.deleteContent(i.createSelection(y,"on"),{doNotAutoparagraph:!0})}}}r.preventDefault(),n.stop()},{context:p})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(o,[n,r])=>{if(r&&!r.is("documentSelection"))return;const l=w(i);if(l)return o.stop(),t.change(c=>{const a=i.getSelectedElement(),h=t.createPositionAt(a,l),d=c.createSelection(h),g=t.insertContent(n,d);return c.setSelection(d),g})},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,i=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(o,n)=>{const[,r,l={}]=n;if(r&&!r.is("documentSelection"))return;const c=w(i);c&&(l.findOptimalPosition=c,n[3]=l)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,i=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(o,[n])=>{if(n&&!n.is("documentSelection"))return;w(i)&&o.stop()},{priority:"high"})}}function Ee(s,e,t){const i=s.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},function(o){const n=this.toDomElement(o);return Se(n,e),Pe(n),n});s.insert(s.createPositionAt(t,"end"),i)}function Se(s,e){for(const t of M){const i=new C({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${t}`],title:e[t],"aria-hidden":"true"},children:[s.ownerDocument.importNode(ye,!0)]});s.appendChild(i.render())}}function Pe(s){const e=new C({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});s.appendChild(e.render())}function Ce(s,e){let t=e;for(const i of e.getAncestors({parentFirst:!0})){if(i.childCount>1||s.isLimit(i))break;t=i}return t}function Te(s){const e=s.model;return(t,i)=>{const o=i.keyCode==P.arrowup,n=i.keyCode==P.arrowdown,r=i.shiftKey,l=e.document.selection;if(!o&&!n)return;const c=n;if(r&&Re(l,c))return;const a=ke(s,l,c);if(a){if(a.isCollapsed){if(l.isCollapsed)return;if(r)return}(a.isCollapsed||Ae(s,a,c))&&(e.change(h=>{const d=c?a.end:a.start;if(r){const g=e.createSelection(l.anchor);g.setFocus(d),h.setSelection(g)}else h.setSelection(d)}),t.stop(),i.preventDefault(),i.stopPropagation())}}}function ke(s,e,t){const i=s.model;if(t){const o=e.isCollapsed?e.focus:e.getLastPosition(),n=R(i,o,"forward");if(!n)return null;const r=i.createRange(o,n),l=W(i.schema,r,"backward");return l?i.createRange(o,l):null}else{const o=e.isCollapsed?e.focus:e.getFirstPosition(),n=R(i,o,"backward");if(!n)return null;const r=i.createRange(n,o),l=W(i.schema,r,"forward");return l?i.createRange(l,o):null}}function R(s,e,t){const i=s.schema,o=s.createRangeIn(e.root),n=t=="forward"?"elementStart":"elementEnd";for(const{previousPosition:r,item:l,type:c}of o.getWalker({startPosition:e,direction:t})){if(i.isLimit(l)&&!i.isInline(l))return r;if(c==n&&i.isBlock(l))return null}return null}function W(s,e,t){const i=t=="backward"?e.end:e.start;if(s.checkChild(i,"$text"))return i;for(const{nextPosition:o}of e.getWalker({direction:t}))if(s.checkChild(o,"$text"))return o;return null}function Ae(s,e,t){const i=s.model,o=s.view.domConverter;if(t){const a=i.createSelection(e.start);i.modifySelection(a),!a.focus.isAtEnd&&!e.start.isEqual(a.focus)&&(e=i.createRange(a.focus,e.end))}const n=s.mapper.toViewRange(e),r=o.viewRangeToDom(n),l=b.getDomRangeRects(r);let c;for(const a of l){if(c===void 0){c=Math.round(a.bottom);continue}if(Math.round(a.top)>=c)return!1;c=Math.max(c,Math.round(a.bottom))}return!0}function Re(s,e){return!s.isCollapsed&&s.isBackward==e}class it extends E{_previouslySelected=new Set;static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[ve,V]}init(){const e=this.editor,t=e.editing.view,i=t.document,o=e.t;this.editor.editing.downcastDispatcher.on("selection",(n,r,l)=>{const c=l.writer,a=r.selection;if(a.isCollapsed)return;const h=a.getSelectedElement();if(!h)return;const d=e.editing.mapper.toViewElement(h);p(d)&&l.consumable.consume(a,"selection")&&c.setSelection(c.createRangeOn(d),{fake:!0,label:ue(d)})}),this.editor.editing.downcastDispatcher.on("selection",(n,r,l)=>{this._clearPreviouslySelectedWidgets(l.writer);const c=l.writer,a=c.document.selection;let h=null;for(const d of a.getRanges())for(const g of d){const u=g.item;p(u)&&!xe(u,h)&&(c.addClass(k,u),this._previouslySelected.add(u),h=u)}},{priority:"low"}),t.addObserver(H),this.listenTo(i,"mousedown",(...n)=>this._onMousedown(...n)),this.listenTo(i,"arrowKey",(...n)=>{this._handleSelectionChangeOnArrowKeyPress(...n)},{context:[p,"$text"]}),this.listenTo(i,"arrowKey",(...n)=>{this._preventDefaultOnArrowKeyPress(...n)},{context:"$root"}),this.listenTo(i,"arrowKey",Te(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",(n,r)=>{this._handleDelete(r.direction=="forward")&&(r.preventDefault(),n.stop())},{context:"$root"}),this.listenTo(i,"tab",(n,r)=>{n.eventPhase=="atTarget"&&(r.shiftKey||this._selectFirstNestedEditable()&&(r.preventDefault(),n.stop()))},{context:p,priority:"low"}),this.listenTo(i,"tab",(n,r)=>{r.shiftKey&&this._selectAncestorWidget()&&(r.preventDefault(),n.stop())},{priority:"low"}),this.listenTo(i,"keydown",(n,r)=>{r.keystroke==P.esc&&this._selectAncestorWidget()&&(r.preventDefault(),n.stop())},{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:o("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:o("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:o("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:o("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:o("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:o("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,o=i.editing.view,n=o.document;let r=t.target;if(!r)return;if(t.domEvent.detail>=3){this._selectBlockContent(r)&&t.preventDefault();return}if(!p(r)){const c=We(r);if(!c)return;if(p(c))r=c;else{const a=ze(o,t);if(a&&p(a))r=a;else return}}D.isAndroid&&t.preventDefault(),n.isFocused||o.focus();const l=i.editing.mapper.toModelElement(r);this._setSelectionOverElement(l)}_selectBlockContent(e){const t=this.editor,i=t.model,o=t.editing.mapper,n=i.schema,r=o.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),l=He(o.toModelElement(r),i.schema);return l?(i.change(c=>{const a=n.isLimit(l)?null:Ve(c.createPositionAfter(l),n),h=c.createPositionAt(l,0),d=a?c.createPositionAt(a,0):c.createPositionAt(l,"end");c.setSelection(c.createRange(h,d))}),!0):!1}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,o=this.editor.model,n=o.schema,r=o.document.selection,l=r.getSelectedElement(),c=j(i,this.editor.locale.contentLanguageDirection),a=c=="down"||c=="right",h=c=="up"||c=="down";if(l&&n.isObject(l)){const g=a?r.getLastPosition():r.getFirstPosition(),u=n.getNearestSelectionRange(g,a?"forward":"backward");u&&(o.change(f=>{f.setSelection(u)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed&&!t.shiftKey){const g=r.getFirstPosition(),u=r.getLastPosition(),f=g.nodeAfter,y=u.nodeBefore;(f&&n.isObject(f)||y&&n.isObject(y))&&(o.change(B=>{B.setSelection(a?u:g)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(a);if(d&&n.isObject(d)){if(n.isInline(d)&&h)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,o=i.schema,n=i.document.selection.getSelectedElement();n&&o.isObject(n)&&(t.preventDefault(),e.stop())}_handleDelete(e){const i=this.editor.model.document.selection;if(!this.editor.model.canEditAt(i)||!i.isCollapsed)return;const o=this._getObjectElementNextToSelection(e);if(o)return this.editor.model.change(n=>{let r=i.anchor.parent;for(;r.isEmpty;){const l=r;r=l.parent,n.remove(l)}this._setSelectionOverElement(o)}),!0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,o=t.document.selection,n=t.createSelection(o);if(t.modifySelection(n,{direction:e?"forward":"backward"}),n.isEqual(o))return null;const r=e?n.focus.nodeBefore:n.focus.nodeAfter;return r&&i.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(k,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,i=this.editor.editing.view.document;for(const o of i.selection.getFirstRange().getItems())if(o.is("editableElement")){const n=e.editing.mapper.toModelElement(o);/* istanbul ignore next -- @preserve */if(!n)continue;const r=e.model.createPositionAt(n,0),l=e.model.schema.getNearestSelectionRange(r,"forward");return e.model.change(c=>{c.setSelection(l)}),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,o=e.editing.view.document.selection.getFirstPosition().parent,r=(o.is("$text")?o.parent:o).findAncestor(p);if(!r)return!1;const l=t.toModelElement(r);/* istanbul ignore next -- @preserve */return l?(e.model.change(c=>{c.setSelection(l,"on")}),!0):!1}}function We(s){let e=s;for(;e;){if(e.is("editableElement")||p(e))return e;e=e.parent}return null}function ze(s,e){const t=q(e.domEvent);let i=null;if(t?i=s.domConverter.domRangeToView(t):i=s.createRange(s.createPositionAt(e.target,0)),!i)return null;const o=i.start;if(!o.parent)return null;let n=o.parent;return o.parent.is("editableElement")&&(o.isAtEnd&&o.nodeBefore?n=o.nodeBefore:o.isAtStart&&o.nodeAfter&&(n=o.nodeAfter)),n.is("$text")?n.parent:n}function xe(s,e){return e?Array.from(s.getAncestors()).includes(e):!1}function He(s,e){for(const t of s.getAncestors({includeSelf:!0,parentFirst:!0})){if(e.checkChild(t,"$text"))return t;if(e.isLimit(t)&&!e.isObject(t))break}return null}function Ve(s,e){const t=new K({startPosition:s});for(const{item:i}of t){if(e.isLimit(i)||!i.is("element"))return null;if(e.checkChild(i,"$text"))return i}return null}class ot extends E{_toolbarDefinitions=new Map;_balloon;static get requires(){return[Z]}static get pluginName(){return"WidgetToolbarRepository"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",i=>{De(e.editing.view.document.selection)&&i.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:o,balloonClassName:n="ck-toolbar-container",positions:r}){if(!i.length){$("widget-toolbar-no-items",{toolbarId:e});return}const l=this.editor,c=l.t,a=new ee(l.locale);if(a.ariaLabel=t||c("Widget toolbar"),this._toolbarDefinitions.has(e))throw new I("widget-toolbar-duplicated",this,{toolbarId:e});const h={view:a,getRelatedElement:o,balloonClassName:n,itemsConfig:i,positions:r,initialized:!1};l.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const d=o(l.editing.view.document.selection);d&&this._showToolbar(h,d)},afterBlur:()=>{this._hideToolbar(h)}}),this._toolbarDefinitions.set(e,h)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const o of this._toolbarDefinitions.values()){const n=o.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!n)this._isToolbarInBalloon(o)&&this._hideToolbar(o);else if(!this.editor.ui.focusTracker.isFocused)this._isToolbarVisible(o)&&this._hideToolbar(o);else{const r=n.getAncestors().length;r>e&&(e=r,t=n,i=o)}}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?z(this.editor,t,e.positions):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:L(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const i of this._toolbarDefinitions.values())if(this._isToolbarVisible(i)){const o=i.getRelatedElement(this.editor.editing.view.document.selection);z(this.editor,o,e.positions)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function z(s,e,t){const i=s.plugins.get("ContextualBalloon"),o=L(s,e,t);i.updatePosition(o)}function L(s,e,t){const i=s.editing.view,o=te.defaultPositions;return{target:i.domConverter.mapViewToDom(e),positions:t||[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}function De(s){const e=s.getSelectedElement();return!!(e&&p(e))}class Ie extends F(){_referenceCoordinates;_options;_originalWidth;_originalHeight;_originalWidthPercents;_aspectRatio;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 o=new b(t);this.activeHandlePosition=Ne(e),this._referenceCoordinates=Oe(t,Me(this.activeHandlePosition)),this._originalWidth=o.width,this._originalHeight=o.height,this._aspectRatio=o.width/o.height;const n=i.style.width;n&&n.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(n):this._originalWidthPercents=me(i,o)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function Oe(s,e){const t=new b(s),i=e.split("-"),o={x:i[1]=="right"?t.right:t.left,y:i[0]=="bottom"?t.bottom:t.top};return o.x+=s.ownerDocument.defaultView.scrollX,o.y+=s.ownerDocument.defaultView.scrollY,o}function Fe(s){return`ck-widget__resizer__handle-${s}`}function Ne(s){const e=["top-left","top-right","bottom-right","bottom-left"];for(const t of e)if(s.classList.contains(Fe(t)))return t}function Me(s){const e=s.split("-"),t={top:"bottom",bottom:"top",left:"right",right:"left"};return`${t[e[0]]}-${t[e[1]]}`}class Le extends oe{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",t=>t?`ck-orientation-${t}`:"")],style:{display:e.if("_isVisible","none",t=>!t)}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",(i,o)=>i!==null&&o!==null),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(i,o,n)=>e.unit==="px"?`${i}×${o}`:`${n}%`),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",(i,o,n)=>o<50||n<50?"above-center":i)}_dismiss(){this.unbind(),this._isVisible=!1}}class x extends F(){_state;_sizeView;_options;_viewResizerWrapper=null;_initialViewWidth;constructor(e){super(),this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",(t,i)=>t&&i),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",t=>{!this.state.proposedWidth&&!this.state.proposedWidthPercents&&(this._cleanup(),t.stop())},{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change(t=>{t.removeClass("ck-hidden",this._viewResizerWrapper)})}hide(){this._options.editor.editing.view.change(t=>{t.addClass("ck-hidden",this._viewResizerWrapper)})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(o=>{const n=o.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},function(r){const l=this.toDomElement(r);return e._appendHandles(l),e._appendSizeUI(l),l});o.insert(o.createPositionAt(t,"end"),n),o.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 Ie(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(a=>{const h=this._options.unit||"%",d=(h==="%"?t.widthPercents:t.width)+h;a.setStyle("width",d,this._options.viewElement)});const o=this._getHandleHost(),n=new b(o),r=Math.round(n.width),l=Math.round(n.height),c=new b(o);t.width=Math.round(c.width),t.height=Math.round(c.height),this.redraw(n),this.state.update({...t,handleHostWidth:r,handleHostHeight:l})}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(!je(t))return;const i=t.parentElement,o=this._getHandleHost(),n=this._viewResizerWrapper,r=[n.getStyle("width"),n.getStyle("height"),n.getStyle("left"),n.getStyle("top")];let l;if(i.isSameNode(o)){const c=e||new b(o);l=[c.width+"px",c.height+"px",void 0,void 0]}else l=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];Y(r,l)!=="same"&&this._options.editor.editing.view.change(c=>{c.setStyle({width:l[0],height:l[1],left:l[2],top:l[3]},n)})}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(t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,i=Ke(e),o=this._options.isCentered?this._options.isCentered(this):!0,n={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(n.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(n.x*=2);let r=Math.abs(t.originalWidth+n.x),l=Math.abs(t.originalHeight+n.y);return(r/t.aspectRatio>l?"width":"height")=="width"?l=r/t.aspectRatio:r=l*t.aspectRatio,{width:Math.round(r),height:Math.round(l),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 i of t)e.appendChild(new C({tag:"div",attributes:{class:`ck-widget__resizer__handle ${Be(i)}`}}).render())}_appendSizeUI(e){this._sizeView=new Le,this._sizeView.render(),e.appendChild(this._sizeView.element)}}function Be(s){return`ck-widget__resizer__handle-${s}`}function Ke(s){return{x:s.pageX,y:s.pageY}}function je(s){return s&&s.ownerDocument&&s.ownerDocument.contains(s)}class nt extends E{_resizers=new Map;_observer;_redrawSelectedResizerThrottled;static get pluginName(){return"WidgetResize"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.editing,t=T.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(H),this._observer=new(G()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=se(()=>this.redrawSelectedResizer(),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",()=>{for(const[o,n]of this._resizers)o.isAttached()||(this._resizers.delete(o),n.destroy())},{priority:"lowest"}),this._observer.listenTo(T.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",()=>{const o=i.getSelectedElement(),n=this.getResizerByViewElement(o)||null;n?this.select(n):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 x(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const r=i.get("WidgetToolbarRepository");t.on("begin",()=>{r.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{r.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{r.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;x.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)}}export{ce as WIDGET_CLASS_NAME,k as WIDGET_SELECTED_CLASS_NAME,it as Widget,nt as WidgetResize,ot as WidgetToolbarRepository,ve as WidgetTypeAround,fe as calculateResizeHostAncestorWidth,me as calculateResizeHostPercentageWidth,tt as findOptimalInsertionRange,ue as getLabel,p as isWidget,N as setHighlightHandling,he as setLabel,Ze as toWidget,et as toWidgetEditable};
|
|
@@ -19,4 +19,4 @@ function E(n){return n&&n.__esModule?n.default:n}class v{on(e,i){return this._ca
|
|
|
19
19
|
</svg>
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
22
|
-
</body></html>`;let C={url:null,method:"post",withCredentials:!1,timeout:null,parallelUploads:2,uploadMultiple:!1,chunking:!1,forceChunking:!1,chunkSize:2097152,parallelChunkUploads:!1,retryChunks:!1,retryChunksLimit:3,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:120,thumbnailHeight:120,thumbnailMethod:"crop",resizeWidth:null,resizeHeight:null,resizeMimeType:null,resizeQuality:.8,resizeMethod:"contain",filesizeBase:1e3,maxFiles:null,headers:null,defaultHeaders:!0,clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,autoProcessQueue:!0,autoQueue:!0,addRemoveLinks:!1,previewsContainer:null,disablePreviews:!1,hiddenInputContainer:"body",capture:null,renameFilename:null,renameFile:null,forceFallback:!1,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictUploadCanceled:"Upload canceled.",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You cannot upload any more files.",dictFileSizeUnits:{tb:"TB",gb:"GB",mb:"MB",kb:"KB",b:"b"},init(){},params(n,e,i){if(i)return{dzuuid:i.file.upload.uuid,dzchunkindex:i.index,dztotalfilesize:i.file.size,dzchunksize:this.options.chunkSize,dztotalchunkcount:i.file.upload.totalChunkCount,dzchunkbyteoffset:i.index*this.options.chunkSize}},accept(n,e){return e()},chunksUploaded:function(n,e){e()},binaryBody:!1,fallback(){let n;this.element.className=`${this.element.className} dz-browser-not-supported`;for(let i of this.element.getElementsByTagName("div"))if(/(^| )dz-message($| )/.test(i.className)){n=i,i.className="dz-message";break}n||(n=r.createElement('<div class="dz-message"><span></span></div>'),this.element.appendChild(n));let e=n.getElementsByTagName("span")[0];return e&&(e.textContent!=null?e.textContent=this.options.dictFallbackMessage:e.innerText!=null&&(e.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize(n,e,i,t){let s={srcX:0,srcY:0,srcWidth:n.width,srcHeight:n.height},l=n.width/n.height;e==null&&i==null?(e=s.srcWidth,i=s.srcHeight):e==null?e=i*l:i==null&&(i=e/l),e=Math.min(e,s.srcWidth),i=Math.min(i,s.srcHeight);let a=e/i;if(s.srcWidth>e||s.srcHeight>i)if(t==="crop")l>a?(s.srcHeight=n.height,s.srcWidth=s.srcHeight*a):(s.srcWidth=n.width,s.srcHeight=s.srcWidth/a);else if(t==="contain")l>a?i=e/l:e=i*l;else throw new Error(`Unknown resizeMethod '${t}'`);return s.srcX=(n.width-s.srcWidth)/2,s.srcY=(n.height-s.srcHeight)/2,s.trgWidth=e,s.trgHeight=i,s},transformFile(n,e){return(this.options.resizeWidth||this.options.resizeHeight)&&n.type.match(/image.*/)?this.resizeImage(n,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,e):e(n)},previewTemplate:E(F),drop(n){return this.element.classList.remove("dz-drag-hover")},dragstart(n){},dragend(n){return this.element.classList.remove("dz-drag-hover")},dragenter(n){return this.element.classList.add("dz-drag-hover")},dragover(n){return this.element.classList.add("dz-drag-hover")},dragleave(n){return this.element.classList.remove("dz-drag-hover")},paste(n){},reset(){return this.element.classList.remove("dz-started")},addedfile(n){if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer&&!this.options.disablePreviews){n.previewElement=r.createElement(this.options.previewTemplate.trim()),n.previewTemplate=n.previewElement,this.previewsContainer.appendChild(n.previewElement);for(var e of n.previewElement.querySelectorAll("[data-dz-name]"))e.textContent=n.name;for(e of n.previewElement.querySelectorAll("[data-dz-size]"))e.innerHTML=this.filesize(n.size);this.options.addRemoveLinks&&(n._removeLink=r.createElement(`<a class="dz-remove" href="javascript:undefined;" data-dz-remove>${this.options.dictRemoveFile}</a>`),n.previewElement.appendChild(n._removeLink));let i=t=>(t.preventDefault(),t.stopPropagation(),n.status===r.UPLOADING?this.options.dictCancelUploadConfirmation?r.confirm(this.options.dictCancelUploadConfirmation,()=>this.removeFile(n)):this.removeFile(n):this.options.dictRemoveFileConfirmation?r.confirm(this.options.dictRemoveFileConfirmation,()=>this.removeFile(n)):this.removeFile(n));for(let t of n.previewElement.querySelectorAll("[data-dz-remove]"))t.addEventListener("click",i)}},removedfile(n){return n.previewElement!=null&&n.previewElement.parentNode!=null&&n.previewElement.parentNode.removeChild(n.previewElement),this._updateMaxFilesReachedClass()},thumbnail(n,e){if(n.previewElement){n.previewElement.classList.remove("dz-file-preview");for(let i of n.previewElement.querySelectorAll("[data-dz-thumbnail]"))i.alt=n.name,i.src=e;return setTimeout(()=>n.previewElement.classList.add("dz-image-preview"),1)}},error(n,e){if(n.previewElement){n.previewElement.classList.add("dz-error"),typeof e!="string"&&e.error&&(e=e.error);for(let i of n.previewElement.querySelectorAll("[data-dz-errormessage]"))i.textContent=e}},errormultiple(){},processing(n){if(n.previewElement&&(n.previewElement.classList.add("dz-processing"),n._removeLink))return n._removeLink.innerHTML=this.options.dictCancelUpload},processingmultiple(){},uploadprogress(n,e,i){if(n.previewElement)for(let t of n.previewElement.querySelectorAll("[data-dz-uploadprogress]"))t.nodeName==="PROGRESS"?t.value=e:t.style.width=`${e}%`},totaluploadprogress(){},sending(){},sendingmultiple(){},success(n){if(n.previewElement)return n.previewElement.classList.add("dz-success")},successmultiple(){},canceled(n){return this.emit("error",n,this.options.dictUploadCanceled)},canceledmultiple(){},complete(n){if(n._removeLink&&(n._removeLink.innerHTML=this.options.dictRemoveFile),n.previewElement)return n.previewElement.classList.add("dz-complete")},completemultiple(){},maxfilesexceeded(){},maxfilesreached(){},queuecomplete(){},addedfiles(){},emptyfolder(){}};var w=C;class r extends v{static initClass(){this.prototype.Emitter=v,this.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","addedfiles","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded","maxfilesreached","queuecomplete","emptyfolder"],this.prototype._thumbnailQueue=[],this.prototype._processingThumbnail=!1}constructor(e,i){super();let t,s;if(this.element=e,this.clickableElements=[],this.listeners=[],this.files=[],typeof this.element=="string"&&(this.element=document.querySelector(this.element)),this.element===null||!this.element instanceof HTMLElement)throw new Error("Invalid dropzone element: not an instance of HTMLElement.");if(this.element.dropzone)throw new Error("Dropzone already attached.");r.instances.push(this),this.element.dropzone=this;let l=(s=r.optionsForElement(this.element))!=null?s:{};if(this.options=Object.assign({},w,l,i??{}),this.options.previewTemplate=this.options.previewTemplate.replace(/\n*/g,""),this.options.forceFallback||!r.isBrowserSupported())return this.options.fallback.call(this);if(this.options.url==null&&(this.options.url=this.element.getAttribute("action")),!this.options.url)throw new Error("No URL provided.");if(this.options.uploadMultiple&&this.options.chunking)throw new Error("You cannot set both: uploadMultiple and chunking.");if(this.options.binaryBody&&this.options.uploadMultiple)throw new Error("You cannot set both: binaryBody and uploadMultiple.");typeof this.options.method=="string"&&(this.options.method=this.options.method.toUpperCase()),(t=this.getExistingFallback())&&t.parentNode&&t.parentNode.removeChild(t),this.options.previewsContainer!==!1&&(this.options.previewsContainer?this.previewsContainer=r.getElement(this.options.previewsContainer,"previewsContainer"):this.previewsContainer=this.element),this.options.clickable&&(this.options.clickable===!0?this.clickableElements=[this.element]:this.clickableElements=r.getElements(this.options.clickable,"clickable")),this.init()}getAcceptedFiles(){return this.files.filter(e=>e.accepted).map(e=>e)}getRejectedFiles(){return this.files.filter(e=>!e.accepted).map(e=>e)}getFilesWithStatus(e){return this.files.filter(i=>i.status===e).map(i=>i)}getQueuedFiles(){return this.getFilesWithStatus(r.QUEUED)}getUploadingFiles(){return this.getFilesWithStatus(r.UPLOADING)}getAddedFiles(){return this.getFilesWithStatus(r.ADDED)}getActiveFiles(){return this.files.filter(e=>e.status===r.UPLOADING||e.status===r.QUEUED).map(e=>e)}init(){if(this.element.tagName==="form"&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(r.createElement(`<div class="dz-default dz-message"><button class="dz-button" type="button">${this.options.dictDefaultMessage}</button></div>`)),this.clickableElements.length){let t=()=>{var s;this.hiddenFileInput&&((s=this.hiddenFileInput.parentNode)==null||s.removeChild(this.hiddenFileInput)),this.hiddenFileInput=document.createElement("input"),this.hiddenFileInput.setAttribute("type","file"),this.hiddenFileInput.setAttribute("form",this.element.id),(this.options.maxFiles===null||this.options.maxFiles>1)&&this.hiddenFileInput.setAttribute("multiple","multiple"),this.hiddenFileInput.className="dz-hidden-input",this.options.acceptedFiles!==null&&this.hiddenFileInput.setAttribute("accept",this.options.acceptedFiles),this.options.capture!==null&&this.hiddenFileInput.setAttribute("capture",this.options.capture),this.hiddenFileInput.setAttribute("tabindex","-1"),this.hiddenFileInput.setAttribute("aria-label","dropzone hidden input"),this.hiddenFileInput.style.visibility="hidden",this.hiddenFileInput.style.position="absolute",this.hiddenFileInput.style.top="0",this.hiddenFileInput.style.left="0",this.hiddenFileInput.style.height="0",this.hiddenFileInput.style.width="0",r.getElement(this.options.hiddenInputContainer,"hiddenInputContainer").appendChild(this.hiddenFileInput),this.hiddenFileInput.addEventListener("change",()=>{let{files:l}=this.hiddenFileInput;if(l.length)for(let a of l)this.addFile(a);this.emit("addedfiles",l),t()})};t()}this.URL=window.URL!==null?window.URL:window.webkitURL;for(let t of this.events)this.on(t,this.options[t]);this.on("uploadprogress",()=>this.updateTotalUploadProgress()),this.on("removedfile",()=>this.updateTotalUploadProgress()),this.on("canceled",t=>this.emit("complete",t)),this.on("complete",t=>{if(this.getAddedFiles().length===0&&this.getUploadingFiles().length===0&&this.getQueuedFiles().length===0)return setTimeout(()=>this.emit("queuecomplete"),0)});const e=function(t){return t.dataTransfer.types&&t.dataTransfer.types.includes("Files")};let i=function(t){if(e(t))return t.stopPropagation(),t.preventDefault()};return this.listeners=[{element:this.element,events:{dragstart:t=>this.emit("dragstart",t),dragenter:t=>(i(t),this.emit("dragenter",t)),dragover:t=>{const s=t.dataTransfer.effectAllowed;return t.dataTransfer.dropEffect=s==="move"||s==="linkMove"?"move":"copy",i(t),this.emit("dragover",t)},dragleave:t=>this.emit("dragleave",t),drop:t=>(i(t),this.drop(t)),dragend:t=>this.emit("dragend",t)}}],this.clickableElements.forEach(t=>this.listeners.push({element:t,events:{click:s=>((t!==this.element||s.target===this.element||r.elementInside(s.target,this.element.querySelector(".dz-message")))&&this.hiddenFileInput.click(),!0)}})),this.enable(),this.options.init.call(this)}destroy(){return this.disable(),this.removeAllFiles(!0),this.hiddenFileInput!=null&&this.hiddenFileInput.parentNode&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,r.instances.splice(r.instances.indexOf(this),1)}updateTotalUploadProgress(){let e,i=0,t=0;if(this.getActiveFiles().length){for(let l of this.getActiveFiles())i+=l.upload.bytesSent,t+=l.upload.total;e=100*i/t}else e=100;return this.emit("totaluploadprogress",e,t,i)}_getParamName(e){return typeof this.options.paramName=="function"?this.options.paramName(e):`${this.options.paramName}${this.options.uploadMultiple?`[${e}]`:""}`}_renameFile(e){const i={...e,name:e.name.replace(/\u202F/g," ")};return typeof this.options.renameFile!="function"?i.name:this.options.renameFile(i)}getFallbackForm(){let e,i;if(e=this.getExistingFallback())return e;let t='<div class="dz-fallback">';this.options.dictFallbackText&&(t+=`<p>${this.options.dictFallbackText}</p>`),t+=`<input type="file" name="${this._getParamName(0)}" ${this.options.uploadMultiple?'multiple="multiple"':void 0} /><input type="submit" value="Upload!"></div>`;let s=r.createElement(t);return this.element.tagName!=="FORM"?(i=r.createElement(`<form action="${this.options.url}" enctype="multipart/form-data" method="${this.options.method}"></form>`),i.appendChild(s)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),i??s}getExistingFallback(){let e=function(t){for(let s of t)if(/(^| )fallback($| )/.test(s.className))return s};for(let t of["div","form"]){var i;if(i=e(this.element.getElementsByTagName(t)))return i}}setupEventListeners(){return this.listeners.map(e=>(()=>{let i=[];for(let t in e.events){let s=e.events[t];i.push(e.element.addEventListener(t,s,!1))}return i})())}removeEventListeners(){return this.listeners.map(e=>(()=>{let i=[];for(let t in e.events){let s=e.events[t];i.push(e.element.removeEventListener(t,s,!1))}return i})())}disable(){return this.clickableElements.forEach(e=>e.classList.remove("dz-clickable")),this.removeEventListeners(),this.disabled=!0,this.files.map(e=>this.cancelUpload(e))}enable(){return delete this.disabled,this.clickableElements.forEach(e=>e.classList.add("dz-clickable")),this.setupEventListeners()}filesize(e){let i=0,t="b";if(e>0){let s=["tb","gb","mb","kb","b"];for(let l=0;l<s.length;l++){let a=s[l],u=Math.pow(this.options.filesizeBase,4-l)/10;if(e>=u){i=e/Math.pow(this.options.filesizeBase,4-l),t=a;break}}i=Math.round(10*i)/10}return`<strong>${i}</strong> ${this.options.dictFileSizeUnits[t]}`}_updateMaxFilesReachedClass(){return this.options.maxFiles!=null&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}drop(e){if(!e.dataTransfer)return;this.emit("drop",e);let i=[];for(let t=0;t<e.dataTransfer.files.length;t++)i[t]=e.dataTransfer.files[t];if(i.length){let{items:t}=e.dataTransfer;t&&t.length&&t[0].webkitGetAsEntry!=null?this._addFilesFromItems(t):this.handleFiles(i)}this.emit("addedfiles",i)}paste(e){if(S(e!=null?e.clipboardData:void 0,t=>t.items)==null)return;this.emit("paste",e);let{items:i}=e.clipboardData;if(i.length)return this._addFilesFromItems(i)}handleFiles(e){for(let i of e)this.addFile(i)}_addFilesFromItems(e){return(()=>{let i=[];for(let s of e){var t;s.webkitGetAsEntry!=null&&(t=s.webkitGetAsEntry())?t.isFile?i.push(this.addFile(s.getAsFile())):t.isDirectory?i.push(this._addFilesFromDirectory(t,t.name)):i.push(void 0):s.getAsFile!=null&&(s.kind==null||s.kind==="file")?i.push(this.addFile(s.getAsFile())):i.push(void 0)}return i})()}_addFilesFromDirectory(e,i){let t=e.createReader(),s=u=>T(console,"log",d=>d.log(u)),l=0;var a=()=>t.readEntries(u=>{if(u.length>0){for(let d of u)d.isFile?(++l,d.file(o=>{if(!(this.options.ignoreHiddenFiles&&o.name.substring(0,1)==="."))return o.fullPath=`${i}/${o.name}`,this.addFile(o)})):d.isDirectory&&this._addFilesFromDirectory(d,`${i}/${d.name}`);a()}else l===0&&this.emit("emptyfolder",i);return null},s);return a()}accept(e,i){this.options.maxFilesize&&e.size>this.options.maxFilesize*1048576?i(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(e.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):r.isValidFile(e,this.options.acceptedFiles)?this.options.maxFiles!=null&&this.getAcceptedFiles().length>=this.options.maxFiles?(i(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",e)):this.options.accept.call(this,e,i):i(this.options.dictInvalidFileType)}addFile(e){e.upload={uuid:window.isSecureContext?self.crypto.randomUUID():r.uuidv4(),progress:0,total:e.size,bytesSent:0,filename:this._renameFile(e)},this.files.push(e),e.status=r.ADDED,this.emit("addedfile",e),this._enqueueThumbnail(e),this.accept(e,i=>{i?(e.accepted=!1,this._errorProcessing([e],i)):(e.accepted=!0,this.options.autoQueue&&this.enqueueFile(e)),this._updateMaxFilesReachedClass()})}enqueueFiles(e){for(let i of e)this.enqueueFile(i);return null}enqueueFile(e){if(e.status===r.ADDED&&e.accepted===!0){if(e.status=r.QUEUED,this.options.autoProcessQueue)return setTimeout(()=>this.processQueue(),0)}else throw new Error("This file can't be queued because it has already been processed or was rejected.")}_enqueueThumbnail(e){if(this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=this.options.maxThumbnailFilesize*1048576)return this._thumbnailQueue.push(e),setTimeout(()=>this._processThumbnailQueue(),0)}_processThumbnailQueue(){if(this._processingThumbnail||this._thumbnailQueue.length===0)return;this._processingThumbnail=!0;let e=this._thumbnailQueue.shift();return this.createThumbnail(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,i=>(this.emit("thumbnail",e,i),this._processingThumbnail=!1,this._processThumbnailQueue()))}removeFile(e){if(e.status===r.UPLOADING&&this.cancelUpload(e),this.files=k(this.files,e),this.emit("removedfile",e),this.files.length===0)return this.emit("reset")}removeAllFiles(e){e==null&&(e=!1);for(let i of this.files.slice())(i.status!==r.UPLOADING||e)&&this.removeFile(i);return null}resizeImage(e,i,t,s,l){return this.createThumbnail(e,i,t,s,!0,(a,u)=>{if(u==null)return l(e);{let{resizeMimeType:d}=this.options;d==null&&(d=e.type);let o=u.toDataURL(d,this.options.resizeQuality);return(d==="image/jpeg"||d==="image/jpg")&&(o=A(e.dataURL,o)),l(r.dataURItoBlob(o))}},!0)}createThumbnail(e,i,t,s,l,a,u=!1){let d=new FileReader;d.onload=()=>{if(e.dataURL=d.result,e.type==="image/svg+xml"){a!=null&&a(d.result);return}this.createThumbnailFromUrl(e,i,t,s,l,a,void 0,u)},d.readAsDataURL(e)}displayExistingFile(e,i,t,s,l=!0){if(this.emit("addedfile",e),this.emit("complete",e),!l)this.emit("thumbnail",e,i),t&&t();else{let a=u=>{this.emit("thumbnail",e,u),t&&t()};e.dataURL=i,this.createThumbnailFromUrl(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,this.options.fixOrientation,a,s)}}createThumbnailFromUrl(e,i,t,s,l,a,u,d=!1){let o=document.createElement("img");u&&(o.crossOrigin=u),l=getComputedStyle(document.body).imageOrientation=="from-image"?!1:l,o.onload=()=>{let g=f=>f(1);return typeof EXIF<"u"&&EXIF!==null&&l&&(g=f=>EXIF.getData(o,function(){return f(EXIF.getTag(this,"Orientation"))})),g(f=>{e.width=o.width,e.height=o.height;let p=this.options.resize.call(this,e,i,t,s),m=document.createElement("canvas"),c=m.getContext("2d");switch(m.width=p.trgWidth,m.height=p.trgHeight,f>4&&(m.width=p.trgHeight,m.height=p.trgWidth),f){case 2:c.translate(m.width,0),c.scale(-1,1);break;case 3:c.translate(m.width,m.height),c.rotate(Math.PI);break;case 4:c.translate(0,m.height),c.scale(1,-1);break;case 5:c.rotate(.5*Math.PI),c.scale(1,-1);break;case 6:c.rotate(.5*Math.PI),c.translate(0,-m.width);break;case 7:c.rotate(.5*Math.PI),c.translate(m.height,-m.width),c.scale(-1,1);break;case 8:c.rotate(-.5*Math.PI),c.translate(-m.height,0);break}L(c,o,p.srcX!=null?p.srcX:0,p.srcY!=null?p.srcY:0,p.srcWidth,p.srcHeight,p.trgX!=null?p.trgX:0,p.trgY!=null?p.trgY:0,p.trgWidth,p.trgHeight);let y=m.toDataURL("image/png");if(a!=null)return a(y,m)})},a!=null&&(o.onerror=a);var h=e.dataURL;return d&&(h=U(h)),o.src=h}processQueue(){let{parallelUploads:e}=this.options,i=this.getUploadingFiles().length,t=i;if(i>=e)return;let s=this.getQueuedFiles();if(s.length>0){if(this.options.uploadMultiple)return this.processFiles(s.slice(0,e-i));for(;t<e;){if(!s.length)return;this.processFile(s.shift()),t++}}}processFile(e){return this.processFiles([e])}processFiles(e){for(let i of e)i.processing=!0,i.status=r.UPLOADING,this.emit("processing",i);return this.options.uploadMultiple&&this.emit("processingmultiple",e),this.uploadFiles(e)}_getFilesWithXhr(e){return this.files.filter(i=>i.xhr===e).map(i=>i)}cancelUpload(e){if(e.status===r.UPLOADING){let i=this._getFilesWithXhr(e.xhr);for(let t of i)t.status=r.CANCELED;typeof e.xhr<"u"&&e.xhr.abort();for(let t of i)this.emit("canceled",t);this.options.uploadMultiple&&this.emit("canceledmultiple",i)}else(e.status===r.ADDED||e.status===r.QUEUED)&&(e.status=r.CANCELED,this.emit("canceled",e),this.options.uploadMultiple&&this.emit("canceledmultiple",[e]));if(this.options.autoProcessQueue)return this.processQueue()}resolveOption(e,...i){return typeof e=="function"?e.apply(this,i):e}uploadFile(e){return this.uploadFiles([e])}uploadFiles(e){this._transformFiles(e,i=>{if(this.options.chunking){let t=i[0];e[0].upload.chunked=this.options.chunking&&(this.options.forceChunking||t.size>this.options.chunkSize),e[0].upload.totalChunkCount=Math.ceil(t.size/this.options.chunkSize),t.size===0&&(e[0].upload.totalChunkCount=1)}if(e[0].upload.chunked){let t=e[0],s=i[0];t.upload.chunks=[];let l=()=>{let a=0;for(;t.upload.chunks[a]!==void 0;)a++;if(a>=t.upload.totalChunkCount)return;let u=a*this.options.chunkSize,d=Math.min(u+this.options.chunkSize,s.size),o={name:this._getParamName(0),data:s.webkitSlice?s.webkitSlice(u,d):s.slice(u,d),filename:t.upload.filename,chunkIndex:a};t.upload.chunks[a]={file:t,index:a,dataBlock:o,status:r.UPLOADING,progress:0,retries:0},this._uploadData(e,[o])};if(t.upload.finishedChunkUpload=(a,u)=>{let d=!0;a.status=r.SUCCESS,a.dataBlock=null,a.response=a.xhr.responseText,a.responseHeaders=a.xhr.getAllResponseHeaders(),a.xhr=null;for(let o=0;o<t.upload.totalChunkCount;o++){if(t.upload.chunks[o]===void 0)return l();t.upload.chunks[o].status!==r.SUCCESS&&(d=!1)}d&&this.options.chunksUploaded(t,()=>{this._finished(e,u,null)})},this.options.parallelChunkUploads){const a=Math.min(this.options.parallelChunkUploads===!0?this.options.parallelUploads:this.options.parallelChunkUploads,t.upload.totalChunkCount);for(let u=0;u<a;u++)l()}else l()}else{let t=[];for(let s=0;s<e.length;s++)t[s]={name:this._getParamName(s),data:i[s],filename:e[s].upload.filename};this._uploadData(e,t)}})}_getChunk(e,i){for(let t=0;t<e.upload.totalChunkCount;t++)if(e.upload.chunks[t]!==void 0&&e.upload.chunks[t].xhr===i)return e.upload.chunks[t]}_uploadData(e,i){let t=new XMLHttpRequest;for(let o of e)o.xhr=t;e[0].upload.chunked&&(e[0].upload.chunks[i[0].chunkIndex].xhr=t);let s=this.resolveOption(this.options.method,e,i),l=this.resolveOption(this.options.url,e,i);t.open(s,l,!0),this.resolveOption(this.options.timeout,e)&&(t.timeout=this.resolveOption(this.options.timeout,e)),t.withCredentials=!!this.options.withCredentials,t.onload=o=>{this._finishedUploading(e,t,o)},t.ontimeout=()=>{this._handleUploadError(e,t,`Request timedout after ${this.options.timeout/1e3} seconds`)},t.onerror=()=>{this._handleUploadError(e,t)};let u=t.upload!=null?t.upload:t;u.onprogress=o=>this._updateFilesUploadProgress(e,t,o);let d=this.options.defaultHeaders?{Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"}:{};this.options.binaryBody&&(d["Content-Type"]=e[0].type),this.options.headers&&Object.assign(d,this.options.headers);for(let o in d){let h=d[o];h&&t.setRequestHeader(o,h)}if(this.options.binaryBody){for(let o of e)this.emit("sending",o,t);this.options.uploadMultiple&&this.emit("sendingmultiple",e,t),this.submitRequest(t,null,e)}else{let o=new FormData;if(this.options.params){let h=this.options.params;typeof h=="function"&&(h=h.call(this,e,t,e[0].upload.chunked?this._getChunk(e[0],t):null));for(let g in h){let f=h[g];if(Array.isArray(f))for(let p=0;p<f.length;p++)o.append(g,f[p]);else o.append(g,f)}}for(let h of e)this.emit("sending",h,t,o);this.options.uploadMultiple&&this.emit("sendingmultiple",e,t,o),this._addFormElementData(o);for(let h=0;h<i.length;h++){let g=i[h];o.append(g.name,g.data,g.filename)}this.submitRequest(t,o,e)}}_transformFiles(e,i){let t=[],s=0;for(let l=0;l<e.length;l++)this.options.transformFile.call(this,e[l],a=>{t[l]=a,++s===e.length&&i(t)})}_addFormElementData(e){if(this.element.tagName==="FORM")for(let i of this.element.querySelectorAll("input, textarea, select, button")){let t=i.getAttribute("name"),s=i.getAttribute("type");if(s&&(s=s.toLowerCase()),!(typeof t>"u"||t===null))if(i.tagName==="SELECT"&&i.hasAttribute("multiple"))for(let l of i.options)l.selected&&e.append(t,l.value);else(!s||s!=="checkbox"&&s!=="radio"||i.checked)&&e.append(t,i.value)}}_updateFilesUploadProgress(e,i,t){if(e[0].upload.chunked){let s=e[0],l=this._getChunk(s,i);t?(l.progress=100*t.loaded/t.total,l.total=t.total,l.bytesSent=t.loaded):(l.progress=100,l.bytesSent=l.total),s.upload.progress=0,s.upload.total=0,s.upload.bytesSent=0;for(let a=0;a<s.upload.totalChunkCount;a++)s.upload.chunks[a]&&typeof s.upload.chunks[a].progress<"u"&&(s.upload.progress+=s.upload.chunks[a].progress,s.upload.total+=s.upload.chunks[a].total,s.upload.bytesSent+=s.upload.chunks[a].bytesSent);s.upload.progress=s.upload.progress/s.upload.totalChunkCount,this.emit("uploadprogress",s,s.upload.progress,s.upload.bytesSent)}else for(let s of e)s.upload.total&&s.upload.bytesSent&&s.upload.bytesSent==s.upload.total||(t?(s.upload.progress=100*t.loaded/t.total,s.upload.total=t.total,s.upload.bytesSent=t.loaded):(s.upload.progress=100,s.upload.bytesSent=s.upload.total),this.emit("uploadprogress",s,s.upload.progress,s.upload.bytesSent))}_finishedUploading(e,i,t){let s;if(e[0].status!==r.CANCELED&&i.readyState===4){if(i.responseType!=="arraybuffer"&&i.responseType!=="blob"&&(s=i.responseText,i.getResponseHeader("content-type")&&~i.getResponseHeader("content-type").indexOf("application/json")))try{s=JSON.parse(s)}catch(l){t=l,s="Invalid JSON response from server."}this._updateFilesUploadProgress(e,i),200<=i.status&&i.status<300?e[0].upload.chunked?e[0].upload.finishedChunkUpload(this._getChunk(e[0],i),s):this._finished(e,s,t):this._handleUploadError(e,i,s)}}_handleUploadError(e,i,t){if(e[0].status!==r.CANCELED){if(e[0].upload.chunked&&this.options.retryChunks){let s=this._getChunk(e[0],i);if(s.retries++<this.options.retryChunksLimit){this._uploadData(e,[s.dataBlock]);return}else console.warn("Retried this chunk too often. Giving up.")}this._errorProcessing(e,t||this.options.dictResponseError.replace("{{statusCode}}",i.status),i)}}submitRequest(e,i,t){if(e.readyState!=1){console.warn("Cannot send this request because the XMLHttpRequest.readyState is not OPENED.");return}if(this.options.binaryBody)if(t[0].upload.chunked){const s=this._getChunk(t[0],e);e.send(s.dataBlock.data)}else e.send(t[0]);else e.send(i)}_finished(e,i,t){for(let s of e)s.status=r.SUCCESS,this.emit("success",s,i,t),this.emit("complete",s);if(this.options.uploadMultiple&&(this.emit("successmultiple",e,i,t),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}_errorProcessing(e,i,t){for(let s of e)s.status=r.ERROR,this.emit("error",s,i,t),this.emit("complete",s);if(this.options.uploadMultiple&&(this.emit("errormultiple",e,i,t),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}static uuidv4(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}}r.initClass();r.options={};r.optionsForElement=function(n){if(n.getAttribute("id")&&typeof r.options<"u")return r.options[z(n.getAttribute("id"))]};r.instances=[];r.forElement=function(n){if(typeof n=="string"&&(n=document.querySelector(n)),(n!=null?n.dropzone:void 0)==null)throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return n.dropzone};r.discover=function(){let n;if(document.querySelectorAll)n=document.querySelectorAll(".dropzone");else{n=[];let e=i=>(()=>{let t=[];for(let s of i)/(^| )dropzone($| )/.test(s.className)?t.push(n.push(s)):t.push(void 0);return t})();e(document.getElementsByTagName("div")),e(document.getElementsByTagName("form"))}return(()=>{let e=[];for(let i of n)r.optionsForElement(i)!==!1?e.push(new r(i)):e.push(void 0);return e})()};r.isBrowserSupported=function(){return typeof Promise<"u"};r.dataURItoBlob=function(n){let e=atob(n.split(",")[1]),i=n.split(",")[0].split(":")[1].split(";")[0],t=new ArrayBuffer(e.length),s=new Uint8Array(t);for(let l=0,a=e.length,u=0<=a;u?l<=a:l>=a;u?l++:l--)s[l]=e.charCodeAt(l);return new Blob([t],{type:i})};const k=(n,e)=>n.filter(i=>i!==e).map(i=>i),z=n=>n.replace(/[\-_](\w)/g,e=>e.charAt(1).toUpperCase());r.createElement=function(n){let e=document.createElement("div");return e.innerHTML=n,e.childNodes[0]};r.elementInside=function(n,e){if(n===e)return!0;for(;n=n.parentNode;)if(n===e)return!0;return!1};r.getElement=function(n,e){let i;if(typeof n=="string"?i=document.querySelector(n):n.nodeType!=null&&(i=n),i==null)throw new Error(`Invalid \`${e}\` option provided. Please provide a CSS selector or a plain HTML element.`);return i};r.getElements=function(n,e){let i,t;if(n instanceof Array){t=[];try{for(i of n)t.push(this.getElement(i,e))}catch{t=null}}else if(typeof n=="string"){t=[];for(i of document.querySelectorAll(n))t.push(i)}else n.nodeType!=null&&(t=[n]);if(t==null||!t.length)throw new Error(`Invalid \`${e}\` option provided. Please provide a CSS selector, a plain HTML element or a list of those.`);return t};r.confirm=function(n,e,i){if(window.confirm(n))return e();if(i!=null)return i()};r.isValidFile=function(n,e){if(!e)return!0;e=e.split(",");let i=n.type,t=i.replace(/\/.*$/,"");for(let s of e)if(s=s.trim(),s.charAt(0)==="."){if(n.name.toLowerCase().indexOf(s.toLowerCase(),n.name.length-s.length)!==-1)return!0}else if(/\/\*$/.test(s)){if(t===s.replace(/\/.*$/,""))return!0}else if(i===s)return!0;return!1};typeof jQuery<"u"&&jQuery!==null&&(jQuery.fn.dropzone=function(n){return this.each(function(){return new r(this,n)})});r.ADDED="added";r.QUEUED="queued";r.ACCEPTED=r.QUEUED;r.UPLOADING="uploading";r.PROCESSING=r.UPLOADING;r.CANCELED="canceled";r.ERROR="error";r.SUCCESS="success";let b=function(n){let e=n.naturalHeight,i=document.createElement("canvas");i.width=1,i.height=e;let t=i.getContext("2d");t.drawImage(n,0,0);let{data:s}=t.getImageData(1,0,1,e),l=0,a=e,u=e;for(;u>l;)s[(u-1)*4+3]===0?a=u:l=u,u=a+l>>1;let d=u/e;return d===0?1:d};var L=function(n,e,i,t,s,l,a,u,d,o){let h=b(e);return n.drawImage(e,i,t,s,l,a,u,d,o/h)};function U(n){var e="data:image/jpeg;base64,";if(!n.startsWith(e))return n;var i=window.atob(n.slice(e.length));if(!i.startsWith("ÿØÿ"))return n;for(var t=0,s="";t<i.length;)if(i.slice(t,t+2)=="ÿÚ"){s+=i.slice(t);break}else if(i.slice(t,t+2)=="ÿØ")s+=i.slice(t,t+2),t+=2;else{var l=i.charCodeAt(t+2)*256+i.charCodeAt(t+3),a=t+l+2,u=i.slice(t,a);u.startsWith("ÿá")||(s+=u),t=a}return e+window.btoa(s)}function A(n,e){var i="data:image/jpeg;base64,";if(!(n.startsWith(i)&&e.startsWith(i)))return e;var t=window.atob(n.slice(i.length));if(!t.startsWith("ÿØÿ"))return e;for(var s=0,l="";s<t.length&&t.slice(s,s+2)!="ÿÚ";)if(t.slice(s,s+2)=="ÿØ")s+=2;else{var a=t.charCodeAt(s+2)*256+t.charCodeAt(s+3),u=s+a+2,d=t.slice(s,u);d.startsWith("ÿá")&&(l+=d),s=u}if(l=="")return e;var o=window.atob(e.slice(i.length));if(!o.startsWith("ÿØÿ"))return e;var h=4+o.charCodeAt(4)*256+o.charCodeAt(5);return o=o.slice(0,h)+l+o.slice(h),i+window.btoa(o)}function S(n,e){return typeof n<"u"&&n!==null?e(n):void 0}function T(n,e,i){if(typeof n<"u"&&n!==null&&typeof n[e]=="function")return i(n,e)}export{r as Dropzone,r as default};
|
|
22
|
+
</body></html>`;let C={url:null,method:"post",withCredentials:!1,timeout:null,parallelUploads:2,uploadMultiple:!1,chunking:!1,forceChunking:!1,chunkSize:2097152,parallelChunkUploads:!1,retryChunks:!1,retryChunksLimit:3,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:120,thumbnailHeight:120,thumbnailMethod:"crop",resizeWidth:null,resizeHeight:null,resizeMimeType:null,resizeQuality:.8,resizeMethod:"contain",filesizeBase:1e3,maxFiles:null,headers:null,defaultHeaders:!0,clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,autoProcessQueue:!0,autoQueue:!0,addRemoveLinks:!1,previewsContainer:null,disablePreviews:!1,hiddenInputContainer:"body",capture:null,renameFilename:null,renameFile:null,forceFallback:!1,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictUploadCanceled:"Upload canceled.",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You cannot upload any more files.",dictFileSizeUnits:{tb:"TB",gb:"GB",mb:"MB",kb:"KB",b:"b"},init(){},params(n,e,i){if(i)return{dzuuid:i.file.upload.uuid,dzchunkindex:i.index,dztotalfilesize:i.file.size,dzchunksize:this.options.chunkSize,dztotalchunkcount:i.file.upload.totalChunkCount,dzchunkbyteoffset:i.index*this.options.chunkSize}},accept(n,e){return e()},chunksUploaded:function(n,e){e()},binaryBody:!1,fallback(){let n;this.element.className=`${this.element.className} dz-browser-not-supported`;for(let i of this.element.getElementsByTagName("div"))if(/(^| )dz-message($| )/.test(i.className)){n=i,i.className="dz-message";break}n||(n=r.createElement('<div class="dz-message"><span></span></div>'),this.element.appendChild(n));let e=n.getElementsByTagName("span")[0];return e&&(e.textContent!=null?e.textContent=this.options.dictFallbackMessage:e.innerText!=null&&(e.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize(n,e,i,t){let s={srcX:0,srcY:0,srcWidth:n.width,srcHeight:n.height},l=n.width/n.height;e==null&&i==null?(e=s.srcWidth,i=s.srcHeight):e==null?e=i*l:i==null&&(i=e/l),e=Math.min(e,s.srcWidth),i=Math.min(i,s.srcHeight);let a=e/i;if(s.srcWidth>e||s.srcHeight>i)if(t==="crop")l>a?(s.srcHeight=n.height,s.srcWidth=s.srcHeight*a):(s.srcWidth=n.width,s.srcHeight=s.srcWidth/a);else if(t==="contain")l>a?i=e/l:e=i*l;else throw new Error(`Unknown resizeMethod '${t}'`);return s.srcX=(n.width-s.srcWidth)/2,s.srcY=(n.height-s.srcHeight)/2,s.trgWidth=e,s.trgHeight=i,s},transformFile(n,e){return(this.options.resizeWidth||this.options.resizeHeight)&&n.type.match(/image.*/)?this.resizeImage(n,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,e):e(n)},previewTemplate:E(F),drop(n){return this.element.classList.remove("dz-drag-hover")},dragstart(n){},dragend(n){return this.element.classList.remove("dz-drag-hover")},dragenter(n){return this.element.classList.add("dz-drag-hover")},dragover(n){return this.element.classList.add("dz-drag-hover")},dragleave(n){return this.element.classList.remove("dz-drag-hover")},paste(n){},reset(){return this.element.classList.remove("dz-started")},addedfile(n){if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer&&!this.options.disablePreviews){n.previewElement=r.createElement(this.options.previewTemplate.trim()),n.previewTemplate=n.previewElement,this.previewsContainer.appendChild(n.previewElement);for(var e of n.previewElement.querySelectorAll("[data-dz-name]"))e.textContent=n.name;for(e of n.previewElement.querySelectorAll("[data-dz-size]"))e.innerHTML=this.filesize(n.size);this.options.addRemoveLinks&&(n._removeLink=r.createElement(`<a class="dz-remove" href="javascript:undefined;" data-dz-remove>${this.options.dictRemoveFile}</a>`),n.previewElement.appendChild(n._removeLink));let i=t=>(t.preventDefault(),t.stopPropagation(),n.status===r.UPLOADING?this.options.dictCancelUploadConfirmation?r.confirm(this.options.dictCancelUploadConfirmation,()=>this.removeFile(n)):this.removeFile(n):this.options.dictRemoveFileConfirmation?r.confirm(this.options.dictRemoveFileConfirmation,()=>this.removeFile(n)):this.removeFile(n));for(let t of n.previewElement.querySelectorAll("[data-dz-remove]"))t.addEventListener("click",i)}},removedfile(n){return n.previewElement!=null&&n.previewElement.parentNode!=null&&n.previewElement.parentNode.removeChild(n.previewElement),this._updateMaxFilesReachedClass()},thumbnail(n,e){if(n.previewElement){n.previewElement.classList.remove("dz-file-preview");for(let i of n.previewElement.querySelectorAll("[data-dz-thumbnail]"))i.alt=n.name,i.src=e;return setTimeout(()=>n.previewElement.classList.add("dz-image-preview"),1)}},error(n,e){if(n.previewElement){n.previewElement.classList.add("dz-error"),typeof e!="string"&&e.error&&(e=e.error);for(let i of n.previewElement.querySelectorAll("[data-dz-errormessage]"))i.textContent=e}},errormultiple(){},processing(n){if(n.previewElement&&(n.previewElement.classList.add("dz-processing"),n._removeLink))return n._removeLink.innerHTML=this.options.dictCancelUpload},processingmultiple(){},uploadprogress(n,e,i){if(n.previewElement)for(let t of n.previewElement.querySelectorAll("[data-dz-uploadprogress]"))t.nodeName==="PROGRESS"?t.value=e:t.style.width=`${e}%`},totaluploadprogress(){},sending(){},sendingmultiple(){},success(n){if(n.previewElement)return n.previewElement.classList.add("dz-success")},successmultiple(){},canceled(n){return this.emit("error",n,this.options.dictUploadCanceled)},canceledmultiple(){},complete(n){if(n._removeLink&&(n._removeLink.innerHTML=this.options.dictRemoveFile),n.previewElement)return n.previewElement.classList.add("dz-complete")},completemultiple(){},maxfilesexceeded(){},maxfilesreached(){},queuecomplete(){},addedfiles(){},emptyfolder(){}};var w=C;class r extends v{static initClass(){this.prototype.Emitter=v,this.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","addedfiles","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded","maxfilesreached","queuecomplete","emptyfolder"],this.prototype._thumbnailQueue=[],this.prototype._processingThumbnail=!1}constructor(e,i){super();let t,s;if(this.element=e,this.clickableElements=[],this.listeners=[],this.files=[],typeof this.element=="string"&&(this.element=document.querySelector(this.element)),this.element===null||!this.element instanceof HTMLElement)throw new Error("Invalid dropzone element: not an instance of HTMLElement.");if(this.element.dropzone)throw new Error("Dropzone already attached.");r.instances.push(this),this.element.dropzone=this;let l=(s=r.optionsForElement(this.element))!=null?s:{};if(this.options=Object.assign({},w,l,i??{}),this.options.previewTemplate=this.options.previewTemplate.replace(/\n*/g,""),this.options.forceFallback||!r.isBrowserSupported())return this.options.fallback.call(this);if(this.options.url==null&&(this.options.url=this.element.getAttribute("action")),!this.options.url)throw new Error("No URL provided.");if(this.options.uploadMultiple&&this.options.chunking)throw new Error("You cannot set both: uploadMultiple and chunking.");if(this.options.binaryBody&&this.options.uploadMultiple)throw new Error("You cannot set both: binaryBody and uploadMultiple.");typeof this.options.method=="string"&&(this.options.method=this.options.method.toUpperCase()),(t=this.getExistingFallback())&&t.parentNode&&t.parentNode.removeChild(t),this.options.previewsContainer!==!1&&(this.options.previewsContainer?this.previewsContainer=r.getElement(this.options.previewsContainer,"previewsContainer"):this.previewsContainer=this.element),this.options.clickable&&(this.options.clickable===!0?this.clickableElements=[this.element]:this.clickableElements=r.getElements(this.options.clickable,"clickable")),this.init()}getAcceptedFiles(){return this.files.filter(e=>e.accepted).map(e=>e)}getRejectedFiles(){return this.files.filter(e=>!e.accepted).map(e=>e)}getFilesWithStatus(e){return this.files.filter(i=>i.status===e).map(i=>i)}getQueuedFiles(){return this.getFilesWithStatus(r.QUEUED)}getUploadingFiles(){return this.getFilesWithStatus(r.UPLOADING)}getAddedFiles(){return this.getFilesWithStatus(r.ADDED)}getActiveFiles(){return this.files.filter(e=>e.status===r.UPLOADING||e.status===r.QUEUED).map(e=>e)}init(){if(this.element.tagName==="form"&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(r.createElement(`<div class="dz-default dz-message"><button class="dz-button" type="button">${this.options.dictDefaultMessage}</button></div>`)),this.clickableElements.length){let t=()=>{this.hiddenFileInput&&this.hiddenFileInput.parentNode?.removeChild(this.hiddenFileInput),this.hiddenFileInput=document.createElement("input"),this.hiddenFileInput.setAttribute("type","file"),this.hiddenFileInput.setAttribute("form",this.element.id),(this.options.maxFiles===null||this.options.maxFiles>1)&&this.hiddenFileInput.setAttribute("multiple","multiple"),this.hiddenFileInput.className="dz-hidden-input",this.options.acceptedFiles!==null&&this.hiddenFileInput.setAttribute("accept",this.options.acceptedFiles),this.options.capture!==null&&this.hiddenFileInput.setAttribute("capture",this.options.capture),this.hiddenFileInput.setAttribute("tabindex","-1"),this.hiddenFileInput.setAttribute("aria-label","dropzone hidden input"),this.hiddenFileInput.style.visibility="hidden",this.hiddenFileInput.style.position="absolute",this.hiddenFileInput.style.top="0",this.hiddenFileInput.style.left="0",this.hiddenFileInput.style.height="0",this.hiddenFileInput.style.width="0",r.getElement(this.options.hiddenInputContainer,"hiddenInputContainer").appendChild(this.hiddenFileInput),this.hiddenFileInput.addEventListener("change",()=>{let{files:s}=this.hiddenFileInput;if(s.length)for(let l of s)this.addFile(l);this.emit("addedfiles",s),t()})};t()}this.URL=window.URL!==null?window.URL:window.webkitURL;for(let t of this.events)this.on(t,this.options[t]);this.on("uploadprogress",()=>this.updateTotalUploadProgress()),this.on("removedfile",()=>this.updateTotalUploadProgress()),this.on("canceled",t=>this.emit("complete",t)),this.on("complete",t=>{if(this.getAddedFiles().length===0&&this.getUploadingFiles().length===0&&this.getQueuedFiles().length===0)return setTimeout(()=>this.emit("queuecomplete"),0)});const e=function(t){return t.dataTransfer.types&&t.dataTransfer.types.includes("Files")};let i=function(t){if(e(t))return t.stopPropagation(),t.preventDefault()};return this.listeners=[{element:this.element,events:{dragstart:t=>this.emit("dragstart",t),dragenter:t=>(i(t),this.emit("dragenter",t)),dragover:t=>{const s=t.dataTransfer.effectAllowed;return t.dataTransfer.dropEffect=s==="move"||s==="linkMove"?"move":"copy",i(t),this.emit("dragover",t)},dragleave:t=>this.emit("dragleave",t),drop:t=>(i(t),this.drop(t)),dragend:t=>this.emit("dragend",t)}}],this.clickableElements.forEach(t=>this.listeners.push({element:t,events:{click:s=>((t!==this.element||s.target===this.element||r.elementInside(s.target,this.element.querySelector(".dz-message")))&&this.hiddenFileInput.click(),!0)}})),this.enable(),this.options.init.call(this)}destroy(){return this.disable(),this.removeAllFiles(!0),this.hiddenFileInput!=null&&this.hiddenFileInput.parentNode&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,r.instances.splice(r.instances.indexOf(this),1)}updateTotalUploadProgress(){let e,i=0,t=0;if(this.getActiveFiles().length){for(let l of this.getActiveFiles())i+=l.upload.bytesSent,t+=l.upload.total;e=100*i/t}else e=100;return this.emit("totaluploadprogress",e,t,i)}_getParamName(e){return typeof this.options.paramName=="function"?this.options.paramName(e):`${this.options.paramName}${this.options.uploadMultiple?`[${e}]`:""}`}_renameFile(e){const i={...e,name:e.name.replace(/\u202F/g," ")};return typeof this.options.renameFile!="function"?i.name:this.options.renameFile(i)}getFallbackForm(){let e,i;if(e=this.getExistingFallback())return e;let t='<div class="dz-fallback">';this.options.dictFallbackText&&(t+=`<p>${this.options.dictFallbackText}</p>`),t+=`<input type="file" name="${this._getParamName(0)}" ${this.options.uploadMultiple?'multiple="multiple"':void 0} /><input type="submit" value="Upload!"></div>`;let s=r.createElement(t);return this.element.tagName!=="FORM"?(i=r.createElement(`<form action="${this.options.url}" enctype="multipart/form-data" method="${this.options.method}"></form>`),i.appendChild(s)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),i??s}getExistingFallback(){let e=function(t){for(let s of t)if(/(^| )fallback($| )/.test(s.className))return s};for(let t of["div","form"]){var i;if(i=e(this.element.getElementsByTagName(t)))return i}}setupEventListeners(){return this.listeners.map(e=>(()=>{let i=[];for(let t in e.events){let s=e.events[t];i.push(e.element.addEventListener(t,s,!1))}return i})())}removeEventListeners(){return this.listeners.map(e=>(()=>{let i=[];for(let t in e.events){let s=e.events[t];i.push(e.element.removeEventListener(t,s,!1))}return i})())}disable(){return this.clickableElements.forEach(e=>e.classList.remove("dz-clickable")),this.removeEventListeners(),this.disabled=!0,this.files.map(e=>this.cancelUpload(e))}enable(){return delete this.disabled,this.clickableElements.forEach(e=>e.classList.add("dz-clickable")),this.setupEventListeners()}filesize(e){let i=0,t="b";if(e>0){let s=["tb","gb","mb","kb","b"];for(let l=0;l<s.length;l++){let a=s[l],u=Math.pow(this.options.filesizeBase,4-l)/10;if(e>=u){i=e/Math.pow(this.options.filesizeBase,4-l),t=a;break}}i=Math.round(10*i)/10}return`<strong>${i}</strong> ${this.options.dictFileSizeUnits[t]}`}_updateMaxFilesReachedClass(){return this.options.maxFiles!=null&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}drop(e){if(!e.dataTransfer)return;this.emit("drop",e);let i=[];for(let t=0;t<e.dataTransfer.files.length;t++)i[t]=e.dataTransfer.files[t];if(i.length){let{items:t}=e.dataTransfer;t&&t.length&&t[0].webkitGetAsEntry!=null?this._addFilesFromItems(t):this.handleFiles(i)}this.emit("addedfiles",i)}paste(e){if(S(e?.clipboardData,t=>t.items)==null)return;this.emit("paste",e);let{items:i}=e.clipboardData;if(i.length)return this._addFilesFromItems(i)}handleFiles(e){for(let i of e)this.addFile(i)}_addFilesFromItems(e){return(()=>{let i=[];for(let s of e){var t;s.webkitGetAsEntry!=null&&(t=s.webkitGetAsEntry())?t.isFile?i.push(this.addFile(s.getAsFile())):t.isDirectory?i.push(this._addFilesFromDirectory(t,t.name)):i.push(void 0):s.getAsFile!=null&&(s.kind==null||s.kind==="file")?i.push(this.addFile(s.getAsFile())):i.push(void 0)}return i})()}_addFilesFromDirectory(e,i){let t=e.createReader(),s=u=>T(console,"log",d=>d.log(u)),l=0;var a=()=>t.readEntries(u=>{if(u.length>0){for(let d of u)d.isFile?(++l,d.file(o=>{if(!(this.options.ignoreHiddenFiles&&o.name.substring(0,1)==="."))return o.fullPath=`${i}/${o.name}`,this.addFile(o)})):d.isDirectory&&this._addFilesFromDirectory(d,`${i}/${d.name}`);a()}else l===0&&this.emit("emptyfolder",i);return null},s);return a()}accept(e,i){this.options.maxFilesize&&e.size>this.options.maxFilesize*1048576?i(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(e.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):r.isValidFile(e,this.options.acceptedFiles)?this.options.maxFiles!=null&&this.getAcceptedFiles().length>=this.options.maxFiles?(i(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",e)):this.options.accept.call(this,e,i):i(this.options.dictInvalidFileType)}addFile(e){e.upload={uuid:window.isSecureContext?self.crypto.randomUUID():r.uuidv4(),progress:0,total:e.size,bytesSent:0,filename:this._renameFile(e)},this.files.push(e),e.status=r.ADDED,this.emit("addedfile",e),this._enqueueThumbnail(e),this.accept(e,i=>{i?(e.accepted=!1,this._errorProcessing([e],i)):(e.accepted=!0,this.options.autoQueue&&this.enqueueFile(e)),this._updateMaxFilesReachedClass()})}enqueueFiles(e){for(let i of e)this.enqueueFile(i);return null}enqueueFile(e){if(e.status===r.ADDED&&e.accepted===!0){if(e.status=r.QUEUED,this.options.autoProcessQueue)return setTimeout(()=>this.processQueue(),0)}else throw new Error("This file can't be queued because it has already been processed or was rejected.")}_enqueueThumbnail(e){if(this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=this.options.maxThumbnailFilesize*1048576)return this._thumbnailQueue.push(e),setTimeout(()=>this._processThumbnailQueue(),0)}_processThumbnailQueue(){if(this._processingThumbnail||this._thumbnailQueue.length===0)return;this._processingThumbnail=!0;let e=this._thumbnailQueue.shift();return this.createThumbnail(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,i=>(this.emit("thumbnail",e,i),this._processingThumbnail=!1,this._processThumbnailQueue()))}removeFile(e){if(e.status===r.UPLOADING&&this.cancelUpload(e),this.files=k(this.files,e),this.emit("removedfile",e),this.files.length===0)return this.emit("reset")}removeAllFiles(e){e==null&&(e=!1);for(let i of this.files.slice())(i.status!==r.UPLOADING||e)&&this.removeFile(i);return null}resizeImage(e,i,t,s,l){return this.createThumbnail(e,i,t,s,!0,(a,u)=>{if(u==null)return l(e);{let{resizeMimeType:d}=this.options;d==null&&(d=e.type);let o=u.toDataURL(d,this.options.resizeQuality);return(d==="image/jpeg"||d==="image/jpg")&&(o=A(e.dataURL,o)),l(r.dataURItoBlob(o))}},!0)}createThumbnail(e,i,t,s,l,a,u=!1){let d=new FileReader;d.onload=()=>{if(e.dataURL=d.result,e.type==="image/svg+xml"){a?.(d.result);return}this.createThumbnailFromUrl(e,i,t,s,l,a,void 0,u)},d.readAsDataURL(e)}displayExistingFile(e,i,t,s,l=!0){if(this.emit("addedfile",e),this.emit("complete",e),!l)this.emit("thumbnail",e,i),t&&t();else{let a=u=>{this.emit("thumbnail",e,u),t&&t()};e.dataURL=i,this.createThumbnailFromUrl(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,this.options.fixOrientation,a,s)}}createThumbnailFromUrl(e,i,t,s,l,a,u,d=!1){let o=document.createElement("img");u&&(o.crossOrigin=u),l=getComputedStyle(document.body).imageOrientation=="from-image"?!1:l,o.onload=()=>{let g=f=>f(1);return typeof EXIF<"u"&&EXIF!==null&&l&&(g=f=>EXIF.getData(o,function(){return f(EXIF.getTag(this,"Orientation"))})),g(f=>{e.width=o.width,e.height=o.height;let p=this.options.resize.call(this,e,i,t,s),m=document.createElement("canvas"),c=m.getContext("2d");switch(m.width=p.trgWidth,m.height=p.trgHeight,f>4&&(m.width=p.trgHeight,m.height=p.trgWidth),f){case 2:c.translate(m.width,0),c.scale(-1,1);break;case 3:c.translate(m.width,m.height),c.rotate(Math.PI);break;case 4:c.translate(0,m.height),c.scale(1,-1);break;case 5:c.rotate(.5*Math.PI),c.scale(1,-1);break;case 6:c.rotate(.5*Math.PI),c.translate(0,-m.width);break;case 7:c.rotate(.5*Math.PI),c.translate(m.height,-m.width),c.scale(-1,1);break;case 8:c.rotate(-.5*Math.PI),c.translate(-m.height,0);break}L(c,o,p.srcX!=null?p.srcX:0,p.srcY!=null?p.srcY:0,p.srcWidth,p.srcHeight,p.trgX!=null?p.trgX:0,p.trgY!=null?p.trgY:0,p.trgWidth,p.trgHeight);let y=m.toDataURL("image/png");if(a!=null)return a(y,m)})},a!=null&&(o.onerror=a);var h=e.dataURL;return d&&(h=U(h)),o.src=h}processQueue(){let{parallelUploads:e}=this.options,i=this.getUploadingFiles().length,t=i;if(i>=e)return;let s=this.getQueuedFiles();if(s.length>0){if(this.options.uploadMultiple)return this.processFiles(s.slice(0,e-i));for(;t<e;){if(!s.length)return;this.processFile(s.shift()),t++}}}processFile(e){return this.processFiles([e])}processFiles(e){for(let i of e)i.processing=!0,i.status=r.UPLOADING,this.emit("processing",i);return this.options.uploadMultiple&&this.emit("processingmultiple",e),this.uploadFiles(e)}_getFilesWithXhr(e){return this.files.filter(i=>i.xhr===e).map(i=>i)}cancelUpload(e){if(e.status===r.UPLOADING){let i=this._getFilesWithXhr(e.xhr);for(let t of i)t.status=r.CANCELED;typeof e.xhr<"u"&&e.xhr.abort();for(let t of i)this.emit("canceled",t);this.options.uploadMultiple&&this.emit("canceledmultiple",i)}else(e.status===r.ADDED||e.status===r.QUEUED)&&(e.status=r.CANCELED,this.emit("canceled",e),this.options.uploadMultiple&&this.emit("canceledmultiple",[e]));if(this.options.autoProcessQueue)return this.processQueue()}resolveOption(e,...i){return typeof e=="function"?e.apply(this,i):e}uploadFile(e){return this.uploadFiles([e])}uploadFiles(e){this._transformFiles(e,i=>{if(this.options.chunking){let t=i[0];e[0].upload.chunked=this.options.chunking&&(this.options.forceChunking||t.size>this.options.chunkSize),e[0].upload.totalChunkCount=Math.ceil(t.size/this.options.chunkSize),t.size===0&&(e[0].upload.totalChunkCount=1)}if(e[0].upload.chunked){let t=e[0],s=i[0];t.upload.chunks=[];let l=()=>{let a=0;for(;t.upload.chunks[a]!==void 0;)a++;if(a>=t.upload.totalChunkCount)return;let u=a*this.options.chunkSize,d=Math.min(u+this.options.chunkSize,s.size),o={name:this._getParamName(0),data:s.webkitSlice?s.webkitSlice(u,d):s.slice(u,d),filename:t.upload.filename,chunkIndex:a};t.upload.chunks[a]={file:t,index:a,dataBlock:o,status:r.UPLOADING,progress:0,retries:0},this._uploadData(e,[o])};if(t.upload.finishedChunkUpload=(a,u)=>{let d=!0;a.status=r.SUCCESS,a.dataBlock=null,a.response=a.xhr.responseText,a.responseHeaders=a.xhr.getAllResponseHeaders(),a.xhr=null;for(let o=0;o<t.upload.totalChunkCount;o++){if(t.upload.chunks[o]===void 0)return l();t.upload.chunks[o].status!==r.SUCCESS&&(d=!1)}d&&this.options.chunksUploaded(t,()=>{this._finished(e,u,null)})},this.options.parallelChunkUploads){const a=Math.min(this.options.parallelChunkUploads===!0?this.options.parallelUploads:this.options.parallelChunkUploads,t.upload.totalChunkCount);for(let u=0;u<a;u++)l()}else l()}else{let t=[];for(let s=0;s<e.length;s++)t[s]={name:this._getParamName(s),data:i[s],filename:e[s].upload.filename};this._uploadData(e,t)}})}_getChunk(e,i){for(let t=0;t<e.upload.totalChunkCount;t++)if(e.upload.chunks[t]!==void 0&&e.upload.chunks[t].xhr===i)return e.upload.chunks[t]}_uploadData(e,i){let t=new XMLHttpRequest;for(let o of e)o.xhr=t;e[0].upload.chunked&&(e[0].upload.chunks[i[0].chunkIndex].xhr=t);let s=this.resolveOption(this.options.method,e,i),l=this.resolveOption(this.options.url,e,i);t.open(s,l,!0),this.resolveOption(this.options.timeout,e)&&(t.timeout=this.resolveOption(this.options.timeout,e)),t.withCredentials=!!this.options.withCredentials,t.onload=o=>{this._finishedUploading(e,t,o)},t.ontimeout=()=>{this._handleUploadError(e,t,`Request timedout after ${this.options.timeout/1e3} seconds`)},t.onerror=()=>{this._handleUploadError(e,t)};let u=t.upload!=null?t.upload:t;u.onprogress=o=>this._updateFilesUploadProgress(e,t,o);let d=this.options.defaultHeaders?{Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"}:{};this.options.binaryBody&&(d["Content-Type"]=e[0].type),this.options.headers&&Object.assign(d,this.options.headers);for(let o in d){let h=d[o];h&&t.setRequestHeader(o,h)}if(this.options.binaryBody){for(let o of e)this.emit("sending",o,t);this.options.uploadMultiple&&this.emit("sendingmultiple",e,t),this.submitRequest(t,null,e)}else{let o=new FormData;if(this.options.params){let h=this.options.params;typeof h=="function"&&(h=h.call(this,e,t,e[0].upload.chunked?this._getChunk(e[0],t):null));for(let g in h){let f=h[g];if(Array.isArray(f))for(let p=0;p<f.length;p++)o.append(g,f[p]);else o.append(g,f)}}for(let h of e)this.emit("sending",h,t,o);this.options.uploadMultiple&&this.emit("sendingmultiple",e,t,o),this._addFormElementData(o);for(let h=0;h<i.length;h++){let g=i[h];o.append(g.name,g.data,g.filename)}this.submitRequest(t,o,e)}}_transformFiles(e,i){let t=[],s=0;for(let l=0;l<e.length;l++)this.options.transformFile.call(this,e[l],a=>{t[l]=a,++s===e.length&&i(t)})}_addFormElementData(e){if(this.element.tagName==="FORM")for(let i of this.element.querySelectorAll("input, textarea, select, button")){let t=i.getAttribute("name"),s=i.getAttribute("type");if(s&&(s=s.toLowerCase()),!(typeof t>"u"||t===null))if(i.tagName==="SELECT"&&i.hasAttribute("multiple"))for(let l of i.options)l.selected&&e.append(t,l.value);else(!s||s!=="checkbox"&&s!=="radio"||i.checked)&&e.append(t,i.value)}}_updateFilesUploadProgress(e,i,t){if(e[0].upload.chunked){let s=e[0],l=this._getChunk(s,i);t?(l.progress=100*t.loaded/t.total,l.total=t.total,l.bytesSent=t.loaded):(l.progress=100,l.bytesSent=l.total),s.upload.progress=0,s.upload.total=0,s.upload.bytesSent=0;for(let a=0;a<s.upload.totalChunkCount;a++)s.upload.chunks[a]&&typeof s.upload.chunks[a].progress<"u"&&(s.upload.progress+=s.upload.chunks[a].progress,s.upload.total+=s.upload.chunks[a].total,s.upload.bytesSent+=s.upload.chunks[a].bytesSent);s.upload.progress=s.upload.progress/s.upload.totalChunkCount,this.emit("uploadprogress",s,s.upload.progress,s.upload.bytesSent)}else for(let s of e)s.upload.total&&s.upload.bytesSent&&s.upload.bytesSent==s.upload.total||(t?(s.upload.progress=100*t.loaded/t.total,s.upload.total=t.total,s.upload.bytesSent=t.loaded):(s.upload.progress=100,s.upload.bytesSent=s.upload.total),this.emit("uploadprogress",s,s.upload.progress,s.upload.bytesSent))}_finishedUploading(e,i,t){let s;if(e[0].status!==r.CANCELED&&i.readyState===4){if(i.responseType!=="arraybuffer"&&i.responseType!=="blob"&&(s=i.responseText,i.getResponseHeader("content-type")&&~i.getResponseHeader("content-type").indexOf("application/json")))try{s=JSON.parse(s)}catch(l){t=l,s="Invalid JSON response from server."}this._updateFilesUploadProgress(e,i),200<=i.status&&i.status<300?e[0].upload.chunked?e[0].upload.finishedChunkUpload(this._getChunk(e[0],i),s):this._finished(e,s,t):this._handleUploadError(e,i,s)}}_handleUploadError(e,i,t){if(e[0].status!==r.CANCELED){if(e[0].upload.chunked&&this.options.retryChunks){let s=this._getChunk(e[0],i);if(s.retries++<this.options.retryChunksLimit){this._uploadData(e,[s.dataBlock]);return}else console.warn("Retried this chunk too often. Giving up.")}this._errorProcessing(e,t||this.options.dictResponseError.replace("{{statusCode}}",i.status),i)}}submitRequest(e,i,t){if(e.readyState!=1){console.warn("Cannot send this request because the XMLHttpRequest.readyState is not OPENED.");return}if(this.options.binaryBody)if(t[0].upload.chunked){const s=this._getChunk(t[0],e);e.send(s.dataBlock.data)}else e.send(t[0]);else e.send(i)}_finished(e,i,t){for(let s of e)s.status=r.SUCCESS,this.emit("success",s,i,t),this.emit("complete",s);if(this.options.uploadMultiple&&(this.emit("successmultiple",e,i,t),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}_errorProcessing(e,i,t){for(let s of e)s.status=r.ERROR,this.emit("error",s,i,t),this.emit("complete",s);if(this.options.uploadMultiple&&(this.emit("errormultiple",e,i,t),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}static uuidv4(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}}r.initClass();r.options={};r.optionsForElement=function(n){if(n.getAttribute("id")&&typeof r.options<"u")return r.options[z(n.getAttribute("id"))]};r.instances=[];r.forElement=function(n){if(typeof n=="string"&&(n=document.querySelector(n)),n?.dropzone==null)throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return n.dropzone};r.discover=function(){let n;if(document.querySelectorAll)n=document.querySelectorAll(".dropzone");else{n=[];let e=i=>(()=>{let t=[];for(let s of i)/(^| )dropzone($| )/.test(s.className)?t.push(n.push(s)):t.push(void 0);return t})();e(document.getElementsByTagName("div")),e(document.getElementsByTagName("form"))}return(()=>{let e=[];for(let i of n)r.optionsForElement(i)!==!1?e.push(new r(i)):e.push(void 0);return e})()};r.isBrowserSupported=function(){return typeof Promise<"u"};r.dataURItoBlob=function(n){let e=atob(n.split(",")[1]),i=n.split(",")[0].split(":")[1].split(";")[0],t=new ArrayBuffer(e.length),s=new Uint8Array(t);for(let l=0,a=e.length,u=0<=a;u?l<=a:l>=a;u?l++:l--)s[l]=e.charCodeAt(l);return new Blob([t],{type:i})};const k=(n,e)=>n.filter(i=>i!==e).map(i=>i),z=n=>n.replace(/[\-_](\w)/g,e=>e.charAt(1).toUpperCase());r.createElement=function(n){let e=document.createElement("div");return e.innerHTML=n,e.childNodes[0]};r.elementInside=function(n,e){if(n===e)return!0;for(;n=n.parentNode;)if(n===e)return!0;return!1};r.getElement=function(n,e){let i;if(typeof n=="string"?i=document.querySelector(n):n.nodeType!=null&&(i=n),i==null)throw new Error(`Invalid \`${e}\` option provided. Please provide a CSS selector or a plain HTML element.`);return i};r.getElements=function(n,e){let i,t;if(n instanceof Array){t=[];try{for(i of n)t.push(this.getElement(i,e))}catch{t=null}}else if(typeof n=="string"){t=[];for(i of document.querySelectorAll(n))t.push(i)}else n.nodeType!=null&&(t=[n]);if(t==null||!t.length)throw new Error(`Invalid \`${e}\` option provided. Please provide a CSS selector, a plain HTML element or a list of those.`);return t};r.confirm=function(n,e,i){if(window.confirm(n))return e();if(i!=null)return i()};r.isValidFile=function(n,e){if(!e)return!0;e=e.split(",");let i=n.type,t=i.replace(/\/.*$/,"");for(let s of e)if(s=s.trim(),s.charAt(0)==="."){if(n.name.toLowerCase().indexOf(s.toLowerCase(),n.name.length-s.length)!==-1)return!0}else if(/\/\*$/.test(s)){if(t===s.replace(/\/.*$/,""))return!0}else if(i===s)return!0;return!1};typeof jQuery<"u"&&jQuery!==null&&(jQuery.fn.dropzone=function(n){return this.each(function(){return new r(this,n)})});r.ADDED="added";r.QUEUED="queued";r.ACCEPTED=r.QUEUED;r.UPLOADING="uploading";r.PROCESSING=r.UPLOADING;r.CANCELED="canceled";r.ERROR="error";r.SUCCESS="success";let b=function(n){let e=n.naturalHeight,i=document.createElement("canvas");i.width=1,i.height=e;let t=i.getContext("2d");t.drawImage(n,0,0);let{data:s}=t.getImageData(1,0,1,e),l=0,a=e,u=e;for(;u>l;)s[(u-1)*4+3]===0?a=u:l=u,u=a+l>>1;let d=u/e;return d===0?1:d};var L=function(n,e,i,t,s,l,a,u,d,o){let h=b(e);return n.drawImage(e,i,t,s,l,a,u,d,o/h)};function U(n){var e="data:image/jpeg;base64,";if(!n.startsWith(e))return n;var i=window.atob(n.slice(e.length));if(!i.startsWith("ÿØÿ"))return n;for(var t=0,s="";t<i.length;)if(i.slice(t,t+2)=="ÿÚ"){s+=i.slice(t);break}else if(i.slice(t,t+2)=="ÿØ")s+=i.slice(t,t+2),t+=2;else{var l=i.charCodeAt(t+2)*256+i.charCodeAt(t+3),a=t+l+2,u=i.slice(t,a);u.startsWith("ÿá")||(s+=u),t=a}return e+window.btoa(s)}function A(n,e){var i="data:image/jpeg;base64,";if(!(n.startsWith(i)&&e.startsWith(i)))return e;var t=window.atob(n.slice(i.length));if(!t.startsWith("ÿØÿ"))return e;for(var s=0,l="";s<t.length&&t.slice(s,s+2)!="ÿÚ";)if(t.slice(s,s+2)=="ÿØ")s+=2;else{var a=t.charCodeAt(s+2)*256+t.charCodeAt(s+3),u=s+a+2,d=t.slice(s,u);d.startsWith("ÿá")&&(l+=d),s=u}if(l=="")return e;var o=window.atob(e.slice(i.length));if(!o.startsWith("ÿØÿ"))return e;var h=4+o.charCodeAt(4)*256+o.charCodeAt(5);return o=o.slice(0,h)+l+o.slice(h),i+window.btoa(o)}function S(n,e){return typeof n<"u"&&n!==null?e(n):void 0}function T(n,e,i){if(typeof n<"u"&&n!==null&&typeof n[e]=="function")return i(n,e)}export{r as Dropzone,r as default};
|
package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__module as s}from"../../../../../../../_virtual/main2.js";import p from"../../../../../../../_virtual/___vite-browser-external.js";import{__require as d}from"../deps/dicer/lib/Dicer.js";import{__require as m}from"./types/multipart.js";import{__require as y}from"./types/urlencoded.js";import{__require as l}from"./utils/parseParams.js";var h;function x(){if(h)return s.exports;h=1;const o=p.Writable,{inherits:f}=p,u=d(),n=m(),a=y(),c=l();function t(e){if(!(this instanceof t))return new t(e);if(typeof e!="object")throw new TypeError("Busboy expected an options-Object.");if(typeof e.headers!="object")throw new TypeError("Busboy expected an options-Object with headers-attribute.");if(typeof e.headers["content-type"]!="string")throw new TypeError("Missing Content-Type-header.");const{headers:r,...i}=e;this.opts={autoDestroy:!1,...i},o.call(this,this.opts),this._done=!1,this._parser=this.getParserByHeaders(r),this._finished=!1}return f(t,o),t.prototype.emit=function(e){
|
|
1
|
+
import{__module as s}from"../../../../../../../_virtual/main2.js";import p from"../../../../../../../_virtual/___vite-browser-external.js";import{__require as d}from"../deps/dicer/lib/Dicer.js";import{__require as m}from"./types/multipart.js";import{__require as y}from"./types/urlencoded.js";import{__require as l}from"./utils/parseParams.js";var h;function x(){if(h)return s.exports;h=1;const o=p.Writable,{inherits:f}=p,u=d(),n=m(),a=y(),c=l();function t(e){if(!(this instanceof t))return new t(e);if(typeof e!="object")throw new TypeError("Busboy expected an options-Object.");if(typeof e.headers!="object")throw new TypeError("Busboy expected an options-Object with headers-attribute.");if(typeof e.headers["content-type"]!="string")throw new TypeError("Missing Content-Type-header.");const{headers:r,...i}=e;this.opts={autoDestroy:!1,...i},o.call(this,this.opts),this._done=!1,this._parser=this.getParserByHeaders(r),this._finished=!1}return f(t,o),t.prototype.emit=function(e){if(e==="finish"){if(this._done){if(this._finished)return}else{this._parser?.end();return}this._finished=!0}o.prototype.emit.apply(this,arguments)},t.prototype.getParserByHeaders=function(e){const r=c(e["content-type"]),i={defCharset:this.opts.defCharset,fileHwm:this.opts.fileHwm,headers:e,highWaterMark:this.opts.highWaterMark,isPartAFile:this.opts.isPartAFile,limits:this.opts.limits,parsedConType:r,preservePath:this.opts.preservePath};if(n.detect.test(r[0]))return new n(this,i);if(a.detect.test(r[0]))return new a(this,i);throw new Error("Unsupported Content-Type.")},t.prototype._write=function(e,r,i){this._parser.write(e,i)},s.exports=t,s.exports.default=t,s.exports.Busboy=t,s.exports.Dicer=u,s.exports}export{x as __require};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__exports as n}from"../../../../../../../../_virtual/fetch.js";import{__require as E}from"../../../../../../undici@5.29.0/node_modules/undici/index.js";var x;function g(){if(x)return n;x=1;var i={};Object.defineProperty(n,"__esModule",{value:!0}),n.request=n.isFetchError=void 0,n.getProxyUrl=f;const c=E();class u extends Error{constructor(t,r){super(),this.response=t,this.data=r}}const P=e=>e instanceof u;n.isFetchError=P;function f(){return i.HTTPS_PROXY||i.HTTP_PROXY||i.https_proxy||i.http_proxy}const h=f(),p=h?new c.ProxyAgent({uri:h}):void 0;p&&(0,c.setGlobalDispatcher)(p);async function a(e,t,r={},d){const _=new URL(e);r?.query&&Object.entries(r.query).forEach(([o,l])=>{_.searchParams.append(o,l)}),e=_.toString(),d&&(r.body=JSON.stringify(d));const s=await fetch(e,{...r,method:t});if(!s.ok){let o;try{o=await s.json()}catch{o=void 0}throw new u(s,o)}const y=await s.text(),q=y?JSON.parse(y):{};return{response:s,data:q}}return n.request={get:(e,t={})=>a(e,"GET",t),post:(e,t,r={})=>a(e,"POST",r,t),put:(e,t,r={})=>a(e,"PUT",r,t),delete:(e,t,r={})=>a(e,"DELETE",r,t)},n}export{g as __require};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__exports as t}from"../../../../../../../../_virtual/figma_rest_api.js";import{__require as f}from"../common/fetch.js";import{__require as d}from"../common/logging.js";import l from"../../package.json.js";var g;function A(){if(g)return t;g=1,Object.defineProperty(t,"__esModule",{value:!0}),t.FigmaRestApi=void 0,t.getApiUrl=u,t.getHeaders=n,t.getDocument=c;const a=f(),r=d(),m=l.version;function u(o){return"https://api.figma.com/v1"}function n(o){return{"X-Figma-Token":o,"Content-Type":"application/json","User-Agent":`code-connect-cli/${m}`}}var s;(function(o){(function(i){i.Boolean="BOOLEAN",i.InstanceSwap="INSTANCE_SWAP",i.Text="TEXT",i.Variant="VARIANT"})(o.ComponentPropertyType||(o.ComponentPropertyType={}))})(s||(t.FigmaRestApi=s={}));async function c(o,i){try{r.logger.info("Fetching component information from Figma...");const e=await a.request.get(o,{headers:n(i)});return e.response.status===200?(r.logger.info("Successfully fetched component information from Figma"),e.data.document):(r.logger.error(`Failed to get node information from Figma with status: ${e.response.status}`),r.logger.debug("Failed to get node information from Figma with Body:",e.data),Promise.reject())}catch(e){return(0,a.isFetchError)(e)?(e.response?r.logger.error(`Failed to get node data from Figma (${e.response.status}): ${e.response.status} ${e.data?.err??e.data?.message}`):r.logger.error(`Failed to get node data from Figma: ${e.message}`),r.logger.debug(JSON.stringify(e.data))):r.logger.error(`Failed to create: ${e}`),Promise.reject()}}return t}export{A as __require};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__exports as a}from"../../../../../../../../_virtual/helpers.js";import U from"../../../../../../../../_virtual/___vite-browser-external.js";import{__require as j}from"../common/logging.js";var g;function $(){return g?a:(g=1,function(i){var m={},_=a&&a.__createBinding||(Object.create?function(e,n,r,o){o===void 0&&(o=r);var t=Object.getOwnPropertyDescriptor(n,r);(!t||("get"in t?!n.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,o,t)}:function(e,n,r,o){o===void 0&&(o=r),e[o]=n[r]}),h=a&&a.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),v=a&&a.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&_(n,e,r);return h(n,e),n};Object.defineProperty(i,"__esModule",{value:!0}),i.validateNodeId=void 0,i.isComponent=f,i.parseNodeIds=b,i.parseFileKey=O,i.findComponentsInDocument=P,i.figmaUrlOfComponent=C,i.normalizePropName=M,i.exitWithFeedbackMessage=p;const I=v(U),l=j(),N=/^I?[0-9]+:[0-9]+(;[0-9]+:[0-9]+)*$/;function f(e){return e.type==="COMPONENT"||e.type==="COMPONENT_SET"}const y=function(e){const n=e.replace("-",":");return N.test(n)||(l.logger.error(`Invalid figma node URL: the provided node-id "${e}" is invalid`),p(1)),n};i.validateNodeId=y;function b(e){const n=[];for(const r of e){const t=I.parse(r,!0).query["node-id"];if(t&&typeof t=="string"){const d=(0,i.validateNodeId)(t);n.push(d)}else if(Array.isArray(t))for(const d of t){const s=(0,i.validateNodeId)(d);n.push(s)}}return n}function O(e){
|
|
1
|
+
import{__exports as a}from"../../../../../../../../_virtual/helpers.js";import U from"../../../../../../../../_virtual/___vite-browser-external.js";import{__require as j}from"../common/logging.js";var g;function $(){return g?a:(g=1,function(i){var m={},_=a&&a.__createBinding||(Object.create?function(e,n,r,o){o===void 0&&(o=r);var t=Object.getOwnPropertyDescriptor(n,r);(!t||("get"in t?!n.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,o,t)}:function(e,n,r,o){o===void 0&&(o=r),e[o]=n[r]}),h=a&&a.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),v=a&&a.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&_(n,e,r);return h(n,e),n};Object.defineProperty(i,"__esModule",{value:!0}),i.validateNodeId=void 0,i.isComponent=f,i.parseNodeIds=b,i.parseFileKey=O,i.findComponentsInDocument=P,i.figmaUrlOfComponent=C,i.normalizePropName=M,i.exitWithFeedbackMessage=p;const I=v(U),l=j(),N=/^I?[0-9]+:[0-9]+(;[0-9]+:[0-9]+)*$/;function f(e){return e.type==="COMPONENT"||e.type==="COMPONENT_SET"}const y=function(e){const n=e.replace("-",":");return N.test(n)||(l.logger.error(`Invalid figma node URL: the provided node-id "${e}" is invalid`),p(1)),n};i.validateNodeId=y;function b(e){const n=[];for(const r of e){const t=I.parse(r,!0).query["node-id"];if(t&&typeof t=="string"){const d=(0,i.validateNodeId)(t);n.push(d)}else if(Array.isArray(t))for(const d of t){const s=(0,i.validateNodeId)(d);n.push(s)}}return n}function O(e){return e.match(/(?:file|design)\/([a-zA-Z0-9]+)/)?.[1]}function P(e,n){const r=[],o=e.children;for(const t of o){if(t.type!=="CANVAS")continue;const d=t.id,s=t.name,u=t.children;for(;u.length>0;){const c=u.pop();if(n&&n.includes(c.id)){if(!f(c))throw new Error("Specified node is not a component or a component set");r.push({...c,pageId:d,pageName:s})}!n&&f(c)&&r.push({...c,pageId:d,pageName:s}),Array.isArray(c.children)&&!f(c)&&u.push(...c.children)}}return r}function C(e,n){const r=m.FILE_URL||"https://figma.com/file/",t=e.id.replace(":","-").replace(":","-");return`${r}${n}/?node-id=${t}`}function M(e){return e.replace(/#[0-9:]*/g,"")}function p(e){l.logger.info("Please raise any bugs or feedback at https://github.com/figma/code-connect/issues."),process.exit(e)}}(a),a)}export{$ as __require};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="1.3.4",o={version:e};export{o as default,e as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computePosition as ot,flip as st,autoPlacement as rt}from"../../../../../@floating-ui_core@1.7.2/node_modules/@floating-ui/core/dist/floating-ui.core.js";import{createCoords as w,rectToClientRect as J,floor as A,max as E,round as H,min as z}from"../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js";import{getOverflowAncestors as M,isElement as v,getDocumentElement as O,getWindow as L,getFrameElement as K,getComputedStyle as R,isHTMLElement as b,isWebKit as Q,isTopLayer as S,getParentNode as W,isLastTraversableNode as N,isTableElement as ct,isContainingBlock as Y,getContainingBlock as lt,getNodeName as _,isOverflowElement as P,getNodeScroll as I}from"../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js";function Z(t){const e=R(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const o=b(t),r=o?t.offsetWidth:n,s=o?t.offsetHeight:i,c=H(n)!==r||H(i)!==s;return c&&(n=r,i=s),{width:n,height:i,$:c}}function $(t){return v(t)?t:t.contextElement}function F(t){const e=$(t);if(!b(e))return w(1);const n=e.getBoundingClientRect(),{width:i,height:o,$:r}=Z(e);let s=(r?H(n.width):n.width)/i,c=(r?H(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const ft=w(0);function X(t){const e=L(t);return!Q()||!e.visualViewport?ft:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ut(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==L(t)?!1:e}function T(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),r=$(t);let s=w(1);e&&(i?v(i)&&(s=F(i)):s=F(t));const c=ut(r,n,i)?X(r):w(0);let l=(o.left+c.x)/s.x,f=(o.top+c.y)/s.y,u=o.width/s.x,h=o.height/s.y;if(r){const p=L(r),a=i&&v(i)?L(i):i;let x=p,g=K(x);for(;g&&i&&a!==x;){const m=F(g),d=g.getBoundingClientRect(),y=R(g),C=d.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,B=d.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;l*=m.x,f*=m.y,u*=m.x,h*=m.y,l+=C,f+=B,x=L(g),g=K(x)}}return J({width:u,height:h,x:l,y:f})}function q(t,e){const n=I(t).scrollLeft;return e?e.left+n:T(O(t)).left+n}function tt(t,e,n){n===void 0&&(n=!1);const i=t.getBoundingClientRect(),o=i.left+e.scrollLeft-(n?0:q(t,i)),r=i.top+e.scrollTop;return{x:o,y:r}}function ht(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t;const r=o==="fixed",s=O(i),c=e?S(e.floating):!1;if(i===s||c&&r)return n;let l={scrollLeft:0,scrollTop:0},f=w(1);const u=w(0),h=b(i);if((h||!h&&!r)&&((_(i)!=="body"||P(s))&&(l=I(i)),b(i))){const a=T(i);f=F(i),u.x=a.x+i.clientLeft,u.y=a.y+i.clientTop}const p=s&&!h&&!r?tt(s,l,!0):w(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-l.scrollLeft*f.x+u.x+p.x,y:n.y*f.y-l.scrollTop*f.y+u.y+p.y}}function at(t){return Array.from(t.getClientRects())}function dt(t){const e=O(t),n=I(t),i=t.ownerDocument.body,o=E(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=E(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-n.scrollLeft+q(t);const c=-n.scrollTop;return R(i).direction==="rtl"&&(s+=E(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:c}}function gt(t,e){const n=L(t),i=O(t),o=n.visualViewport;let r=i.clientWidth,s=i.clientHeight,c=0,l=0;if(o){r=o.width,s=o.height;const f=Q();(!f||f&&e==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}return{width:r,height:s,x:c,y:l}}const pt=new Set(["absolute","fixed"]);function mt(t,e){const n=T(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,r=b(t)?F(t):w(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,l=o*r.x,f=i*r.y;return{width:s,height:c,x:l,y:f}}function j(t,e,n){let i;if(e==="viewport")i=gt(t,n);else if(e==="document")i=dt(O(t));else if(v(e))i=mt(e,n);else{const o=X(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return J(i)}function et(t,e){const n=W(t);return n===e||!v(n)||N(n)?!1:R(n).position==="fixed"||et(n,e)}function wt(t,e){const n=e.get(t);if(n)return n;let i=M(t,[],!1).filter(c=>v(c)&&_(c)!=="body"),o=null;const r=R(t).position==="fixed";let s=r?W(t):t;for(;v(s)&&!N(s);){const c=R(s),l=Y(s);!l&&c.position==="fixed"&&(o=null),(r?!l&&!o:!l&&c.position==="static"&&!!o&&pt.has(o.position)||P(s)&&!l&&et(t,s))?i=i.filter(u=>u!==s):o=c,s=W(s)}return e.set(t,i),i}function xt(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t;const s=[...n==="clippingAncestors"?S(e)?[]:wt(e,this._c):[].concat(n),i],c=s[0],l=s.reduce((f,u)=>{const h=j(e,u,o);return f.top=E(h.top,f.top),f.right=z(h.right,f.right),f.bottom=z(h.bottom,f.bottom),f.left=E(h.left,f.left),f},j(e,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function yt(t){const{width:e,height:n}=Z(t);return{width:e,height:n}}function vt(t,e,n){const i=b(e),o=O(e),r=n==="fixed",s=T(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const l=w(0);function f(){l.x=q(o)}if(i||!i&&!r)if((_(e)!=="body"||P(o))&&(c=I(e)),i){const a=T(e,!0,r,e);l.x=a.x+e.clientLeft,l.y=a.y+e.clientTop}else o&&f();r&&!i&&o&&f();const u=o&&!i&&!r?tt(o,c):w(0),h=s.left+c.scrollLeft-l.x-u.x,p=s.top+c.scrollTop-l.y-u.y;return{x:h,y:p,width:s.width,height:s.height}}function V(t){return R(t).position==="static"}function G(t,e){if(!b(t)||R(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return O(t)===n&&(n=n.ownerDocument.body),n}function nt(t,e){const n=L(t);if(S(t))return n;if(!b(t)){let o=W(t);for(;o&&!N(o);){if(v(o)&&!V(o))return o;o=W(o)}return n}let i=G(t,e);for(;i&&ct(i)&&V(i);)i=G(i,e);return i&&N(i)&&V(i)&&!Y(i)?n:i||lt(t)||n}const Rt=async function(t){const e=this.getOffsetParent||nt,n=this.getDimensions,i=await n(t.floating);return{reference:vt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ot(t){return R(t).direction==="rtl"}const bt={convertOffsetParentRelativeRectToViewportRelativeRect:ht,getDocumentElement:O,getClippingRect:xt,getOffsetParent:nt,getElementRects:Rt,getClientRects:at,getDimensions:yt,getScale:F,isElement:v,isRTL:Ot};function it(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ct(t,e){let n=null,i;const o=O(t);function r(){var c;clearTimeout(i),(c=n)==null||c.disconnect(),n=null}function s(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),r();const f=t.getBoundingClientRect(),{left:u,top:h,width:p,height:a}=f;if(c||e(),!p||!a)return;const x=A(h),g=A(o.clientWidth-(u+p)),m=A(o.clientHeight-(h+a)),d=A(u),C={rootMargin:-x+"px "+-g+"px "+-m+"px "+-d+"px",threshold:E(0,z(1,l))||1};let B=!0;function k(U){const D=U[0].intersectionRatio;if(D!==l){if(!B)return s();D?s(!1,D):i=setTimeout(()=>{s(!1,1e-7)},1e3)}D===1&&!it(f,t.getBoundingClientRect())&&s(),B=!1}try{n=new IntersectionObserver(k,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,C)}n.observe(t)}return s(!0),r}function Ft(t,e,n,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,f=$(t),u=o||r?[...f?M(f):[],...M(e)]:[];u.forEach(d=>{o&&d.addEventListener("scroll",n,{passive:!0}),r&&d.addEventListener("resize",n)});const h=f&&c?Ct(f,n):null;let p=-1,a=null;s&&(a=new ResizeObserver(d=>{let[y]=d;y&&y.target===f&&a&&(a.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=a)==null||C.observe(e)})),n()}),f&&!l&&a.observe(f),a.observe(e));let x,g=l?T(t):null;l&&m();function m(){const d=T(t);g&&!it(g,d)&&n(),g=d,x=requestAnimationFrame(m)}return n(),()=>{var d;u.forEach(y=>{o&&y.removeEventListener("scroll",n),r&&y.removeEventListener("resize",n)}),h
|
|
1
|
+
import{computePosition as ot,flip as st,autoPlacement as rt}from"../../../../../@floating-ui_core@1.7.2/node_modules/@floating-ui/core/dist/floating-ui.core.js";import{createCoords as w,rectToClientRect as J,floor as A,max as E,round as H,min as z}from"../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js";import{getOverflowAncestors as M,isElement as v,getDocumentElement as O,getWindow as L,getFrameElement as K,getComputedStyle as R,isHTMLElement as b,isWebKit as Q,isTopLayer as S,getParentNode as W,isLastTraversableNode as N,isTableElement as ct,isContainingBlock as Y,getContainingBlock as lt,getNodeName as _,isOverflowElement as P,getNodeScroll as I}from"../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js";function Z(t){const e=R(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const o=b(t),r=o?t.offsetWidth:n,s=o?t.offsetHeight:i,c=H(n)!==r||H(i)!==s;return c&&(n=r,i=s),{width:n,height:i,$:c}}function $(t){return v(t)?t:t.contextElement}function F(t){const e=$(t);if(!b(e))return w(1);const n=e.getBoundingClientRect(),{width:i,height:o,$:r}=Z(e);let s=(r?H(n.width):n.width)/i,c=(r?H(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const ft=w(0);function X(t){const e=L(t);return!Q()||!e.visualViewport?ft:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ut(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==L(t)?!1:e}function T(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),r=$(t);let s=w(1);e&&(i?v(i)&&(s=F(i)):s=F(t));const c=ut(r,n,i)?X(r):w(0);let l=(o.left+c.x)/s.x,f=(o.top+c.y)/s.y,u=o.width/s.x,h=o.height/s.y;if(r){const p=L(r),a=i&&v(i)?L(i):i;let x=p,g=K(x);for(;g&&i&&a!==x;){const m=F(g),d=g.getBoundingClientRect(),y=R(g),C=d.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,B=d.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;l*=m.x,f*=m.y,u*=m.x,h*=m.y,l+=C,f+=B,x=L(g),g=K(x)}}return J({width:u,height:h,x:l,y:f})}function q(t,e){const n=I(t).scrollLeft;return e?e.left+n:T(O(t)).left+n}function tt(t,e,n){n===void 0&&(n=!1);const i=t.getBoundingClientRect(),o=i.left+e.scrollLeft-(n?0:q(t,i)),r=i.top+e.scrollTop;return{x:o,y:r}}function ht(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t;const r=o==="fixed",s=O(i),c=e?S(e.floating):!1;if(i===s||c&&r)return n;let l={scrollLeft:0,scrollTop:0},f=w(1);const u=w(0),h=b(i);if((h||!h&&!r)&&((_(i)!=="body"||P(s))&&(l=I(i)),b(i))){const a=T(i);f=F(i),u.x=a.x+i.clientLeft,u.y=a.y+i.clientTop}const p=s&&!h&&!r?tt(s,l,!0):w(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-l.scrollLeft*f.x+u.x+p.x,y:n.y*f.y-l.scrollTop*f.y+u.y+p.y}}function at(t){return Array.from(t.getClientRects())}function dt(t){const e=O(t),n=I(t),i=t.ownerDocument.body,o=E(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=E(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-n.scrollLeft+q(t);const c=-n.scrollTop;return R(i).direction==="rtl"&&(s+=E(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:c}}function gt(t,e){const n=L(t),i=O(t),o=n.visualViewport;let r=i.clientWidth,s=i.clientHeight,c=0,l=0;if(o){r=o.width,s=o.height;const f=Q();(!f||f&&e==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}return{width:r,height:s,x:c,y:l}}const pt=new Set(["absolute","fixed"]);function mt(t,e){const n=T(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,r=b(t)?F(t):w(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,l=o*r.x,f=i*r.y;return{width:s,height:c,x:l,y:f}}function j(t,e,n){let i;if(e==="viewport")i=gt(t,n);else if(e==="document")i=dt(O(t));else if(v(e))i=mt(e,n);else{const o=X(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return J(i)}function et(t,e){const n=W(t);return n===e||!v(n)||N(n)?!1:R(n).position==="fixed"||et(n,e)}function wt(t,e){const n=e.get(t);if(n)return n;let i=M(t,[],!1).filter(c=>v(c)&&_(c)!=="body"),o=null;const r=R(t).position==="fixed";let s=r?W(t):t;for(;v(s)&&!N(s);){const c=R(s),l=Y(s);!l&&c.position==="fixed"&&(o=null),(r?!l&&!o:!l&&c.position==="static"&&!!o&&pt.has(o.position)||P(s)&&!l&&et(t,s))?i=i.filter(u=>u!==s):o=c,s=W(s)}return e.set(t,i),i}function xt(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t;const s=[...n==="clippingAncestors"?S(e)?[]:wt(e,this._c):[].concat(n),i],c=s[0],l=s.reduce((f,u)=>{const h=j(e,u,o);return f.top=E(h.top,f.top),f.right=z(h.right,f.right),f.bottom=z(h.bottom,f.bottom),f.left=E(h.left,f.left),f},j(e,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function yt(t){const{width:e,height:n}=Z(t);return{width:e,height:n}}function vt(t,e,n){const i=b(e),o=O(e),r=n==="fixed",s=T(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const l=w(0);function f(){l.x=q(o)}if(i||!i&&!r)if((_(e)!=="body"||P(o))&&(c=I(e)),i){const a=T(e,!0,r,e);l.x=a.x+e.clientLeft,l.y=a.y+e.clientTop}else o&&f();r&&!i&&o&&f();const u=o&&!i&&!r?tt(o,c):w(0),h=s.left+c.scrollLeft-l.x-u.x,p=s.top+c.scrollTop-l.y-u.y;return{x:h,y:p,width:s.width,height:s.height}}function V(t){return R(t).position==="static"}function G(t,e){if(!b(t)||R(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return O(t)===n&&(n=n.ownerDocument.body),n}function nt(t,e){const n=L(t);if(S(t))return n;if(!b(t)){let o=W(t);for(;o&&!N(o);){if(v(o)&&!V(o))return o;o=W(o)}return n}let i=G(t,e);for(;i&&ct(i)&&V(i);)i=G(i,e);return i&&N(i)&&V(i)&&!Y(i)?n:i||lt(t)||n}const Rt=async function(t){const e=this.getOffsetParent||nt,n=this.getDimensions,i=await n(t.floating);return{reference:vt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ot(t){return R(t).direction==="rtl"}const bt={convertOffsetParentRelativeRectToViewportRelativeRect:ht,getDocumentElement:O,getClippingRect:xt,getOffsetParent:nt,getElementRects:Rt,getClientRects:at,getDimensions:yt,getScale:F,isElement:v,isRTL:Ot};function it(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ct(t,e){let n=null,i;const o=O(t);function r(){var c;clearTimeout(i),(c=n)==null||c.disconnect(),n=null}function s(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),r();const f=t.getBoundingClientRect(),{left:u,top:h,width:p,height:a}=f;if(c||e(),!p||!a)return;const x=A(h),g=A(o.clientWidth-(u+p)),m=A(o.clientHeight-(h+a)),d=A(u),C={rootMargin:-x+"px "+-g+"px "+-m+"px "+-d+"px",threshold:E(0,z(1,l))||1};let B=!0;function k(U){const D=U[0].intersectionRatio;if(D!==l){if(!B)return s();D?s(!1,D):i=setTimeout(()=>{s(!1,1e-7)},1e3)}D===1&&!it(f,t.getBoundingClientRect())&&s(),B=!1}try{n=new IntersectionObserver(k,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,C)}n.observe(t)}return s(!0),r}function Ft(t,e,n,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,f=$(t),u=o||r?[...f?M(f):[],...M(e)]:[];u.forEach(d=>{o&&d.addEventListener("scroll",n,{passive:!0}),r&&d.addEventListener("resize",n)});const h=f&&c?Ct(f,n):null;let p=-1,a=null;s&&(a=new ResizeObserver(d=>{let[y]=d;y&&y.target===f&&a&&(a.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=a)==null||C.observe(e)})),n()}),f&&!l&&a.observe(f),a.observe(e));let x,g=l?T(t):null;l&&m();function m(){const d=T(t);g&&!it(g,d)&&n(),g=d,x=requestAnimationFrame(m)}return n(),()=>{var d;u.forEach(y=>{o&&y.removeEventListener("scroll",n),r&&y.removeEventListener("resize",n)}),h?.(),(d=a)==null||d.disconnect(),a=null,l&&cancelAnimationFrame(x)}}const Wt=rt,Bt=st,Dt=(t,e,n)=>{const i=new Map,o={platform:bt,...n},r={...o.platform,_c:i};return ot(t,e,{...o,platform:r})};export{Wt as autoPlacement,Ft as autoUpdate,Dt as computePosition,Bt as flip,M as getOverflowAncestors,bt as platform};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{getCompatibleStyle as
|
|
1
|
+
import{getCompatibleStyle as d,adoptStyles as _}from"./css-tag.js";import{CSSResult as O,css as C,supportsAdoptingStyleSheets as M,unsafeCSS as R}from"./css-tag.js";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2017 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const{is
|
|
5
|
+
*/const{is:$,defineProperty:y,getOwnPropertyDescriptor:m,getOwnPropertyNames:g,getOwnPropertySymbols:b,getPrototypeOf:P}=Object,p=globalThis,u=p.trustedTypes,v=u?u.emptyScript:"",w=p.reactiveElementPolyfillSupport,n=(o,t)=>o,c={toAttribute(o,t){switch(t){case Boolean:o=o?v:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},E=(o,t)=>!$(o,t),f={attribute:!0,type:String,converter:c,reflect:!1,useDefault:!1,hasChanged:E};Symbol.metadata??=Symbol("metadata"),p.litPropertyMetadata??=new WeakMap;class h extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=f){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&y(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:r}=m(this.prototype,t)??{get(){return this[e]},set(a){this[e]=a}};return{get:i,set(a){const l=i?.call(this);r?.call(this,a),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??f}static _$Ei(){if(this.hasOwnProperty(n("elementProperties")))return;const t=P(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(n("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(n("properties"))){const e=this.properties,s=[...g(e),...b(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(d(i))}else t!==void 0&&e.push(d(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return _(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const r=(s.converter?.toAttribute!==void 0?s.converter:c).toAttribute(e,s.type);this._$Em=t,r==null?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const r=s.getPropertyOptions(i),a=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:c;this._$Em=i,this[i]=a.fromAttribute(e,r.type)??this._$Ej?.get(i)??null,this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){const i=this.constructor,r=this[t];if(s??=i.getPropertyOptions(t),!((s.hasChanged??E)(r,e)||s.useDefault&&s.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:r},a){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,a??e??this[t]),r!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,r]of this._$Ep)this[i]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,r]of s){const{wrapped:a}=r,l=this[i];a!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,r,l)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}}h.elementStyles=[],h.shadowRootOptions={mode:"open"},h[n("elementProperties")]=new Map,h[n("finalized")]=new Map,w?.({ReactiveElement:h}),(p.reactiveElementVersions??=[]).push("2.1.0");export{O as CSSResult,h as ReactiveElement,_ as adoptStyles,C as css,c as defaultConverter,d as getCompatibleStyle,E as notEqual,M as supportsAdoptingStyleSheets,R as unsafeCSS};
|