@zsviczian/excalidraw 0.18.0-12 → 0.18.0-13
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/excalidraw.development.js +49 -16
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/styles.development.css +16 -0
- package/dist/styles.production.css +1 -0
- package/package.json +1 -1
- package/types/common/src/constants.d.ts +1 -0
- package/types/element/src/binding.d.ts +10 -2
- package/types/element/src/newElement.d.ts +2 -2
- package/types/element/src/typeChecks.d.ts +3 -0
- package/types/element/src/types.d.ts +3 -0
- package/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/types/excalidraw/actions/types.d.ts +2 -2
- package/types/excalidraw/components/App.d.ts +2 -0
- package/types/excalidraw/components/ConvertElementTypePopup.d.ts +49 -0
- package/types/excalidraw/components/Stats/utils.d.ts +1 -8
- package/types/excalidraw/editor-jotai.d.ts +6 -6
- package/types/excalidraw/types.d.ts +1 -0
- package/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
|
@@ -12926,7 +12926,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
12926
12926
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
12927
12927
|
|
|
12928
12928
|
"use strict";
|
|
12929
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ACTIVE_THRESHOLD: () => (/* binding */ ACTIVE_THRESHOLD),\n/* harmony export */ ALLOWED_PASTE_MIME_TYPES: () => (/* binding */ ALLOWED_PASTE_MIME_TYPES),\n/* harmony export */ APP_NAME: () => (/* binding */ APP_NAME),\n/* harmony export */ ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO: () => (/* binding */ ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO),\n/* harmony export */ ARROW_LABEL_WIDTH_FRACTION: () => (/* binding */ ARROW_LABEL_WIDTH_FRACTION),\n/* harmony export */ ARROW_TYPE: () => (/* binding */ ARROW_TYPE),\n/* harmony export */ BOUND_TEXT_PADDING: () => (/* binding */ BOUND_TEXT_PADDING),\n/* harmony export */ CANVAS_ONLY_ACTIONS: () => (/* binding */ CANVAS_ONLY_ACTIONS),\n/* harmony export */ CANVAS_SEARCH_TAB: () => (/* binding */ CANVAS_SEARCH_TAB),\n/* harmony export */ CJK_HAND_DRAWN_FALLBACK_FONT: () => (/* binding */ CJK_HAND_DRAWN_FALLBACK_FONT),\n/* harmony export */ CLASSES: () => (/* binding */ CLASSES),\n/* harmony export */ COLOR_CHARCOAL_BLACK: () => (/* binding */ COLOR_CHARCOAL_BLACK),\n/* harmony export */ COLOR_NAMES: () => (/* binding */ COLOR_NAMES),\n/* harmony export */ COLOR_VOICE_CALL: () => (/* binding */ COLOR_VOICE_CALL),\n/* harmony export */ COLOR_WHITE: () => (/* binding */ COLOR_WHITE),\n/* harmony export */ CURSOR_TYPE: () => (/* binding */ CURSOR_TYPE),\n/* harmony export */ DEFAULT_ADAPTIVE_RADIUS: () => (/* binding */ DEFAULT_ADAPTIVE_RADIUS),\n/* harmony export */ DEFAULT_COLLISION_THRESHOLD: () => (/* binding */ DEFAULT_COLLISION_THRESHOLD),\n/* harmony export */ DEFAULT_ELEMENT_PROPS: () => (/* binding */ DEFAULT_ELEMENT_PROPS),\n/* harmony export */ DEFAULT_EXPORT_PADDING: () => (/* binding */ DEFAULT_EXPORT_PADDING),\n/* harmony export */ DEFAULT_FILENAME: () => (/* binding */ DEFAULT_FILENAME),\n/* harmony export */ DEFAULT_FONT_FAMILY: () => (/* binding */ DEFAULT_FONT_FAMILY),\n/* harmony export */ DEFAULT_FONT_SIZE: () => (/* binding */ DEFAULT_FONT_SIZE),\n/* harmony export */ DEFAULT_GRID_SIZE: () => (/* binding */ DEFAULT_GRID_SIZE),\n/* harmony export */ DEFAULT_GRID_STEP: () => (/* binding */ DEFAULT_GRID_STEP),\n/* harmony export */ DEFAULT_LASER_COLOR: () => (/* binding */ DEFAULT_LASER_COLOR),\n/* harmony export */ DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT: () => (/* binding */ DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT),\n/* harmony export */ DEFAULT_PROPORTIONAL_RADIUS: () => (/* binding */ DEFAULT_PROPORTIONAL_RADIUS),\n/* harmony export */ DEFAULT_REDUCED_GLOBAL_ALPHA: () => (/* binding */ DEFAULT_REDUCED_GLOBAL_ALPHA),\n/* harmony export */ DEFAULT_SIDEBAR: () => (/* binding */ DEFAULT_SIDEBAR),\n/* harmony export */ DEFAULT_TEXT_ALIGN: () => (/* binding */ DEFAULT_TEXT_ALIGN),\n/* harmony export */ DEFAULT_TRANSFORM_HANDLE_SPACING: () => (/* binding */ DEFAULT_TRANSFORM_HANDLE_SPACING),\n/* harmony export */ DEFAULT_UI_OPTIONS: () => (/* binding */ DEFAULT_UI_OPTIONS),\n/* harmony export */ DEFAULT_VERSION: () => (/* binding */ DEFAULT_VERSION),\n/* harmony export */ DEFAULT_VERTICAL_ALIGN: () => (/* binding */ DEFAULT_VERTICAL_ALIGN),\n/* harmony export */ DRAGGING_THRESHOLD: () => (/* binding */ DRAGGING_THRESHOLD),\n/* harmony export */ EDITOR_LS_KEYS: () => (/* binding */ EDITOR_LS_KEYS),\n/* harmony export */ ELEMENT_LINK_KEY: () => (/* binding */ ELEMENT_LINK_KEY),\n/* harmony export */ ELEMENT_READY_TO_ERASE_OPACITY: () => (/* binding */ ELEMENT_READY_TO_ERASE_OPACITY),\n/* harmony export */ ELEMENT_SHIFT_TRANSLATE_AMOUNT: () => (/* binding */ ELEMENT_SHIFT_TRANSLATE_AMOUNT),\n/* harmony export */ ELEMENT_TRANSLATE_AMOUNT: () => (/* binding */ ELEMENT_TRANSLATE_AMOUNT),\n/* harmony export */ ENCRYPTION_KEY_BITS: () => (/* binding */ ENCRYPTION_KEY_BITS),\n/* harmony export */ ENV: () => (/* binding */ ENV),\n/* harmony export */ EPSILON: () => (/* binding */ EPSILON),\n/* harmony export */ EVENT: () => (/* binding */ EVENT),\n/* harmony export */ EXPORT_DATA_TYPES: () => (/* binding */ EXPORT_DATA_TYPES),\n/* harmony export */ EXPORT_IMAGE_TYPES: () => (/* binding */ EXPORT_IMAGE_TYPES),\n/* harmony export */ EXPORT_SCALES: () => (/* binding */ EXPORT_SCALES),\n/* harmony export */ EXPORT_SOURCE: () => (/* binding */ EXPORT_SOURCE),\n/* harmony export */ FONT_FAMILY: () => (/* binding */ FONT_FAMILY),\n/* harmony export */ FONT_FAMILY_FALLBACKS: () => (/* binding */ FONT_FAMILY_FALLBACKS),\n/* harmony export */ FRAME_STYLE: () => (/* binding */ FRAME_STYLE),\n/* harmony export */ HYPERLINK_TOOLTIP_DELAY: () => (/* binding */ HYPERLINK_TOOLTIP_DELAY),\n/* harmony export */ IDLE_THRESHOLD: () => (/* binding */ IDLE_THRESHOLD),\n/* harmony export */ IMAGE_MIME_TYPES: () => (/* binding */ IMAGE_MIME_TYPES),\n/* harmony export */ IMAGE_RENDER_TIMEOUT: () => (/* binding */ IMAGE_RENDER_TIMEOUT),\n/* harmony export */ LIBRARY_DISABLED_TYPES: () => (/* binding */ LIBRARY_DISABLED_TYPES),\n/* harmony export */ LIBRARY_SIDEBAR_TAB: () => (/* binding */ LIBRARY_SIDEBAR_TAB),\n/* harmony export */ LINE_CONFIRM_THRESHOLD: () => (/* binding */ LINE_CONFIRM_THRESHOLD),\n/* harmony export */ MAX_ALLOWED_FILE_BYTES: () => (/* binding */ MAX_ALLOWED_FILE_BYTES),\n/* harmony export */ MAX_DECIMALS_FOR_SVG_EXPORT: () => (/* binding */ MAX_DECIMALS_FOR_SVG_EXPORT),\n/* harmony export */ MAX_ZOOM: () => (/* binding */ MAX_ZOOM),\n/* harmony export */ MIME_TYPES: () => (/* binding */ MIME_TYPES),\n/* harmony export */ MIN_FONT_SIZE: () => (/* binding */ MIN_FONT_SIZE),\n/* harmony export */ MIN_WIDTH_OR_HEIGHT: () => (/* binding */ MIN_WIDTH_OR_HEIGHT),\n/* harmony export */ MIN_ZOOM: () => (/* binding */ MIN_ZOOM),\n/* harmony export */ MQ_MAX_HEIGHT_LANDSCAPE: () => (/* binding */ MQ_MAX_HEIGHT_LANDSCAPE),\n/* harmony export */ MQ_MAX_WIDTH_LANDSCAPE: () => (/* binding */ MQ_MAX_WIDTH_LANDSCAPE),\n/* harmony export */ MQ_MAX_WIDTH_PORTRAIT: () => (/* binding */ MQ_MAX_WIDTH_PORTRAIT),\n/* harmony export */ MQ_RIGHT_SIDEBAR_MIN_WIDTH: () => (/* binding */ MQ_RIGHT_SIDEBAR_MIN_WIDTH),\n/* harmony export */ ORIG_ID: () => (/* binding */ ORIG_ID),\n/* harmony export */ POINTER_BUTTON: () => (/* binding */ POINTER_BUTTON),\n/* harmony export */ POINTER_EVENTS: () => (/* binding */ POINTER_EVENTS),\n/* harmony export */ PRECEDING_ELEMENT_KEY: () => (/* binding */ PRECEDING_ELEMENT_KEY),\n/* harmony export */ ROUGHNESS: () => (/* binding */ ROUGHNESS),\n/* harmony export */ ROUNDNESS: () => (/* binding */ ROUNDNESS),\n/* harmony export */ SCROLL_TIMEOUT: () => (/* binding */ SCROLL_TIMEOUT),\n/* harmony export */ SHIFT_LOCKING_ANGLE: () => (/* binding */ SHIFT_LOCKING_ANGLE),\n/* harmony export */ SIDE_RESIZING_THRESHOLD: () => (/* binding */ SIDE_RESIZING_THRESHOLD),\n/* harmony export */ STATS_PANELS: () => (/* binding */ STATS_PANELS),\n/* harmony export */ STROKE_WIDTH: () => (/* binding */ STROKE_WIDTH),\n/* harmony export */ SVG_DOCUMENT_PREAMBLE: () => (/* binding */ SVG_DOCUMENT_PREAMBLE),\n/* harmony export */ SVG_NS: () => (/* binding */ SVG_NS),\n/* harmony export */ TAP_TWICE_TIMEOUT: () => (/* binding */ TAP_TWICE_TIMEOUT),\n/* harmony export */ TEXT_ALIGN: () => (/* binding */ TEXT_ALIGN),\n/* harmony export */ TEXT_AUTOWRAP_THRESHOLD: () => (/* binding */ TEXT_AUTOWRAP_THRESHOLD),\n/* harmony export */ TEXT_TO_CENTER_SNAP_THRESHOLD: () => (/* binding */ TEXT_TO_CENTER_SNAP_THRESHOLD),\n/* harmony export */ THEME: () => (/* binding */ THEME),\n/* harmony export */ THEME_FILTER: () => (/* binding */ THEME_FILTER),\n/* harmony export */ TITLE_TIMEOUT: () => (/* binding */ TITLE_TIMEOUT),\n/* harmony export */ TOOL_TYPE: () => (/* binding */ TOOL_TYPE),\n/* harmony export */ TOUCH_CTX_MENU_TIMEOUT: () => (/* binding */ TOUCH_CTX_MENU_TIMEOUT),\n/* harmony export */ URL_HASH_KEYS: () => (/* binding */ URL_HASH_KEYS),\n/* harmony export */ URL_QUERY_KEYS: () => (/* binding */ URL_QUERY_KEYS),\n/* harmony export */ UserIdleState: () => (/* binding */ UserIdleState),\n/* harmony export */ VERSIONS: () => (/* binding */ VERSIONS),\n/* harmony export */ VERSION_TIMEOUT: () => (/* binding */ VERSION_TIMEOUT),\n/* harmony export */ VERTICAL_ALIGN: () => (/* binding */ VERTICAL_ALIGN),\n/* harmony export */ WINDOWS_EMOJI_FALLBACK_FONT: () => (/* binding */ WINDOWS_EMOJI_FALLBACK_FONT),\n/* harmony export */ YOUTUBE_STATES: () => (/* binding */ YOUTUBE_STATES),\n/* harmony export */ ZOOM_STEP: () => (/* binding */ ZOOM_STEP),\n/* harmony export */ getFontFamilyFallbacks: () => (/* binding */ getFontFamilyFallbacks),\n/* harmony export */ isAndroid: () => (/* binding */ isAndroid),\n/* harmony export */ isBrave: () => (/* binding */ isBrave),\n/* harmony export */ isChrome: () => (/* binding */ isChrome),\n/* harmony export */ isDarwin: () => (/* binding */ isDarwin),\n/* harmony export */ isFirefox: () => (/* binding */ isFirefox),\n/* harmony export */ isIOS: () => (/* binding */ isIOS),\n/* harmony export */ isSafari: () => (/* binding */ isSafari),\n/* harmony export */ isWindows: () => (/* binding */ isWindows),\n/* harmony export */ supportsResizeObserver: () => (/* binding */ supportsResizeObserver)\n/* harmony export */ });\n/* harmony import */ var _colors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./colors */ \"../common/src/colors.ts\");\n\nconst isDarwin = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\nconst isWindows = /^Win/.test(navigator.platform);\nconst isAndroid = /\\b(android)\\b/i.test(navigator.userAgent);\nconst isFirefox = \"netscape\" in window && navigator.userAgent.indexOf(\"rv:\") > 1 && navigator.userAgent.indexOf(\"Gecko\") > 1;\nconst isChrome = navigator.userAgent.indexOf(\"Chrome\") !== -1;\nconst isSafari = !isChrome && navigator.userAgent.indexOf(\"Safari\") !== -1;\nconst isIOS = /iPad|iPhone/.test(navigator.platform) || // iPadOS 13+\nnavigator.userAgent.includes(\"Mac\") && \"ontouchend\" in document; // keeping function so it can be mocked in test\n\nconst isBrave = () => {\n var _a, _b;\n\n return ((_b = (_a = navigator.brave) === null || _a === void 0 ? void 0 : _a.isBrave) === null || _b === void 0 ? void 0 : _b.name) === \"isBrave\";\n};\nconst supportsResizeObserver = typeof window !== \"undefined\" && \"ResizeObserver\" in window;\nconst APP_NAME = \"Excalidraw\"; // distance when creating text before it's considered `autoResize: false`\n// we're using higher threshold so that clicks that end up being drags\n// don't unintentionally create text elements that are wrapped to a few chars\n// (happens a lot with fast clicks with the text tool)\n\nconst TEXT_AUTOWRAP_THRESHOLD = 36; // px\n\nconst DRAGGING_THRESHOLD = 10; // px\n\nconst LINE_CONFIRM_THRESHOLD = 8; // px\n\nconst ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;\nconst ELEMENT_TRANSLATE_AMOUNT = 1;\nconst TEXT_TO_CENTER_SNAP_THRESHOLD = 30;\nconst SHIFT_LOCKING_ANGLE = Math.PI / 12;\nconst DEFAULT_LASER_COLOR = \"red\";\nconst CURSOR_TYPE = {\n TEXT: \"text\",\n CROSSHAIR: \"crosshair\",\n GRABBING: \"grabbing\",\n GRAB: \"grab\",\n POINTER: \"pointer\",\n MOVE: \"move\",\n AUTO: \"\"\n};\nconst POINTER_BUTTON = {\n MAIN: 0,\n WHEEL: 1,\n SECONDARY: 2,\n TOUCH: -1,\n ERASER: 5\n};\nconst POINTER_EVENTS = {\n enabled: \"all\",\n disabled: \"none\",\n // asserted as any so it can be freely assigned to React Element\n // \"pointerEnvets\" CSS prop\n inheritFromUI: \"var(--ui-pointerEvents)\"\n};\nvar EVENT;\n\n(function (EVENT) {\n EVENT[\"COPY\"] = \"copy\";\n EVENT[\"PASTE\"] = \"paste\";\n EVENT[\"CUT\"] = \"cut\";\n EVENT[\"KEYDOWN\"] = \"keydown\";\n EVENT[\"KEYUP\"] = \"keyup\";\n EVENT[\"MOUSE_MOVE\"] = \"mousemove\";\n EVENT[\"RESIZE\"] = \"resize\";\n EVENT[\"UNLOAD\"] = \"unload\";\n EVENT[\"FOCUS\"] = \"focus\";\n EVENT[\"BLUR\"] = \"blur\";\n EVENT[\"DRAG_OVER\"] = \"dragover\";\n EVENT[\"DROP\"] = \"drop\";\n EVENT[\"GESTURE_END\"] = \"gestureend\";\n EVENT[\"BEFORE_UNLOAD\"] = \"beforeunload\";\n EVENT[\"GESTURE_START\"] = \"gesturestart\";\n EVENT[\"GESTURE_CHANGE\"] = \"gesturechange\";\n EVENT[\"POINTER_MOVE\"] = \"pointermove\";\n EVENT[\"POINTER_DOWN\"] = \"pointerdown\";\n EVENT[\"POINTER_UP\"] = \"pointerup\";\n EVENT[\"STATE_CHANGE\"] = \"statechange\";\n EVENT[\"WHEEL\"] = \"wheel\";\n EVENT[\"TOUCH_START\"] = \"touchstart\";\n EVENT[\"TOUCH_END\"] = \"touchend\";\n EVENT[\"HASHCHANGE\"] = \"hashchange\";\n EVENT[\"VISIBILITY_CHANGE\"] = \"visibilitychange\";\n EVENT[\"SCROLL\"] = \"scroll\"; // custom events\n\n EVENT[\"EXCALIDRAW_LINK\"] = \"excalidraw-link\";\n EVENT[\"MENU_ITEM_SELECT\"] = \"menu.itemSelect\";\n EVENT[\"MESSAGE\"] = \"message\";\n EVENT[\"FULLSCREENCHANGE\"] = \"fullscreenchange\";\n})(EVENT || (EVENT = {}));\n\nconst YOUTUBE_STATES = {\n UNSTARTED: -1,\n ENDED: 0,\n PLAYING: 1,\n PAUSED: 2,\n BUFFERING: 3,\n CUED: 5\n};\nconst ENV = {\n TEST: \"test\",\n DEVELOPMENT: \"development\",\n PRODUCTION: \"production\"\n};\nconst CLASSES = {\n SHAPE_ACTIONS_MENU: \"App-menu__left\",\n SHAPE_ACTIONS_MOBILE_MENU: \"App-mobile-menu\",\n MOBILE_TOOLBAR: \"App-toolbar-content\",\n ZOOM_ACTIONS: \"zoom-actions\",\n SEARCH_MENU_INPUT_WRAPPER: \"layer-ui__search-inputWrapper\"\n};\nconst CJK_HAND_DRAWN_FALLBACK_FONT = \"Xiaolai\";\nconst WINDOWS_EMOJI_FALLBACK_FONT = \"Segoe UI Emoji\";\n/**\r\n * // TODO: shouldn't be really `const`, likely neither have integers as values, due to value for the custom fonts, which should likely be some hash.\r\n *\r\n * Let's think this through and consider:\r\n * - https://developer.mozilla.org/en-US/docs/Web/CSS/generic-family\r\n * - https://drafts.csswg.org/css-fonts-4/#font-family-prop\r\n * - https://learn.microsoft.com/en-us/typography/opentype/spec/ibmfc\r\n */\n\nconst FONT_FAMILY = {\n Virgil: 1,\n Helvetica: 2,\n Cascadia: 3,\n \"Local Font\": 4,\n // leave 4 unused as it was historically used for Assistant (which we don't use anymore) or custom font (Obsidian)\n Excalifont: 5,\n Nunito: 6,\n \"Lilita One\": 7,\n \"Comic Shanns\": 8,\n \"Liberation Sans\": 9\n};\nconst FONT_FAMILY_FALLBACKS = {\n [CJK_HAND_DRAWN_FALLBACK_FONT]: 100,\n [WINDOWS_EMOJI_FALLBACK_FONT]: 1000\n};\nconst getFontFamilyFallbacks = fontFamily => {\n switch (fontFamily) {\n case FONT_FAMILY.Excalifont:\n return [CJK_HAND_DRAWN_FALLBACK_FONT, WINDOWS_EMOJI_FALLBACK_FONT];\n\n default:\n return [WINDOWS_EMOJI_FALLBACK_FONT];\n }\n};\nconst THEME = {\n LIGHT: \"light\",\n DARK: \"dark\"\n};\nconst FRAME_STYLE = {\n strokeColor: \"#bbb\",\n strokeWidth: 2,\n strokeStyle: \"solid\",\n fillStyle: \"solid\",\n roughness: 0,\n roundness: null,\n backgroundColor: \"transparent\",\n radius: 8,\n nameOffsetY: 3,\n nameColorLightTheme: \"#999999\",\n nameColorDarkTheme: \"#7a7a7a\",\n nameFontSize: 14,\n nameLineHeight: 1.25\n};\nconst MIN_FONT_SIZE = 1;\nconst DEFAULT_FONT_SIZE = 20;\nconst DEFAULT_FONT_FAMILY = FONT_FAMILY.Excalifont;\nconst DEFAULT_TEXT_ALIGN = \"left\";\nconst DEFAULT_VERTICAL_ALIGN = \"top\";\nconst DEFAULT_VERSION = \"{version}\";\nconst DEFAULT_TRANSFORM_HANDLE_SPACING = 2;\nconst SIDE_RESIZING_THRESHOLD = 2 * DEFAULT_TRANSFORM_HANDLE_SPACING; // a small epsilon to make side resizing always take precedence\n// (avoids an increase in renders and changes to tests)\n\nconst EPSILON = 0.00001;\nconst DEFAULT_COLLISION_THRESHOLD = 2 * SIDE_RESIZING_THRESHOLD - EPSILON;\nconst COLOR_WHITE = \"#ffffff\";\nconst COLOR_CHARCOAL_BLACK = \"#1e1e1e\"; // keep this in sync with CSS\n\nconst COLOR_VOICE_CALL = \"#a2f1a6\";\nconst CANVAS_ONLY_ACTIONS = [\"selectAll\"];\nconst DEFAULT_GRID_SIZE = 20;\nconst DEFAULT_GRID_STEP = 5;\nconst IMAGE_MIME_TYPES = {\n svg: \"image/svg+xml\",\n png: \"image/png\",\n jpg: \"image/jpeg\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n bmp: \"image/bmp\",\n ico: \"image/x-icon\",\n avif: \"image/avif\",\n jfif: \"image/jfif\"\n};\nconst MIME_TYPES = Object.assign({\n text: \"text/plain\",\n html: \"text/html\",\n json: \"application/json\",\n // excalidraw data\n excalidraw: \"application/vnd.excalidraw+json\",\n excalidrawlib: \"application/vnd.excalidrawlib+json\",\n // image-encoded excalidraw data\n \"excalidraw.svg\": \"image/svg+xml\",\n \"excalidraw.png\": \"image/png\",\n // binary\n binary: \"application/octet-stream\"\n}, IMAGE_MIME_TYPES);\nconst ALLOWED_PASTE_MIME_TYPES = [MIME_TYPES.text, MIME_TYPES.html, ...Object.values(IMAGE_MIME_TYPES)];\nconst EXPORT_IMAGE_TYPES = {\n png: \"png\",\n svg: \"svg\",\n clipboard: \"clipboard\"\n};\nconst EXPORT_DATA_TYPES = {\n excalidraw: \"excalidraw\",\n excalidrawClipboard: \"excalidraw/clipboard\",\n excalidrawLibrary: \"excalidrawlib\",\n excalidrawClipboardWithAPI: \"excalidraw-api/clipboard\"\n};\nconst EXPORT_SOURCE = window.EXCALIDRAW_EXPORT_SOURCE || window.location.origin; // time in milliseconds\n\nconst IMAGE_RENDER_TIMEOUT = 500;\nconst TAP_TWICE_TIMEOUT = 300;\nconst TOUCH_CTX_MENU_TIMEOUT = 500;\nconst TITLE_TIMEOUT = 10000;\nconst VERSION_TIMEOUT = 30000;\nconst SCROLL_TIMEOUT = 100;\nconst ZOOM_STEP = 0.05; //zsviczian\n\nconst MIN_ZOOM = 0.1;\nconst MAX_ZOOM = 30;\nconst HYPERLINK_TOOLTIP_DELAY = 300; // Report a user inactive after IDLE_THRESHOLD milliseconds\n\nconst IDLE_THRESHOLD = 60000; // Report a user active each ACTIVE_THRESHOLD milliseconds\n\nconst ACTIVE_THRESHOLD = 3000; // duplicates --theme-filter, should be removed soon\n\nconst THEME_FILTER = \"invert(93%) hue-rotate(180deg)\";\nconst URL_QUERY_KEYS = {\n addLibrary: \"addLibrary\"\n};\nconst URL_HASH_KEYS = {\n addLibrary: \"addLibrary\"\n};\nconst DEFAULT_UI_OPTIONS = {\n canvasActions: {\n changeViewBackgroundColor: true,\n clearCanvas: true,\n export: {\n saveFileToDisk: true\n },\n loadScene: true,\n saveToActiveFile: true,\n toggleTheme: null,\n saveAsImage: true\n },\n tools: {\n image: true\n }\n}; // breakpoints\n// -----------------------------------------------------------------------------\n// md screen\n\nconst MQ_MAX_WIDTH_PORTRAIT = 730;\nconst MQ_MAX_WIDTH_LANDSCAPE = 1000;\nconst MQ_MAX_HEIGHT_LANDSCAPE = 500; // sidebar\n\nconst MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229; // -----------------------------------------------------------------------------\n\nconst MAX_DECIMALS_FOR_SVG_EXPORT = 2;\nconst EXPORT_SCALES = [1, 2, 3];\nconst DEFAULT_EXPORT_PADDING = 10; // px\n\nconst DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 2880; //zsviczian was 1440\n\nconst MAX_ALLOWED_FILE_BYTES = 20 * 1024 * 1024;\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\nconst SVG_DOCUMENT_PREAMBLE = `<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n`;\nconst ENCRYPTION_KEY_BITS = 128;\nconst VERSIONS = {\n excalidraw: 2,\n excalidrawLibrary: 2\n};\nconst BOUND_TEXT_PADDING = 5;\nconst ARROW_LABEL_WIDTH_FRACTION = 0.7;\nconst ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO = 11;\nconst VERTICAL_ALIGN = {\n TOP: \"top\",\n MIDDLE: \"middle\",\n BOTTOM: \"bottom\"\n};\nconst TEXT_ALIGN = {\n LEFT: \"left\",\n CENTER: \"center\",\n RIGHT: \"right\"\n};\nconst ELEMENT_READY_TO_ERASE_OPACITY = 20; // Radius represented as 25% of element's largest side (width/height).\n// Used for LEGACY and PROPORTIONAL_RADIUS algorithms, or when the element is\n// below the cutoff size.\n\nconst DEFAULT_PROPORTIONAL_RADIUS = 0.25; // Fixed radius for the ADAPTIVE_RADIUS algorithm. In pixels.\n\nconst DEFAULT_ADAPTIVE_RADIUS = 32; // roundness type (algorithm)\n\nconst ROUNDNESS = {\n // Used for legacy rounding (rectangles), which currently works the same\n // as PROPORTIONAL_RADIUS, but we need to differentiate for UI purposes and\n // forwards-compat.\n LEGACY: 1,\n // Used for linear elements & diamonds\n PROPORTIONAL_RADIUS: 2,\n // Current default algorithm for rectangles, using fixed pixel radius.\n // It's working similarly to a regular border-radius, but attemps to make\n // radius visually similar across differnt element sizes, especially\n // very large and very small elements.\n //\n // NOTE right now we don't allow configuration and use a constant radius\n // (see DEFAULT_ADAPTIVE_RADIUS constant)\n ADAPTIVE_RADIUS: 3\n};\n/** key containt id of precedeing elemnt id we use in reconciliation during\r\n * collaboration */\n\nconst PRECEDING_ELEMENT_KEY = \"__precedingElement__\"; //zsviczian\n\nconst COLOR_NAMES = {\n aliceblue: \"#f0f8ff\",\n antiquewhite: \"#faebd7\",\n aqua: \"#00ffff\",\n aquamarine: \"#7fffd4\",\n azure: \"#f0ffff\",\n beige: \"#f5f5dc\",\n bisque: \"#ffe4c4\",\n black: \"#000000\",\n blanchedalmond: \"#ffebcd\",\n blue: \"#0000ff\",\n blueviolet: \"#8a2be2\",\n brown: \"#a52a2a\",\n burlywood: \"#deb887\",\n cadetblue: \"#5f9ea0\",\n chartreuse: \"#7fff00\",\n chocolate: \"#d2691e\",\n coral: \"#ff7f50\",\n cornflowerblue: \"#6495ed\",\n cornsilk: \"#fff8dc\",\n crimson: \"#dc143c\",\n cyan: \"#00ffff\",\n darkblue: \"#00008b\",\n darkcyan: \"#008b8b\",\n darkgoldenrod: \"#b8860b\",\n darkgray: \"#a9a9a9\",\n darkgreen: \"#006400\",\n darkkhaki: \"#bdb76b\",\n darkmagenta: \"#8b008b\",\n darkolivegreen: \"#556b2f\",\n darkorange: \"#ff8c00\",\n darkorchid: \"#9932cc\",\n darkred: \"#8b0000\",\n darksalmon: \"#e9967a\",\n darkseagreen: \"#8fbc8f\",\n darkslateblue: \"#483d8b\",\n darkslategray: \"#2f4f4f\",\n darkturquoise: \"#00ced1\",\n darkviolet: \"#9400d3\",\n deeppink: \"#ff1493\",\n deepskyblue: \"#00bfff\",\n dimgray: \"#696969\",\n dodgerblue: \"#1e90ff\",\n firebrick: \"#b22222\",\n floralwhite: \"#fffaf0\",\n forestgreen: \"#228b22\",\n fuchsia: \"#ff00ff\",\n gainsboro: \"#dcdcdc\",\n ghostwhite: \"#f8f8ff\",\n gold: \"#ffd700\",\n goldenrod: \"#daa520\",\n gray: \"#808080\",\n green: \"#008000\",\n greenyellow: \"#adff2f\",\n honeydew: \"#f0fff0\",\n hotpink: \"#ff69b4\",\n indianred: \"#cd5c5c\",\n indigo: \"#4b0082\",\n ivory: \"#fffff0\",\n khaki: \"#f0e68c\",\n lavender: \"#e6e6fa\",\n lavenderblush: \"#fff0f5\",\n lawngreen: \"#7cfc00\",\n lemonchiffon: \"#fffacd\",\n lightblue: \"#add8e6\",\n lightcoral: \"#f08080\",\n lightcyan: \"#e0ffff\",\n lightgoldenrodyellow: \"#fafad2\",\n lightgrey: \"#d3d3d3\",\n lightgreen: \"#90ee90\",\n lightpink: \"#ffb6c1\",\n lightsalmon: \"#ffa07a\",\n lightseagreen: \"#20b2aa\",\n lightskyblue: \"#87cefa\",\n lightslategray: \"#778899\",\n lightsteelblue: \"#b0c4de\",\n lightyellow: \"#ffffe0\",\n lime: \"#00ff00\",\n limegreen: \"#32cd32\",\n linen: \"#faf0e6\",\n magenta: \"#ff00ff\",\n maroon: \"#800000\",\n mediumaquamarine: \"#66cdaa\",\n mediumblue: \"#0000cd\",\n mediumorchid: \"#ba55d3\",\n mediumpurple: \"#9370d8\",\n mediumseagreen: \"#3cb371\",\n mediumslateblue: \"#7b68ee\",\n mediumspringgreen: \"#00fa9a\",\n mediumturquoise: \"#48d1cc\",\n mediumvioletred: \"#c71585\",\n midnightblue: \"#191970\",\n mintcream: \"#f5fffa\",\n mistyrose: \"#ffe4e1\",\n moccasin: \"#ffe4b5\",\n navajowhite: \"#ffdead\",\n navy: \"#000080\",\n oldlace: \"#fdf5e6\",\n olive: \"#808000\",\n olivedrab: \"#6b8e23\",\n orange: \"#ffa500\",\n orangered: \"#ff4500\",\n orchid: \"#da70d6\",\n palegoldenrod: \"#eee8aa\",\n palegreen: \"#98fb98\",\n paleturquoise: \"#afeeee\",\n palevioletred: \"#d87093\",\n papayawhip: \"#ffefd5\",\n peachpuff: \"#ffdab9\",\n peru: \"#cd853f\",\n pink: \"#ffc0cb\",\n plum: \"#dda0dd\",\n powderblue: \"#b0e0e6\",\n purple: \"#800080\",\n rebeccapurple: \"#663399\",\n red: \"#ff0000\",\n rosybrown: \"#bc8f8f\",\n royalblue: \"#4169e1\",\n saddlebrown: \"#8b4513\",\n salmon: \"#fa8072\",\n sandybrown: \"#f4a460\",\n seagreen: \"#2e8b57\",\n seashell: \"#fff5ee\",\n sienna: \"#a0522d\",\n silver: \"#c0c0c0\",\n skyblue: \"#87ceeb\",\n slateblue: \"#6a5acd\",\n slategray: \"#708090\",\n snow: \"#fffafa\",\n springgreen: \"#00ff7f\",\n steelblue: \"#4682b4\",\n tan: \"#d2b48c\",\n teal: \"#008080\",\n thistle: \"#d8bfd8\",\n tomato: \"#ff6347\",\n turquoise: \"#40e0d0\",\n violet: \"#ee82ee\",\n wheat: \"#f5deb3\",\n white: \"#ffffff\",\n whitesmoke: \"#f5f5f5\",\n yellow: \"#ffff00\",\n yellowgreen: \"#9acd32\"\n};\nconst ROUGHNESS = {\n architect: 0,\n artist: 1,\n cartoonist: 2\n};\nconst STROKE_WIDTH = {\n extraThin: 0.5,\n thin: 1,\n bold: 2,\n extraBold: 4\n};\nconst DEFAULT_ELEMENT_PROPS = {\n strokeColor: _colors__WEBPACK_IMPORTED_MODULE_0__.COLOR_PALETTE.black,\n backgroundColor: _colors__WEBPACK_IMPORTED_MODULE_0__.COLOR_PALETTE.transparent,\n fillStyle: \"solid\",\n strokeWidth: 2,\n strokeStyle: \"solid\",\n roughness: ROUGHNESS.artist,\n opacity: 100,\n locked: false\n};\nconst LIBRARY_SIDEBAR_TAB = \"library\";\nconst CANVAS_SEARCH_TAB = \"search\";\nconst DEFAULT_SIDEBAR = {\n name: \"default\",\n defaultTab: LIBRARY_SIDEBAR_TAB\n};\nconst LIBRARY_DISABLED_TYPES = new Set([\"iframe\", \"embeddable\", \"image\"]); // use these constants to easily identify reference sites\n\nconst TOOL_TYPE = {\n selection: \"selection\",\n lasso: \"lasso\",\n rectangle: \"rectangle\",\n diamond: \"diamond\",\n ellipse: \"ellipse\",\n arrow: \"arrow\",\n line: \"line\",\n freedraw: \"freedraw\",\n text: \"text\",\n image: \"image\",\n eraser: \"eraser\",\n hand: \"hand\",\n frame: \"frame\",\n magicframe: \"magicframe\",\n embeddable: \"embeddable\",\n laser: \"laser\"\n};\nconst EDITOR_LS_KEYS = {\n OAI_API_KEY: \"excalidraw-oai-api-key\",\n // legacy naming (non)scheme\n MERMAID_TO_EXCALIDRAW: \"mermaid-to-excalidraw\",\n PUBLISH_LIBRARY: \"publish-library-data\"\n};\n/**\r\n * not translated as this is used only in public, stateless API as default value\r\n * where filename is optional and we can't retrieve name from app state\r\n */\n\nconst DEFAULT_FILENAME = \"Untitled\";\nconst STATS_PANELS = {\n generalStats: 1,\n elementProperties: 2\n};\nconst MIN_WIDTH_OR_HEIGHT = 1;\nconst ARROW_TYPE = {\n sharp: \"sharp\",\n round: \"round\",\n elbow: \"elbow\"\n};\nconst DEFAULT_REDUCED_GLOBAL_ALPHA = 0.3;\nconst ELEMENT_LINK_KEY = \"element\";\n/** used in tests */\n\nconst ORIG_ID = Symbol.for(\"__test__originalId__\");\nvar UserIdleState;\n\n(function (UserIdleState) {\n UserIdleState[\"ACTIVE\"] = \"active\";\n UserIdleState[\"AWAY\"] = \"away\";\n UserIdleState[\"IDLE\"] = \"idle\";\n})(UserIdleState || (UserIdleState = {}));\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/constants.ts?");
|
|
12929
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ACTIVE_THRESHOLD: () => (/* binding */ ACTIVE_THRESHOLD),\n/* harmony export */ ALLOWED_PASTE_MIME_TYPES: () => (/* binding */ ALLOWED_PASTE_MIME_TYPES),\n/* harmony export */ APP_NAME: () => (/* binding */ APP_NAME),\n/* harmony export */ ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO: () => (/* binding */ ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO),\n/* harmony export */ ARROW_LABEL_WIDTH_FRACTION: () => (/* binding */ ARROW_LABEL_WIDTH_FRACTION),\n/* harmony export */ ARROW_TYPE: () => (/* binding */ ARROW_TYPE),\n/* harmony export */ BOUND_TEXT_PADDING: () => (/* binding */ BOUND_TEXT_PADDING),\n/* harmony export */ CANVAS_ONLY_ACTIONS: () => (/* binding */ CANVAS_ONLY_ACTIONS),\n/* harmony export */ CANVAS_SEARCH_TAB: () => (/* binding */ CANVAS_SEARCH_TAB),\n/* harmony export */ CJK_HAND_DRAWN_FALLBACK_FONT: () => (/* binding */ CJK_HAND_DRAWN_FALLBACK_FONT),\n/* harmony export */ CLASSES: () => (/* binding */ CLASSES),\n/* harmony export */ COLOR_CHARCOAL_BLACK: () => (/* binding */ COLOR_CHARCOAL_BLACK),\n/* harmony export */ COLOR_NAMES: () => (/* binding */ COLOR_NAMES),\n/* harmony export */ COLOR_VOICE_CALL: () => (/* binding */ COLOR_VOICE_CALL),\n/* harmony export */ COLOR_WHITE: () => (/* binding */ COLOR_WHITE),\n/* harmony export */ CURSOR_TYPE: () => (/* binding */ CURSOR_TYPE),\n/* harmony export */ DEFAULT_ADAPTIVE_RADIUS: () => (/* binding */ DEFAULT_ADAPTIVE_RADIUS),\n/* harmony export */ DEFAULT_COLLISION_THRESHOLD: () => (/* binding */ DEFAULT_COLLISION_THRESHOLD),\n/* harmony export */ DEFAULT_ELEMENT_PROPS: () => (/* binding */ DEFAULT_ELEMENT_PROPS),\n/* harmony export */ DEFAULT_EXPORT_PADDING: () => (/* binding */ DEFAULT_EXPORT_PADDING),\n/* harmony export */ DEFAULT_FILENAME: () => (/* binding */ DEFAULT_FILENAME),\n/* harmony export */ DEFAULT_FONT_FAMILY: () => (/* binding */ DEFAULT_FONT_FAMILY),\n/* harmony export */ DEFAULT_FONT_SIZE: () => (/* binding */ DEFAULT_FONT_SIZE),\n/* harmony export */ DEFAULT_GRID_SIZE: () => (/* binding */ DEFAULT_GRID_SIZE),\n/* harmony export */ DEFAULT_GRID_STEP: () => (/* binding */ DEFAULT_GRID_STEP),\n/* harmony export */ DEFAULT_LASER_COLOR: () => (/* binding */ DEFAULT_LASER_COLOR),\n/* harmony export */ DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT: () => (/* binding */ DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT),\n/* harmony export */ DEFAULT_PROPORTIONAL_RADIUS: () => (/* binding */ DEFAULT_PROPORTIONAL_RADIUS),\n/* harmony export */ DEFAULT_REDUCED_GLOBAL_ALPHA: () => (/* binding */ DEFAULT_REDUCED_GLOBAL_ALPHA),\n/* harmony export */ DEFAULT_SIDEBAR: () => (/* binding */ DEFAULT_SIDEBAR),\n/* harmony export */ DEFAULT_TEXT_ALIGN: () => (/* binding */ DEFAULT_TEXT_ALIGN),\n/* harmony export */ DEFAULT_TRANSFORM_HANDLE_SPACING: () => (/* binding */ DEFAULT_TRANSFORM_HANDLE_SPACING),\n/* harmony export */ DEFAULT_UI_OPTIONS: () => (/* binding */ DEFAULT_UI_OPTIONS),\n/* harmony export */ DEFAULT_VERSION: () => (/* binding */ DEFAULT_VERSION),\n/* harmony export */ DEFAULT_VERTICAL_ALIGN: () => (/* binding */ DEFAULT_VERTICAL_ALIGN),\n/* harmony export */ DRAGGING_THRESHOLD: () => (/* binding */ DRAGGING_THRESHOLD),\n/* harmony export */ EDITOR_LS_KEYS: () => (/* binding */ EDITOR_LS_KEYS),\n/* harmony export */ ELEMENT_LINK_KEY: () => (/* binding */ ELEMENT_LINK_KEY),\n/* harmony export */ ELEMENT_READY_TO_ERASE_OPACITY: () => (/* binding */ ELEMENT_READY_TO_ERASE_OPACITY),\n/* harmony export */ ELEMENT_SHIFT_TRANSLATE_AMOUNT: () => (/* binding */ ELEMENT_SHIFT_TRANSLATE_AMOUNT),\n/* harmony export */ ELEMENT_TRANSLATE_AMOUNT: () => (/* binding */ ELEMENT_TRANSLATE_AMOUNT),\n/* harmony export */ ENCRYPTION_KEY_BITS: () => (/* binding */ ENCRYPTION_KEY_BITS),\n/* harmony export */ ENV: () => (/* binding */ ENV),\n/* harmony export */ EPSILON: () => (/* binding */ EPSILON),\n/* harmony export */ EVENT: () => (/* binding */ EVENT),\n/* harmony export */ EXPORT_DATA_TYPES: () => (/* binding */ EXPORT_DATA_TYPES),\n/* harmony export */ EXPORT_IMAGE_TYPES: () => (/* binding */ EXPORT_IMAGE_TYPES),\n/* harmony export */ EXPORT_SCALES: () => (/* binding */ EXPORT_SCALES),\n/* harmony export */ EXPORT_SOURCE: () => (/* binding */ EXPORT_SOURCE),\n/* harmony export */ FONT_FAMILY: () => (/* binding */ FONT_FAMILY),\n/* harmony export */ FONT_FAMILY_FALLBACKS: () => (/* binding */ FONT_FAMILY_FALLBACKS),\n/* harmony export */ FRAME_STYLE: () => (/* binding */ FRAME_STYLE),\n/* harmony export */ HYPERLINK_TOOLTIP_DELAY: () => (/* binding */ HYPERLINK_TOOLTIP_DELAY),\n/* harmony export */ IDLE_THRESHOLD: () => (/* binding */ IDLE_THRESHOLD),\n/* harmony export */ IMAGE_MIME_TYPES: () => (/* binding */ IMAGE_MIME_TYPES),\n/* harmony export */ IMAGE_RENDER_TIMEOUT: () => (/* binding */ IMAGE_RENDER_TIMEOUT),\n/* harmony export */ LIBRARY_DISABLED_TYPES: () => (/* binding */ LIBRARY_DISABLED_TYPES),\n/* harmony export */ LIBRARY_SIDEBAR_TAB: () => (/* binding */ LIBRARY_SIDEBAR_TAB),\n/* harmony export */ LINE_CONFIRM_THRESHOLD: () => (/* binding */ LINE_CONFIRM_THRESHOLD),\n/* harmony export */ MAX_ALLOWED_FILE_BYTES: () => (/* binding */ MAX_ALLOWED_FILE_BYTES),\n/* harmony export */ MAX_DECIMALS_FOR_SVG_EXPORT: () => (/* binding */ MAX_DECIMALS_FOR_SVG_EXPORT),\n/* harmony export */ MAX_ZOOM: () => (/* binding */ MAX_ZOOM),\n/* harmony export */ MIME_TYPES: () => (/* binding */ MIME_TYPES),\n/* harmony export */ MIN_FONT_SIZE: () => (/* binding */ MIN_FONT_SIZE),\n/* harmony export */ MIN_WIDTH_OR_HEIGHT: () => (/* binding */ MIN_WIDTH_OR_HEIGHT),\n/* harmony export */ MIN_ZOOM: () => (/* binding */ MIN_ZOOM),\n/* harmony export */ MQ_MAX_HEIGHT_LANDSCAPE: () => (/* binding */ MQ_MAX_HEIGHT_LANDSCAPE),\n/* harmony export */ MQ_MAX_WIDTH_LANDSCAPE: () => (/* binding */ MQ_MAX_WIDTH_LANDSCAPE),\n/* harmony export */ MQ_MAX_WIDTH_PORTRAIT: () => (/* binding */ MQ_MAX_WIDTH_PORTRAIT),\n/* harmony export */ MQ_RIGHT_SIDEBAR_MIN_WIDTH: () => (/* binding */ MQ_RIGHT_SIDEBAR_MIN_WIDTH),\n/* harmony export */ ORIG_ID: () => (/* binding */ ORIG_ID),\n/* harmony export */ POINTER_BUTTON: () => (/* binding */ POINTER_BUTTON),\n/* harmony export */ POINTER_EVENTS: () => (/* binding */ POINTER_EVENTS),\n/* harmony export */ PRECEDING_ELEMENT_KEY: () => (/* binding */ PRECEDING_ELEMENT_KEY),\n/* harmony export */ ROUGHNESS: () => (/* binding */ ROUGHNESS),\n/* harmony export */ ROUNDNESS: () => (/* binding */ ROUNDNESS),\n/* harmony export */ SCROLL_TIMEOUT: () => (/* binding */ SCROLL_TIMEOUT),\n/* harmony export */ SHIFT_LOCKING_ANGLE: () => (/* binding */ SHIFT_LOCKING_ANGLE),\n/* harmony export */ SIDE_RESIZING_THRESHOLD: () => (/* binding */ SIDE_RESIZING_THRESHOLD),\n/* harmony export */ STATS_PANELS: () => (/* binding */ STATS_PANELS),\n/* harmony export */ STROKE_WIDTH: () => (/* binding */ STROKE_WIDTH),\n/* harmony export */ SVG_DOCUMENT_PREAMBLE: () => (/* binding */ SVG_DOCUMENT_PREAMBLE),\n/* harmony export */ SVG_NS: () => (/* binding */ SVG_NS),\n/* harmony export */ TAP_TWICE_TIMEOUT: () => (/* binding */ TAP_TWICE_TIMEOUT),\n/* harmony export */ TEXT_ALIGN: () => (/* binding */ TEXT_ALIGN),\n/* harmony export */ TEXT_AUTOWRAP_THRESHOLD: () => (/* binding */ TEXT_AUTOWRAP_THRESHOLD),\n/* harmony export */ TEXT_TO_CENTER_SNAP_THRESHOLD: () => (/* binding */ TEXT_TO_CENTER_SNAP_THRESHOLD),\n/* harmony export */ THEME: () => (/* binding */ THEME),\n/* harmony export */ THEME_FILTER: () => (/* binding */ THEME_FILTER),\n/* harmony export */ TITLE_TIMEOUT: () => (/* binding */ TITLE_TIMEOUT),\n/* harmony export */ TOOL_TYPE: () => (/* binding */ TOOL_TYPE),\n/* harmony export */ TOUCH_CTX_MENU_TIMEOUT: () => (/* binding */ TOUCH_CTX_MENU_TIMEOUT),\n/* harmony export */ URL_HASH_KEYS: () => (/* binding */ URL_HASH_KEYS),\n/* harmony export */ URL_QUERY_KEYS: () => (/* binding */ URL_QUERY_KEYS),\n/* harmony export */ UserIdleState: () => (/* binding */ UserIdleState),\n/* harmony export */ VERSIONS: () => (/* binding */ VERSIONS),\n/* harmony export */ VERSION_TIMEOUT: () => (/* binding */ VERSION_TIMEOUT),\n/* harmony export */ VERTICAL_ALIGN: () => (/* binding */ VERTICAL_ALIGN),\n/* harmony export */ WINDOWS_EMOJI_FALLBACK_FONT: () => (/* binding */ WINDOWS_EMOJI_FALLBACK_FONT),\n/* harmony export */ YOUTUBE_STATES: () => (/* binding */ YOUTUBE_STATES),\n/* harmony export */ ZOOM_STEP: () => (/* binding */ ZOOM_STEP),\n/* harmony export */ getFontFamilyFallbacks: () => (/* binding */ getFontFamilyFallbacks),\n/* harmony export */ isAndroid: () => (/* binding */ isAndroid),\n/* harmony export */ isBrave: () => (/* binding */ isBrave),\n/* harmony export */ isChrome: () => (/* binding */ isChrome),\n/* harmony export */ isDarwin: () => (/* binding */ isDarwin),\n/* harmony export */ isFirefox: () => (/* binding */ isFirefox),\n/* harmony export */ isIOS: () => (/* binding */ isIOS),\n/* harmony export */ isSafari: () => (/* binding */ isSafari),\n/* harmony export */ isWindows: () => (/* binding */ isWindows),\n/* harmony export */ supportsResizeObserver: () => (/* binding */ supportsResizeObserver)\n/* harmony export */ });\n/* harmony import */ var _colors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./colors */ \"../common/src/colors.ts\");\n\nconst isDarwin = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\nconst isWindows = /^Win/.test(navigator.platform);\nconst isAndroid = /\\b(android)\\b/i.test(navigator.userAgent);\nconst isFirefox = \"netscape\" in window && navigator.userAgent.indexOf(\"rv:\") > 1 && navigator.userAgent.indexOf(\"Gecko\") > 1;\nconst isChrome = navigator.userAgent.indexOf(\"Chrome\") !== -1;\nconst isSafari = !isChrome && navigator.userAgent.indexOf(\"Safari\") !== -1;\nconst isIOS = /iPad|iPhone/.test(navigator.platform) || // iPadOS 13+\nnavigator.userAgent.includes(\"Mac\") && \"ontouchend\" in document; // keeping function so it can be mocked in test\n\nconst isBrave = () => {\n var _a, _b;\n\n return ((_b = (_a = navigator.brave) === null || _a === void 0 ? void 0 : _a.isBrave) === null || _b === void 0 ? void 0 : _b.name) === \"isBrave\";\n};\nconst supportsResizeObserver = typeof window !== \"undefined\" && \"ResizeObserver\" in window;\nconst APP_NAME = \"Excalidraw\"; // distance when creating text before it's considered `autoResize: false`\n// we're using higher threshold so that clicks that end up being drags\n// don't unintentionally create text elements that are wrapped to a few chars\n// (happens a lot with fast clicks with the text tool)\n\nconst TEXT_AUTOWRAP_THRESHOLD = 36; // px\n\nconst DRAGGING_THRESHOLD = 10; // px\n\nconst LINE_CONFIRM_THRESHOLD = 8; // px\n\nconst ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;\nconst ELEMENT_TRANSLATE_AMOUNT = 1;\nconst TEXT_TO_CENTER_SNAP_THRESHOLD = 30;\nconst SHIFT_LOCKING_ANGLE = Math.PI / 12;\nconst DEFAULT_LASER_COLOR = \"red\";\nconst CURSOR_TYPE = {\n TEXT: \"text\",\n CROSSHAIR: \"crosshair\",\n GRABBING: \"grabbing\",\n GRAB: \"grab\",\n POINTER: \"pointer\",\n MOVE: \"move\",\n AUTO: \"\"\n};\nconst POINTER_BUTTON = {\n MAIN: 0,\n WHEEL: 1,\n SECONDARY: 2,\n TOUCH: -1,\n ERASER: 5\n};\nconst POINTER_EVENTS = {\n enabled: \"all\",\n disabled: \"none\",\n // asserted as any so it can be freely assigned to React Element\n // \"pointerEnvets\" CSS prop\n inheritFromUI: \"var(--ui-pointerEvents)\"\n};\nvar EVENT;\n\n(function (EVENT) {\n EVENT[\"COPY\"] = \"copy\";\n EVENT[\"PASTE\"] = \"paste\";\n EVENT[\"CUT\"] = \"cut\";\n EVENT[\"KEYDOWN\"] = \"keydown\";\n EVENT[\"KEYUP\"] = \"keyup\";\n EVENT[\"MOUSE_MOVE\"] = \"mousemove\";\n EVENT[\"RESIZE\"] = \"resize\";\n EVENT[\"UNLOAD\"] = \"unload\";\n EVENT[\"FOCUS\"] = \"focus\";\n EVENT[\"BLUR\"] = \"blur\";\n EVENT[\"DRAG_OVER\"] = \"dragover\";\n EVENT[\"DROP\"] = \"drop\";\n EVENT[\"GESTURE_END\"] = \"gestureend\";\n EVENT[\"BEFORE_UNLOAD\"] = \"beforeunload\";\n EVENT[\"GESTURE_START\"] = \"gesturestart\";\n EVENT[\"GESTURE_CHANGE\"] = \"gesturechange\";\n EVENT[\"POINTER_MOVE\"] = \"pointermove\";\n EVENT[\"POINTER_DOWN\"] = \"pointerdown\";\n EVENT[\"POINTER_UP\"] = \"pointerup\";\n EVENT[\"STATE_CHANGE\"] = \"statechange\";\n EVENT[\"WHEEL\"] = \"wheel\";\n EVENT[\"TOUCH_START\"] = \"touchstart\";\n EVENT[\"TOUCH_END\"] = \"touchend\";\n EVENT[\"HASHCHANGE\"] = \"hashchange\";\n EVENT[\"VISIBILITY_CHANGE\"] = \"visibilitychange\";\n EVENT[\"SCROLL\"] = \"scroll\"; // custom events\n\n EVENT[\"EXCALIDRAW_LINK\"] = \"excalidraw-link\";\n EVENT[\"MENU_ITEM_SELECT\"] = \"menu.itemSelect\";\n EVENT[\"MESSAGE\"] = \"message\";\n EVENT[\"FULLSCREENCHANGE\"] = \"fullscreenchange\";\n})(EVENT || (EVENT = {}));\n\nconst YOUTUBE_STATES = {\n UNSTARTED: -1,\n ENDED: 0,\n PLAYING: 1,\n PAUSED: 2,\n BUFFERING: 3,\n CUED: 5\n};\nconst ENV = {\n TEST: \"test\",\n DEVELOPMENT: \"development\",\n PRODUCTION: \"production\"\n};\nconst CLASSES = {\n SHAPE_ACTIONS_MENU: \"App-menu__left\",\n SHAPE_ACTIONS_MOBILE_MENU: \"App-mobile-menu\",\n MOBILE_TOOLBAR: \"App-toolbar-content\",\n ZOOM_ACTIONS: \"zoom-actions\",\n SEARCH_MENU_INPUT_WRAPPER: \"layer-ui__search-inputWrapper\",\n CONVERT_ELEMENT_TYPE_POPUP: \"ConvertElementTypePopup\"\n};\nconst CJK_HAND_DRAWN_FALLBACK_FONT = \"Xiaolai\";\nconst WINDOWS_EMOJI_FALLBACK_FONT = \"Segoe UI Emoji\";\n/**\r\n * // TODO: shouldn't be really `const`, likely neither have integers as values, due to value for the custom fonts, which should likely be some hash.\r\n *\r\n * Let's think this through and consider:\r\n * - https://developer.mozilla.org/en-US/docs/Web/CSS/generic-family\r\n * - https://drafts.csswg.org/css-fonts-4/#font-family-prop\r\n * - https://learn.microsoft.com/en-us/typography/opentype/spec/ibmfc\r\n */\n\nconst FONT_FAMILY = {\n Virgil: 1,\n Helvetica: 2,\n Cascadia: 3,\n \"Local Font\": 4,\n // leave 4 unused as it was historically used for Assistant (which we don't use anymore) or custom font (Obsidian)\n Excalifont: 5,\n Nunito: 6,\n \"Lilita One\": 7,\n \"Comic Shanns\": 8,\n \"Liberation Sans\": 9\n};\nconst FONT_FAMILY_FALLBACKS = {\n [CJK_HAND_DRAWN_FALLBACK_FONT]: 100,\n [WINDOWS_EMOJI_FALLBACK_FONT]: 1000\n};\nconst getFontFamilyFallbacks = fontFamily => {\n switch (fontFamily) {\n case FONT_FAMILY.Excalifont:\n return [CJK_HAND_DRAWN_FALLBACK_FONT, WINDOWS_EMOJI_FALLBACK_FONT];\n\n default:\n return [WINDOWS_EMOJI_FALLBACK_FONT];\n }\n};\nconst THEME = {\n LIGHT: \"light\",\n DARK: \"dark\"\n};\nconst FRAME_STYLE = {\n strokeColor: \"#bbb\",\n strokeWidth: 2,\n strokeStyle: \"solid\",\n fillStyle: \"solid\",\n roughness: 0,\n roundness: null,\n backgroundColor: \"transparent\",\n radius: 8,\n nameOffsetY: 3,\n nameColorLightTheme: \"#999999\",\n nameColorDarkTheme: \"#7a7a7a\",\n nameFontSize: 14,\n nameLineHeight: 1.25\n};\nconst MIN_FONT_SIZE = 1;\nconst DEFAULT_FONT_SIZE = 20;\nconst DEFAULT_FONT_FAMILY = FONT_FAMILY.Excalifont;\nconst DEFAULT_TEXT_ALIGN = \"left\";\nconst DEFAULT_VERTICAL_ALIGN = \"top\";\nconst DEFAULT_VERSION = \"{version}\";\nconst DEFAULT_TRANSFORM_HANDLE_SPACING = 2;\nconst SIDE_RESIZING_THRESHOLD = 2 * DEFAULT_TRANSFORM_HANDLE_SPACING; // a small epsilon to make side resizing always take precedence\n// (avoids an increase in renders and changes to tests)\n\nconst EPSILON = 0.00001;\nconst DEFAULT_COLLISION_THRESHOLD = 2 * SIDE_RESIZING_THRESHOLD - EPSILON;\nconst COLOR_WHITE = \"#ffffff\";\nconst COLOR_CHARCOAL_BLACK = \"#1e1e1e\"; // keep this in sync with CSS\n\nconst COLOR_VOICE_CALL = \"#a2f1a6\";\nconst CANVAS_ONLY_ACTIONS = [\"selectAll\"];\nconst DEFAULT_GRID_SIZE = 20;\nconst DEFAULT_GRID_STEP = 5;\nconst IMAGE_MIME_TYPES = {\n svg: \"image/svg+xml\",\n png: \"image/png\",\n jpg: \"image/jpeg\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n bmp: \"image/bmp\",\n ico: \"image/x-icon\",\n avif: \"image/avif\",\n jfif: \"image/jfif\"\n};\nconst MIME_TYPES = Object.assign({\n text: \"text/plain\",\n html: \"text/html\",\n json: \"application/json\",\n // excalidraw data\n excalidraw: \"application/vnd.excalidraw+json\",\n excalidrawlib: \"application/vnd.excalidrawlib+json\",\n // image-encoded excalidraw data\n \"excalidraw.svg\": \"image/svg+xml\",\n \"excalidraw.png\": \"image/png\",\n // binary\n binary: \"application/octet-stream\"\n}, IMAGE_MIME_TYPES);\nconst ALLOWED_PASTE_MIME_TYPES = [MIME_TYPES.text, MIME_TYPES.html, ...Object.values(IMAGE_MIME_TYPES)];\nconst EXPORT_IMAGE_TYPES = {\n png: \"png\",\n svg: \"svg\",\n clipboard: \"clipboard\"\n};\nconst EXPORT_DATA_TYPES = {\n excalidraw: \"excalidraw\",\n excalidrawClipboard: \"excalidraw/clipboard\",\n excalidrawLibrary: \"excalidrawlib\",\n excalidrawClipboardWithAPI: \"excalidraw-api/clipboard\"\n};\nconst EXPORT_SOURCE = window.EXCALIDRAW_EXPORT_SOURCE || window.location.origin; // time in milliseconds\n\nconst IMAGE_RENDER_TIMEOUT = 500;\nconst TAP_TWICE_TIMEOUT = 300;\nconst TOUCH_CTX_MENU_TIMEOUT = 500;\nconst TITLE_TIMEOUT = 10000;\nconst VERSION_TIMEOUT = 30000;\nconst SCROLL_TIMEOUT = 100;\nconst ZOOM_STEP = 0.05; //zsviczian\n\nconst MIN_ZOOM = 0.1;\nconst MAX_ZOOM = 30;\nconst HYPERLINK_TOOLTIP_DELAY = 300; // Report a user inactive after IDLE_THRESHOLD milliseconds\n\nconst IDLE_THRESHOLD = 60000; // Report a user active each ACTIVE_THRESHOLD milliseconds\n\nconst ACTIVE_THRESHOLD = 3000; // duplicates --theme-filter, should be removed soon\n\nconst THEME_FILTER = \"invert(93%) hue-rotate(180deg)\";\nconst URL_QUERY_KEYS = {\n addLibrary: \"addLibrary\"\n};\nconst URL_HASH_KEYS = {\n addLibrary: \"addLibrary\"\n};\nconst DEFAULT_UI_OPTIONS = {\n canvasActions: {\n changeViewBackgroundColor: true,\n clearCanvas: true,\n export: {\n saveFileToDisk: true\n },\n loadScene: true,\n saveToActiveFile: true,\n toggleTheme: null,\n saveAsImage: true\n },\n tools: {\n image: true\n }\n}; // breakpoints\n// -----------------------------------------------------------------------------\n// md screen\n\nconst MQ_MAX_WIDTH_PORTRAIT = 730;\nconst MQ_MAX_WIDTH_LANDSCAPE = 1000;\nconst MQ_MAX_HEIGHT_LANDSCAPE = 500; // sidebar\n\nconst MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229; // -----------------------------------------------------------------------------\n\nconst MAX_DECIMALS_FOR_SVG_EXPORT = 2;\nconst EXPORT_SCALES = [1, 2, 3];\nconst DEFAULT_EXPORT_PADDING = 10; // px\n\nconst DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 2880; //zsviczian was 1440\n\nconst MAX_ALLOWED_FILE_BYTES = 20 * 1024 * 1024;\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\nconst SVG_DOCUMENT_PREAMBLE = `<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n`;\nconst ENCRYPTION_KEY_BITS = 128;\nconst VERSIONS = {\n excalidraw: 2,\n excalidrawLibrary: 2\n};\nconst BOUND_TEXT_PADDING = 5;\nconst ARROW_LABEL_WIDTH_FRACTION = 0.7;\nconst ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO = 11;\nconst VERTICAL_ALIGN = {\n TOP: \"top\",\n MIDDLE: \"middle\",\n BOTTOM: \"bottom\"\n};\nconst TEXT_ALIGN = {\n LEFT: \"left\",\n CENTER: \"center\",\n RIGHT: \"right\"\n};\nconst ELEMENT_READY_TO_ERASE_OPACITY = 20; // Radius represented as 25% of element's largest side (width/height).\n// Used for LEGACY and PROPORTIONAL_RADIUS algorithms, or when the element is\n// below the cutoff size.\n\nconst DEFAULT_PROPORTIONAL_RADIUS = 0.25; // Fixed radius for the ADAPTIVE_RADIUS algorithm. In pixels.\n\nconst DEFAULT_ADAPTIVE_RADIUS = 32; // roundness type (algorithm)\n\nconst ROUNDNESS = {\n // Used for legacy rounding (rectangles), which currently works the same\n // as PROPORTIONAL_RADIUS, but we need to differentiate for UI purposes and\n // forwards-compat.\n LEGACY: 1,\n // Used for linear elements & diamonds\n PROPORTIONAL_RADIUS: 2,\n // Current default algorithm for rectangles, using fixed pixel radius.\n // It's working similarly to a regular border-radius, but attemps to make\n // radius visually similar across differnt element sizes, especially\n // very large and very small elements.\n //\n // NOTE right now we don't allow configuration and use a constant radius\n // (see DEFAULT_ADAPTIVE_RADIUS constant)\n ADAPTIVE_RADIUS: 3\n};\n/** key containt id of precedeing elemnt id we use in reconciliation during\r\n * collaboration */\n\nconst PRECEDING_ELEMENT_KEY = \"__precedingElement__\"; //zsviczian\n\nconst COLOR_NAMES = {\n aliceblue: \"#f0f8ff\",\n antiquewhite: \"#faebd7\",\n aqua: \"#00ffff\",\n aquamarine: \"#7fffd4\",\n azure: \"#f0ffff\",\n beige: \"#f5f5dc\",\n bisque: \"#ffe4c4\",\n black: \"#000000\",\n blanchedalmond: \"#ffebcd\",\n blue: \"#0000ff\",\n blueviolet: \"#8a2be2\",\n brown: \"#a52a2a\",\n burlywood: \"#deb887\",\n cadetblue: \"#5f9ea0\",\n chartreuse: \"#7fff00\",\n chocolate: \"#d2691e\",\n coral: \"#ff7f50\",\n cornflowerblue: \"#6495ed\",\n cornsilk: \"#fff8dc\",\n crimson: \"#dc143c\",\n cyan: \"#00ffff\",\n darkblue: \"#00008b\",\n darkcyan: \"#008b8b\",\n darkgoldenrod: \"#b8860b\",\n darkgray: \"#a9a9a9\",\n darkgreen: \"#006400\",\n darkkhaki: \"#bdb76b\",\n darkmagenta: \"#8b008b\",\n darkolivegreen: \"#556b2f\",\n darkorange: \"#ff8c00\",\n darkorchid: \"#9932cc\",\n darkred: \"#8b0000\",\n darksalmon: \"#e9967a\",\n darkseagreen: \"#8fbc8f\",\n darkslateblue: \"#483d8b\",\n darkslategray: \"#2f4f4f\",\n darkturquoise: \"#00ced1\",\n darkviolet: \"#9400d3\",\n deeppink: \"#ff1493\",\n deepskyblue: \"#00bfff\",\n dimgray: \"#696969\",\n dodgerblue: \"#1e90ff\",\n firebrick: \"#b22222\",\n floralwhite: \"#fffaf0\",\n forestgreen: \"#228b22\",\n fuchsia: \"#ff00ff\",\n gainsboro: \"#dcdcdc\",\n ghostwhite: \"#f8f8ff\",\n gold: \"#ffd700\",\n goldenrod: \"#daa520\",\n gray: \"#808080\",\n green: \"#008000\",\n greenyellow: \"#adff2f\",\n honeydew: \"#f0fff0\",\n hotpink: \"#ff69b4\",\n indianred: \"#cd5c5c\",\n indigo: \"#4b0082\",\n ivory: \"#fffff0\",\n khaki: \"#f0e68c\",\n lavender: \"#e6e6fa\",\n lavenderblush: \"#fff0f5\",\n lawngreen: \"#7cfc00\",\n lemonchiffon: \"#fffacd\",\n lightblue: \"#add8e6\",\n lightcoral: \"#f08080\",\n lightcyan: \"#e0ffff\",\n lightgoldenrodyellow: \"#fafad2\",\n lightgrey: \"#d3d3d3\",\n lightgreen: \"#90ee90\",\n lightpink: \"#ffb6c1\",\n lightsalmon: \"#ffa07a\",\n lightseagreen: \"#20b2aa\",\n lightskyblue: \"#87cefa\",\n lightslategray: \"#778899\",\n lightsteelblue: \"#b0c4de\",\n lightyellow: \"#ffffe0\",\n lime: \"#00ff00\",\n limegreen: \"#32cd32\",\n linen: \"#faf0e6\",\n magenta: \"#ff00ff\",\n maroon: \"#800000\",\n mediumaquamarine: \"#66cdaa\",\n mediumblue: \"#0000cd\",\n mediumorchid: \"#ba55d3\",\n mediumpurple: \"#9370d8\",\n mediumseagreen: \"#3cb371\",\n mediumslateblue: \"#7b68ee\",\n mediumspringgreen: \"#00fa9a\",\n mediumturquoise: \"#48d1cc\",\n mediumvioletred: \"#c71585\",\n midnightblue: \"#191970\",\n mintcream: \"#f5fffa\",\n mistyrose: \"#ffe4e1\",\n moccasin: \"#ffe4b5\",\n navajowhite: \"#ffdead\",\n navy: \"#000080\",\n oldlace: \"#fdf5e6\",\n olive: \"#808000\",\n olivedrab: \"#6b8e23\",\n orange: \"#ffa500\",\n orangered: \"#ff4500\",\n orchid: \"#da70d6\",\n palegoldenrod: \"#eee8aa\",\n palegreen: \"#98fb98\",\n paleturquoise: \"#afeeee\",\n palevioletred: \"#d87093\",\n papayawhip: \"#ffefd5\",\n peachpuff: \"#ffdab9\",\n peru: \"#cd853f\",\n pink: \"#ffc0cb\",\n plum: \"#dda0dd\",\n powderblue: \"#b0e0e6\",\n purple: \"#800080\",\n rebeccapurple: \"#663399\",\n red: \"#ff0000\",\n rosybrown: \"#bc8f8f\",\n royalblue: \"#4169e1\",\n saddlebrown: \"#8b4513\",\n salmon: \"#fa8072\",\n sandybrown: \"#f4a460\",\n seagreen: \"#2e8b57\",\n seashell: \"#fff5ee\",\n sienna: \"#a0522d\",\n silver: \"#c0c0c0\",\n skyblue: \"#87ceeb\",\n slateblue: \"#6a5acd\",\n slategray: \"#708090\",\n snow: \"#fffafa\",\n springgreen: \"#00ff7f\",\n steelblue: \"#4682b4\",\n tan: \"#d2b48c\",\n teal: \"#008080\",\n thistle: \"#d8bfd8\",\n tomato: \"#ff6347\",\n turquoise: \"#40e0d0\",\n violet: \"#ee82ee\",\n wheat: \"#f5deb3\",\n white: \"#ffffff\",\n whitesmoke: \"#f5f5f5\",\n yellow: \"#ffff00\",\n yellowgreen: \"#9acd32\"\n};\nconst ROUGHNESS = {\n architect: 0,\n artist: 1,\n cartoonist: 2\n};\nconst STROKE_WIDTH = {\n extraThin: 0.5,\n thin: 1,\n bold: 2,\n extraBold: 4\n};\nconst DEFAULT_ELEMENT_PROPS = {\n strokeColor: _colors__WEBPACK_IMPORTED_MODULE_0__.COLOR_PALETTE.black,\n backgroundColor: _colors__WEBPACK_IMPORTED_MODULE_0__.COLOR_PALETTE.transparent,\n fillStyle: \"solid\",\n strokeWidth: 2,\n strokeStyle: \"solid\",\n roughness: ROUGHNESS.artist,\n opacity: 100,\n locked: false\n};\nconst LIBRARY_SIDEBAR_TAB = \"library\";\nconst CANVAS_SEARCH_TAB = \"search\";\nconst DEFAULT_SIDEBAR = {\n name: \"default\",\n defaultTab: LIBRARY_SIDEBAR_TAB\n};\nconst LIBRARY_DISABLED_TYPES = new Set([\"iframe\", \"embeddable\", \"image\"]); // use these constants to easily identify reference sites\n\nconst TOOL_TYPE = {\n selection: \"selection\",\n lasso: \"lasso\",\n rectangle: \"rectangle\",\n diamond: \"diamond\",\n ellipse: \"ellipse\",\n arrow: \"arrow\",\n line: \"line\",\n freedraw: \"freedraw\",\n text: \"text\",\n image: \"image\",\n eraser: \"eraser\",\n hand: \"hand\",\n frame: \"frame\",\n magicframe: \"magicframe\",\n embeddable: \"embeddable\",\n laser: \"laser\"\n};\nconst EDITOR_LS_KEYS = {\n OAI_API_KEY: \"excalidraw-oai-api-key\",\n // legacy naming (non)scheme\n MERMAID_TO_EXCALIDRAW: \"mermaid-to-excalidraw\",\n PUBLISH_LIBRARY: \"publish-library-data\"\n};\n/**\r\n * not translated as this is used only in public, stateless API as default value\r\n * where filename is optional and we can't retrieve name from app state\r\n */\n\nconst DEFAULT_FILENAME = \"Untitled\";\nconst STATS_PANELS = {\n generalStats: 1,\n elementProperties: 2\n};\nconst MIN_WIDTH_OR_HEIGHT = 1;\nconst ARROW_TYPE = {\n sharp: \"sharp\",\n round: \"round\",\n elbow: \"elbow\"\n};\nconst DEFAULT_REDUCED_GLOBAL_ALPHA = 0.3;\nconst ELEMENT_LINK_KEY = \"element\";\n/** used in tests */\n\nconst ORIG_ID = Symbol.for(\"__test__originalId__\");\nvar UserIdleState;\n\n(function (UserIdleState) {\n UserIdleState[\"ACTIVE\"] = \"active\";\n UserIdleState[\"AWAY\"] = \"away\";\n UserIdleState[\"IDLE\"] = \"idle\";\n})(UserIdleState || (UserIdleState = {}));\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/constants.ts?");
|
|
12930
12930
|
|
|
12931
12931
|
/***/ }),
|
|
12932
12932
|
|
|
@@ -13080,7 +13080,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
13080
13080
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
13081
13081
|
|
|
13082
13082
|
"use strict";
|
|
13083
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BINDING_HIGHLIGHT_OFFSET: () => (/* binding */ BINDING_HIGHLIGHT_OFFSET),\n/* harmony export */ BINDING_HIGHLIGHT_THICKNESS: () => (/* binding */ BINDING_HIGHLIGHT_THICKNESS),\n/* harmony export */ BindableElement: () => (/* binding */ BindableElement),\n/* harmony export */ BoundElement: () => (/* binding */ BoundElement),\n/* harmony export */ FIXED_BINDING_DISTANCE: () => (/* binding */ FIXED_BINDING_DISTANCE),\n/* harmony export */ avoidRectangularCorner: () => (/* binding */ avoidRectangularCorner),\n/* harmony export */ bindLinearElement: () => (/* binding */ bindLinearElement),\n/* harmony export */ bindOrUnbindLinearElement: () => (/* binding */ bindOrUnbindLinearElement),\n/* harmony export */ bindOrUnbindLinearElements: () => (/* binding */ bindOrUnbindLinearElements),\n/* harmony export */ bindPointToSnapToElementOutline: () => (/* binding */ bindPointToSnapToElementOutline),\n/* harmony export */ bindingBorderTest: () => (/* binding */ bindingBorderTest),\n/* harmony export */ bindingProperties: () => (/* binding */ bindingProperties),\n/* harmony export */ calculateFixedPointForElbowArrowBinding: () => (/* binding */ calculateFixedPointForElbowArrowBinding),\n/* harmony export */ determineFocusDistance: () => (/* binding */ determineFocusDistance),\n/* harmony export */ fixBindingsAfterDeletion: () => (/* binding */ fixBindingsAfterDeletion),\n/* harmony export */ fixDuplicatedBindingsAfterDuplication: () => (/* binding */ fixDuplicatedBindingsAfterDuplication),\n/* harmony export */ getArrowLocalFixedPoints: () => (/* binding */ getArrowLocalFixedPoints),\n/* harmony export */ getGlobalFixedPointForBindableElement: () => (/* binding */ getGlobalFixedPointForBindableElement),\n/* harmony export */ getGlobalFixedPoints: () => (/* binding */ getGlobalFixedPoints),\n/* harmony export */ getHeadingForElbowArrowSnap: () => (/* binding */ getHeadingForElbowArrowSnap),\n/* harmony export */ getHoveredElementForBinding: () => (/* binding */ getHoveredElementForBinding),\n/* harmony export */ getSuggestedBindingsForArrows: () => (/* binding */ getSuggestedBindingsForArrows),\n/* harmony export */ isBindingEnabled: () => (/* binding */ isBindingEnabled),\n/* harmony export */ isLinearElementSimpleAndAlreadyBound: () => (/* binding */ isLinearElementSimpleAndAlreadyBound),\n/* harmony export */ maxBindingGap: () => (/* binding */ maxBindingGap),\n/* harmony export */ maybeBindLinearElement: () => (/* binding */ maybeBindLinearElement),\n/* harmony export */ normalizeFixedPoint: () => (/* binding */ normalizeFixedPoint),\n/* harmony export */ shouldEnableBindingForPointerEvent: () => (/* binding */ shouldEnableBindingForPointerEvent),\n/* harmony export */ snapToMid: () => (/* binding */ snapToMid),\n/* harmony export */ updateBoundElements: () => (/* binding */ updateBoundElements)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/utils/collision */ \"../utils/src/collision.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _collision__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./collision */ \"../element/src/collision.ts\");\n/* harmony import */ var _distance__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./distance */ \"../element/src/distance.ts\");\n/* harmony import */ var _heading__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./heading */ \"../element/src/heading.ts\");\n/* harmony import */ var _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _mutateElement__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _textElement__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shapes */ \"../element/src/shapes.ts\");\n/* harmony import */ var _elbowArrow__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./elbowArrow */ \"../element/src/elbowArrow.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst shouldEnableBindingForPointerEvent = event => {\n return !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.CTRL_OR_CMD];\n};\nconst isBindingEnabled = appState => {\n return appState.invertBindingBehaviour //zsviczian\n ? !appState.isBindingEnabled : appState.isBindingEnabled;\n};\nconst FIXED_BINDING_DISTANCE = 5;\nconst BINDING_HIGHLIGHT_THICKNESS = 10;\nconst BINDING_HIGHLIGHT_OFFSET = 4;\n\nconst getNonDeletedElements = (scene, ids) => {\n const result = [];\n ids.forEach(id => {\n const element = scene.getNonDeletedElement(id);\n\n if (element != null) {\n result.push(element);\n }\n });\n return result;\n};\n\nconst bindOrUnbindLinearElement = (linearElement, startBindingElement, endBindingElement, scene) => {\n const boundToElementIds = new Set();\n const unboundFromElementIds = new Set();\n bindOrUnbindLinearElementEdge(linearElement, startBindingElement, endBindingElement, \"start\", boundToElementIds, unboundFromElementIds, scene);\n bindOrUnbindLinearElementEdge(linearElement, endBindingElement, startBindingElement, \"end\", boundToElementIds, unboundFromElementIds, scene);\n const onlyUnbound = Array.from(unboundFromElementIds).filter(id => !boundToElementIds.has(id));\n getNonDeletedElements(scene, onlyUnbound).forEach(element => {\n var _a;\n\n scene.mutateElement(element, {\n boundElements: (_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.filter(element => element.type !== \"arrow\" || element.id !== linearElement.id)\n });\n });\n};\n\nconst bindOrUnbindLinearElementEdge = (linearElement, bindableElement, otherEdgeBindableElement, startOrEnd, // Is mutated\nboundToElementIds, // Is mutated\nunboundFromElementIds, scene) => {\n // \"keep\" is for method chaining convenience, a \"no-op\", so just bail out\n if (bindableElement === \"keep\") {\n return;\n } // null means break the bind, so nothing to consider here\n\n\n if (bindableElement === null) {\n const unbound = unbindLinearElement(linearElement, startOrEnd, scene);\n\n if (unbound != null) {\n unboundFromElementIds.add(unbound);\n }\n\n return;\n } // While complext arrows can do anything, simple arrow with both ends trying\n // to bind to the same bindable should not be allowed, start binding takes\n // precedence\n\n\n if (isLinearElementSimple(linearElement)) {\n if (otherEdgeBindableElement == null || (otherEdgeBindableElement === \"keep\" ? // TODO: Refactor - Needlessly complex\n !isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, bindableElement, startOrEnd) : startOrEnd === \"start\" || otherEdgeBindableElement.id !== bindableElement.id)) {\n bindLinearElement(linearElement, bindableElement, startOrEnd, scene);\n boundToElementIds.add(bindableElement.id);\n }\n } else {\n bindLinearElement(linearElement, bindableElement, startOrEnd, scene);\n boundToElementIds.add(bindableElement.id);\n }\n};\n\nconst getOriginalBindingIfStillCloseOfLinearElementEdge = (linearElement, edge, elementsMap, zoom) => {\n var _a, _b;\n\n const coors = getLinearElementEdgeCoors(linearElement, edge, elementsMap);\n const elementId = edge === \"start\" ? (_a = linearElement.startBinding) === null || _a === void 0 ? void 0 : _a.elementId : (_b = linearElement.endBinding) === null || _b === void 0 ? void 0 : _b.elementId;\n\n if (elementId) {\n const element = elementsMap.get(elementId);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element) && bindingBorderTest(element, coors, elementsMap, zoom)) {\n return element;\n }\n }\n\n return null;\n};\n\nconst getOriginalBindingsIfStillCloseToArrowEnds = (linearElement, elementsMap, zoom) => [\"start\", \"end\"].map(edge => getOriginalBindingIfStillCloseOfLinearElementEdge(linearElement, edge, elementsMap, zoom));\n\nconst getBindingStrategyForDraggingArrowEndpoints = (selectedElement, isBindingEnabled, draggingPoints, elementsMap, elements, zoom) => {\n const startIdx = 0;\n const endIdx = selectedElement.points.length - 1;\n const startDragged = draggingPoints.findIndex(i => i === startIdx) > -1;\n const endDragged = draggingPoints.findIndex(i => i === endIdx) > -1;\n const start = startDragged ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"start\", elementsMap, elements, zoom) : null // If binding is disabled and start is dragged, break all binds\n : \"keep\";\n const end = endDragged ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"end\", elementsMap, elements, zoom) : null // If binding is disabled and end is dragged, break all binds\n : \"keep\";\n return [start, end];\n};\n\nconst getBindingStrategyForDraggingArrowOrJoints = (selectedElement, elementsMap, elements, isBindingEnabled, zoom) => {\n // Elbow arrows don't bind when dragged as a whole\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(selectedElement)) {\n return [\"keep\", \"keep\"];\n }\n\n const [startIsClose, endIsClose] = getOriginalBindingsIfStillCloseToArrowEnds(selectedElement, elementsMap, zoom);\n const start = startIsClose ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"start\", elementsMap, elements, zoom) : null : null;\n const end = endIsClose ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"end\", elementsMap, elements, zoom) : null : null;\n return [start, end];\n};\n\nconst bindOrUnbindLinearElements = (selectedElements, isBindingEnabled, draggingPoints, scene, zoom) => {\n selectedElements.forEach(selectedElement => {\n const [start, end] = (draggingPoints === null || draggingPoints === void 0 ? void 0 : draggingPoints.length) ? // The arrow edge points are dragged (i.e. start, end)\n getBindingStrategyForDraggingArrowEndpoints(selectedElement, isBindingEnabled, draggingPoints !== null && draggingPoints !== void 0 ? draggingPoints : [], scene.getNonDeletedElementsMap(), scene.getNonDeletedElements(), zoom) : // The arrow itself (the shaft) or the inner joins are dragged\n getBindingStrategyForDraggingArrowOrJoints(selectedElement, scene.getNonDeletedElementsMap(), scene.getNonDeletedElements(), isBindingEnabled, zoom);\n bindOrUnbindLinearElement(selectedElement, start, end, scene);\n });\n};\nconst getSuggestedBindingsForArrows = (selectedElements, elementsMap, zoom) => {\n // HOT PATH: Bail out if selected elements list is too large\n if (selectedElements.length > 50) {\n return [];\n }\n\n return selectedElements.filter(_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isLinearElement).flatMap(element => getOriginalBindingsIfStillCloseToArrowEnds(element, elementsMap, zoom)).filter(element => element !== null) // Filter out bind candidates which are in the\n // same selection / group with the arrow\n //\n // TODO: Is it worth turning the list into a set to avoid dupes?\n .filter(element => selectedElements.filter(selected => selected.id === (element === null || element === void 0 ? void 0 : element.id)).length === 0);\n};\nconst maybeBindLinearElement = (linearElement, appState, pointerCoords, scene) => {\n const elements = scene.getNonDeletedElements();\n const elementsMap = scene.getNonDeletedElementsMap();\n\n if (appState.startBoundElement != null) {\n bindLinearElement(linearElement, appState.startBoundElement, \"start\", scene);\n }\n\n const hoveredElement = getHoveredElementForBinding(pointerCoords, elements, elementsMap, appState.zoom, (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement), (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement));\n\n if (hoveredElement !== null) {\n if (!isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, hoveredElement, \"end\")) {\n bindLinearElement(linearElement, hoveredElement, \"end\", scene);\n }\n }\n};\n\nconst normalizePointBinding = (binding, hoveredElement) => {\n let gap = binding.gap;\n const maxGap = maxBindingGap(hoveredElement, hoveredElement.width, hoveredElement.height);\n\n if (gap > maxGap) {\n gap = BINDING_HIGHLIGHT_THICKNESS + BINDING_HIGHLIGHT_OFFSET;\n }\n\n return Object.assign(Object.assign({}, binding), {\n gap\n });\n};\n\nconst bindLinearElement = (linearElement, hoveredElement, startOrEnd, scene) => {\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isArrowElement)(linearElement)) {\n return;\n }\n\n let binding = Object.assign({\n elementId: hoveredElement.id\n }, normalizePointBinding(calculateFocusAndGap(linearElement, hoveredElement, startOrEnd, scene.getNonDeletedElementsMap()), hoveredElement));\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement)) {\n binding = Object.assign(Object.assign({}, binding), calculateFixedPointForElbowArrowBinding(linearElement, hoveredElement, startOrEnd));\n }\n\n scene.mutateElement(linearElement, {\n [startOrEnd === \"start\" ? \"startBinding\" : \"endBinding\"]: binding\n });\n const boundElementsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.arrayToMap)(hoveredElement.boundElements || []);\n\n if (!boundElementsMap.has(linearElement.id)) {\n scene.mutateElement(hoveredElement, {\n boundElements: (hoveredElement.boundElements || []).concat({\n id: linearElement.id,\n type: \"arrow\"\n })\n });\n }\n}; // Don't bind both ends of a simple segment\n\nconst isLinearElementSimpleAndAlreadyBoundOnOppositeEdge = (linearElement, bindableElement, startOrEnd) => {\n const otherBinding = linearElement[startOrEnd === \"start\" ? \"endBinding\" : \"startBinding\"];\n return isLinearElementSimpleAndAlreadyBound(linearElement, otherBinding === null || otherBinding === void 0 ? void 0 : otherBinding.elementId, bindableElement);\n};\n\nconst isLinearElementSimpleAndAlreadyBound = (linearElement, alreadyBoundToId, bindableElement) => {\n return alreadyBoundToId === bindableElement.id && isLinearElementSimple(linearElement);\n};\n\nconst isLinearElementSimple = linearElement => linearElement.points.length < 3;\n\nconst unbindLinearElement = (linearElement, startOrEnd, scene) => {\n const field = startOrEnd === \"start\" ? \"startBinding\" : \"endBinding\";\n const binding = linearElement[field];\n\n if (binding == null) {\n return null;\n }\n\n scene.mutateElement(linearElement, {\n [field]: null\n });\n return binding.elementId;\n};\n\nconst getHoveredElementForBinding = (pointerCoords, elements, elementsMap, zoom, fullShape, considerAllElements) => {\n if (considerAllElements) {\n let cullRest = false;\n const candidateElements = getAllElementsAtPositionForBinding(elements, element => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element, false) && bindingBorderTest(element, pointerCoords, elementsMap, zoom, (fullShape || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isBindingFallthroughEnabled)(element)) && // disable fullshape snapping for frame elements so we\n // can bind to frame children\n !(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isFrameLikeElement)(element))).filter(element => {\n if (cullRest) {\n return false;\n }\n\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isBindingFallthroughEnabled)(element)) {\n cullRest = true;\n }\n\n return true;\n }); // Return early if there are no candidates or just one candidate\n\n if (!candidateElements || candidateElements.length === 0) {\n return null;\n }\n\n if (candidateElements.length === 1) {\n return candidateElements[0];\n } // Prefer the shape with the border being tested (if any)\n\n\n const borderTestElements = candidateElements.filter(element => bindingBorderTest(element, pointerCoords, elementsMap, zoom, false));\n\n if (borderTestElements.length === 1) {\n return borderTestElements[0];\n } // Prefer smaller shapes\n\n\n return candidateElements.sort((a, b) => b.width ** 2 + b.height ** 2 - (a.width ** 2 + a.height ** 2)).pop();\n }\n\n const hoveredElement = getElementAtPositionForBinding(elements, element => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element, false) && bindingBorderTest(element, pointerCoords, elementsMap, zoom, // disable fullshape snapping for frame elements so we\n // can bind to frame children\n (fullShape || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isBindingFallthroughEnabled)(element)) && !(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isFrameLikeElement)(element)));\n return hoveredElement;\n};\n\nconst getElementAtPositionForBinding = (elements, isAtPositionFn) => {\n let hitElement = null; // We need to to hit testing from front (end of the array) to back (beginning of the array)\n // because array is ordered from lower z-index to highest and we want element z-index\n // with higher z-index\n\n for (let index = elements.length - 1; index >= 0; --index) {\n const element = elements[index];\n\n if (element.isDeleted) {\n continue;\n }\n\n if (isAtPositionFn(element)) {\n hitElement = element;\n break;\n }\n }\n\n return hitElement;\n};\n\nconst getAllElementsAtPositionForBinding = (elements, isAtPositionFn) => {\n const elementsAtPosition = []; // We need to to hit testing from front (end of the array) to back (beginning of the array)\n // because array is ordered from lower z-index to highest and we want element z-index\n // with higher z-index\n\n for (let index = elements.length - 1; index >= 0; --index) {\n const element = elements[index];\n\n if (element.isDeleted) {\n continue;\n }\n\n if (isAtPositionFn(element)) {\n elementsAtPosition.push(element);\n }\n }\n\n return elementsAtPosition;\n};\n\nconst calculateFocusAndGap = (linearElement, hoveredElement, startOrEnd, elementsMap) => {\n const direction = startOrEnd === \"start\" ? -1 : 1;\n const edgePointIndex = direction === -1 ? 0 : linearElement.points.length - 1;\n const adjacentPointIndex = edgePointIndex - direction;\n const edgePoint = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, edgePointIndex, elementsMap);\n const adjacentPoint = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, adjacentPointIndex, elementsMap);\n return {\n focus: determineFocusDistance(hoveredElement, adjacentPoint, edgePoint),\n gap: Math.max(1, (0,_distance__WEBPACK_IMPORTED_MODULE_5__.distanceToBindableElement)(hoveredElement, edgePoint))\n };\n}; // Supports translating, rotating and scaling `changedElement` with bound\n// linear elements.\n// Because scaling involves moving the focus points as well, it is\n// done before the `changedElement` is updated, and the `newSize` is passed\n// in explicitly.\n\n\nconst updateBoundElements = (changedElement, scene, options) => {\n const {\n newSize,\n simultaneouslyUpdated\n } = options !== null && options !== void 0 ? options : {};\n const simultaneouslyUpdatedElementIds = getSimultaneouslyUpdatedElementIds(simultaneouslyUpdated);\n\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(changedElement)) {\n return;\n }\n\n const elementsMap = scene.getNonDeletedElementsMap();\n boundElementsVisitor(elementsMap, changedElement, element => {\n var _a, _b;\n\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isLinearElement)(element) || element.isDeleted) {\n return;\n } // In case the boundElements are stale\n\n\n if (!doesNeedUpdate(element, changedElement)) {\n return;\n } // Check for intersections before updating bound elements incase connected elements overlap\n\n\n const startBindingElement = element.startBinding ? elementsMap.get(element.startBinding.elementId) : null;\n const endBindingElement = element.endBinding ? elementsMap.get(element.endBinding.elementId) : null;\n let startBounds = null;\n let endBounds = null;\n\n if (startBindingElement && endBindingElement) {\n startBounds = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementBounds)(startBindingElement, elementsMap);\n endBounds = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementBounds)(endBindingElement, elementsMap);\n }\n\n const bindings = {\n startBinding: maybeCalculateNewGapWhenScaling(changedElement, element.startBinding, newSize),\n endBinding: maybeCalculateNewGapWhenScaling(changedElement, element.endBinding, newSize)\n }; // `linearElement` is being moved/scaled already, just update the binding\n\n if (simultaneouslyUpdatedElementIds.has(element.id)) {\n scene.mutateElement(element, bindings);\n return;\n }\n\n const updates = bindableElementsVisitor(elementsMap, element, (bindableElement, bindingProp) => {\n var _a, _b;\n\n if (bindableElement && (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(bindableElement) && (bindingProp === \"startBinding\" || bindingProp === \"endBinding\") && (changedElement.id === ((_a = element[bindingProp]) === null || _a === void 0 ? void 0 : _a.elementId) || changedElement.id === ((_b = element[bindingProp === \"startBinding\" ? \"endBinding\" : \"startBinding\"]) === null || _b === void 0 ? void 0 : _b.elementId) && !(0,_bounds__WEBPACK_IMPORTED_MODULE_3__.doBoundsIntersect)(startBounds, endBounds))) {\n const point = updateBoundPoint(element, bindingProp, bindings[bindingProp], bindableElement, elementsMap);\n\n if (point) {\n return {\n index: bindingProp === \"startBinding\" ? 0 : element.points.length - 1,\n point\n };\n }\n }\n\n return null;\n }).filter(update => update !== null);\n _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.movePoints(element, scene, updates, Object.assign(Object.assign({}, changedElement.id === ((_a = element.startBinding) === null || _a === void 0 ? void 0 : _a.elementId) ? {\n startBinding: bindings.startBinding\n } : {}), changedElement.id === ((_b = element.endBinding) === null || _b === void 0 ? void 0 : _b.elementId) ? {\n endBinding: bindings.endBinding\n } : {}));\n const boundText = (0,_textElement__WEBPACK_IMPORTED_MODULE_9__.getBoundTextElement)(element, elementsMap);\n\n if (boundText && !boundText.isDeleted) {\n (0,_textElement__WEBPACK_IMPORTED_MODULE_9__.handleBindTextResize)(element, scene, false);\n }\n });\n};\n\nconst doesNeedUpdate = (boundElement, changedElement) => {\n var _a, _b;\n\n return ((_a = boundElement.startBinding) === null || _a === void 0 ? void 0 : _a.elementId) === changedElement.id || ((_b = boundElement.endBinding) === null || _b === void 0 ? void 0 : _b.elementId) === changedElement.id;\n};\n\nconst getSimultaneouslyUpdatedElementIds = simultaneouslyUpdated => {\n return new Set((simultaneouslyUpdated || []).map(element => element.id));\n};\n\nconst getHeadingForElbowArrowSnap = (p, otherPoint, bindableElement, aabb, origPoint, zoom) => {\n const otherPointHeading = (0,_heading__WEBPACK_IMPORTED_MODULE_6__.vectorToHeading)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(otherPoint, p));\n\n if (!bindableElement || !aabb) {\n return otherPointHeading;\n }\n\n const distance = getDistanceForBinding(origPoint, bindableElement, zoom);\n\n if (!distance) {\n return (0,_heading__WEBPACK_IMPORTED_MODULE_6__.vectorToHeading)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(p, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(bindableElement)));\n }\n\n return (0,_heading__WEBPACK_IMPORTED_MODULE_6__.headingForPointFromElement)(bindableElement, aabb, p);\n};\n\nconst getDistanceForBinding = (point, bindableElement, zoom) => {\n const distance = (0,_distance__WEBPACK_IMPORTED_MODULE_5__.distanceToBindableElement)(bindableElement, point);\n const bindDistance = maxBindingGap(bindableElement, bindableElement.width, bindableElement.height, zoom);\n return distance > bindDistance ? null : distance;\n};\n\nconst bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd) => {\n var _a;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isDevEnv)() || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.invariant)(arrow.points.length > 1, \"Arrow should have at least 2 points\");\n }\n\n const aabb = (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.aabbForElement)(bindableElement);\n const localP = arrow.points[startOrEnd === \"start\" ? 0 : arrow.points.length - 1];\n const globalP = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + localP[0], arrow.y + localP[1]);\n const edgePoint = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isRectanguloidElement)(bindableElement) ? avoidRectangularCorner(bindableElement, globalP) : globalP;\n const elbowed = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(arrow);\n const center = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getCenterForBounds)(aabb);\n const adjacentPointIdx = startOrEnd === \"start\" ? 1 : arrow.points.length - 2;\n const adjacentPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + arrow.points[adjacentPointIdx][0], arrow.y + arrow.points[adjacentPointIdx][1]), center, (_a = arrow.angle) !== null && _a !== void 0 ? _a : 0);\n let intersection = null;\n\n if (elbowed) {\n const isHorizontal = (0,_heading__WEBPACK_IMPORTED_MODULE_6__.headingIsHorizontal)((0,_heading__WEBPACK_IMPORTED_MODULE_6__.headingForPointFromElement)(bindableElement, aabb, globalP));\n const otherPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(isHorizontal ? center[0] : edgePoint[0], !isHorizontal ? center[1] : edgePoint[1]);\n intersection = (0,_collision__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLineSegment)(bindableElement, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(otherPoint, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(edgePoint, otherPoint)), Math.max(bindableElement.width, bindableElement.height) * 2), otherPoint)))[0];\n } else {\n intersection = (0,_collision__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLineSegment)(bindableElement, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(adjacentPoint, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(edgePoint, adjacentPoint)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(edgePoint, adjacentPoint) + Math.max(bindableElement.width, bindableElement.height) * 2), adjacentPoint)), FIXED_BINDING_DISTANCE).sort((g, h) => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(g, adjacentPoint) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(h, adjacentPoint))[0];\n }\n\n if (!intersection || // Too close to determine vector from intersection to edgePoint\n (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(edgePoint, intersection) < _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.PRECISION) {\n return edgePoint;\n }\n\n if (elbowed) {\n const scalar = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(edgePoint, center) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(intersection, center) > 0 ? FIXED_BINDING_DISTANCE : -FIXED_BINDING_DISTANCE;\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(edgePoint, intersection)), scalar), intersection);\n }\n\n return edgePoint;\n};\nconst avoidRectangularCorner = (element, p) => {\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element);\n const nonRotatedPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(p, center, -element.angle);\n\n if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {\n // Top left\n if (nonRotatedPoint[1] - element.y > -FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - FIXED_BINDING_DISTANCE, element.y), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y - FIXED_BINDING_DISTANCE), center, element.angle);\n } else if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] > element.y + element.height) {\n // Bottom left\n if (nonRotatedPoint[0] - element.x > -FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height + FIXED_BINDING_DISTANCE), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - FIXED_BINDING_DISTANCE, element.y + element.height), center, element.angle);\n } else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] > element.y + element.height) {\n // Bottom right\n if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height + FIXED_BINDING_DISTANCE), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width + FIXED_BINDING_DISTANCE, element.y + element.height), center, element.angle);\n } else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] < element.y) {\n // Top right\n if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y - FIXED_BINDING_DISTANCE), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width + FIXED_BINDING_DISTANCE, element.y), center, element.angle);\n }\n\n return p;\n};\nconst snapToMid = (element, p, tolerance = 0.05) => {\n const {\n x,\n y,\n width,\n height,\n angle\n } = element;\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element, -0.1, -0.1);\n const nonRotated = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(p, center, -angle); // snap-to-center point is adaptive to element size, but we don't want to go\n // above and below certain px distance\n\n const verticalThrehsold = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(tolerance * height, 5, 80);\n const horizontalThrehsold = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(tolerance * width, 5, 80);\n\n if (nonRotated[0] <= x + width / 2 && nonRotated[1] > center[1] - verticalThrehsold && nonRotated[1] < center[1] + verticalThrehsold) {\n // LEFT\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x - FIXED_BINDING_DISTANCE, center[1]), center, angle);\n } else if (nonRotated[1] <= y + height / 2 && nonRotated[0] > center[0] - horizontalThrehsold && nonRotated[0] < center[0] + horizontalThrehsold) {\n // TOP\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(center[0], y - FIXED_BINDING_DISTANCE), center, angle);\n } else if (nonRotated[0] >= x + width / 2 && nonRotated[1] > center[1] - verticalThrehsold && nonRotated[1] < center[1] + verticalThrehsold) {\n // RIGHT\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x + width + FIXED_BINDING_DISTANCE, center[1]), center, angle);\n } else if (nonRotated[1] >= y + height / 2 && nonRotated[0] > center[0] - horizontalThrehsold && nonRotated[0] < center[0] + horizontalThrehsold) {\n // DOWN\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(center[0], y + height + FIXED_BINDING_DISTANCE), center, angle);\n }\n\n return p;\n};\n\nconst updateBoundPoint = (linearElement, startOrEnd, binding, bindableElement, elementsMap) => {\n var _a;\n\n if (binding == null || // We only need to update the other end if this is a 2 point line element\n binding.elementId !== bindableElement.id && linearElement.points.length > 2) {\n return null;\n }\n\n const direction = startOrEnd === \"startBinding\" ? -1 : 1;\n const edgePointIndex = direction === -1 ? 0 : linearElement.points.length - 1;\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement) && (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isFixedPointBinding)(binding)) {\n const fixedPoint = (_a = normalizeFixedPoint(binding.fixedPoint)) !== null && _a !== void 0 ? _a : calculateFixedPointForElbowArrowBinding(linearElement, bindableElement, startOrEnd === \"startBinding\" ? \"start\" : \"end\").fixedPoint;\n const globalMidPoint = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(bindableElement);\n const global = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(bindableElement.x + fixedPoint[0] * bindableElement.width, bindableElement.y + fixedPoint[1] * bindableElement.height);\n const rotatedGlobal = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(global, globalMidPoint, bindableElement.angle);\n return _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(linearElement, rotatedGlobal, elementsMap);\n }\n\n const adjacentPointIndex = edgePointIndex - direction;\n const adjacentPoint = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, adjacentPointIndex, elementsMap);\n const focusPointAbsolute = determineFocusPoint(bindableElement, binding.focus, adjacentPoint);\n let newEdgePoint; // The linear element was not originally pointing inside the bound shape,\n // we can point directly at the focus point\n\n if (binding.gap === 0) {\n newEdgePoint = focusPointAbsolute;\n } else {\n const edgePointAbsolute = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, edgePointIndex, elementsMap);\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(bindableElement);\n const interceptorLength = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(adjacentPoint, edgePointAbsolute) + (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(adjacentPoint, center) + Math.max(bindableElement.width, bindableElement.height) * 2;\n const intersections = [...(0,_collision__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLineSegment)(bindableElement, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(adjacentPoint, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(focusPointAbsolute, adjacentPoint)), interceptorLength), adjacentPoint)), binding.gap).sort((g, h) => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(g, adjacentPoint) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(h, adjacentPoint)), // Fallback when arrow doesn't point to the shape\n (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(focusPointAbsolute, adjacentPoint)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(adjacentPoint, edgePointAbsolute)), adjacentPoint)];\n\n if (intersections.length > 1) {\n // The adjacent point is outside the shape (+ gap)\n newEdgePoint = intersections[0];\n } else if (intersections.length === 1) {\n // The adjacent point is inside the shape (+ gap)\n newEdgePoint = focusPointAbsolute;\n } else {\n // Shouldn't happend, but just in case\n newEdgePoint = edgePointAbsolute;\n }\n }\n\n return _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(linearElement, newEdgePoint, elementsMap);\n};\n\nconst calculateFixedPointForElbowArrowBinding = (linearElement, hoveredElement, startOrEnd) => {\n const bounds = [hoveredElement.x, hoveredElement.y, hoveredElement.x + hoveredElement.width, hoveredElement.y + hoveredElement.height];\n const snappedPoint = bindPointToSnapToElementOutline(linearElement, hoveredElement, startOrEnd);\n const globalMidPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(bounds[0] + (bounds[2] - bounds[0]) / 2, bounds[1] + (bounds[3] - bounds[1]) / 2);\n const nonRotatedSnappedGlobalPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(snappedPoint, globalMidPoint, -hoveredElement.angle);\n return {\n fixedPoint: normalizeFixedPoint([(nonRotatedSnappedGlobalPoint[0] - hoveredElement.x) / hoveredElement.width, (nonRotatedSnappedGlobalPoint[1] - hoveredElement.y) / hoveredElement.height])\n };\n};\n\nconst maybeCalculateNewGapWhenScaling = (changedElement, currentBinding, newSize) => {\n if (currentBinding == null || newSize == null) {\n return currentBinding;\n }\n\n const {\n width: newWidth,\n height: newHeight\n } = newSize;\n const {\n width,\n height\n } = changedElement;\n const newGap = Math.max(1, Math.min(maxBindingGap(changedElement, newWidth, newHeight), currentBinding.gap * (newWidth < newHeight ? newWidth / width : newHeight / height)));\n return Object.assign(Object.assign({}, currentBinding), {\n gap: newGap\n });\n};\n\nconst getElligibleElementForBindingElement = (linearElement, startOrEnd, elementsMap, elements, zoom) => {\n return getHoveredElementForBinding(getLinearElementEdgeCoors(linearElement, startOrEnd, elementsMap), elements, elementsMap, zoom, (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement), (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement));\n};\n\nconst getLinearElementEdgeCoors = (linearElement, startOrEnd, elementsMap) => {\n const index = startOrEnd === \"start\" ? 0 : -1;\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.tupleToCoors)(_linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, index, elementsMap));\n};\n\nconst fixDuplicatedBindingsAfterDuplication = (duplicatedElements, origIdToDuplicateId, duplicateElementsMap) => {\n var _a;\n\n for (const duplicateElement of duplicatedElements) {\n if (\"boundElements\" in duplicateElement && duplicateElement.boundElements) {\n Object.assign(duplicateElement, {\n boundElements: duplicateElement.boundElements.reduce((acc, binding) => {\n const newBindingId = origIdToDuplicateId.get(binding.id);\n\n if (newBindingId) {\n acc.push(Object.assign(Object.assign({}, binding), {\n id: newBindingId\n }));\n }\n\n return acc;\n }, [])\n });\n }\n\n if (\"containerId\" in duplicateElement && duplicateElement.containerId) {\n Object.assign(duplicateElement, {\n containerId: (_a = origIdToDuplicateId.get(duplicateElement.containerId)) !== null && _a !== void 0 ? _a : null\n });\n }\n\n if (\"endBinding\" in duplicateElement && duplicateElement.endBinding) {\n const newEndBindingId = origIdToDuplicateId.get(duplicateElement.endBinding.elementId);\n Object.assign(duplicateElement, {\n endBinding: newEndBindingId ? Object.assign(Object.assign({}, duplicateElement.endBinding), {\n elementId: newEndBindingId\n }) : null\n });\n }\n\n if (\"startBinding\" in duplicateElement && duplicateElement.startBinding) {\n const newEndBindingId = origIdToDuplicateId.get(duplicateElement.startBinding.elementId);\n Object.assign(duplicateElement, {\n startBinding: newEndBindingId ? Object.assign(Object.assign({}, duplicateElement.startBinding), {\n elementId: newEndBindingId\n }) : null\n });\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(duplicateElement)) {\n Object.assign(duplicateElement, (0,_elbowArrow__WEBPACK_IMPORTED_MODULE_12__.updateElbowArrowPoints)(duplicateElement, duplicateElementsMap, {\n points: [duplicateElement.points[0], duplicateElement.points[duplicateElement.points.length - 1]]\n }));\n }\n }\n};\nconst fixBindingsAfterDeletion = (sceneElements, deletedElements) => {\n const elements = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.arrayToMap)(sceneElements);\n\n for (const element of deletedElements) {\n BoundElement.unbindAffected(elements, element, (element, updates) => (0,_mutateElement__WEBPACK_IMPORTED_MODULE_8__.mutateElement)(element, elements, updates));\n BindableElement.unbindAffected(elements, element, (element, updates) => (0,_mutateElement__WEBPACK_IMPORTED_MODULE_8__.mutateElement)(element, elements, updates));\n }\n};\n\nconst newBoundElements = (boundElements, idsToRemove, elementsToAdd = []) => {\n if (!boundElements) {\n return null;\n }\n\n const nextBoundElements = boundElements.filter(boundElement => !idsToRemove.has(boundElement.id));\n nextBoundElements.push(...elementsToAdd.map(x => ({\n id: x.id,\n type: x.type\n })));\n return nextBoundElements;\n};\n\nconst bindingBorderTest = (element, {\n x,\n y\n}, elementsMap, zoom, fullShape) => {\n const threshold = maxBindingGap(element, element.width, element.height, zoom);\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.getElementShape)(element, elementsMap);\n return (0,_excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_2__.isPointOnShape)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x, y), shape, threshold) || fullShape === true && (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.pointInsideBounds)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x, y), (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.aabbForElement)(element));\n};\nconst maxBindingGap = (element, elementWidth, elementHeight, zoom) => {\n const zoomValue = (zoom === null || zoom === void 0 ? void 0 : zoom.value) && zoom.value < 1 ? zoom.value : 1; // Aligns diamonds with rectangles\n\n const shapeRatio = element.type === \"diamond\" ? 1 / Math.sqrt(2) : 1;\n const smallerDimension = shapeRatio * Math.min(elementWidth, elementHeight);\n return Math.max(16, // bigger bindable boundary for bigger elements\n Math.min(0.25 * smallerDimension, 32), // keep in sync with the zoomed highlight\n BINDING_HIGHLIGHT_THICKNESS / zoomValue + BINDING_HIGHLIGHT_OFFSET);\n}; // The focus distance is the oriented ratio between the size of\n// the `element` and the \"focus image\" of the element on which\n// all focus points lie, so it's a number between -1 and 1.\n// The line going through `a` and `b` is a tangent to the \"focus image\"\n// of the element.\n\nconst determineFocusDistance = ( //zsviczian added export\nelement, // Point on the line, in absolute coordinates\na, // Another point on the line, in absolute coordinates (closer to element)\nb) => {\n var _a;\n\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element);\n\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointsEqual)(a, b)) {\n return 0;\n }\n\n const rotatedA = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(a, center, -element.angle);\n const rotatedB = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(b, center, -element.angle);\n const sign = Math.sign((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(rotatedB, a), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(rotatedB, center))) * -1;\n const rotatedInterceptor = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(rotatedB, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(rotatedB, rotatedA)), Math.max(element.width * 2, element.height * 2)), rotatedB));\n const axes = element.type === \"diamond\" ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y + element.height)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height / 2))] : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height))];\n const interceptees = element.type === \"diamond\" ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y - element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y + element.height * 2)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - element.width, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * 2, element.y + element.height / 2))] : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - element.width, element.y - element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * 2, element.y + element.height * 2)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * 2, element.y - element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - element.width, element.y + element.height * 2))];\n const ordered = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegmentIntersectionPoints)(rotatedInterceptor, interceptees[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegmentIntersectionPoints)(rotatedInterceptor, interceptees[1])].filter(p => p !== null).sort((g, h) => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(g, b) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(h, b)).map((p, idx) => sign * (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(center, p) / (element.type === \"diamond\" ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(axes[idx][0], axes[idx][1]) / 2 : Math.sqrt(element.width ** 2 + element.height ** 2) / 2)).sort((g, h) => Math.abs(g) - Math.abs(h));\n const signedDistanceRatio = (_a = ordered[0]) !== null && _a !== void 0 ? _a : 0;\n return signedDistanceRatio;\n};\n\nconst determineFocusPoint = (element, // The oriented, relative distance from the center of `element` of the\n// returned focusPoint\nfocus, adjacentPoint) => {\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element);\n\n if (focus === 0) {\n return center;\n }\n\n const candidates = (element.type === \"diamond\" ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y + element.height)] : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height)]).map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(p, center), Math.abs(focus)), center)).map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(p, center, element.angle));\n const selected = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[1], candidates[0])) > 0 && ( // TOP\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[2], candidates[1])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[3]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[0], candidates[3])) < 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[2], candidates[1])) > 0 && ( // RIGHT\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[2]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[3], candidates[2])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[1], candidates[0])) < 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[2]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[3], candidates[2])) > 0 && ( // BOTTOM\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[3]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[0], candidates[3])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[2], candidates[1])) < 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[3]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[0], candidates[3])) > 0 && ( // LEFT\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[1], candidates[0])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[2]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[3], candidates[2])) < 0)];\n const focusPoint = selected[0] ? focus > 0 ? candidates[1] : candidates[0] : selected[1] ? focus > 0 ? candidates[2] : candidates[1] : selected[2] ? focus > 0 ? candidates[3] : candidates[2] : focus > 0 ? candidates[0] : candidates[3];\n return focusPoint;\n};\n\nconst bindingProperties = new Set([\"boundElements\", \"frameId\", \"containerId\", \"startBinding\", \"endBinding\"]);\n/**\r\n * Tries to visit each bound element (does not have to be found).\r\n */\n\nconst boundElementsVisitor = (elements, element, visit) => {\n var _a, _b;\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element)) {\n // create new instance so that possible mutations won't play a role in visiting order\n const boundElements = (_b = (_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : []; // last added text should be the one we keep (~previous are duplicates)\n\n boundElements.forEach(({\n id\n }) => {\n visit(elements.get(id), \"boundElements\", id);\n });\n }\n};\n/**\r\n * Tries to visit each bindable element (does not have to be found).\r\n */\n\n\nconst bindableElementsVisitor = (elements, element, visit) => {\n const result = [];\n\n if (element.frameId) {\n const id = element.frameId;\n result.push(visit(elements.get(id), \"frameId\", id));\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBoundToContainer)(element)) {\n const id = element.containerId;\n result.push(visit(elements.get(id), \"containerId\", id));\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isArrowElement)(element)) {\n if (element.startBinding) {\n const id = element.startBinding.elementId;\n result.push(visit(elements.get(id), \"startBinding\", id));\n }\n\n if (element.endBinding) {\n const id = element.endBinding.elementId;\n result.push(visit(elements.get(id), \"endBinding\", id));\n }\n }\n\n return result;\n};\n/**\r\n * Bound element containing bindings to `frameId`, `containerId`, `startBinding` or `endBinding`.\r\n */\n\n\nclass BoundElement {\n /**\r\n * Unbind the affected non deleted bindable elements (removing element from `boundElements`).\r\n * - iterates non deleted bindable elements (`containerId` | `startBinding.elementId` | `endBinding.elementId`) of the current element\r\n * - prepares updates to unbind each bindable element's `boundElements` from the current element\r\n */\n static unbindAffected(elements, boundElement, updateElementWith) {\n if (!boundElement) {\n return;\n }\n\n bindableElementsVisitor(elements, boundElement, bindableElement => {\n // bindable element is deleted, this is fine\n if (!bindableElement || bindableElement.isDeleted) {\n return;\n }\n\n boundElementsVisitor(elements, bindableElement, (_, __, boundElementId) => {\n if (boundElementId === boundElement.id) {\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set([boundElementId]))\n });\n }\n });\n });\n }\n\n}\n/**\r\n * Rebind the next affected non deleted bindable elements (adding element to `boundElements`).\r\n * - iterates non deleted bindable elements (`containerId` | `startBinding.elementId` | `endBinding.elementId`) of the current element\r\n * - prepares updates to rebind each bindable element's `boundElements` to the current element\r\n *\r\n * NOTE: rebind expects that affected elements were previously unbound with `BoundElement.unbindAffected`\r\n */\n\nBoundElement.rebindAffected = (elements, boundElement, updateElementWith) => {\n // don't try to rebind element that is deleted\n if (!boundElement || boundElement.isDeleted) {\n return;\n }\n\n bindableElementsVisitor(elements, boundElement, (bindableElement, bindingProp) => {\n var _a, _b; // unbind from bindable elements, as bindings from non deleted elements into deleted elements are incorrect\n\n\n if (!bindableElement || bindableElement.isDeleted) {\n updateElementWith(boundElement, {\n [bindingProp]: null\n });\n return;\n } // frame bindings are unidirectional, there is nothing to rebind\n\n\n if (bindingProp === \"frameId\") {\n return;\n }\n\n if ((_a = bindableElement.boundElements) === null || _a === void 0 ? void 0 : _a.find(x => x.id === boundElement.id)) {\n return;\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isArrowElement)(boundElement)) {\n // rebind if not found!\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set(), new Array(boundElement))\n });\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isTextElement)(boundElement)) {\n if (!((_b = bindableElement.boundElements) === null || _b === void 0 ? void 0 : _b.find(x => x.type === \"text\"))) {\n // rebind only if there is no other text bound already\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set(), new Array(boundElement))\n });\n } else {\n // unbind otherwise\n updateElementWith(boundElement, {\n [bindingProp]: null\n });\n }\n }\n });\n};\n/**\r\n * Bindable element containing bindings to `boundElements`.\r\n */\n\n\nclass BindableElement {\n /**\r\n * Unbind the affected non deleted bound elements (resetting `containerId`, `startBinding`, `endBinding` to `null`).\r\n * - iterates through non deleted `boundElements` of the current element\r\n * - prepares updates to unbind each bound element from the current element\r\n */\n static unbindAffected(elements, bindableElement, updateElementWith) {\n if (!bindableElement) {\n return;\n }\n\n boundElementsVisitor(elements, bindableElement, boundElement => {\n // bound element is deleted, this is fine\n if (!boundElement || boundElement.isDeleted) {\n return;\n }\n\n bindableElementsVisitor(elements, boundElement, (_, bindingProp, bindableElementId) => {\n // making sure there is an element to be unbound\n if (bindableElementId === bindableElement.id) {\n updateElementWith(boundElement, {\n [bindingProp]: null\n });\n }\n });\n });\n }\n\n}\n/**\r\n * Rebind the affected non deleted bound elements (for now setting only `containerId`, as we cannot rebind arrows atm).\r\n * - iterates through non deleted `boundElements` of the current element\r\n * - prepares updates to rebind each bound element to the current element or unbind it from `boundElements` in case of conflicts\r\n *\r\n * NOTE: rebind expects that affected elements were previously unbound with `BindaleElement.unbindAffected`\r\n */\n\nBindableElement.rebindAffected = (elements, bindableElement, updateElementWith) => {\n // don't try to rebind element that is deleted (i.e. updated as deleted)\n if (!bindableElement || bindableElement.isDeleted) {\n return;\n }\n\n boundElementsVisitor(elements, bindableElement, (boundElement, _, boundElementId) => {\n var _a, _b, _c; // unbind from bindable elements, as bindings from non deleted elements into deleted elements are incorrect\n\n\n if (!boundElement || boundElement.isDeleted) {\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set([boundElementId]))\n });\n return;\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isTextElement)(boundElement)) {\n const boundElements = (_b = (_a = bindableElement.boundElements) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : []; // check if this is the last element in the array, if not, there is an previously bound text which should be unbound\n\n if (((_c = boundElements.reverse().find(x => x.type === \"text\")) === null || _c === void 0 ? void 0 : _c.id) === boundElement.id) {\n if (boundElement.containerId !== bindableElement.id) {\n // rebind if not bound already!\n updateElementWith(boundElement, {\n containerId: bindableElement.id\n });\n }\n } else {\n if (boundElement.containerId !== null) {\n // unbind if not unbound already\n updateElementWith(boundElement, {\n containerId: null\n });\n } // unbind from boundElements as the element got bound to some other element in the meantime\n\n\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set([boundElement.id]))\n });\n }\n }\n });\n};\n\nconst getGlobalFixedPointForBindableElement = (fixedPointRatio, element) => {\n const [fixedX, fixedY] = normalizeFixedPoint(fixedPointRatio);\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * fixedX, element.y + element.height * fixedY), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element), element.angle);\n};\nconst getGlobalFixedPoints = (arrow, elementsMap) => {\n const startElement = arrow.startBinding && elementsMap.get(arrow.startBinding.elementId);\n const endElement = arrow.endBinding && elementsMap.get(arrow.endBinding.elementId);\n const startPoint = startElement && arrow.startBinding ? getGlobalFixedPointForBindableElement(arrow.startBinding.fixedPoint, startElement) : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + arrow.points[0][0], arrow.y + arrow.points[0][1]);\n const endPoint = endElement && arrow.endBinding ? getGlobalFixedPointForBindableElement(arrow.endBinding.fixedPoint, endElement) : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + arrow.points[arrow.points.length - 1][0], arrow.y + arrow.points[arrow.points.length - 1][1]);\n return [startPoint, endPoint];\n};\nconst getArrowLocalFixedPoints = (arrow, elementsMap) => {\n const [startPoint, endPoint] = getGlobalFixedPoints(arrow, elementsMap);\n return [_linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(arrow, startPoint, elementsMap), _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(arrow, endPoint, elementsMap)];\n};\nconst normalizeFixedPoint = fixedPoint => {\n // Do not allow a precise 0.5 for fixed point ratio\n // to avoid jumping arrow heading due to floating point imprecision\n if (fixedPoint && (Math.abs(fixedPoint[0] - 0.5) < 0.0001 || Math.abs(fixedPoint[1] - 0.5) < 0.0001)) {\n return fixedPoint.map(ratio => Math.abs(ratio - 0.5) < 0.0001 ? 0.5001 : ratio);\n }\n\n return fixedPoint;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/binding.ts?");
|
|
13083
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BINDING_HIGHLIGHT_OFFSET: () => (/* binding */ BINDING_HIGHLIGHT_OFFSET),\n/* harmony export */ BINDING_HIGHLIGHT_THICKNESS: () => (/* binding */ BINDING_HIGHLIGHT_THICKNESS),\n/* harmony export */ BindableElement: () => (/* binding */ BindableElement),\n/* harmony export */ BoundElement: () => (/* binding */ BoundElement),\n/* harmony export */ FIXED_BINDING_DISTANCE: () => (/* binding */ FIXED_BINDING_DISTANCE),\n/* harmony export */ avoidRectangularCorner: () => (/* binding */ avoidRectangularCorner),\n/* harmony export */ bindLinearElement: () => (/* binding */ bindLinearElement),\n/* harmony export */ bindOrUnbindLinearElement: () => (/* binding */ bindOrUnbindLinearElement),\n/* harmony export */ bindOrUnbindLinearElements: () => (/* binding */ bindOrUnbindLinearElements),\n/* harmony export */ bindPointToSnapToElementOutline: () => (/* binding */ bindPointToSnapToElementOutline),\n/* harmony export */ bindingBorderTest: () => (/* binding */ bindingBorderTest),\n/* harmony export */ bindingProperties: () => (/* binding */ bindingProperties),\n/* harmony export */ calculateFixedPointForElbowArrowBinding: () => (/* binding */ calculateFixedPointForElbowArrowBinding),\n/* harmony export */ determineFocusDistance: () => (/* binding */ determineFocusDistance),\n/* harmony export */ fixBindingsAfterDeletion: () => (/* binding */ fixBindingsAfterDeletion),\n/* harmony export */ fixDuplicatedBindingsAfterDuplication: () => (/* binding */ fixDuplicatedBindingsAfterDuplication),\n/* harmony export */ getArrowLocalFixedPoints: () => (/* binding */ getArrowLocalFixedPoints),\n/* harmony export */ getGlobalFixedPointForBindableElement: () => (/* binding */ getGlobalFixedPointForBindableElement),\n/* harmony export */ getGlobalFixedPoints: () => (/* binding */ getGlobalFixedPoints),\n/* harmony export */ getHeadingForElbowArrowSnap: () => (/* binding */ getHeadingForElbowArrowSnap),\n/* harmony export */ getHoveredElementForBinding: () => (/* binding */ getHoveredElementForBinding),\n/* harmony export */ getSuggestedBindingsForArrows: () => (/* binding */ getSuggestedBindingsForArrows),\n/* harmony export */ isBindingEnabled: () => (/* binding */ isBindingEnabled),\n/* harmony export */ isLinearElementSimpleAndAlreadyBound: () => (/* binding */ isLinearElementSimpleAndAlreadyBound),\n/* harmony export */ maxBindingGap: () => (/* binding */ maxBindingGap),\n/* harmony export */ maybeBindLinearElement: () => (/* binding */ maybeBindLinearElement),\n/* harmony export */ normalizeFixedPoint: () => (/* binding */ normalizeFixedPoint),\n/* harmony export */ shouldEnableBindingForPointerEvent: () => (/* binding */ shouldEnableBindingForPointerEvent),\n/* harmony export */ snapToMid: () => (/* binding */ snapToMid),\n/* harmony export */ updateBindings: () => (/* binding */ updateBindings),\n/* harmony export */ updateBoundElements: () => (/* binding */ updateBoundElements)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/utils/collision */ \"../utils/src/collision.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _collision__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./collision */ \"../element/src/collision.ts\");\n/* harmony import */ var _distance__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./distance */ \"../element/src/distance.ts\");\n/* harmony import */ var _heading__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./heading */ \"../element/src/heading.ts\");\n/* harmony import */ var _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _mutateElement__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _textElement__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shapes */ \"../element/src/shapes.ts\");\n/* harmony import */ var _elbowArrow__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./elbowArrow */ \"../element/src/elbowArrow.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst shouldEnableBindingForPointerEvent = event => {\n return !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.CTRL_OR_CMD];\n};\nconst isBindingEnabled = appState => {\n return appState.invertBindingBehaviour //zsviczian\n ? !appState.isBindingEnabled : appState.isBindingEnabled;\n};\nconst FIXED_BINDING_DISTANCE = 5;\nconst BINDING_HIGHLIGHT_THICKNESS = 10;\nconst BINDING_HIGHLIGHT_OFFSET = 4;\n\nconst getNonDeletedElements = (scene, ids) => {\n const result = [];\n ids.forEach(id => {\n const element = scene.getNonDeletedElement(id);\n\n if (element != null) {\n result.push(element);\n }\n });\n return result;\n};\n\nconst bindOrUnbindLinearElement = (linearElement, startBindingElement, endBindingElement, scene) => {\n const boundToElementIds = new Set();\n const unboundFromElementIds = new Set();\n bindOrUnbindLinearElementEdge(linearElement, startBindingElement, endBindingElement, \"start\", boundToElementIds, unboundFromElementIds, scene);\n bindOrUnbindLinearElementEdge(linearElement, endBindingElement, startBindingElement, \"end\", boundToElementIds, unboundFromElementIds, scene);\n const onlyUnbound = Array.from(unboundFromElementIds).filter(id => !boundToElementIds.has(id));\n getNonDeletedElements(scene, onlyUnbound).forEach(element => {\n var _a;\n\n scene.mutateElement(element, {\n boundElements: (_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.filter(element => element.type !== \"arrow\" || element.id !== linearElement.id)\n });\n });\n};\n\nconst bindOrUnbindLinearElementEdge = (linearElement, bindableElement, otherEdgeBindableElement, startOrEnd, // Is mutated\nboundToElementIds, // Is mutated\nunboundFromElementIds, scene) => {\n // \"keep\" is for method chaining convenience, a \"no-op\", so just bail out\n if (bindableElement === \"keep\") {\n return;\n } // null means break the bind, so nothing to consider here\n\n\n if (bindableElement === null) {\n const unbound = unbindLinearElement(linearElement, startOrEnd, scene);\n\n if (unbound != null) {\n unboundFromElementIds.add(unbound);\n }\n\n return;\n } // While complext arrows can do anything, simple arrow with both ends trying\n // to bind to the same bindable should not be allowed, start binding takes\n // precedence\n\n\n if (isLinearElementSimple(linearElement)) {\n if (otherEdgeBindableElement == null || (otherEdgeBindableElement === \"keep\" ? // TODO: Refactor - Needlessly complex\n !isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, bindableElement, startOrEnd) : startOrEnd === \"start\" || otherEdgeBindableElement.id !== bindableElement.id)) {\n bindLinearElement(linearElement, bindableElement, startOrEnd, scene);\n boundToElementIds.add(bindableElement.id);\n }\n } else {\n bindLinearElement(linearElement, bindableElement, startOrEnd, scene);\n boundToElementIds.add(bindableElement.id);\n }\n};\n\nconst getOriginalBindingIfStillCloseOfLinearElementEdge = (linearElement, edge, elementsMap, zoom) => {\n var _a, _b;\n\n const coors = getLinearElementEdgeCoors(linearElement, edge, elementsMap);\n const elementId = edge === \"start\" ? (_a = linearElement.startBinding) === null || _a === void 0 ? void 0 : _a.elementId : (_b = linearElement.endBinding) === null || _b === void 0 ? void 0 : _b.elementId;\n\n if (elementId) {\n const element = elementsMap.get(elementId);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element) && bindingBorderTest(element, coors, elementsMap, zoom)) {\n return element;\n }\n }\n\n return null;\n};\n\nconst getOriginalBindingsIfStillCloseToArrowEnds = (linearElement, elementsMap, zoom) => [\"start\", \"end\"].map(edge => getOriginalBindingIfStillCloseOfLinearElementEdge(linearElement, edge, elementsMap, zoom));\n\nconst getBindingStrategyForDraggingArrowEndpoints = (selectedElement, isBindingEnabled, draggingPoints, elementsMap, elements, zoom) => {\n const startIdx = 0;\n const endIdx = selectedElement.points.length - 1;\n const startDragged = draggingPoints.findIndex(i => i === startIdx) > -1;\n const endDragged = draggingPoints.findIndex(i => i === endIdx) > -1;\n const start = startDragged ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"start\", elementsMap, elements, zoom) : null // If binding is disabled and start is dragged, break all binds\n : \"keep\";\n const end = endDragged ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"end\", elementsMap, elements, zoom) : null // If binding is disabled and end is dragged, break all binds\n : \"keep\";\n return [start, end];\n};\n\nconst getBindingStrategyForDraggingArrowOrJoints = (selectedElement, elementsMap, elements, isBindingEnabled, zoom) => {\n // Elbow arrows don't bind when dragged as a whole\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(selectedElement)) {\n return [\"keep\", \"keep\"];\n }\n\n const [startIsClose, endIsClose] = getOriginalBindingsIfStillCloseToArrowEnds(selectedElement, elementsMap, zoom);\n const start = startIsClose ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"start\", elementsMap, elements, zoom) : null : null;\n const end = endIsClose ? isBindingEnabled ? getElligibleElementForBindingElement(selectedElement, \"end\", elementsMap, elements, zoom) : null : null;\n return [start, end];\n};\n\nconst bindOrUnbindLinearElements = (selectedElements, isBindingEnabled, draggingPoints, scene, zoom) => {\n selectedElements.forEach(selectedElement => {\n const [start, end] = (draggingPoints === null || draggingPoints === void 0 ? void 0 : draggingPoints.length) ? // The arrow edge points are dragged (i.e. start, end)\n getBindingStrategyForDraggingArrowEndpoints(selectedElement, isBindingEnabled, draggingPoints !== null && draggingPoints !== void 0 ? draggingPoints : [], scene.getNonDeletedElementsMap(), scene.getNonDeletedElements(), zoom) : // The arrow itself (the shaft) or the inner joins are dragged\n getBindingStrategyForDraggingArrowOrJoints(selectedElement, scene.getNonDeletedElementsMap(), scene.getNonDeletedElements(), isBindingEnabled, zoom);\n bindOrUnbindLinearElement(selectedElement, start, end, scene);\n });\n};\nconst getSuggestedBindingsForArrows = (selectedElements, elementsMap, zoom) => {\n // HOT PATH: Bail out if selected elements list is too large\n if (selectedElements.length > 50) {\n return [];\n }\n\n return selectedElements.filter(_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isLinearElement).flatMap(element => getOriginalBindingsIfStillCloseToArrowEnds(element, elementsMap, zoom)).filter(element => element !== null) // Filter out bind candidates which are in the\n // same selection / group with the arrow\n //\n // TODO: Is it worth turning the list into a set to avoid dupes?\n .filter(element => selectedElements.filter(selected => selected.id === (element === null || element === void 0 ? void 0 : element.id)).length === 0);\n};\nconst maybeBindLinearElement = (linearElement, appState, pointerCoords, scene) => {\n const elements = scene.getNonDeletedElements();\n const elementsMap = scene.getNonDeletedElementsMap();\n\n if (appState.startBoundElement != null) {\n bindLinearElement(linearElement, appState.startBoundElement, \"start\", scene);\n }\n\n const hoveredElement = getHoveredElementForBinding(pointerCoords, elements, elementsMap, appState.zoom, (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement), (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement));\n\n if (hoveredElement !== null) {\n if (!isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, hoveredElement, \"end\")) {\n bindLinearElement(linearElement, hoveredElement, \"end\", scene);\n }\n }\n};\n\nconst normalizePointBinding = (binding, hoveredElement) => {\n let gap = binding.gap;\n const maxGap = maxBindingGap(hoveredElement, hoveredElement.width, hoveredElement.height);\n\n if (gap > maxGap) {\n gap = BINDING_HIGHLIGHT_THICKNESS + BINDING_HIGHLIGHT_OFFSET;\n }\n\n return Object.assign(Object.assign({}, binding), {\n gap\n });\n};\n\nconst bindLinearElement = (linearElement, hoveredElement, startOrEnd, scene) => {\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isArrowElement)(linearElement)) {\n return;\n }\n\n let binding = Object.assign({\n elementId: hoveredElement.id\n }, normalizePointBinding(calculateFocusAndGap(linearElement, hoveredElement, startOrEnd, scene.getNonDeletedElementsMap()), hoveredElement));\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement)) {\n binding = Object.assign(Object.assign({}, binding), calculateFixedPointForElbowArrowBinding(linearElement, hoveredElement, startOrEnd));\n }\n\n scene.mutateElement(linearElement, {\n [startOrEnd === \"start\" ? \"startBinding\" : \"endBinding\"]: binding\n });\n const boundElementsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.arrayToMap)(hoveredElement.boundElements || []);\n\n if (!boundElementsMap.has(linearElement.id)) {\n scene.mutateElement(hoveredElement, {\n boundElements: (hoveredElement.boundElements || []).concat({\n id: linearElement.id,\n type: \"arrow\"\n })\n });\n }\n}; // Don't bind both ends of a simple segment\n\nconst isLinearElementSimpleAndAlreadyBoundOnOppositeEdge = (linearElement, bindableElement, startOrEnd) => {\n const otherBinding = linearElement[startOrEnd === \"start\" ? \"endBinding\" : \"startBinding\"];\n return isLinearElementSimpleAndAlreadyBound(linearElement, otherBinding === null || otherBinding === void 0 ? void 0 : otherBinding.elementId, bindableElement);\n};\n\nconst isLinearElementSimpleAndAlreadyBound = (linearElement, alreadyBoundToId, bindableElement) => {\n return alreadyBoundToId === bindableElement.id && isLinearElementSimple(linearElement);\n};\n\nconst isLinearElementSimple = linearElement => linearElement.points.length < 3;\n\nconst unbindLinearElement = (linearElement, startOrEnd, scene) => {\n const field = startOrEnd === \"start\" ? \"startBinding\" : \"endBinding\";\n const binding = linearElement[field];\n\n if (binding == null) {\n return null;\n }\n\n scene.mutateElement(linearElement, {\n [field]: null\n });\n return binding.elementId;\n};\n\nconst getHoveredElementForBinding = (pointerCoords, elements, elementsMap, zoom, fullShape, considerAllElements) => {\n if (considerAllElements) {\n let cullRest = false;\n const candidateElements = getAllElementsAtPositionForBinding(elements, element => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element, false) && bindingBorderTest(element, pointerCoords, elementsMap, zoom, (fullShape || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isBindingFallthroughEnabled)(element)) && // disable fullshape snapping for frame elements so we\n // can bind to frame children\n !(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isFrameLikeElement)(element))).filter(element => {\n if (cullRest) {\n return false;\n }\n\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isBindingFallthroughEnabled)(element)) {\n cullRest = true;\n }\n\n return true;\n }); // Return early if there are no candidates or just one candidate\n\n if (!candidateElements || candidateElements.length === 0) {\n return null;\n }\n\n if (candidateElements.length === 1) {\n return candidateElements[0];\n } // Prefer the shape with the border being tested (if any)\n\n\n const borderTestElements = candidateElements.filter(element => bindingBorderTest(element, pointerCoords, elementsMap, zoom, false));\n\n if (borderTestElements.length === 1) {\n return borderTestElements[0];\n } // Prefer smaller shapes\n\n\n return candidateElements.sort((a, b) => b.width ** 2 + b.height ** 2 - (a.width ** 2 + a.height ** 2)).pop();\n }\n\n const hoveredElement = getElementAtPositionForBinding(elements, element => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element, false) && bindingBorderTest(element, pointerCoords, elementsMap, zoom, // disable fullshape snapping for frame elements so we\n // can bind to frame children\n (fullShape || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isBindingFallthroughEnabled)(element)) && !(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isFrameLikeElement)(element)));\n return hoveredElement;\n};\n\nconst getElementAtPositionForBinding = (elements, isAtPositionFn) => {\n let hitElement = null; // We need to to hit testing from front (end of the array) to back (beginning of the array)\n // because array is ordered from lower z-index to highest and we want element z-index\n // with higher z-index\n\n for (let index = elements.length - 1; index >= 0; --index) {\n const element = elements[index];\n\n if (element.isDeleted) {\n continue;\n }\n\n if (isAtPositionFn(element)) {\n hitElement = element;\n break;\n }\n }\n\n return hitElement;\n};\n\nconst getAllElementsAtPositionForBinding = (elements, isAtPositionFn) => {\n const elementsAtPosition = []; // We need to to hit testing from front (end of the array) to back (beginning of the array)\n // because array is ordered from lower z-index to highest and we want element z-index\n // with higher z-index\n\n for (let index = elements.length - 1; index >= 0; --index) {\n const element = elements[index];\n\n if (element.isDeleted) {\n continue;\n }\n\n if (isAtPositionFn(element)) {\n elementsAtPosition.push(element);\n }\n }\n\n return elementsAtPosition;\n};\n\nconst calculateFocusAndGap = (linearElement, hoveredElement, startOrEnd, elementsMap) => {\n const direction = startOrEnd === \"start\" ? -1 : 1;\n const edgePointIndex = direction === -1 ? 0 : linearElement.points.length - 1;\n const adjacentPointIndex = edgePointIndex - direction;\n const edgePoint = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, edgePointIndex, elementsMap);\n const adjacentPoint = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, adjacentPointIndex, elementsMap);\n return {\n focus: determineFocusDistance(hoveredElement, adjacentPoint, edgePoint),\n gap: Math.max(1, (0,_distance__WEBPACK_IMPORTED_MODULE_5__.distanceToBindableElement)(hoveredElement, edgePoint))\n };\n}; // Supports translating, rotating and scaling `changedElement` with bound\n// linear elements.\n\n\nconst updateBoundElements = (changedElement, scene, options) => {\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(changedElement)) {\n return;\n }\n\n const {\n newSize,\n simultaneouslyUpdated\n } = options !== null && options !== void 0 ? options : {};\n const simultaneouslyUpdatedElementIds = getSimultaneouslyUpdatedElementIds(simultaneouslyUpdated);\n let elementsMap = scene.getNonDeletedElementsMap();\n\n if (options === null || options === void 0 ? void 0 : options.changedElements) {\n elementsMap = new Map(elementsMap);\n options.changedElements.forEach(element => {\n elementsMap.set(element.id, element);\n });\n }\n\n boundElementsVisitor(elementsMap, changedElement, element => {\n var _a, _b;\n\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isLinearElement)(element) || element.isDeleted) {\n return;\n } // In case the boundElements are stale\n\n\n if (!doesNeedUpdate(element, changedElement)) {\n return;\n } // Check for intersections before updating bound elements incase connected elements overlap\n\n\n const startBindingElement = element.startBinding ? elementsMap.get(element.startBinding.elementId) : null;\n const endBindingElement = element.endBinding ? elementsMap.get(element.endBinding.elementId) : null;\n let startBounds = null;\n let endBounds = null;\n\n if (startBindingElement && endBindingElement) {\n startBounds = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementBounds)(startBindingElement, elementsMap);\n endBounds = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementBounds)(endBindingElement, elementsMap);\n }\n\n const bindings = {\n startBinding: maybeCalculateNewGapWhenScaling(changedElement, element.startBinding, newSize),\n endBinding: maybeCalculateNewGapWhenScaling(changedElement, element.endBinding, newSize)\n }; // `linearElement` is being moved/scaled already, just update the binding\n\n if (simultaneouslyUpdatedElementIds.has(element.id)) {\n scene.mutateElement(element, bindings);\n return;\n }\n\n const updates = bindableElementsVisitor(elementsMap, element, (bindableElement, bindingProp) => {\n var _a, _b;\n\n if (bindableElement && (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(bindableElement) && (bindingProp === \"startBinding\" || bindingProp === \"endBinding\") && (changedElement.id === ((_a = element[bindingProp]) === null || _a === void 0 ? void 0 : _a.elementId) || changedElement.id === ((_b = element[bindingProp === \"startBinding\" ? \"endBinding\" : \"startBinding\"]) === null || _b === void 0 ? void 0 : _b.elementId) && !(0,_bounds__WEBPACK_IMPORTED_MODULE_3__.doBoundsIntersect)(startBounds, endBounds))) {\n const point = updateBoundPoint(element, bindingProp, bindings[bindingProp], bindableElement, elementsMap);\n\n if (point) {\n return {\n index: bindingProp === \"startBinding\" ? 0 : element.points.length - 1,\n point\n };\n }\n }\n\n return null;\n }).filter(update => update !== null);\n _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.movePoints(element, scene, updates, Object.assign(Object.assign({}, changedElement.id === ((_a = element.startBinding) === null || _a === void 0 ? void 0 : _a.elementId) ? {\n startBinding: bindings.startBinding\n } : {}), changedElement.id === ((_b = element.endBinding) === null || _b === void 0 ? void 0 : _b.elementId) ? {\n endBinding: bindings.endBinding\n } : {}));\n const boundText = (0,_textElement__WEBPACK_IMPORTED_MODULE_9__.getBoundTextElement)(element, elementsMap);\n\n if (boundText && !boundText.isDeleted) {\n (0,_textElement__WEBPACK_IMPORTED_MODULE_9__.handleBindTextResize)(element, scene, false);\n }\n });\n};\nconst updateBindings = (latestElement, scene, options) => {\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isLinearElement)(latestElement)) {\n bindOrUnbindLinearElements([latestElement], true, [], scene, options === null || options === void 0 ? void 0 : options.zoom);\n } else {\n updateBoundElements(latestElement, scene, Object.assign(Object.assign({}, options), {\n changedElements: new Map([[latestElement.id, latestElement]])\n }));\n }\n};\n\nconst doesNeedUpdate = (boundElement, changedElement) => {\n var _a, _b;\n\n return ((_a = boundElement.startBinding) === null || _a === void 0 ? void 0 : _a.elementId) === changedElement.id || ((_b = boundElement.endBinding) === null || _b === void 0 ? void 0 : _b.elementId) === changedElement.id;\n};\n\nconst getSimultaneouslyUpdatedElementIds = simultaneouslyUpdated => {\n return new Set((simultaneouslyUpdated || []).map(element => element.id));\n};\n\nconst getHeadingForElbowArrowSnap = (p, otherPoint, bindableElement, aabb, origPoint, zoom) => {\n const otherPointHeading = (0,_heading__WEBPACK_IMPORTED_MODULE_6__.vectorToHeading)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(otherPoint, p));\n\n if (!bindableElement || !aabb) {\n return otherPointHeading;\n }\n\n const distance = getDistanceForBinding(origPoint, bindableElement, zoom);\n\n if (!distance) {\n return (0,_heading__WEBPACK_IMPORTED_MODULE_6__.vectorToHeading)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(p, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(bindableElement)));\n }\n\n return (0,_heading__WEBPACK_IMPORTED_MODULE_6__.headingForPointFromElement)(bindableElement, aabb, p);\n};\n\nconst getDistanceForBinding = (point, bindableElement, zoom) => {\n const distance = (0,_distance__WEBPACK_IMPORTED_MODULE_5__.distanceToBindableElement)(bindableElement, point);\n const bindDistance = maxBindingGap(bindableElement, bindableElement.width, bindableElement.height, zoom);\n return distance > bindDistance ? null : distance;\n};\n\nconst bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd) => {\n var _a;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isDevEnv)() || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.invariant)(arrow.points.length > 1, \"Arrow should have at least 2 points\");\n }\n\n const aabb = (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.aabbForElement)(bindableElement);\n const localP = arrow.points[startOrEnd === \"start\" ? 0 : arrow.points.length - 1];\n const globalP = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + localP[0], arrow.y + localP[1]);\n const edgePoint = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isRectanguloidElement)(bindableElement) ? avoidRectangularCorner(bindableElement, globalP) : globalP;\n const elbowed = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(arrow);\n const center = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getCenterForBounds)(aabb);\n const adjacentPointIdx = startOrEnd === \"start\" ? 1 : arrow.points.length - 2;\n const adjacentPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + arrow.points[adjacentPointIdx][0], arrow.y + arrow.points[adjacentPointIdx][1]), center, (_a = arrow.angle) !== null && _a !== void 0 ? _a : 0);\n let intersection = null;\n\n if (elbowed) {\n const isHorizontal = (0,_heading__WEBPACK_IMPORTED_MODULE_6__.headingIsHorizontal)((0,_heading__WEBPACK_IMPORTED_MODULE_6__.headingForPointFromElement)(bindableElement, aabb, globalP));\n const otherPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(isHorizontal ? center[0] : edgePoint[0], !isHorizontal ? center[1] : edgePoint[1]);\n intersection = (0,_collision__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLineSegment)(bindableElement, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(otherPoint, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(edgePoint, otherPoint)), Math.max(bindableElement.width, bindableElement.height) * 2), otherPoint)))[0];\n } else {\n intersection = (0,_collision__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLineSegment)(bindableElement, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(adjacentPoint, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(edgePoint, adjacentPoint)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(edgePoint, adjacentPoint) + Math.max(bindableElement.width, bindableElement.height) * 2), adjacentPoint)), FIXED_BINDING_DISTANCE).sort((g, h) => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(g, adjacentPoint) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(h, adjacentPoint))[0];\n }\n\n if (!intersection || // Too close to determine vector from intersection to edgePoint\n (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(edgePoint, intersection) < _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.PRECISION) {\n return edgePoint;\n }\n\n if (elbowed) {\n const scalar = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(edgePoint, center) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(intersection, center) > 0 ? FIXED_BINDING_DISTANCE : -FIXED_BINDING_DISTANCE;\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(edgePoint, intersection)), scalar), intersection);\n }\n\n return edgePoint;\n};\nconst avoidRectangularCorner = (element, p) => {\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element);\n const nonRotatedPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(p, center, -element.angle);\n\n if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {\n // Top left\n if (nonRotatedPoint[1] - element.y > -FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - FIXED_BINDING_DISTANCE, element.y), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y - FIXED_BINDING_DISTANCE), center, element.angle);\n } else if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] > element.y + element.height) {\n // Bottom left\n if (nonRotatedPoint[0] - element.x > -FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height + FIXED_BINDING_DISTANCE), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - FIXED_BINDING_DISTANCE, element.y + element.height), center, element.angle);\n } else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] > element.y + element.height) {\n // Bottom right\n if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height + FIXED_BINDING_DISTANCE), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width + FIXED_BINDING_DISTANCE, element.y + element.height), center, element.angle);\n } else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] < element.y) {\n // Top right\n if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y - FIXED_BINDING_DISTANCE), center, element.angle);\n }\n\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width + FIXED_BINDING_DISTANCE, element.y), center, element.angle);\n }\n\n return p;\n};\nconst snapToMid = (element, p, tolerance = 0.05) => {\n const {\n x,\n y,\n width,\n height,\n angle\n } = element;\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element, -0.1, -0.1);\n const nonRotated = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(p, center, -angle); // snap-to-center point is adaptive to element size, but we don't want to go\n // above and below certain px distance\n\n const verticalThrehsold = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(tolerance * height, 5, 80);\n const horizontalThrehsold = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(tolerance * width, 5, 80);\n\n if (nonRotated[0] <= x + width / 2 && nonRotated[1] > center[1] - verticalThrehsold && nonRotated[1] < center[1] + verticalThrehsold) {\n // LEFT\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x - FIXED_BINDING_DISTANCE, center[1]), center, angle);\n } else if (nonRotated[1] <= y + height / 2 && nonRotated[0] > center[0] - horizontalThrehsold && nonRotated[0] < center[0] + horizontalThrehsold) {\n // TOP\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(center[0], y - FIXED_BINDING_DISTANCE), center, angle);\n } else if (nonRotated[0] >= x + width / 2 && nonRotated[1] > center[1] - verticalThrehsold && nonRotated[1] < center[1] + verticalThrehsold) {\n // RIGHT\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x + width + FIXED_BINDING_DISTANCE, center[1]), center, angle);\n } else if (nonRotated[1] >= y + height / 2 && nonRotated[0] > center[0] - horizontalThrehsold && nonRotated[0] < center[0] + horizontalThrehsold) {\n // DOWN\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(center[0], y + height + FIXED_BINDING_DISTANCE), center, angle);\n }\n\n return p;\n};\n\nconst updateBoundPoint = (linearElement, startOrEnd, binding, bindableElement, elementsMap) => {\n var _a;\n\n if (binding == null || // We only need to update the other end if this is a 2 point line element\n binding.elementId !== bindableElement.id && linearElement.points.length > 2) {\n return null;\n }\n\n const direction = startOrEnd === \"startBinding\" ? -1 : 1;\n const edgePointIndex = direction === -1 ? 0 : linearElement.points.length - 1;\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement) && (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isFixedPointBinding)(binding)) {\n const fixedPoint = (_a = normalizeFixedPoint(binding.fixedPoint)) !== null && _a !== void 0 ? _a : calculateFixedPointForElbowArrowBinding(linearElement, bindableElement, startOrEnd === \"startBinding\" ? \"start\" : \"end\").fixedPoint;\n const globalMidPoint = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(bindableElement);\n const global = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(bindableElement.x + fixedPoint[0] * bindableElement.width, bindableElement.y + fixedPoint[1] * bindableElement.height);\n const rotatedGlobal = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(global, globalMidPoint, bindableElement.angle);\n return _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(linearElement, rotatedGlobal, elementsMap);\n }\n\n const adjacentPointIndex = edgePointIndex - direction;\n const adjacentPoint = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, adjacentPointIndex, elementsMap);\n const focusPointAbsolute = determineFocusPoint(bindableElement, binding.focus, adjacentPoint);\n let newEdgePoint; // The linear element was not originally pointing inside the bound shape,\n // we can point directly at the focus point\n\n if (binding.gap === 0) {\n newEdgePoint = focusPointAbsolute;\n } else {\n const edgePointAbsolute = _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, edgePointIndex, elementsMap);\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(bindableElement);\n const interceptorLength = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(adjacentPoint, edgePointAbsolute) + (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(adjacentPoint, center) + Math.max(bindableElement.width, bindableElement.height) * 2;\n const intersections = [...(0,_collision__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLineSegment)(bindableElement, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(adjacentPoint, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(focusPointAbsolute, adjacentPoint)), interceptorLength), adjacentPoint)), binding.gap).sort((g, h) => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(g, adjacentPoint) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(h, adjacentPoint)), // Fallback when arrow doesn't point to the shape\n (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(focusPointAbsolute, adjacentPoint)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(adjacentPoint, edgePointAbsolute)), adjacentPoint)];\n\n if (intersections.length > 1) {\n // The adjacent point is outside the shape (+ gap)\n newEdgePoint = intersections[0];\n } else if (intersections.length === 1) {\n // The adjacent point is inside the shape (+ gap)\n newEdgePoint = focusPointAbsolute;\n } else {\n // Shouldn't happend, but just in case\n newEdgePoint = edgePointAbsolute;\n }\n }\n\n return _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(linearElement, newEdgePoint, elementsMap);\n};\n\nconst calculateFixedPointForElbowArrowBinding = (linearElement, hoveredElement, startOrEnd) => {\n const bounds = [hoveredElement.x, hoveredElement.y, hoveredElement.x + hoveredElement.width, hoveredElement.y + hoveredElement.height];\n const snappedPoint = bindPointToSnapToElementOutline(linearElement, hoveredElement, startOrEnd);\n const globalMidPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(bounds[0] + (bounds[2] - bounds[0]) / 2, bounds[1] + (bounds[3] - bounds[1]) / 2);\n const nonRotatedSnappedGlobalPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(snappedPoint, globalMidPoint, -hoveredElement.angle);\n return {\n fixedPoint: normalizeFixedPoint([(nonRotatedSnappedGlobalPoint[0] - hoveredElement.x) / hoveredElement.width, (nonRotatedSnappedGlobalPoint[1] - hoveredElement.y) / hoveredElement.height])\n };\n};\n\nconst maybeCalculateNewGapWhenScaling = (changedElement, currentBinding, newSize) => {\n if (currentBinding == null || newSize == null) {\n return currentBinding;\n }\n\n const {\n width: newWidth,\n height: newHeight\n } = newSize;\n const {\n width,\n height\n } = changedElement;\n const newGap = Math.max(1, Math.min(maxBindingGap(changedElement, newWidth, newHeight), currentBinding.gap * (newWidth < newHeight ? newWidth / width : newHeight / height)));\n return Object.assign(Object.assign({}, currentBinding), {\n gap: newGap\n });\n};\n\nconst getElligibleElementForBindingElement = (linearElement, startOrEnd, elementsMap, elements, zoom) => {\n return getHoveredElementForBinding(getLinearElementEdgeCoors(linearElement, startOrEnd, elementsMap), elements, elementsMap, zoom, (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement), (0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(linearElement));\n};\n\nconst getLinearElementEdgeCoors = (linearElement, startOrEnd, elementsMap) => {\n const index = startOrEnd === \"start\" ? 0 : -1;\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.tupleToCoors)(_linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, index, elementsMap));\n};\n\nconst fixDuplicatedBindingsAfterDuplication = (duplicatedElements, origIdToDuplicateId, duplicateElementsMap) => {\n var _a;\n\n for (const duplicateElement of duplicatedElements) {\n if (\"boundElements\" in duplicateElement && duplicateElement.boundElements) {\n Object.assign(duplicateElement, {\n boundElements: duplicateElement.boundElements.reduce((acc, binding) => {\n const newBindingId = origIdToDuplicateId.get(binding.id);\n\n if (newBindingId) {\n acc.push(Object.assign(Object.assign({}, binding), {\n id: newBindingId\n }));\n }\n\n return acc;\n }, [])\n });\n }\n\n if (\"containerId\" in duplicateElement && duplicateElement.containerId) {\n Object.assign(duplicateElement, {\n containerId: (_a = origIdToDuplicateId.get(duplicateElement.containerId)) !== null && _a !== void 0 ? _a : null\n });\n }\n\n if (\"endBinding\" in duplicateElement && duplicateElement.endBinding) {\n const newEndBindingId = origIdToDuplicateId.get(duplicateElement.endBinding.elementId);\n Object.assign(duplicateElement, {\n endBinding: newEndBindingId ? Object.assign(Object.assign({}, duplicateElement.endBinding), {\n elementId: newEndBindingId\n }) : null\n });\n }\n\n if (\"startBinding\" in duplicateElement && duplicateElement.startBinding) {\n const newEndBindingId = origIdToDuplicateId.get(duplicateElement.startBinding.elementId);\n Object.assign(duplicateElement, {\n startBinding: newEndBindingId ? Object.assign(Object.assign({}, duplicateElement.startBinding), {\n elementId: newEndBindingId\n }) : null\n });\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isElbowArrow)(duplicateElement)) {\n Object.assign(duplicateElement, (0,_elbowArrow__WEBPACK_IMPORTED_MODULE_12__.updateElbowArrowPoints)(duplicateElement, duplicateElementsMap, {\n points: [duplicateElement.points[0], duplicateElement.points[duplicateElement.points.length - 1]]\n }));\n }\n }\n};\nconst fixBindingsAfterDeletion = (sceneElements, deletedElements) => {\n const elements = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.arrayToMap)(sceneElements);\n\n for (const element of deletedElements) {\n BoundElement.unbindAffected(elements, element, (element, updates) => (0,_mutateElement__WEBPACK_IMPORTED_MODULE_8__.mutateElement)(element, elements, updates));\n BindableElement.unbindAffected(elements, element, (element, updates) => (0,_mutateElement__WEBPACK_IMPORTED_MODULE_8__.mutateElement)(element, elements, updates));\n }\n};\n\nconst newBoundElements = (boundElements, idsToRemove, elementsToAdd = []) => {\n if (!boundElements) {\n return null;\n }\n\n const nextBoundElements = boundElements.filter(boundElement => !idsToRemove.has(boundElement.id));\n nextBoundElements.push(...elementsToAdd.map(x => ({\n id: x.id,\n type: x.type\n })));\n return nextBoundElements;\n};\n\nconst bindingBorderTest = (element, {\n x,\n y\n}, elementsMap, zoom, fullShape) => {\n const threshold = maxBindingGap(element, element.width, element.height, zoom);\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.getElementShape)(element, elementsMap);\n return (0,_excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_2__.isPointOnShape)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x, y), shape, threshold) || fullShape === true && (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.pointInsideBounds)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(x, y), (0,_shapes__WEBPACK_IMPORTED_MODULE_11__.aabbForElement)(element));\n};\nconst maxBindingGap = (element, elementWidth, elementHeight, zoom) => {\n const zoomValue = (zoom === null || zoom === void 0 ? void 0 : zoom.value) && zoom.value < 1 ? zoom.value : 1; // Aligns diamonds with rectangles\n\n const shapeRatio = element.type === \"diamond\" ? 1 / Math.sqrt(2) : 1;\n const smallerDimension = shapeRatio * Math.min(elementWidth, elementHeight);\n return Math.max(16, // bigger bindable boundary for bigger elements\n Math.min(0.25 * smallerDimension, 32), // keep in sync with the zoomed highlight\n BINDING_HIGHLIGHT_THICKNESS / zoomValue + BINDING_HIGHLIGHT_OFFSET);\n}; // The focus distance is the oriented ratio between the size of\n// the `element` and the \"focus image\" of the element on which\n// all focus points lie, so it's a number between -1 and 1.\n// The line going through `a` and `b` is a tangent to the \"focus image\"\n// of the element.\n\nconst determineFocusDistance = ( //zsviczian added export\nelement, // Point on the line, in absolute coordinates\na, // Another point on the line, in absolute coordinates (closer to element)\nb) => {\n var _a;\n\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element);\n\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointsEqual)(a, b)) {\n return 0;\n }\n\n const rotatedA = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(a, center, -element.angle);\n const rotatedB = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(b, center, -element.angle);\n const sign = Math.sign((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(rotatedB, a), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(rotatedB, center))) * -1;\n const rotatedInterceptor = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(rotatedB, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(rotatedB, rotatedA)), Math.max(element.width * 2, element.height * 2)), rotatedB));\n const axes = element.type === \"diamond\" ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y + element.height)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height / 2))] : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height))];\n const interceptees = element.type === \"diamond\" ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y - element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y + element.height * 2)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - element.width, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * 2, element.y + element.height / 2))] : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - element.width, element.y - element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * 2, element.y + element.height * 2)), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * 2, element.y - element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x - element.width, element.y + element.height * 2))];\n const ordered = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegmentIntersectionPoints)(rotatedInterceptor, interceptees[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegmentIntersectionPoints)(rotatedInterceptor, interceptees[1])].filter(p => p !== null).sort((g, h) => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(g, b) - (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistanceSq)(h, b)).map((p, idx) => sign * (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(center, p) / (element.type === \"diamond\" ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointDistance)(axes[idx][0], axes[idx][1]) / 2 : Math.sqrt(element.width ** 2 + element.height ** 2) / 2)).sort((g, h) => Math.abs(g) - Math.abs(h));\n const signedDistanceRatio = (_a = ordered[0]) !== null && _a !== void 0 ? _a : 0;\n return signedDistanceRatio;\n};\n\nconst determineFocusPoint = (element, // The oriented, relative distance from the center of `element` of the\n// returned focusPoint\nfocus, adjacentPoint) => {\n const center = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element);\n\n if (focus === 0) {\n return center;\n }\n\n const candidates = (element.type === \"diamond\" ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height / 2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width / 2, element.y + element.height)] : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width, element.y + element.height), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x, element.y + element.height)]).map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFromVector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(p, center), Math.abs(focus)), center)).map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)(p, center, element.angle));\n const selected = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[1], candidates[0])) > 0 && ( // TOP\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[2], candidates[1])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[3]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[0], candidates[3])) < 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[2], candidates[1])) > 0 && ( // RIGHT\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[2]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[3], candidates[2])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[1], candidates[0])) < 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[2]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[3], candidates[2])) > 0 && ( // BOTTOM\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[3]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[0], candidates[3])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[2], candidates[1])) < 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[3]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[0], candidates[3])) > 0 && ( // LEFT\n focus > 0 ? (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[0]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[1], candidates[0])) < 0 : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorCross)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(adjacentPoint, candidates[2]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.vectorFromPoint)(candidates[3], candidates[2])) < 0)];\n const focusPoint = selected[0] ? focus > 0 ? candidates[1] : candidates[0] : selected[1] ? focus > 0 ? candidates[2] : candidates[1] : selected[2] ? focus > 0 ? candidates[3] : candidates[2] : focus > 0 ? candidates[0] : candidates[3];\n return focusPoint;\n};\n\nconst bindingProperties = new Set([\"boundElements\", \"frameId\", \"containerId\", \"startBinding\", \"endBinding\"]);\n/**\r\n * Tries to visit each bound element (does not have to be found).\r\n */\n\nconst boundElementsVisitor = (elements, element, visit) => {\n var _a, _b;\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBindableElement)(element)) {\n // create new instance so that possible mutations won't play a role in visiting order\n const boundElements = (_b = (_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : []; // last added text should be the one we keep (~previous are duplicates)\n\n boundElements.forEach(({\n id\n }) => {\n visit(elements.get(id), \"boundElements\", id);\n });\n }\n};\n/**\r\n * Tries to visit each bindable element (does not have to be found).\r\n */\n\n\nconst bindableElementsVisitor = (elements, element, visit) => {\n const result = [];\n\n if (element.frameId) {\n const id = element.frameId;\n result.push(visit(elements.get(id), \"frameId\", id));\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isBoundToContainer)(element)) {\n const id = element.containerId;\n result.push(visit(elements.get(id), \"containerId\", id));\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isArrowElement)(element)) {\n if (element.startBinding) {\n const id = element.startBinding.elementId;\n result.push(visit(elements.get(id), \"startBinding\", id));\n }\n\n if (element.endBinding) {\n const id = element.endBinding.elementId;\n result.push(visit(elements.get(id), \"endBinding\", id));\n }\n }\n\n return result;\n};\n/**\r\n * Bound element containing bindings to `frameId`, `containerId`, `startBinding` or `endBinding`.\r\n */\n\n\nclass BoundElement {\n /**\r\n * Unbind the affected non deleted bindable elements (removing element from `boundElements`).\r\n * - iterates non deleted bindable elements (`containerId` | `startBinding.elementId` | `endBinding.elementId`) of the current element\r\n * - prepares updates to unbind each bindable element's `boundElements` from the current element\r\n */\n static unbindAffected(elements, boundElement, updateElementWith) {\n if (!boundElement) {\n return;\n }\n\n bindableElementsVisitor(elements, boundElement, bindableElement => {\n // bindable element is deleted, this is fine\n if (!bindableElement || bindableElement.isDeleted) {\n return;\n }\n\n boundElementsVisitor(elements, bindableElement, (_, __, boundElementId) => {\n if (boundElementId === boundElement.id) {\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set([boundElementId]))\n });\n }\n });\n });\n }\n\n}\n/**\r\n * Rebind the next affected non deleted bindable elements (adding element to `boundElements`).\r\n * - iterates non deleted bindable elements (`containerId` | `startBinding.elementId` | `endBinding.elementId`) of the current element\r\n * - prepares updates to rebind each bindable element's `boundElements` to the current element\r\n *\r\n * NOTE: rebind expects that affected elements were previously unbound with `BoundElement.unbindAffected`\r\n */\n\nBoundElement.rebindAffected = (elements, boundElement, updateElementWith) => {\n // don't try to rebind element that is deleted\n if (!boundElement || boundElement.isDeleted) {\n return;\n }\n\n bindableElementsVisitor(elements, boundElement, (bindableElement, bindingProp) => {\n var _a, _b; // unbind from bindable elements, as bindings from non deleted elements into deleted elements are incorrect\n\n\n if (!bindableElement || bindableElement.isDeleted) {\n updateElementWith(boundElement, {\n [bindingProp]: null\n });\n return;\n } // frame bindings are unidirectional, there is nothing to rebind\n\n\n if (bindingProp === \"frameId\") {\n return;\n }\n\n if ((_a = bindableElement.boundElements) === null || _a === void 0 ? void 0 : _a.find(x => x.id === boundElement.id)) {\n return;\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isArrowElement)(boundElement)) {\n // rebind if not found!\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set(), new Array(boundElement))\n });\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isTextElement)(boundElement)) {\n if (!((_b = bindableElement.boundElements) === null || _b === void 0 ? void 0 : _b.find(x => x.type === \"text\"))) {\n // rebind only if there is no other text bound already\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set(), new Array(boundElement))\n });\n } else {\n // unbind otherwise\n updateElementWith(boundElement, {\n [bindingProp]: null\n });\n }\n }\n });\n};\n/**\r\n * Bindable element containing bindings to `boundElements`.\r\n */\n\n\nclass BindableElement {\n /**\r\n * Unbind the affected non deleted bound elements (resetting `containerId`, `startBinding`, `endBinding` to `null`).\r\n * - iterates through non deleted `boundElements` of the current element\r\n * - prepares updates to unbind each bound element from the current element\r\n */\n static unbindAffected(elements, bindableElement, updateElementWith) {\n if (!bindableElement) {\n return;\n }\n\n boundElementsVisitor(elements, bindableElement, boundElement => {\n // bound element is deleted, this is fine\n if (!boundElement || boundElement.isDeleted) {\n return;\n }\n\n bindableElementsVisitor(elements, boundElement, (_, bindingProp, bindableElementId) => {\n // making sure there is an element to be unbound\n if (bindableElementId === bindableElement.id) {\n updateElementWith(boundElement, {\n [bindingProp]: null\n });\n }\n });\n });\n }\n\n}\n/**\r\n * Rebind the affected non deleted bound elements (for now setting only `containerId`, as we cannot rebind arrows atm).\r\n * - iterates through non deleted `boundElements` of the current element\r\n * - prepares updates to rebind each bound element to the current element or unbind it from `boundElements` in case of conflicts\r\n *\r\n * NOTE: rebind expects that affected elements were previously unbound with `BindaleElement.unbindAffected`\r\n */\n\nBindableElement.rebindAffected = (elements, bindableElement, updateElementWith) => {\n // don't try to rebind element that is deleted (i.e. updated as deleted)\n if (!bindableElement || bindableElement.isDeleted) {\n return;\n }\n\n boundElementsVisitor(elements, bindableElement, (boundElement, _, boundElementId) => {\n var _a, _b, _c; // unbind from bindable elements, as bindings from non deleted elements into deleted elements are incorrect\n\n\n if (!boundElement || boundElement.isDeleted) {\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set([boundElementId]))\n });\n return;\n }\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_10__.isTextElement)(boundElement)) {\n const boundElements = (_b = (_a = bindableElement.boundElements) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : []; // check if this is the last element in the array, if not, there is an previously bound text which should be unbound\n\n if (((_c = boundElements.reverse().find(x => x.type === \"text\")) === null || _c === void 0 ? void 0 : _c.id) === boundElement.id) {\n if (boundElement.containerId !== bindableElement.id) {\n // rebind if not bound already!\n updateElementWith(boundElement, {\n containerId: bindableElement.id\n });\n }\n } else {\n if (boundElement.containerId !== null) {\n // unbind if not unbound already\n updateElementWith(boundElement, {\n containerId: null\n });\n } // unbind from boundElements as the element got bound to some other element in the meantime\n\n\n updateElementWith(bindableElement, {\n boundElements: newBoundElements(bindableElement.boundElements, new Set([boundElement.id]))\n });\n }\n }\n });\n};\n\nconst getGlobalFixedPointForBindableElement = (fixedPointRatio, element) => {\n const [fixedX, fixedY] = normalizeFixedPoint(fixedPointRatio);\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(element.x + element.width * fixedX, element.y + element.height * fixedY), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.elementCenterPoint)(element), element.angle);\n};\nconst getGlobalFixedPoints = (arrow, elementsMap) => {\n const startElement = arrow.startBinding && elementsMap.get(arrow.startBinding.elementId);\n const endElement = arrow.endBinding && elementsMap.get(arrow.endBinding.elementId);\n const startPoint = startElement && arrow.startBinding ? getGlobalFixedPointForBindableElement(arrow.startBinding.fixedPoint, startElement) : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + arrow.points[0][0], arrow.y + arrow.points[0][1]);\n const endPoint = endElement && arrow.endBinding ? getGlobalFixedPointForBindableElement(arrow.endBinding.fixedPoint, endElement) : (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(arrow.x + arrow.points[arrow.points.length - 1][0], arrow.y + arrow.points[arrow.points.length - 1][1]);\n return [startPoint, endPoint];\n};\nconst getArrowLocalFixedPoints = (arrow, elementsMap) => {\n const [startPoint, endPoint] = getGlobalFixedPoints(arrow, elementsMap);\n return [_linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(arrow, startPoint, elementsMap), _linearElementEditor__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.pointFromAbsoluteCoords(arrow, endPoint, elementsMap)];\n};\nconst normalizeFixedPoint = fixedPoint => {\n // Do not allow a precise 0.5 for fixed point ratio\n // to avoid jumping arrow heading due to floating point imprecision\n if (fixedPoint && (Math.abs(fixedPoint[0] - 0.5) < 0.0001 || Math.abs(fixedPoint[1] - 0.5) < 0.0001)) {\n return fixedPoint.map(ratio => Math.abs(ratio - 0.5) < 0.0001 ? 0.5001 : ratio);\n }\n\n return fixedPoint;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/binding.ts?");
|
|
13084
13084
|
|
|
13085
13085
|
/***/ }),
|
|
13086
13086
|
|
|
@@ -13476,7 +13476,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
13476
13476
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
13477
13477
|
|
|
13478
13478
|
"use strict";
|
|
13479
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ canApplyRoundnessTypeToElement: () => (/* binding */ canApplyRoundnessTypeToElement),\n/* harmony export */ getDefaultRoundnessTypeForElement: () => (/* binding */ getDefaultRoundnessTypeForElement),\n/* harmony export */ hasBoundTextElement: () => (/* binding */ hasBoundTextElement),\n/* harmony export */ isArrowElement: () => (/* binding */ isArrowElement),\n/* harmony export */ isBindableElement: () => (/* binding */ isBindableElement),\n/* harmony export */ isBindingElement: () => (/* binding */ isBindingElement),\n/* harmony export */ isBindingElementType: () => (/* binding */ isBindingElementType),\n/* harmony export */ isBoundToContainer: () => (/* binding */ isBoundToContainer),\n/* harmony export */ isBounds: () => (/* binding */ isBounds),\n/* harmony export */ isElbowArrow: () => (/* binding */ isElbowArrow),\n/* harmony export */ isEmbeddableElement: () => (/* binding */ isEmbeddableElement),\n/* harmony export */ isExcalidrawElement: () => (/* binding */ isExcalidrawElement),\n/* harmony export */ isFixedPointBinding: () => (/* binding */ isFixedPointBinding),\n/* harmony export */ isFlowchartNodeElement: () => (/* binding */ isFlowchartNodeElement),\n/* harmony export */ isFrameElement: () => (/* binding */ isFrameElement),\n/* harmony export */ isFrameLikeElement: () => (/* binding */ isFrameLikeElement),\n/* harmony export */ isFreeDrawElement: () => (/* binding */ isFreeDrawElement),\n/* harmony export */ isFreeDrawElementType: () => (/* binding */ isFreeDrawElementType),\n/* harmony export */ isIframeElement: () => (/* binding */ isIframeElement),\n/* harmony export */ isIframeLikeElement: () => (/* binding */ isIframeLikeElement),\n/* harmony export */ isImageElement: () => (/* binding */ isImageElement),\n/* harmony export */ isInitializedImageElement: () => (/* binding */ isInitializedImageElement),\n/* harmony export */ isLinearElement: () => (/* binding */ isLinearElement),\n/* harmony export */ isLinearElementType: () => (/* binding */ isLinearElementType),\n/* harmony export */ isMagicFrameElement: () => (/* binding */ isMagicFrameElement),\n/* harmony export */ isRectangularElement: () => (/* binding */ isRectangularElement),\n/* harmony export */ isRectanguloidElement: () => (/* binding */ isRectanguloidElement),\n/* harmony export */ isTextBindableContainer: () => (/* binding */ isTextBindableContainer),\n/* harmony export */ isTextElement: () => (/* binding */ isTextElement),\n/* harmony export */ isUsingAdaptiveRadius: () => (/* binding */ isUsingAdaptiveRadius),\n/* harmony export */ isUsingProportionalRadius: () => (/* binding */ isUsingProportionalRadius)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n\nconst isInitializedImageElement = element => {\n return !!element && element.type === \"image\" && !!element.fileId;\n};\nconst isImageElement = element => {\n return !!element && element.type === \"image\";\n};\nconst isEmbeddableElement = element => {\n return !!element && element.type === \"embeddable\";\n};\nconst isIframeElement = element => {\n return !!element && element.type === \"iframe\";\n};\nconst isIframeLikeElement = element => {\n return !!element && (element.type === \"iframe\" || element.type === \"embeddable\");\n};\nconst isTextElement = element => {\n return element != null && element.type === \"text\";\n};\nconst isFrameElement = element => {\n return element != null && element.type === \"frame\";\n};\nconst isMagicFrameElement = element => {\n return element != null && element.type === \"magicframe\";\n};\nconst isFrameLikeElement = element => {\n return element != null && (element.type === \"frame\" || element.type === \"magicframe\");\n};\nconst isFreeDrawElement = element => {\n return element != null && isFreeDrawElementType(element.type);\n};\nconst isFreeDrawElementType = elementType => {\n return elementType === \"freedraw\";\n};\nconst isLinearElement = element => {\n return element != null && isLinearElementType(element.type);\n};\nconst isArrowElement = element => {\n return element != null && element.type === \"arrow\";\n};\nconst isElbowArrow = element => {\n return isArrowElement(element) && element.elbowed;\n};\nconst isLinearElementType = elementType => {\n return elementType === \"arrow\" || elementType === \"line\" // || elementType === \"freedraw\"\n ;\n};\nconst isBindingElement = (element, includeLocked = true) => {\n return element != null && (!element.locked || includeLocked === true) && isBindingElementType(element.type);\n};\nconst isBindingElementType = elementType => {\n return elementType === \"arrow\";\n};\nconst isBindableElement = (element, includeLocked = true) => {\n return element != null && (!element.locked || includeLocked === true) && (element.type === \"rectangle\" || element.type === \"diamond\" || element.type === \"ellipse\" || element.type === \"image\" || element.type === \"iframe\" || element.type === \"embeddable\" || element.type === \"frame\" || element.type === \"magicframe\" || element.type === \"text\" && !element.containerId);\n};\nconst isRectanguloidElement = element => {\n return element != null && (element.type === \"rectangle\" || element.type === \"diamond\" || element.type === \"image\" || element.type === \"iframe\" || element.type === \"embeddable\" || element.type === \"frame\" || element.type === \"magicframe\" || element.type === \"text\" && !element.containerId);\n}; // TODO: Remove this when proper distance calculation is introduced\n// @see binding.ts:distanceToBindableElement()\n\nconst isRectangularElement = element => {\n return element != null && (element.type === \"rectangle\" || element.type === \"image\" || element.type === \"text\" || element.type === \"iframe\" || element.type === \"embeddable\" || element.type === \"frame\" || element.type === \"magicframe\" || element.type === \"freedraw\");\n};\nconst isTextBindableContainer = (element, includeLocked = true) => {\n return element != null && (!element.locked || includeLocked === true) && (element.type === \"rectangle\" || element.type === \"diamond\" || element.type === \"ellipse\" || isArrowElement(element));\n};\nconst isExcalidrawElement = element => {\n const type = element === null || element === void 0 ? void 0 : element.type;\n\n if (!type) {\n return false;\n }\n\n switch (type) {\n case \"text\":\n case \"diamond\":\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n case \"ellipse\":\n case \"arrow\":\n case \"freedraw\":\n case \"line\":\n case \"frame\":\n case \"magicframe\":\n case \"image\":\n case \"selection\":\n {\n return true;\n }\n\n default:\n {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.assertNever)(type, null);\n return false;\n }\n }\n};\nconst isFlowchartNodeElement = element => {\n return element.type === \"rectangle\" || element.type === \"ellipse\" || element.type === \"diamond\";\n};\nconst hasBoundTextElement = element => {\n var _a;\n\n return isTextBindableContainer(element) && !!((_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.some(({\n type\n }) => type === \"text\"));\n};\nconst isBoundToContainer = element => {\n return element !== null && \"containerId\" in element && element.containerId !== null && isTextElement(element);\n};\nconst isUsingAdaptiveRadius = type => type === \"rectangle\" || type === \"embeddable\" || type === \"iframe\" || type === \"image\";\nconst isUsingProportionalRadius = type => type === \"line\" || type === \"arrow\" || type === \"diamond\";\nconst canApplyRoundnessTypeToElement = (roundnessType, element) => {\n if ((roundnessType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.ADAPTIVE_RADIUS || // if legacy roundness, it can be applied to elements that currently\n // use adaptive radius\n roundnessType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.LEGACY) && isUsingAdaptiveRadius(element.type)) {\n return true;\n }\n\n if (roundnessType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.PROPORTIONAL_RADIUS && isUsingProportionalRadius(element.type)) {\n return true;\n }\n\n return false;\n};\nconst getDefaultRoundnessTypeForElement = element => {\n if (isUsingProportionalRadius(element.type)) {\n return {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.PROPORTIONAL_RADIUS\n };\n }\n\n if (isUsingAdaptiveRadius(element.type)) {\n return {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.ADAPTIVE_RADIUS\n };\n }\n\n return null;\n};\nconst isFixedPointBinding = binding => {\n return Object.hasOwn(binding, \"fixedPoint\") && binding.fixedPoint != null;\n}; // TODO: Move this to @excalidraw/math\n\nconst isBounds = box => Array.isArray(box) && box.length === 4 && typeof box[0] === \"number\" && typeof box[1] === \"number\" && typeof box[2] === \"number\" && typeof box[3] === \"number\";\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/typeChecks.ts?");
|
|
13479
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ canApplyRoundnessTypeToElement: () => (/* binding */ canApplyRoundnessTypeToElement),\n/* harmony export */ getDefaultRoundnessTypeForElement: () => (/* binding */ getDefaultRoundnessTypeForElement),\n/* harmony export */ hasBoundTextElement: () => (/* binding */ hasBoundTextElement),\n/* harmony export */ isArrowBoundToElement: () => (/* binding */ isArrowBoundToElement),\n/* harmony export */ isArrowElement: () => (/* binding */ isArrowElement),\n/* harmony export */ isBindableElement: () => (/* binding */ isBindableElement),\n/* harmony export */ isBindingElement: () => (/* binding */ isBindingElement),\n/* harmony export */ isBindingElementType: () => (/* binding */ isBindingElementType),\n/* harmony export */ isBoundToContainer: () => (/* binding */ isBoundToContainer),\n/* harmony export */ isBounds: () => (/* binding */ isBounds),\n/* harmony export */ isCurvedArrow: () => (/* binding */ isCurvedArrow),\n/* harmony export */ isElbowArrow: () => (/* binding */ isElbowArrow),\n/* harmony export */ isEmbeddableElement: () => (/* binding */ isEmbeddableElement),\n/* harmony export */ isExcalidrawElement: () => (/* binding */ isExcalidrawElement),\n/* harmony export */ isFixedPointBinding: () => (/* binding */ isFixedPointBinding),\n/* harmony export */ isFlowchartNodeElement: () => (/* binding */ isFlowchartNodeElement),\n/* harmony export */ isFrameElement: () => (/* binding */ isFrameElement),\n/* harmony export */ isFrameLikeElement: () => (/* binding */ isFrameLikeElement),\n/* harmony export */ isFreeDrawElement: () => (/* binding */ isFreeDrawElement),\n/* harmony export */ isFreeDrawElementType: () => (/* binding */ isFreeDrawElementType),\n/* harmony export */ isIframeElement: () => (/* binding */ isIframeElement),\n/* harmony export */ isIframeLikeElement: () => (/* binding */ isIframeLikeElement),\n/* harmony export */ isImageElement: () => (/* binding */ isImageElement),\n/* harmony export */ isInitializedImageElement: () => (/* binding */ isInitializedImageElement),\n/* harmony export */ isLinearElement: () => (/* binding */ isLinearElement),\n/* harmony export */ isLinearElementType: () => (/* binding */ isLinearElementType),\n/* harmony export */ isMagicFrameElement: () => (/* binding */ isMagicFrameElement),\n/* harmony export */ isRectangularElement: () => (/* binding */ isRectangularElement),\n/* harmony export */ isRectanguloidElement: () => (/* binding */ isRectanguloidElement),\n/* harmony export */ isSharpArrow: () => (/* binding */ isSharpArrow),\n/* harmony export */ isTextBindableContainer: () => (/* binding */ isTextBindableContainer),\n/* harmony export */ isTextElement: () => (/* binding */ isTextElement),\n/* harmony export */ isUsingAdaptiveRadius: () => (/* binding */ isUsingAdaptiveRadius),\n/* harmony export */ isUsingProportionalRadius: () => (/* binding */ isUsingProportionalRadius)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n\nconst isInitializedImageElement = element => {\n return !!element && element.type === \"image\" && !!element.fileId;\n};\nconst isImageElement = element => {\n return !!element && element.type === \"image\";\n};\nconst isEmbeddableElement = element => {\n return !!element && element.type === \"embeddable\";\n};\nconst isIframeElement = element => {\n return !!element && element.type === \"iframe\";\n};\nconst isIframeLikeElement = element => {\n return !!element && (element.type === \"iframe\" || element.type === \"embeddable\");\n};\nconst isTextElement = element => {\n return element != null && element.type === \"text\";\n};\nconst isFrameElement = element => {\n return element != null && element.type === \"frame\";\n};\nconst isMagicFrameElement = element => {\n return element != null && element.type === \"magicframe\";\n};\nconst isFrameLikeElement = element => {\n return element != null && (element.type === \"frame\" || element.type === \"magicframe\");\n};\nconst isFreeDrawElement = element => {\n return element != null && isFreeDrawElementType(element.type);\n};\nconst isFreeDrawElementType = elementType => {\n return elementType === \"freedraw\";\n};\nconst isLinearElement = element => {\n return element != null && isLinearElementType(element.type);\n};\nconst isArrowElement = element => {\n return element != null && element.type === \"arrow\";\n};\nconst isElbowArrow = element => {\n return isArrowElement(element) && element.elbowed;\n};\nconst isSharpArrow = element => {\n return isArrowElement(element) && !element.elbowed && !element.roundness;\n};\nconst isCurvedArrow = element => {\n return isArrowElement(element) && !element.elbowed && element.roundness !== null;\n};\nconst isLinearElementType = elementType => {\n return elementType === \"arrow\" || elementType === \"line\" // || elementType === \"freedraw\"\n ;\n};\nconst isBindingElement = (element, includeLocked = true) => {\n return element != null && (!element.locked || includeLocked === true) && isBindingElementType(element.type);\n};\nconst isBindingElementType = elementType => {\n return elementType === \"arrow\";\n};\nconst isBindableElement = (element, includeLocked = true) => {\n return element != null && (!element.locked || includeLocked === true) && (element.type === \"rectangle\" || element.type === \"diamond\" || element.type === \"ellipse\" || element.type === \"image\" || element.type === \"iframe\" || element.type === \"embeddable\" || element.type === \"frame\" || element.type === \"magicframe\" || element.type === \"text\" && !element.containerId);\n};\nconst isRectanguloidElement = element => {\n return element != null && (element.type === \"rectangle\" || element.type === \"diamond\" || element.type === \"image\" || element.type === \"iframe\" || element.type === \"embeddable\" || element.type === \"frame\" || element.type === \"magicframe\" || element.type === \"text\" && !element.containerId);\n}; // TODO: Remove this when proper distance calculation is introduced\n// @see binding.ts:distanceToBindableElement()\n\nconst isRectangularElement = element => {\n return element != null && (element.type === \"rectangle\" || element.type === \"image\" || element.type === \"text\" || element.type === \"iframe\" || element.type === \"embeddable\" || element.type === \"frame\" || element.type === \"magicframe\" || element.type === \"freedraw\");\n};\nconst isTextBindableContainer = (element, includeLocked = true) => {\n return element != null && (!element.locked || includeLocked === true) && (element.type === \"rectangle\" || element.type === \"diamond\" || element.type === \"ellipse\" || isArrowElement(element));\n};\nconst isExcalidrawElement = element => {\n const type = element === null || element === void 0 ? void 0 : element.type;\n\n if (!type) {\n return false;\n }\n\n switch (type) {\n case \"text\":\n case \"diamond\":\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n case \"ellipse\":\n case \"arrow\":\n case \"freedraw\":\n case \"line\":\n case \"frame\":\n case \"magicframe\":\n case \"image\":\n case \"selection\":\n {\n return true;\n }\n\n default:\n {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.assertNever)(type, null);\n return false;\n }\n }\n};\nconst isFlowchartNodeElement = element => {\n return element.type === \"rectangle\" || element.type === \"ellipse\" || element.type === \"diamond\";\n};\nconst hasBoundTextElement = element => {\n var _a;\n\n return isTextBindableContainer(element) && !!((_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.some(({\n type\n }) => type === \"text\"));\n};\nconst isBoundToContainer = element => {\n return element !== null && \"containerId\" in element && element.containerId !== null && isTextElement(element);\n};\nconst isArrowBoundToElement = element => {\n return !!element.startBinding || !!element.endBinding;\n};\nconst isUsingAdaptiveRadius = type => type === \"rectangle\" || type === \"embeddable\" || type === \"iframe\" || type === \"image\";\nconst isUsingProportionalRadius = type => type === \"line\" || type === \"arrow\" || type === \"diamond\";\nconst canApplyRoundnessTypeToElement = (roundnessType, element) => {\n if ((roundnessType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.ADAPTIVE_RADIUS || // if legacy roundness, it can be applied to elements that currently\n // use adaptive radius\n roundnessType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.LEGACY) && isUsingAdaptiveRadius(element.type)) {\n return true;\n }\n\n if (roundnessType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.PROPORTIONAL_RADIUS && isUsingProportionalRadius(element.type)) {\n return true;\n }\n\n return false;\n};\nconst getDefaultRoundnessTypeForElement = element => {\n if (isUsingProportionalRadius(element.type)) {\n return {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.PROPORTIONAL_RADIUS\n };\n }\n\n if (isUsingAdaptiveRadius(element.type)) {\n return {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.ROUNDNESS.ADAPTIVE_RADIUS\n };\n }\n\n return null;\n};\nconst isFixedPointBinding = binding => {\n return Object.hasOwn(binding, \"fixedPoint\") && binding.fixedPoint != null;\n}; // TODO: Move this to @excalidraw/math\n\nconst isBounds = box => Array.isArray(box) && box.length === 4 && typeof box[0] === \"number\" && typeof box[1] === \"number\" && typeof box[2] === \"number\" && typeof box[3] === \"number\";\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/typeChecks.ts?");
|
|
13480
13480
|
|
|
13481
13481
|
/***/ }),
|
|
13482
13482
|
|
|
@@ -14041,6 +14041,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
14041
14041
|
|
|
14042
14042
|
/***/ }),
|
|
14043
14043
|
|
|
14044
|
+
/***/ "./actions/actionToggleShapeSwitch.tsx":
|
|
14045
|
+
/*!*********************************************!*\
|
|
14046
|
+
!*** ./actions/actionToggleShapeSwitch.tsx ***!
|
|
14047
|
+
\*********************************************/
|
|
14048
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14049
|
+
|
|
14050
|
+
"use strict";
|
|
14051
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ actionToggleShapeSwitch: () => (/* binding */ actionToggleShapeSwitch)\n/* harmony export */ });\n/* harmony import */ var _components_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../components/ConvertElementTypePopup */ \"./components/ConvertElementTypePopup.tsx\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../store */ \"./store.ts\");\n/* harmony import */ var _register__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./register */ \"./actions/register.ts\");\n\n\n\n\nconst actionToggleShapeSwitch = (0,_register__WEBPACK_IMPORTED_MODULE_3__.register)({\n name: \"toggleShapeSwitch\",\n label: \"labels.shapeSwitch\",\n icon: () => null,\n viewMode: true,\n trackEvent: {\n category: \"shape_switch\",\n action: \"toggle\"\n },\n keywords: [\"change\", \"switch\", \"swap\"],\n\n perform(elements, appState, _, app) {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_1__.editorJotaiStore.set(_components_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_0__.convertElementTypePopupAtom, {\n type: \"panel\"\n });\n return {\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.NEVER\n };\n },\n\n checked: appState => appState.gridModeEnabled,\n predicate: (elements, appState, props) => (0,_components_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_0__.getConversionTypeFromElements)(elements) !== null\n});\n\n//# sourceURL=webpack://ExcalidrawLib/./actions/actionToggleShapeSwitch.tsx?");
|
|
14052
|
+
|
|
14053
|
+
/***/ }),
|
|
14054
|
+
|
|
14044
14055
|
/***/ "./actions/actionToggleStats.tsx":
|
|
14045
14056
|
/*!***************************************!*\
|
|
14046
14057
|
!*** ./actions/actionToggleStats.tsx ***!
|
|
@@ -14257,7 +14268,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
14257
14268
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14258
14269
|
|
|
14259
14270
|
"use strict";
|
|
14260
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawContainerContext: () => (/* binding */ ExcalidrawContainerContext),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ useApp: () => (/* binding */ useApp),\n/* harmony export */ useAppProps: () => (/* binding */ useAppProps),\n/* harmony export */ useDevice: () => (/* binding */ useDevice),\n/* harmony export */ useExcalidrawActionManager: () => (/* binding */ useExcalidrawActionManager),\n/* harmony export */ useExcalidrawAppState: () => (/* binding */ useExcalidrawAppState),\n/* harmony export */ useExcalidrawContainer: () => (/* binding */ useExcalidrawContainer),\n/* harmony export */ useExcalidrawElements: () => (/* binding */ useExcalidrawElements),\n/* harmony export */ useExcalidrawSetAppState: () => (/* binding */ useExcalidrawSetAppState)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.throttle */ \"../../node_modules/lodash.throttle/index.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_throttle__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-dom */ \"react-dom\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_103__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/utils/collision */ \"../utils/src/collision.ts\");\n/* harmony import */ var _excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/utils/shape */ \"../utils/src/shape.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @excalidraw/element/binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @excalidraw/element/duplicate */ \"../element/src/duplicate.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @excalidraw/element/sizeHelpers */ \"../element/src/sizeHelpers.ts\");\n/* harmony import */ var _excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @excalidraw/element/shapes */ \"../element/src/shapes.ts\");\n/* harmony import */ var _excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @excalidraw/element/embeddable */ \"../element/src/embeddable.ts\");\n/* harmony import */ var _excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @excalidraw/element/image */ \"../element/src/image.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_transformHandles__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @excalidraw/element/transformHandles */ \"../element/src/transformHandles.ts\");\n/* harmony import */ var _excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @excalidraw/element/frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @excalidraw/element/collision */ \"../element/src/collision.ts\");\n/* harmony import */ var _excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! @excalidraw/element/flowchart */ \"../element/src/flowchart.ts\");\n/* harmony import */ var _excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! @excalidraw/element/cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @excalidraw/element/elementLink */ \"../element/src/elementLink.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! @excalidraw/element/ShapeCache */ \"../element/src/ShapeCache.ts\");\n/* harmony import */ var _excalidraw_element_renderElement__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! @excalidraw/element/renderElement */ \"../element/src/renderElement.ts\");\n/* harmony import */ var _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! @excalidraw/element/groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! @excalidraw/element/fractionalIndex */ \"../element/src/fractionalIndex.ts\");\n/* harmony import */ var _excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! @excalidraw/element/selection */ \"../element/src/selection.ts\");\n/* harmony import */ var _excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @excalidraw/element/resizeElements */ \"../element/src/resizeElements.ts\");\n/* harmony import */ var _excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! @excalidraw/element/resizeTest */ \"../element/src/resizeTest.ts\");\n/* harmony import */ var _excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! @excalidraw/element/dragElements */ \"../element/src/dragElements.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _excalidraw_element_Scene__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! @excalidraw/element/Scene */ \"../element/src/Scene.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ../actions/actionBoundText */ \"./actions/actionBoundText.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ../actions/actionClipboard */ \"./actions/actionClipboard.tsx\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ../actions/actionElementLock */ \"./actions/actionElementLock.ts\");\n/* harmony import */ var _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ../actions/actionFrame */ \"./actions/actionFrame.ts\");\n/* harmony import */ var _actions_actionHistory__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ../actions/actionHistory */ \"./actions/actionHistory.tsx\");\n/* harmony import */ var _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ../actions/actionTextAutoResize */ \"./actions/actionTextAutoResize.ts\");\n/* harmony import */ var _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ../actions/actionToggleViewMode */ \"./actions/actionToggleViewMode.tsx\");\n/* harmony import */ var _actions_manager__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ../actions/manager */ \"./actions/manager.tsx\");\n/* harmony import */ var _actions_register__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ../actions/register */ \"./actions/register.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _animation_frame_handler__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ../animation-frame-handler */ \"./animation-frame-handler.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ../data */ \"./data/index.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ../data/library */ \"./data/library.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ../data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _gesture__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ../gesture */ \"./gesture.ts\");\n/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ../history */ \"./history.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_filesystem__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ../data/filesystem */ \"./data/filesystem.ts\");\n/* harmony import */ var _components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ../components/hyperlink/Hyperlink */ \"./components/hyperlink/Hyperlink.tsx\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _snapping__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ../snapping */ \"./snapping.ts\");\n/* harmony import */ var _data_transform__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ../data/transform */ \"./data/transform.ts\");\n/* harmony import */ var _scene_Renderer__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(/*! ../scene/Renderer */ \"./scene/Renderer.ts\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_73__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _emitter__WEBPACK_IMPORTED_MODULE_74__ = __webpack_require__(/*! ../emitter */ \"./emitter.ts\");\n/* harmony import */ var _components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_75__ = __webpack_require__(/*! ../components/ElementCanvasButtons */ \"./components/ElementCanvasButtons.tsx\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_76__ = __webpack_require__(/*! ../store */ \"./store.ts\");\n/* harmony import */ var _laser_trails__WEBPACK_IMPORTED_MODULE_77__ = __webpack_require__(/*! ../laser-trails */ \"./laser-trails.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_78__ = __webpack_require__(/*! ../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_79__ = __webpack_require__(/*! ../wysiwyg/textWysiwyg */ \"./wysiwyg/textWysiwyg.tsx\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_80__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _mermaid__WEBPACK_IMPORTED_MODULE_81__ = __webpack_require__(/*! ../mermaid */ \"./mermaid.ts\");\n/* harmony import */ var _lasso__WEBPACK_IMPORTED_MODULE_82__ = __webpack_require__(/*! ../lasso */ \"./lasso/index.ts\");\n/* harmony import */ var _eraser__WEBPACK_IMPORTED_MODULE_83__ = __webpack_require__(/*! ../eraser */ \"./eraser/index.ts\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_84__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_85__ = __webpack_require__(/*! ./BraveMeasureTextError */ \"./components/BraveMeasureTextError.tsx\");\n/* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_86__ = __webpack_require__(/*! ./ContextMenu */ \"./components/ContextMenu.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_87__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_88__ = __webpack_require__(/*! ./FollowMode/FollowMode */ \"./components/FollowMode/FollowMode.tsx\");\n/* harmony import */ var _LayerUI__WEBPACK_IMPORTED_MODULE_89__ = __webpack_require__(/*! ./LayerUI */ \"./components/LayerUI.tsx\");\n/* harmony import */ var _MagicButton__WEBPACK_IMPORTED_MODULE_90__ = __webpack_require__(/*! ./MagicButton */ \"./components/MagicButton.tsx\");\n/* harmony import */ var _SVGLayer__WEBPACK_IMPORTED_MODULE_91__ = __webpack_require__(/*! ./SVGLayer */ \"./components/SVGLayer.tsx\");\n/* harmony import */ var _SearchMenu__WEBPACK_IMPORTED_MODULE_92__ = __webpack_require__(/*! ./SearchMenu */ \"./components/SearchMenu.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_93__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _canvases__WEBPACK_IMPORTED_MODULE_94__ = __webpack_require__(/*! ./canvases */ \"./components/canvases/index.tsx\");\n/* harmony import */ var _canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_95__ = __webpack_require__(/*! ./canvases/NewElementCanvas */ \"./components/canvases/NewElementCanvas.tsx\");\n/* harmony import */ var _hyperlink_helpers__WEBPACK_IMPORTED_MODULE_96__ = __webpack_require__(/*! ./hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_97__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _Toast__WEBPACK_IMPORTED_MODULE_98__ = __webpack_require__(/*! ./Toast */ \"./components/Toast.tsx\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_99__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_100__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_101__ = __webpack_require__(/*! ./Tooltip */ \"./components/Tooltip.tsx\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_102__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst AppContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst AppPropsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst deviceContextInitialValue = {\n viewport: {\n isMobile: false,\n isLandscape: false\n },\n editor: {\n isMobile: false,\n canFitSidebar: false\n },\n isTouchScreen: false\n};\nconst DeviceContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(deviceContextInitialValue);\nDeviceContext.displayName = \"DeviceContext\";\nconst ExcalidrawContainerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext({\n container: null,\n id: null\n});\nExcalidrawContainerContext.displayName = \"ExcalidrawContainerContext\";\nconst ExcalidrawElementsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext([]);\nExcalidrawElementsContext.displayName = \"ExcalidrawElementsContext\";\nconst ExcalidrawAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_54__.getDefaultAppState)()), {\n width: 0,\n height: 0,\n offsetLeft: 0,\n offsetTop: 0\n}));\nExcalidrawAppStateContext.displayName = \"ExcalidrawAppStateContext\";\nconst ExcalidrawSetAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(() => {\n console.warn(\"Uninitialized ExcalidrawSetAppStateContext context!\");\n});\nExcalidrawSetAppStateContext.displayName = \"ExcalidrawSetAppStateContext\";\nconst ExcalidrawActionManagerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawActionManagerContext.displayName = \"ExcalidrawActionManagerContext\";\nconst useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppContext);\nconst useAppProps = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppPropsContext);\nconst useDevice = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(DeviceContext);\nconst useExcalidrawContainer = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawContainerContext);\nconst useExcalidrawElements = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawElementsContext);\nconst useExcalidrawAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawAppStateContext);\nconst useExcalidrawSetAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawSetAppStateContext);\nconst useExcalidrawActionManager = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawActionManagerContext);\nlet didTapTwice = false;\nlet tappedTwiceTimer = 0;\nlet isHoldingSpace = false;\nlet isPanning = false;\nlet isDraggingScrollBar = false;\nlet currentScrollBars = {\n horizontal: null,\n vertical: null\n};\nlet touchTimeout = 0;\nlet invalidateContextMenu = false;\n/**\r\n * Map of youtube embed video states\r\n */\n\nconst YOUTUBE_VIDEO_STATES = new Map();\nlet IS_PLAIN_PASTE = false;\nlet IS_PLAIN_PASTE_TIMER = 0;\nlet PLAIN_PASTE_TOAST_SHOWN = false;\nlet lastPointerUp = null;\nconst gesture = {\n pointers: new Map(),\n lastCenter: null,\n initialDistance: null,\n initialScale: null\n};\n\nclass App extends (react__WEBPACK_IMPORTED_MODULE_2___default().Component) {\n constructor(props) {\n super(props);\n this.interactiveCanvas = null;\n this.unmounted = false;\n this.device = deviceContextInitialValue;\n this.excalidrawContainerRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createRef();\n this.shouldRenderAllEmbeddables = false; //zsviczian\n\n this.files = {};\n this.imageCache = new Map();\n this.iFrameRefs = new Map();\n /**\r\n * Indicates whether the embeddable's url has been validated for rendering.\r\n * If value not set, indicates that the validation is pending.\r\n * Initially or on url change the flag is not reset so that we can guarantee\r\n * the validation came from a trusted source (the editor).\r\n **/\n\n this.embedsValidationStatus = new Map();\n /** embeds that have been inserted to DOM (as a perf optim, we don't want to\r\n * insert to DOM before user initially scrolls to them) */\n\n this.initializedEmbeds = new Set();\n this.elementsPendingErasure = new Set();\n this.flowChartCreator = new _excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.FlowChartCreator();\n this.flowChartNavigator = new _excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.FlowChartNavigator();\n this.lastPointerDownEvent = null;\n this.lastPointerUpEvent = null;\n this.lastPointerMoveEvent = null;\n this.lastPointerMoveCoords = null;\n this.lastViewportPosition = {\n x: 0,\n y: 0\n };\n this.allowMobileMode = true; //zsviczian\n\n this.animationFrameHandler = new _animation_frame_handler__WEBPACK_IMPORTED_MODULE_53__.AnimationFrameHandler();\n this.laserTrails = new _laser_trails__WEBPACK_IMPORTED_MODULE_77__.LaserTrails(this.animationFrameHandler, this);\n this.eraserTrail = new _eraser__WEBPACK_IMPORTED_MODULE_83__.EraserTrail(this.animationFrameHandler, this);\n this.lassoTrail = new _lasso__WEBPACK_IMPORTED_MODULE_82__.LassoTrail(this.animationFrameHandler, this);\n this.onChangeEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onPointerDownEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onPointerUpEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onUserFollowEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onScrollChangeEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.missingPointerEventCleanupEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onRemoveEventListenersEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n /**\r\n * Returns gridSize taking into account `gridModeEnabled`.\r\n * If disabled, returns null.\r\n */\n\n this.getEffectiveGridSize = () => {\n return (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isGridModeEnabled)(this) ? this.state.gridSize : null;\n };\n\n this.updateEmbedValidationStatus = (element, status) => {\n this.embedsValidationStatus.set(element.id, status);\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element);\n };\n\n this.updateEmbeddables = () => {\n const iframeLikes = new Set();\n let updated = false;\n this.scene.getNonDeletedElements().filter(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(element)) {\n iframeLikes.add(element.id);\n\n if (!this.embedsValidationStatus.has(element.id)) {\n updated = true;\n const validated = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.embeddableURLValidator)(element.link, this.props.validateEmbeddable);\n this.updateEmbedValidationStatus(element, validated);\n }\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(element)) {\n iframeLikes.add(element.id);\n }\n\n return false;\n });\n\n if (updated) {\n this.scene.triggerUpdate();\n } // GC\n\n\n this.iFrameRefs.forEach((ref, id) => {\n if (!iframeLikes.has(id)) {\n this.iFrameRefs.delete(id);\n }\n });\n };\n\n this.getFrameNameDOMId = frameElement => {\n return `${this.id}-frame-name-${frameElement.id}`;\n };\n\n this.frameNameBoundsCache = {\n get: frameElement => {\n let bounds = this.frameNameBoundsCache._cache.get(frameElement.id);\n\n if (!bounds || bounds.zoom !== this.state.zoom.value || bounds.versionNonce !== frameElement.versionNonce) {\n const frameNameDiv = document.getElementById(this.getFrameNameDOMId(frameElement));\n\n if (frameNameDiv) {\n const box = frameNameDiv.getBoundingClientRect();\n const boxSceneTopLeft = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: box.x,\n clientY: box.y\n }, this.state);\n const boxSceneBottomRight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: box.right,\n clientY: box.bottom\n }, this.state);\n bounds = {\n x: boxSceneTopLeft.x,\n y: boxSceneTopLeft.y,\n width: boxSceneBottomRight.x - boxSceneTopLeft.x,\n height: boxSceneBottomRight.y - boxSceneTopLeft.y,\n angle: 0,\n zoom: this.state.zoom.value,\n versionNonce: frameElement.versionNonce\n };\n\n this.frameNameBoundsCache._cache.set(frameElement.id, bounds);\n\n return bounds;\n }\n\n return null;\n }\n\n return bounds;\n },\n\n /**\r\n * @private\r\n */\n _cache: new Map()\n };\n\n this.resetEditingFrame = frame => {\n var _a;\n\n if (frame) {\n this.scene.mutateElement(frame, {\n name: ((_a = frame.name) === null || _a === void 0 ? void 0 : _a.trim()) || null\n });\n }\n\n this.setState({\n editingFrame: null\n });\n };\n\n this.renderFrameNames = () => {\n if (!this.state.frameRendering.enabled || !this.state.frameRendering.name) {\n if (this.state.editingFrame) {\n this.resetEditingFrame(null);\n }\n\n return null;\n }\n\n const isDarkTheme = this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.DARK;\n return this.scene.getNonDeletedFramesLikes().map(f => {\n var _a, _b;\n\n if (!(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementInViewport)(f, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap())) {\n if (this.state.editingFrame === f.id) {\n this.resetEditingFrame(f);\n } // if frame not visible, don't render its name\n\n\n return null;\n }\n\n const {\n x: x1,\n y: y1\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: f.x,\n sceneY: f.y\n }, this.state);\n const FRAME_NAME_EDIT_PADDING = 6;\n let frameNameJSX;\n const frameName = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getFrameLikeTitle)(f);\n\n if (f.id === this.state.editingFrame) {\n const frameNameInEdit = frameName;\n frameNameJSX = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"input\", {\n autoFocus: true,\n value: frameNameInEdit,\n onChange: e => {\n this.scene.mutateElement(f, {\n name: e.target.value\n });\n },\n onFocus: e => e.target.select(),\n onBlur: () => this.resetEditingFrame(f),\n onKeyDown: event => {\n // for some inexplicable reason, `onBlur` triggered on ESC\n // does not reset `state.editingFrame` despite being called,\n // and we need to reset it here as well\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) {\n this.resetEditingFrame(f);\n }\n },\n style: {\n background: this.state.viewBackgroundColor,\n filter: isDarkTheme ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME_FILTER : \"none\",\n zIndex: 2,\n border: \"none\",\n display: \"block\",\n padding: `${FRAME_NAME_EDIT_PADDING}px`,\n borderRadius: 4,\n boxShadow: \"inset 0 0 0 2px var(--color-on-primary-container)\",\n fontFamily: \"Assistant\",\n fontSize: \"14px\",\n transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`,\n color: \"var(--color-gray-80)\",\n overflow: \"hidden\",\n maxWidth: `${(0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.getExcalidrawContentEl)().clientWidth - x1 - FRAME_NAME_EDIT_PADDING //zsviczian was document.body\n }px`\n },\n size: frameNameInEdit.length + 1 || 1,\n dir: \"auto\",\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n autoCorrect: \"off\"\n });\n } else {\n frameNameJSX = frameName;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n id: this.getFrameNameDOMId(f),\n key: f.id,\n style: {\n position: \"absolute\",\n // Positioning from bottom so that we don't to either\n // calculate text height or adjust using transform (which)\n // messes up input position when editing the frame name.\n // This makes the positioning deterministic and we can calculate\n // the same position when rendering to canvas / svg.\n bottom: `${this.state.height + _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameOffsetY - y1 + this.state.offsetTop}px`,\n left: `${x1 - this.state.offsetLeft}px`,\n zIndex: 2,\n fontSize: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameFontSize,\n color: (_b = (_a = this.state.frameColor) === null || _a === void 0 ? void 0 : _a.nameColor) !== null && _b !== void 0 ? _b : isDarkTheme //zsviczian\n ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameColorLightTheme,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameLineHeight,\n width: \"max-content\",\n maxWidth: `${f.width}px`,\n overflow: f.id === this.state.editingFrame ? \"visible\" : \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n cursor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE,\n pointerEvents: this.state.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.enabled\n },\n onPointerDown: event => this.handleCanvasPointerDown(event),\n onWheel: event => this.handleWheel(event),\n onContextMenu: this.handleCanvasContextMenu,\n onDoubleClick: () => {\n this.setState({\n editingFrame: f.id\n });\n }\n }, frameNameJSX);\n });\n };\n\n this.focusContainer = () => {\n var _a;\n\n (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n };\n\n this.getSceneElementsIncludingDeleted = () => {\n return this.scene.getElementsIncludingDeleted();\n };\n\n this.getSceneElements = () => {\n return this.scene.getNonDeletedElements();\n };\n\n this.onInsertElements = elements => {\n this.addElementsFromPasteOrLibrary({\n elements,\n position: \"center\",\n files: null\n });\n };\n\n this.onExportImage = async (type, elements, opts) => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"export\", type, \"ui\");\n const fileHandle = await (0,_data__WEBPACK_IMPORTED_MODULE_56__.exportCanvas)(type, elements, this.state, this.files, {\n exportBackground: this.state.exportBackground,\n name: this.getName(),\n viewBackgroundColor: this.state.viewBackgroundColor,\n exportingFrame: opts.exportingFrame\n }).catch(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.muteFSAbortError).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: error.message\n });\n });\n\n if (this.state.exportEmbedScene && fileHandle && (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isImageFileHandle)(fileHandle)) {\n this.setState({\n fileHandle\n });\n }\n };\n\n this.magicGenerations = new Map();\n\n this.updateMagicGeneration = ({\n frameElement,\n data\n }) => {\n if (data.status === \"pending\") {\n // We don't wanna persist pending state to storage. It should be in-app\n // state only.\n // Thus reset so that we prefer local cache (if there was some\n // generationData set previously)\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: undefined\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: data\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n this.magicGenerations.set(frameElement.id, data);\n this.triggerRender();\n };\n\n this.plugins = {};\n\n this.onMagicframeToolSelect = () => {\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds\n });\n\n if (selectedElements.length === 0) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"tool-select (empty-selection)\", \"d2c\");\n } else {\n const selectedMagicFrame = selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isMagicFrameElement)(selectedElements[0]) && selectedElements[0]; // case: user selected elements containing frame-like(s) or are frame\n // members, we don't want to wrap into another magicframe\n // (unless the only selected element is a magic frame which we reuse)\n\n if (!selectedMagicFrame && selectedElements.some(el => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(el) || el.frameId)) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe\n });\n return;\n }\n\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"tool-select (existing selection)\", \"d2c\");\n let frame;\n\n if (selectedMagicFrame) {\n // a single magicframe already selected -> use it\n frame = selectedMagicFrame;\n } else {\n // selected elements aren't wrapped in magic frame yet -> wrap now\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements);\n const padding = 50;\n frame = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newMagicFrameElement)(Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE), {\n x: minX - padding,\n y: minY - padding,\n width: maxX - minX + padding * 2,\n height: maxY - minY + padding * 2,\n opacity: 100,\n locked: false\n }));\n this.scene.insertElement(frame);\n\n for (const child of selectedElements) {\n this.scene.mutateElement(child, {\n frameId: frame.id\n });\n }\n\n this.setState({\n selectedElementIds: {\n [frame.id]: true\n }\n });\n }\n\n this.onMagicFrameGenerate(frame, \"upstream\");\n }\n };\n\n this.openEyeDropper = ({\n type\n }) => {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.set(_EyeDropper__WEBPACK_IMPORTED_MODULE_87__.activeEyeDropperAtom, {\n swapPreviewOnAlt: true,\n colorPickerType: type === \"stroke\" ? \"elementStroke\" : \"elementBackground\",\n onSelect: (color, event) => {\n const shouldUpdateStrokeColor = type === \"background\" && event.altKey || type === \"stroke\" && !event.altKey;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (!selectedElements.length || this.state.activeTool.type !== \"selection\") {\n if (shouldUpdateStrokeColor) {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemStrokeColor: color\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n } else {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemBackgroundColor: color\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n } else {\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().map(el => {\n if (this.state.selectedElementIds[el.id]) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(el, {\n [shouldUpdateStrokeColor ? \"strokeColor\" : \"backgroundColor\"]: color\n });\n }\n\n return el;\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n },\n keepOpenOnAlt: false\n });\n };\n\n this.dismissLinearEditor = () => {\n setTimeout(() => {\n this.setState({\n editingLinearElement: null\n });\n });\n };\n\n this.syncActionResult = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(actionResult => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.unmounted || actionResult === false) {\n return;\n }\n\n if (actionResult.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER) {\n this.store.shouldUpdateSnapshot();\n } else if (actionResult.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY) {\n this.store.shouldCaptureIncrement();\n }\n\n let didUpdate = false;\n let editingTextElement = null;\n\n if (actionResult.elements) {\n this.scene.replaceAllElements(actionResult.elements);\n didUpdate = true;\n }\n\n if (actionResult.files) {\n this.addMissingFiles(actionResult.files, actionResult.replaceFiles);\n this.addNewImagesToImageCache();\n }\n\n if (actionResult.appState || editingTextElement || this.state.contextMenu) {\n let viewModeEnabled = ((_a = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _a === void 0 ? void 0 : _a.viewModeEnabled) || false;\n let zenModeEnabled = ((_b = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _b === void 0 ? void 0 : _b.zenModeEnabled) || false;\n const theme = ((_c = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _c === void 0 ? void 0 : _c.theme) || this.props.theme || _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.LIGHT;\n const name = (_e = (_d = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : this.state.name;\n const errorMessage = (_g = (_f = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _f === void 0 ? void 0 : _f.errorMessage) !== null && _g !== void 0 ? _g : this.state.errorMessage;\n\n if (typeof this.props.viewModeEnabled !== \"undefined\") {\n viewModeEnabled = this.props.viewModeEnabled;\n }\n\n if (typeof this.props.zenModeEnabled !== \"undefined\") {\n zenModeEnabled = this.props.zenModeEnabled;\n }\n\n editingTextElement = ((_h = actionResult.appState) === null || _h === void 0 ? void 0 : _h.editingTextElement) || null; // make sure editingTextElement points to latest element reference\n\n if (actionResult.elements && editingTextElement) {\n actionResult.elements.forEach(element => {\n if ((editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.id) === element.id && editingTextElement !== element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_37__.isNonDeletedElement)(element) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element)) {\n editingTextElement = element;\n }\n });\n }\n\n if (editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.isDeleted) {\n editingTextElement = null;\n }\n\n this.setState(prevAppState => {\n const actionAppState = actionResult.appState || {};\n return Object.assign(Object.assign(Object.assign({}, prevAppState), actionAppState), {\n // NOTE this will prevent opening context menu using an action\n // or programmatically from the host, so it will need to be\n // rewritten later\n contextMenu: null,\n editingTextElement,\n viewModeEnabled,\n zenModeEnabled,\n theme,\n name,\n errorMessage\n });\n });\n didUpdate = true;\n }\n\n if (!didUpdate && actionResult.captureUpdate !== _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.EVENTUALLY) {\n this.scene.triggerUpdate();\n }\n }); // Lifecycle\n\n this.onBlur = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(() => {\n isHoldingSpace = false;\n this.setState({\n isBindingEnabled: true\n });\n });\n\n this.onUnload = () => {\n this.onBlur();\n };\n\n this.disableEvent = event => {\n event.preventDefault();\n };\n\n this.resetHistory = () => {\n this.history.clear();\n };\n\n this.resetStore = () => {\n this.store.clear();\n };\n /**\r\n * Resets scene & history.\r\n * ! Do not use to clear scene user action !\r\n */\n\n\n this.resetScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(opts => {\n this.scene.replaceAllElements([]);\n this.setState(state => Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_54__.getDefaultAppState)()), {\n isLoading: (opts === null || opts === void 0 ? void 0 : opts.resetLoadingState) ? false : state.isLoading,\n theme: this.state.theme\n }));\n this.resetStore();\n this.resetHistory();\n });\n\n this.initializeScene = async () => {\n var _a;\n\n if (\"launchQueue\" in window && \"LaunchParams\" in window) {\n window.launchQueue.setConsumer(async launchParams => {\n if (!launchParams.files.length) {\n return;\n }\n\n const fileHandle = launchParams.files[0];\n const blob = await fileHandle.getFile();\n this.loadFileToCanvas(new File([blob], blob.name || \"\", {\n type: blob.type\n }), fileHandle);\n });\n }\n\n if (this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n if (!this.state.isLoading) {\n this.setState({\n isLoading: true\n });\n }\n\n let initialData = null;\n\n try {\n if (typeof this.props.initialData === \"function\") {\n initialData = (await this.props.initialData()) || null;\n } else {\n initialData = (await this.props.initialData) || null;\n }\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.libraryItems) {\n this.library.updateLibrary({\n libraryItems: initialData.libraryItems,\n merge: true\n }).catch(error => {\n console.error(error);\n });\n }\n } catch (error) {\n console.error(error);\n initialData = {\n appState: {\n errorMessage: error.message || \"Encountered an error during importing or restoring scene data\"\n }\n };\n }\n\n const scene = (0,_data_restore__WEBPACK_IMPORTED_MODULE_58__.restore)(initialData, null, null, {\n repairBindings: true\n });\n scene.appState = Object.assign(Object.assign({}, scene.appState), {\n theme: this.props.theme || scene.appState.theme,\n // we're falling back to current (pre-init) state when deciding\n // whether to open the library, to handle a case where we\n // update the state outside of initialData (e.g. when loading the app\n // with a library install link, which should auto-open the library)\n openSidebar: ((_a = scene.appState) === null || _a === void 0 ? void 0 : _a.openSidebar) || this.state.openSidebar,\n activeTool: scene.appState.activeTool.type === \"image\" ? Object.assign(Object.assign({}, scene.appState.activeTool), {\n type: \"selection\"\n }) : scene.appState.activeTool,\n isLoading: false,\n toast: this.state.toast\n });\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.scrollToContent) {\n scene.appState = Object.assign(Object.assign({}, scene.appState), (0,_scene__WEBPACK_IMPORTED_MODULE_62__.calculateScrollCenter)(scene.elements, Object.assign(Object.assign({}, scene.appState), {\n width: this.state.width,\n height: this.state.height,\n offsetTop: this.state.offsetTop,\n offsetLeft: this.state.offsetLeft\n })));\n }\n\n this.resetStore();\n this.resetHistory();\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n })); // clear the shape and image cache so that any images in initialData\n // can be loaded fresh\n\n this.clearImageShapeCache(); // manually loading the font faces seems faster even in browsers that do fire the loadingdone event\n\n this.fonts.loadSceneFonts().then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n\n if ((0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.isElementLink)(window.location.href)) {\n this.scrollToContent(window.location.href, {\n animate: false\n });\n }\n };\n\n this.isMobileBreakpoint = (width, height) => {\n return width !== 0 && //zsviczian changing tabs in Obsidian causes MobileMenu to be rendered\n this.allowMobileMode && ( //zsviczian\n width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_MAX_WIDTH_PORTRAIT || height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_MAX_HEIGHT_LANDSCAPE && width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_MAX_WIDTH_LANDSCAPE);\n };\n\n this.refreshViewportBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n clientWidth: viewportWidth,\n clientHeight: viewportHeight\n } = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.getExcalidrawContentEl)(); //zsviczian was document.body;\n\n const prevViewportState = this.device.viewport;\n const nextViewportState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevViewportState, {\n isLandscape: viewportWidth > viewportHeight,\n isMobile: this.isMobileBreakpoint(viewportWidth, viewportHeight)\n });\n\n if (prevViewportState !== nextViewportState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n viewport: nextViewportState\n });\n return true;\n }\n\n return false;\n };\n\n this.refreshEditorBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n width: editorWidth,\n height: editorHeight\n } = container.getBoundingClientRect();\n const sidebarBreakpoint = this.props.UIOptions.dockedSidebarBreakpoint != null ? this.props.UIOptions.dockedSidebarBreakpoint : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_RIGHT_SIDEBAR_MIN_WIDTH;\n const prevEditorState = this.device.editor;\n const nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight),\n canFitSidebar: editorWidth > sidebarBreakpoint\n });\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n return true;\n }\n\n return false;\n };\n\n this.onResize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(() => {\n this.scene.getElementsIncludingDeleted().forEach(element => _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element));\n this.refreshViewportBreakpoints();\n this.updateDOMRect();\n\n if (!_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.supportsResizeObserver) {\n this.refreshEditorBreakpoints();\n }\n\n this.setState({});\n });\n /** generally invoked only if fullscreen was invoked programmatically */\n\n this.onFullscreenChange = () => {\n var _a;\n\n if ( // points to the iframe element we fullscreened\n !document.fullscreenElement && ((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.state) === \"active\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n };\n\n this.renderInteractiveSceneCallback = ({\n atLeastOneVisibleElement,\n scrollBars,\n elementsMap\n }) => {\n if (!document.querySelector(\".excalidraw\")) {\n return;\n } //zsviczian - address issue when moving excalidraw to a new window/document\n\n\n if (scrollBars) {\n currentScrollBars = scrollBars;\n }\n\n const scrolledOutside = // hide when editing text\n this.state.editingTextElement ? false : !atLeastOneVisibleElement && elementsMap.size > 0;\n\n if (this.state.scrolledOutside !== scrolledOutside) {\n this.setState({\n scrolledOutside\n });\n }\n\n this.scheduleImageRefresh();\n };\n\n this.onScroll = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.debounce)(() => {\n const {\n offsetTop,\n offsetLeft\n } = this.getCanvasOffsets();\n this.setState(state => {\n if (state.offsetLeft === offsetLeft && state.offsetTop === offsetTop) {\n return null;\n }\n\n return {\n offsetTop,\n offsetLeft\n };\n });\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.SCROLL_TIMEOUT); // Copy/paste\n\n this.onCut = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionCut, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n this.onCopy = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionCopy, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n\n this.onTouchStart = event => {\n // fix for Apple Pencil Scribble (do not prevent for other devices)\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isIOS) {\n event.preventDefault();\n }\n\n if (!didTapTwice) {\n didTapTwice = true;\n clearTimeout(tappedTwiceTimer);\n tappedTwiceTimer = window.setTimeout(App.resetTapTwice, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TAP_TWICE_TIMEOUT);\n return;\n } // insert text only if we tapped twice with a single finger\n // event.touches.length === 1 will also prevent inserting text when user's zooming\n\n\n if (didTapTwice && event.touches.length === 1) {\n const touch = event.touches[0]; // @ts-ignore\n\n this.handleCanvasDoubleClick({\n clientX: touch.clientX,\n clientY: touch.clientY\n });\n didTapTwice = false;\n clearTimeout(tappedTwiceTimer);\n }\n\n if (event.touches.length === 2) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n };\n\n this.onTouchEnd = event => {\n this.resetContextMenuTimer();\n\n if (event.touches.length > 0) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n } else {\n gesture.pointers.clear();\n }\n };\n\n this.pasteFromClipboard = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(async event => {\n var _a, _b;\n\n const isPlainPaste = !!IS_PLAIN_PASTE; // #686\n\n const target = document.activeElement;\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(target);\n\n if (event && !isExcalidrawActive) {\n return;\n }\n\n const elementUnderCursor = document.elementFromPoint(this.lastViewportPosition.x, this.lastViewportPosition.y);\n\n if (event && (!(elementUnderCursor instanceof HTMLCanvasElement) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(target))) {\n return;\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state); // must be called in the same frame (thus before any awaits) as the paste\n // event else some browsers (FF...) will clear the clipboardData\n // (something something security)\n\n let file = (_b = event === null || event === void 0 ? void 0 : event.clipboardData) === null || _b === void 0 ? void 0 : _b.files[0];\n const data = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_55__.parseClipboard)(event, isPlainPaste);\n\n if (!file && !isPlainPaste) {\n if (data.mixedContent) {\n return this.addElementsFromMixedContentPaste(data.mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n });\n } else if (data.text) {\n const string = data.text.trim();\n\n if (string.startsWith(\"<svg\") && string.endsWith(\"</svg>\")) {\n // ignore SVG validation/normalization which will be done during image\n // initialization\n file = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.SVGStringToFile)(string);\n }\n }\n } // prefer spreadsheet data over image file (MS Office/Libre Office)\n\n\n if ((0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isSupportedImageFile)(file) && !data.spreadsheet) {\n if (!this.isToolSupported(\"image\")) {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const imageElement = this.createImageElement({\n sceneX,\n sceneY\n });\n this.insertImageElement(imageElement, file);\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n });\n return;\n }\n\n if (this.props.onPaste) {\n try {\n if ((await this.props.onPaste(data, event)) === false) {\n return;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n if (data.errorMessage) {\n this.setState({\n errorMessage: data.errorMessage\n });\n } else if (data.spreadsheet && !isPlainPaste) {\n this.setState({\n pasteDialog: {\n data: data.spreadsheet,\n shown: true\n }\n });\n } else if (data.elements) {\n const elements = data.programmaticAPI ? (0,_data_transform__WEBPACK_IMPORTED_MODULE_71__.convertToExcalidrawElements)(data.elements) : data.elements; // TODO remove formatting from elements if isPlainPaste\n\n this.addElementsFromPasteOrLibrary({\n elements,\n files: data.files || null,\n position: \"cursor\",\n retainSeed: isPlainPaste\n });\n } else if (data.text) {\n if (data.text && (0,_mermaid__WEBPACK_IMPORTED_MODULE_81__.isMaybeMermaidDefinition)(data.text)) {\n const api = await Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! @zsviczian/mermaid-to-excalidraw */ \"../../node_modules/@zsviczian/mermaid-to-excalidraw/dist/index.js\"));\n\n try {\n const {\n elements: skeletonElements,\n files\n } = await api.parseMermaidToExcalidraw(data.text);\n const elements = (0,_data_transform__WEBPACK_IMPORTED_MODULE_71__.convertToExcalidrawElements)(skeletonElements, {\n regenerateIds: true\n });\n this.addElementsFromPasteOrLibrary({\n elements,\n files,\n position: \"cursor\"\n });\n return;\n } catch (err) {\n console.warn(`parsing pasted text as mermaid definition failed: ${err.message}`);\n }\n }\n\n const nonEmptyLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeEOL)(data.text).split(/\\n+/).map(s => s.trim()).filter(Boolean);\n const embbeddableUrls = nonEmptyLines.map(str => (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.maybeParseEmbedSrc)(str)).filter(string => {\n var _a;\n\n return (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.embeddableURLValidator)(string, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(string) || ((_a = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)(string)) === null || _a === void 0 ? void 0 : _a.type) === \"video\");\n });\n\n if (!IS_PLAIN_PASTE && embbeddableUrls.length > 0 && // if there were non-embeddable text (lines) mixed in with embeddable\n // urls, ignore and paste as text\n embbeddableUrls.length === nonEmptyLines.length) {\n const embeddables = [];\n\n for (const url of embbeddableUrls) {\n const prevEmbeddable = embeddables[embeddables.length - 1];\n const embeddable = this.insertEmbeddableElement({\n sceneX: prevEmbeddable ? prevEmbeddable.x + prevEmbeddable.width + 20 : sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeLink)(url)\n });\n\n if (embeddable) {\n embeddables.push(embeddable);\n }\n }\n\n if (embeddables.length) {\n this.setState({\n selectedElementIds: Object.fromEntries(embeddables.map(embeddable => [embeddable.id, true]))\n });\n }\n\n return;\n }\n\n this.addTextFromPaste(data.text, isPlainPaste);\n }\n\n this.setActiveTool({\n type: \"selection\"\n });\n event === null || event === void 0 ? void 0 : event.preventDefault();\n });\n\n this.addElementsFromPasteOrLibrary = opts => {\n var _a, _b;\n\n const elements = (0,_data_restore__WEBPACK_IMPORTED_MODULE_58__.restoreElements)(opts.elements, null, undefined);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(elements);\n const elementsCenterX = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(minX, maxX) / 2;\n const elementsCenterY = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(minY, maxY) / 2;\n const clientX = typeof opts.position === \"object\" ? opts.position.clientX : opts.position === \"cursor\" ? this.lastViewportPosition.x : this.state.width / 2 + this.state.offsetLeft;\n const clientY = typeof opts.position === \"object\" ? opts.position.clientY : opts.position === \"cursor\" ? this.lastViewportPosition.y : this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const dx = x - elementsCenterX;\n const dy = y - elementsCenterY;\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(dx, dy, this.getEffectiveGridSize());\n const {\n duplicatedElements\n } = (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElements)({\n type: \"everything\",\n elements: elements.map(element => {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(element, {\n x: element.x + gridX - minX,\n y: element.y + gridY - minY\n });\n }),\n randomizeSeed: !opts.retainSeed\n });\n const prevElements = this.scene.getElementsIncludingDeleted();\n let nextElements = [...prevElements, ...duplicatedElements];\n const mappedNewSceneElements = (_b = (_a = this.props).onDuplicate) === null || _b === void 0 ? void 0 : _b.call(_a, nextElements, prevElements);\n nextElements = mappedNewSceneElements || nextElements;\n (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncMovedIndices)(nextElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(duplicatedElements));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n\n if (topLayerFrame) {\n const eligibleElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.filterElementsEligibleAsFrameChildren)(duplicatedElements, topLayerFrame);\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.addElementsToFrame)(nextElements, eligibleElements, topLayerFrame, this.state);\n }\n\n this.scene.replaceAllElements(nextElements);\n duplicatedElements.forEach(newElement => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(newElement) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(newElement)) {\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(newElement, this.scene.getElementsMapIncludingDeleted());\n (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.redrawTextBoundingBox)(newElement, container, this.scene);\n }\n }); // paste event may not fire FontFace loadingdone event in Safari, hence loading font faces manually\n\n if (true) {\n //zsviczian - isSafari\n _fonts__WEBPACK_IMPORTED_MODULE_67__.Fonts.loadElementsFonts(duplicatedElements).then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n }\n\n if (opts.files) {\n this.addMissingFiles(opts.files);\n }\n\n this.store.shouldCaptureIncrement();\n const nextElementsToSelect = (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.excludeElementsInFramesFromSelection)(duplicatedElements);\n this.setState(Object.assign(Object.assign(Object.assign({}, this.state), {\n // keep sidebar (presumably the library) open if it's docked and\n // can fit.\n //\n // Note, we should close the sidebar only if we're dropping items\n // from library, not when pasting from clipboard. Alas.\n openSidebar: this.state.openSidebar && this.device.editor.canFitSidebar && _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.get(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_93__.isSidebarDockedAtom) ? this.state.openSidebar : null\n }), (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: null,\n selectedElementIds: nextElementsToSelect.reduce((acc, element) => {\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(element)) {\n acc[element.id] = true;\n }\n\n return acc;\n }, {})\n }, this.scene.getNonDeletedElements(), this.state, this)), () => {\n if (opts.files) {\n this.addNewImagesToImageCache();\n }\n });\n this.setActiveTool({\n type: \"selection\"\n });\n\n if (opts.fitToContent) {\n this.scrollToContent(duplicatedElements, {\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n };\n\n this.setAppState = (state, callback) => {\n this.setState(state, callback);\n };\n\n this.removePointer = event => {\n if (touchTimeout) {\n this.resetContextMenuTimer();\n }\n\n gesture.pointers.delete(event.pointerId);\n };\n\n this.toggleLock = (source = \"ui\") => {\n if (!this.state.activeTool.locked) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"toolbar\", \"toggleLock\", `${source} (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n this.setState(prevState => {\n return {\n activeTool: Object.assign(Object.assign(Object.assign({}, prevState.activeTool), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, prevState.activeTool.locked ? {\n type: \"selection\"\n } : prevState.activeTool)), {\n locked: !prevState.activeTool.locked\n })\n };\n });\n };\n\n this.updateFrameRendering = opts => {\n this.setState(prevState => {\n var _a, _b, _c, _d;\n\n const next = typeof opts === \"function\" ? opts(prevState.frameRendering) : opts;\n return {\n frameRendering: {\n enabled: (_a = next === null || next === void 0 ? void 0 : next.enabled) !== null && _a !== void 0 ? _a : prevState.frameRendering.enabled,\n clip: (_b = next === null || next === void 0 ? void 0 : next.clip) !== null && _b !== void 0 ? _b : prevState.frameRendering.clip,\n name: (_c = next === null || next === void 0 ? void 0 : next.name) !== null && _c !== void 0 ? _c : prevState.frameRendering.name,\n outline: (_d = next === null || next === void 0 ? void 0 : next.outline) !== null && _d !== void 0 ? _d : prevState.frameRendering.outline\n }\n };\n });\n };\n\n this.togglePenMode = force => {\n this.setState(prevState => {\n return {\n penMode: force !== null && force !== void 0 ? force : !prevState.penMode,\n penDetected: true\n };\n });\n };\n\n this.onHandToolToggle = () => {\n //zsviczian added timeout because button won't select otherwise\n setTimeout(() => this.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.actionToggleHandTool));\n };\n /**\r\n * Zooms on canvas viewport center\r\n */\n\n\n this.zoomCanvas = (\n /**\r\n * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.\r\n * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom\r\n */\n value) => {\n this.setState(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: this.state.width / 2 + this.state.offsetLeft,\n viewportY: this.state.height / 2 + this.state.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(value)\n }, this.state)));\n };\n\n this.cancelInProgressAnimation = null;\n\n this.scrollToContent = (\n /**\r\n * target to scroll to\r\n *\r\n * - string - id of element or group, or url containing elementLink\r\n * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects\r\n */\n target = this.scene.getNonDeletedElements(), opts) => {\n var _a, _b, _c, _d;\n\n if (typeof target === \"string\") {\n let id;\n\n if ((0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.isElementLink)(target)) {\n id = (0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.parseElementLinkFromURL)(target);\n } else {\n id = target;\n }\n\n if (id) {\n const elements = this.scene.getElementsFromId(id);\n\n if (elements === null || elements === void 0 ? void 0 : elements.length) {\n this.scrollToContent(elements, {\n fitToContent: (_a = opts === null || opts === void 0 ? void 0 : opts.fitToContent) !== null && _a !== void 0 ? _a : true,\n animate: (_b = opts === null || opts === void 0 ? void 0 : opts.animate) !== null && _b !== void 0 ? _b : true\n });\n } else if ((0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.isElementLink)(target)) {\n this.setState({\n toast: {\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"elementLink.notFound\"),\n duration: 3000,\n closable: true\n }\n });\n }\n }\n\n return;\n }\n\n (_c = this.cancelInProgressAnimation) === null || _c === void 0 ? void 0 : _c.call(this); // convert provided target into ExcalidrawElement[] if necessary\n\n const targetElements = Array.isArray(target) ? target : [target];\n let zoom = this.state.zoom;\n let scrollX = this.state.scrollX;\n let scrollY = this.state.scrollY;\n\n if ((opts === null || opts === void 0 ? void 0 : opts.fitToContent) || (opts === null || opts === void 0 ? void 0 : opts.fitToViewport)) {\n const {\n appState\n } = (0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.zoomToFit)({\n canvasOffsets: opts.canvasOffsets,\n targetElements,\n appState: this.state,\n fitToViewport: !!(opts === null || opts === void 0 ? void 0 : opts.fitToViewport),\n viewportZoomFactor: opts === null || opts === void 0 ? void 0 : opts.viewportZoomFactor,\n minZoom: opts === null || opts === void 0 ? void 0 : opts.minZoom,\n maxZoom: opts === null || opts === void 0 ? void 0 : opts.maxZoom\n });\n zoom = appState.zoom;\n scrollX = appState.scrollX;\n scrollY = appState.scrollY;\n } else {\n // compute only the viewport location, without any zoom adjustment\n const scroll = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.calculateScrollCenter)(targetElements, this.state);\n scrollX = scroll.scrollX;\n scrollY = scroll.scrollY;\n } // when animating, we use RequestAnimationFrame to prevent the animation\n // from slowing down other processes\n\n\n if (opts === null || opts === void 0 ? void 0 : opts.animate) {\n const origScrollX = this.state.scrollX;\n const origScrollY = this.state.scrollY;\n const origZoom = this.state.zoom.value;\n const cancel = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.easeToValuesRAF)({\n fromValues: {\n scrollX: origScrollX,\n scrollY: origScrollY,\n zoom: origZoom\n },\n toValues: {\n scrollX,\n scrollY,\n zoom: zoom.value\n },\n interpolateValue: (from, to, progress, key) => {\n // for zoom, use different easing\n if (key === \"zoom\") {\n return from * Math.pow(to / from, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.easeOut)(progress));\n } // handle using default\n\n\n return undefined;\n },\n onStep: ({\n scrollX,\n scrollY,\n zoom\n }) => {\n this.setState({\n scrollX,\n scrollY,\n zoom: {\n value: zoom\n }\n });\n },\n onStart: () => {\n this.setState({\n shouldCacheIgnoreZoom: true\n });\n },\n onEnd: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n onCancel: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n duration: (_d = opts === null || opts === void 0 ? void 0 : opts.duration) !== null && _d !== void 0 ? _d : 500\n });\n\n this.cancelInProgressAnimation = () => {\n cancel();\n this.cancelInProgressAnimation = null;\n };\n } else {\n this.setState({\n scrollX,\n scrollY,\n zoom\n });\n }\n };\n\n this.maybeUnfollowRemoteUser = () => {\n if (this.state.userToFollow) {\n this.setState({\n userToFollow: null\n });\n }\n };\n /** use when changing scrollX/scrollY/zoom based on user interaction */\n\n\n this.translateCanvas = state => {\n var _a;\n\n (_a = this.cancelInProgressAnimation) === null || _a === void 0 ? void 0 : _a.call(this);\n this.maybeUnfollowRemoteUser();\n this.setState(state);\n }; //zsviczian\n\n\n this.setForceRenderAllEmbeddables = force => {\n this.shouldRenderAllEmbeddables = force;\n\n if (force) {\n this.setState({});\n }\n }; //zsviczian\n\n\n this.zoomToFit = (target = this.scene.getNonDeletedElements(), maxZoom, //null will zoom to max based on viewport\n margin = 0.03) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.getMaxZoom)();\n }\n\n if (!target) {\n target = this.scene.getNonDeletedElements();\n }\n\n if (target.length === 0) {\n maxZoom = 1;\n }\n\n this.setState((0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.zoomToFitElements)(target, this.state, false, this, maxZoom, margin).appState);\n }; //zsviczian\n\n\n this.getColorAtScenePoint = ({\n sceneX,\n sceneY\n }) => {\n if (!this.canvas) {\n console.error(\"Canvas not available\");\n return null;\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX,\n sceneY\n }, this.state);\n const context = this.canvas.getContext(\"2d\");\n\n if (!context) {\n console.error(\"2D context not available\");\n return null;\n } // Get pixel data directly from the given scene coordinates\n\n\n const pixelData = context.getImageData(x, y, 1, 1).data;\n const [r, g, b, a] = pixelData; // Check for transparency\n\n if (a === 0) {\n return this.state.theme === \"light\" ? \"rgba(255,255,255,1)\" : \"rgba(0,0,0,1)\";\n } // Return the color in rgba format\n\n\n return `rgba(${r}, ${g}, ${b}, ${a / 255})`;\n }; //zsviczian\n\n\n this.startLineEditor = (el, selectedPointsIndices = null) => {\n if (!el || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(el)) {\n return;\n }\n\n const editingLinearElement = new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(el, this.scene.getNonDeletedElementsMap());\n this.setState({\n selectedLinearElement: editingLinearElement,\n editingLinearElement: Object.assign(Object.assign({}, editingLinearElement), {\n selectedPointsIndices\n })\n });\n }; //zsviczian\n\n\n this.updateContainerSize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(containers => {\n containers.forEach(element => {\n // Get absolute coordinates for the bottom-right corner\n const [x1, y1, x2, y2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getResizedElementAbsoluteCoords)(element, element.width, element.height, true); // Get rotated pointer position at bottom-right corner\n\n const [pointerX, pointerY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((x1 + x2) / 2, (y1 + y2) / 2), element.angle);\n const {\n nextWidth,\n nextHeight\n } = (0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.getNextSingleWidthAndHeightFromPointer)(element, element, \"se\", pointerX, pointerY);\n (0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.resizeSingleElement)(nextWidth, nextHeight, element, element, this.scene.getElementsMapIncludingDeleted(), this.scene, \"se\", {\n shouldMaintainAspectRatio: true,\n shouldResizeFromCenter: false\n });\n });\n });\n\n this.setToast = toast => {\n this.setState({\n toast\n });\n };\n\n this.restoreFileFromShare = async () => {\n try {\n const webShareTargetCache = await caches.open(\"web-share-target\");\n const response = await webShareTargetCache.match(\"shared-file\");\n\n if (response) {\n const blob = await response.blob();\n const file = new File([blob], blob.name || \"\", {\n type: blob.type\n });\n this.loadFileToCanvas(file, null);\n await webShareTargetCache.delete(\"shared-file\");\n window.history.replaceState(null, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.APP_NAME, window.location.pathname);\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n };\n /**\r\n * adds supplied files to existing files in the appState.\r\n * NOTE if file already exists in editor state, the file data is not updated\r\n * */\n\n\n this.addFiles = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(files => {\n const {\n addedFiles\n } = this.addMissingFiles(files, undefined, true); //zsviczian\n\n this.clearImageShapeCache(addedFiles);\n this.scene.triggerUpdate();\n this.addNewImagesToImageCache();\n }); //zsviczian https://github.com/zsviczian/excalibrain/issues/9\n\n this.setMobileModeAllowed = allow => {\n const {\n width: editorWidth,\n height: editorHeight\n } = this.excalidrawContainerRef.current.getBoundingClientRect();\n this.allowMobileMode = allow;\n const prevEditorState = this.device.editor;\n let nextEditorState;\n\n if (allow) {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight)\n });\n } else {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevEditorState, {\n isMobile: false //must test this\n\n });\n }\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n this.forceUpdate();\n }\n }; //zsviczian\n\n\n this.debounceClearHighlightSearchResults = false;\n\n this.selectElements = (elements, highlightSearchResult = false) => {\n //zsviczian\n if (highlightSearchResult) {\n this.debounceClearHighlightSearchResults = true;\n setTimeout(() => {\n this.debounceClearHighlightSearchResults = false;\n }, 500);\n }\n\n this.updateScene({\n appState: Object.assign(Object.assign({}, this.state), {\n editingGroupId: null,\n selectedElementIds: elements.reduce((map, element) => {\n map[element.id] = true;\n return map;\n }, {}),\n highlightSearchResult\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER,\n forceFlushSync: true\n });\n }; //zsviczian\n\n\n this.bringToFront = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionBringToFront.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.bringForward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionBringForward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n }; //zsviczian\n\n\n this.sendToBack = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionSendToBack.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.sendBackward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionSendBackward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n };\n\n this.addMissingFiles = (files, replace = false, force = false) => {\n var _a;\n\n const nextFiles = replace ? {} : Object.assign({}, this.files);\n const addedFiles = {};\n\n const _files = Array.isArray(files) ? files : Object.values(files);\n\n for (const fileData of _files) {\n if (!force && nextFiles[fileData.id]) {\n //zsviczian\n continue;\n }\n\n addedFiles[fileData.id] = fileData;\n nextFiles[fileData.id] = fileData;\n\n if (fileData.mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n try {\n const restoredDataURL = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getDataURL_sync)((0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.normalizeSVG)((0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.dataURLToString)(fileData.dataURL)), _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg);\n\n if (fileData.dataURL !== restoredDataURL) {\n // bump version so persistence layer can update the store\n fileData.version = ((_a = fileData.version) !== null && _a !== void 0 ? _a : 1) + 1;\n fileData.dataURL = restoredDataURL;\n }\n } catch (error) {\n console.error(error);\n }\n }\n }\n\n this.files = nextFiles;\n return {\n addedFiles\n };\n };\n\n this.updateScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(sceneData => {\n var _a;\n\n const nextElements = (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncInvalidIndices)((_a = sceneData.elements) !== null && _a !== void 0 ? _a : []);\n\n if (sceneData.captureUpdate && sceneData.captureUpdate !== _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.EVENTUALLY) {\n const prevCommittedAppState = this.store.snapshot.appState;\n const prevCommittedElements = this.store.snapshot.elements;\n const nextCommittedAppState = sceneData.appState ? Object.assign({}, prevCommittedAppState, sceneData.appState) // new instance, with partial appstate applied to previously captured one, including hidden prop inside `prevCommittedAppState`\n : prevCommittedAppState;\n const nextCommittedElements = sceneData.elements ? this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(), // Only used to detect uncomitted local elements\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(nextElements)) : prevCommittedElements; // WARN: store action always performs deep clone of changed elements, for ephemeral remote updates (i.e. remote dragging, resizing, drawing) we might consider doing something smarter\n // do NOT schedule store actions (execute after re-render), as it might cause unexpected concurrency issues if not handled well\n\n if (sceneData.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY) {\n this.store.captureIncrement(nextCommittedElements, nextCommittedAppState);\n } else if (sceneData.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER) {\n this.store.updateSnapshot(nextCommittedElements, nextCommittedAppState);\n }\n } //zsviczian forceFlushSync is set to true in ExcalidrawView.updateScene.\n //without this e.g. text search did not select the elements\n\n\n if (sceneData.forceFlushSync === true) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (sceneData.appState) {\n this.setState(sceneData.appState);\n }\n });\n } else if (sceneData.appState) {\n this.setState(sceneData.appState);\n }\n\n if (sceneData.elements) {\n this.scene.replaceAllElements(nextElements);\n }\n\n if (sceneData.collaborators) {\n this.setState({\n collaborators: sceneData.collaborators\n });\n }\n });\n\n this.mutateElement = (element, updates, informMutation = true) => {\n return this.scene.mutateElement(element, updates, {\n informMutation,\n isDragging: false\n });\n };\n\n this.triggerRender = (\n /** force always re-renders canvas even if no change */\n force) => {\n if (force === true) {\n this.scene.triggerUpdate();\n } else {\n this.setState({});\n }\n };\n /**\r\n * @returns whether the menu was toggled on or off\r\n */\n\n\n this.toggleSidebar = ({\n name,\n tab,\n force\n }) => {\n var _a, _b;\n\n let nextName;\n\n if (force === undefined) {\n nextName = ((_a = this.state.openSidebar) === null || _a === void 0 ? void 0 : _a.name) === name && ((_b = this.state.openSidebar) === null || _b === void 0 ? void 0 : _b.tab) === tab ? null : name;\n } else {\n nextName = force ? name : null;\n }\n\n const nextState = nextName ? {\n name: nextName\n } : null;\n\n if (nextState && tab) {\n nextState.tab = tab;\n }\n\n this.setState({\n openSidebar: nextState\n });\n return !!nextName;\n };\n\n this.updateCurrentCursorPosition = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n this.lastViewportPosition.x = event.clientX;\n this.lastViewportPosition.y = event.clientY;\n });\n\n this.getEditorUIOffsets = () => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n const toolbarBottom = ((_e = (_d = (_c = (_b = (_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.querySelector(\".App-toolbar\")) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) === null || _d === void 0 ? void 0 : _d.bottom) !== null && _e !== void 0 ? _e : 0) - this.state.offsetTop;\n const sidebarRect = (_h = (_g = (_f = this.excalidrawContainerRef) === null || _f === void 0 ? void 0 : _f.current) === null || _g === void 0 ? void 0 : _g.querySelector(\".sidebar\")) === null || _h === void 0 ? void 0 : _h.getBoundingClientRect();\n const propertiesPanelRect = (_l = (_k = (_j = this.excalidrawContainerRef) === null || _j === void 0 ? void 0 : _j.current) === null || _k === void 0 ? void 0 : _k.querySelector(\".App-menu__left\")) === null || _l === void 0 ? void 0 : _l.getBoundingClientRect();\n const PADDING = 16;\n\n const adjustRectValueForOffset = ( //zsviczian https://github.com/excalidraw/excalidraw/issues/8561\n value, fallback) => (value !== null && value !== void 0 ? value : fallback + this.state.offsetLeft) - this.state.offsetLeft;\n\n return (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.getLanguage)().rtl ? {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset( //zsivczian\n propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.left, this.state.width), 0) + PADDING,\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.right, 0), 0) + PADDING\n } : {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.left, this.state.width) + //zsivczian\n PADDING, 0),\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.right, 0), 0) + PADDING\n };\n }; // Input handling\n\n\n this.onKeyDown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a, _b;\n\n if (this.state.activeTool.type === \"selection\" && this.state.resizingElement && (event.shiftKey || event.altKey)) {\n event.stopPropagation(); //zsviczian shift fires repeatedly causing slowdown when resizing sticky notes\n\n return;\n } // normalize `event.key` when CapsLock is pressed #2372\n\n\n if (\"Proxy\" in window && (!event.shiftKey && /^[A-Z]$/.test(event.key) || event.shiftKey && /^[a-z]$/.test(event.key))) {\n event = new Proxy(event, {\n get(ev, prop) {\n const value = ev[prop];\n\n if (typeof value === \"function\") {\n // fix for Proxies hijacking `this`\n return value.bind(ev);\n }\n\n return prop === \"key\" ? // CapsLock inverts capitalization based on ShiftKey, so invert\n // it back\n event.shiftKey ? ev.key.toUpperCase() : ev.key.toLowerCase() : value;\n }\n\n });\n }\n\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isInputLike)(event.target)) {\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) && this.state.croppingElementId) {\n this.finishImageCropping();\n return;\n }\n\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(selectedElements[0]) && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE && this.flowChartCreator.isCreatingChart) {\n this.flowChartCreator.clear();\n this.triggerRender(true);\n return;\n }\n\n const arrowKeyPressed = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key);\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && arrowKeyPressed && !event.shiftKey) {\n event.preventDefault();\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFlowchartNodeElement)(selectedElements[0])) {\n this.flowChartCreator.createNodes(selectedElements[0], this.state, (0,_excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.getLinkDirectionFromKey)(event.key), this.scene);\n }\n\n if (((_a = this.flowChartCreator.pendingNodes) === null || _a === void 0 ? void 0 : _a.length) && !(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementCompletelyInViewport)(this.flowChartCreator.pendingNodes, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(this.flowChartCreator.pendingNodes, {\n animate: true,\n duration: 300,\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n\n return;\n }\n\n if (event.altKey) {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && arrowKeyPressed) {\n event.preventDefault();\n const nextId = this.flowChartNavigator.exploreByDirection(selectedElements[0], this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.getLinkDirectionFromKey)(event.key));\n\n if (nextId) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [nextId]: true\n }, prevState)\n }));\n const nextNode = this.scene.getNonDeletedElementsMap().get(nextId);\n\n if (nextNode && !(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementCompletelyInViewport)([nextNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(nextNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n return;\n }\n }\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.P && !event.shiftKey && !event.altKey) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"commandPalette.shortcutHint\", {\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_51__.getShortcutFromShortcutName)(\"commandPalette\")\n })\n });\n event.preventDefault();\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.V) {\n IS_PLAIN_PASTE = event.shiftKey;\n clearTimeout(IS_PLAIN_PASTE_TIMER); // reset (100ms to be safe that we it runs after the ensuing\n // paste event). Though, technically unnecessary to reset since we\n // (re)set the flag before each paste event.\n\n IS_PLAIN_PASTE_TIMER = window.setTimeout(() => {\n IS_PLAIN_PASTE = false;\n }, 100);\n } // prevent browser zoom in input fields\n\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target)) {\n if (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CODES.EQUAL) {\n event.preventDefault();\n return;\n }\n } // bail if\n\n\n if ( // inside an input\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target) && // unless pressing escape (finalize action)\n event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE || // or unless using arrows (to move between buttons)\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isInputLike)(event.target)) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.QUESTION_MARK) {\n this.setState({\n openDialog: {\n name: \"help\"\n }\n });\n return;\n } else if (event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.E && event.shiftKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n this.setState({\n openDialog: {\n name: \"imageExport\"\n }\n });\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.PAGE_UP || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.PAGE_DOWN) {\n let offset = (event.shiftKey ? this.state.width : this.state.height) / this.state.zoom.value;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.PAGE_DOWN) {\n offset = -offset;\n }\n\n if (event.shiftKey) {\n this.translateCanvas(state => ({\n scrollX: state.scrollX + offset\n }));\n } else {\n this.translateCanvas(state => ({\n scrollY: state.scrollY + offset\n }));\n }\n }\n\n if (((_b = this.state.openDialog) === null || _b === void 0 ? void 0 : _b.name) === \"elementLinkSelector\") {\n return;\n }\n\n if (this.actionManager.handleKeyDown(event)) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isLaserPointerActive)(this.state)) {\n this.setActiveTool({\n type: \"selection\"\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (this.state.viewModeEnabled) {\n //revert to hand in case a key is pressed (K is handled above)\n if (event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.K) {\n this.setActiveTool({\n type: \"selection\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: false\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key)) {\n let selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n const elbowArrow = selectedElements.find(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow);\n const arrowIdsToRemove = new Set();\n selectedElements.filter(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow).filter(arrow => {\n const startElementNotInSelection = arrow.startBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.startBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n const endElementNotInSelection = arrow.endBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.endBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n return startElementNotInSelection || endElementNotInSelection;\n }).forEach(arrow => arrowIdsToRemove.add(arrow.id));\n selectedElements = selectedElements.filter(el => !arrowIdsToRemove.has(el.id));\n const step = this.getEffectiveGridSize() && (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_TRANSLATE_AMOUNT : this.getEffectiveGridSize()) || (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_SHIFT_TRANSLATE_AMOUNT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_TRANSLATE_AMOUNT);\n let offsetX = 0;\n let offsetY = 0;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_LEFT) {\n offsetX = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_RIGHT) {\n offsetX = step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_UP) {\n offsetY = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_DOWN) {\n offsetY = step;\n }\n\n selectedElements.forEach(element => {\n this.scene.mutateElement(element, {\n x: element.x + offsetX,\n y: element.y + offsetY\n }, {\n informMutation: false,\n isDragging: false\n });\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.updateBoundElements)(element, this.scene, {\n simultaneouslyUpdated: selectedElements\n });\n });\n this.setState({\n suggestedBindings: (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getSuggestedBindingsForArrows)(selectedElements.filter(element => element.id !== (elbowArrow === null || elbowArrow === void 0 ? void 0 : elbowArrow.id) || step !== 0), this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n this.scene.triggerUpdate();\n event.preventDefault();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n const selectedElement = selectedElements[0];\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(selectedElement)) {\n if (!this.state.editingLinearElement || this.state.editingLinearElement.elementId !== selectedElements[0].id) {\n this.store.shouldCaptureIncrement();\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElement)) {\n this.setState({\n editingLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(selectedElement, this.scene.getNonDeletedElementsMap())\n });\n }\n }\n }\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElement) || (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.isValidTextContainer)(selectedElement)) {\n let container;\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElement)) {\n container = selectedElement;\n }\n\n const midPoint = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerCenter)(selectedElement, this.state, this.scene.getNonDeletedElementsMap());\n const sceneX = midPoint.x;\n const sceneY = midPoint.y;\n this.startTextEditing({\n sceneX,\n sceneY,\n container\n });\n event.preventDefault();\n return;\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(selectedElement)) {\n this.setState({\n editingFrame: selectedElement.id\n });\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(selectedElement)) {\n //zsviczian\n this.setState({\n activeEmbeddable: {\n element: selectedElement,\n state: \"active\"\n }\n });\n }\n }\n } else if (!event.ctrlKey && !event.altKey && !event.metaKey && !this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged) {\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_99__.findShapeByKey)(event.key);\n\n if (shape) {\n if (this.state.activeTool.type !== shape) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"toolbar\", shape, `keyboard (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n if (shape === \"arrow\" && this.state.activeTool.type === \"arrow\") {\n this.setState(prevState => ({\n currentItemArrowType: prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.sharp ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.round : prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.round ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.elbow : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.sharp\n }));\n }\n\n this.setActiveTool({\n type: shape\n });\n event.stopPropagation();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.Q) {\n this.toggleLock(\"keyboard\");\n event.stopPropagation();\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.SPACE && gesture.pointers.size === 0) {\n isHoldingSpace = true;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n event.preventDefault();\n }\n\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.G || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.S) && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.G && ((0,_scene__WEBPACK_IMPORTED_MODULE_62__.hasBackground)(this.state.activeTool.type) || selectedElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_62__.hasBackground)(element.type)))) {\n this.setState({\n openPopup: \"elementBackground\"\n });\n event.stopPropagation();\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.S) {\n this.setState({\n openPopup: \"elementStroke\"\n });\n event.stopPropagation();\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.F) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (this.state.activeTool.type === \"text\" || selectedElements.find(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element) || (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(element, this.scene.getNonDeletedElementsMap()))) {\n event.preventDefault();\n this.setState({\n openPopup: \"fontFamily\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if (this.state.activeTool.type === \"laser\") {\n this.setActiveTool({\n type: \"selection\"\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.BACKSPACE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.DELETE)) {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.set(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_84__.activeConfirmDialogAtom, \"clearCanvas\");\n } // eye dropper\n // -----------------------------------------------------------------------\n\n\n const lowerCased = event.key.toLocaleLowerCase();\n const isPickingStroke = lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.S && event.shiftKey;\n const isPickingBackground = event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.I || lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.G && event.shiftKey;\n\n if (isPickingStroke || isPickingBackground) {\n this.openEyeDropper({\n type: isPickingStroke ? \"stroke\" : \"background\"\n });\n } // -----------------------------------------------------------------------\n\n });\n this.onKeyUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.SPACE) {\n if (this.state.viewModeEnabled || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else if (this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n isHoldingSpace = false;\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && !this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: true\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.bindOrUnbindLinearElements)(this.scene.getSelectedElements(this.state).filter(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement), (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state), (_c = (_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) !== null && _c !== void 0 ? _c : [], this.scene, this.state.zoom);\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (!event.altKey) {\n if (this.flowChartNavigator.isExploring) {\n this.flowChartNavigator.clear();\n this.syncActionResult({\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if (this.flowChartCreator.isCreatingChart) {\n if ((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) {\n this.scene.insertElements(this.flowChartCreator.pendingNodes);\n }\n\n const firstNode = (_e = this.flowChartCreator.pendingNodes) === null || _e === void 0 ? void 0 : _e[0];\n\n if (firstNode) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [firstNode.id]: true\n }, prevState)\n }));\n\n if (!(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementCompletelyInViewport)([firstNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(firstNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n this.flowChartCreator.clear();\n this.syncActionResult({\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n }); // We purposely widen the `tool` type so this helper can be called with\n // any tool without having to type check it\n\n this.isToolSupported = tool => {\n var _a;\n\n return ((_a = this.props.UIOptions.tools) === null || _a === void 0 ? void 0 : _a[tool]) !== false;\n };\n\n this.setActiveTool = (tool, keepSelection = false) => {\n var _a;\n\n if (!this.isToolSupported(tool.type)) {\n console.warn(`\"${tool.type}\" tool is disabled via \"UIOptions.canvasActions.tools.${tool.type}\"`);\n return;\n }\n\n const nextActiveTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, tool);\n\n if (nextActiveTool.type === \"hand\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else if (!isHoldingSpace) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, Object.assign(Object.assign({}, this.state), {\n activeTool: nextActiveTool\n }));\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isToolIcon)(document.activeElement)) {\n this.focusContainer();\n }\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElementType)(nextActiveTool.type)) {\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (nextActiveTool.type === \"image\") {\n this.onImageAction({\n insertOnCanvasDirectly: (_a = tool.type === \"image\" && tool.insertOnCanvasDirectly) !== null && _a !== void 0 ? _a : false\n });\n }\n\n setTimeout(() => {\n this.setState(prevState => {\n const commonResets = {\n snapLines: prevState.snapLines.length ? [] : prevState.snapLines,\n originSnapOffset: null,\n activeEmbeddable: null\n };\n\n if (nextActiveTool.type === \"freedraw\") {\n this.store.shouldCaptureIncrement();\n }\n\n if (nextActiveTool.type === \"lasso\") {\n return Object.assign(Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), keepSelection ? {} : {\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n selectedGroupIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n } else if (nextActiveTool.type !== \"selection\") {\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool,\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextActiveTool.type === \"mermaid\" //zsviczian\n ? this.state.selectedElementIds : {}, prevState),\n selectedGroupIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n }\n\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), commonResets);\n });\n }); //zsviczian added timeout because button won't select otherwise\n };\n\n this.setOpenDialog = dialogType => {\n this.setState({\n openDialog: dialogType\n });\n };\n\n this.setCursor = cursor => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, cursor);\n };\n\n this.resetCursor = () => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n };\n /**\r\n * returns whether user is making a gesture with >= 2 fingers (points)\r\n * on o touch screen (not on a trackpad). Currently only relates to Darwin\r\n * (iOS/iPadOS,MacOS), but may work on other devices in the future if\r\n * GestureEvent is standardized.\r\n */\n\n\n this.isTouchScreenMultiTouchGesture = () => {\n // we don't want to deselect when using trackpad, and multi-point gestures\n // only work on touch screens, so checking for >= pointers means we're on a\n // touchscreen\n return gesture.pointers.size >= 2;\n };\n\n this.getName = () => {\n return this.state.name || this.props.name || `${(0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getDateTime)()}`;\n }; // fires only on Safari\n\n\n this.onGestureStart = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n event.preventDefault(); // we only want to deselect on touch screens because user may have selected\n // elements by mistake while zooming\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n\n gesture.initialScale = this.state.zoom.value;\n }); // fires only on Safari\n\n this.onGestureChange = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n event.preventDefault(); // onGestureChange only has zoom factor but not the center.\n // If we're on iPad or iPhone, then we recognize multi-touch and will\n // zoom in at the right location in the touchmove handler\n // (handleCanvasPointerMove).\n //\n // On Macbook trackpad, we don't have those events so will zoom in at the\n // current location instead.\n //\n // As such, bail from this handler on touch devices.\n\n if (this.isTouchScreenMultiTouchGesture()) {\n return;\n }\n\n const initialScale = gesture.initialScale;\n\n if (initialScale) {\n this.setState(state => Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(initialScale * event.scale)\n }, state)));\n }\n }); // fires only on Safari\n\n this.onGestureEnd = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n event.preventDefault(); // reselect elements only on touch screens (see onGestureStart)\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n }\n\n gesture.initialScale = null;\n });\n\n this.startTextEditing = ({\n sceneX,\n sceneY,\n insertAtParentCenter = true,\n container,\n autoEdit = true\n }) => {\n var _a;\n\n let shouldBindToContainer = false;\n let parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n\n if (container && parentCenterPosition) {\n const boundTextElementToContainer = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(container, this.scene.getNonDeletedElementsMap());\n\n if (!boundTextElementToContainer) {\n shouldBindToContainer = true;\n }\n }\n\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n const fontFamily = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.fontFamily) || this.state.currentItemFontFamily;\n const lineHeight = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.lineHeight) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getLineHeight)(fontFamily);\n const fontSize = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_102__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value); //zsviczian\n\n if (!existingTextElement && shouldBindToContainer && container && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isArrowElement)(container)) {\n const fontString = {\n fontSize,\n fontFamily\n };\n const minWidth = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getApproxMinLineWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getFontString)(fontString), lineHeight);\n const minHeight = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getApproxMinLineHeight)(fontSize, lineHeight);\n const newHeight = Math.max(container.height, minHeight);\n const newWidth = Math.max(container.width, minWidth);\n this.scene.mutateElement(container, {\n height: newHeight,\n width: newWidth\n });\n sceneX = container.x + newWidth / 2;\n sceneY = container.y + newHeight / 2;\n\n if (parentCenterPosition) {\n parentCenterPosition = this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n }\n }\n\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: sceneX,\n y: sceneY\n });\n const element = existingTextElement || (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newTextElement)({\n x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX,\n y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text: \"\",\n rawText: \"\",\n fontSize,\n fontFamily,\n textAlign: parentCenterPosition ? \"center\" : this.state.currentItemTextAlign,\n verticalAlign: parentCenterPosition ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.VERTICAL_ALIGN.MIDDLE : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_VERTICAL_ALIGN,\n containerId: shouldBindToContainer ? container === null || container === void 0 ? void 0 : container.id : undefined,\n groupIds: (_a = container === null || container === void 0 ? void 0 : container.groupIds) !== null && _a !== void 0 ? _a : [],\n lineHeight,\n angle: container ? (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isArrowElement)(container) ? 0 : container.angle : 0,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n\n if (!existingTextElement && shouldBindToContainer && container) {\n this.scene.mutateElement(container, {\n boundElements: (container.boundElements || []).concat({\n type: \"text\",\n id: element.id\n })\n });\n }\n\n this.setState({\n editingTextElement: element\n });\n\n if (!existingTextElement) {\n if (container && shouldBindToContainer) {\n const containerIndex = this.scene.getElementIndex(container.id);\n this.scene.insertElementAtIndex(element, containerIndex + 1);\n } else {\n this.scene.insertElement(element);\n }\n }\n\n if (autoEdit || existingTextElement || container) {\n this.handleTextWysiwyg(element, {\n isExistingElement: !!existingTextElement\n });\n } else {\n this.setState({\n newElement: element,\n multiElement: null\n });\n }\n };\n\n this.debounceDoubleClickTimestamp = 0; //zsviczian\n\n this.startImageCropping = image => {\n this.store.shouldCaptureIncrement();\n this.setState({\n croppingElementId: image.id\n });\n };\n\n this.finishImageCropping = () => {\n if (this.state.croppingElementId) {\n this.store.shouldCaptureIncrement();\n this.setState({\n croppingElementId: null\n });\n }\n };\n\n this.handleCanvasDoubleClick = event => {\n var _a; // case: double-clicking with arrow/line tool selected would both create\n // text and enter multiElement mode\n\n\n if (this.state.multiElement) {\n return;\n }\n\n if ( //zsviczian - double click eraser\n this.state.penMode && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.allowDoubleTapEraser)() && ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.pointerType) === \"touch\" && this.state.activeTool.type !== \"selection\") {\n const now = Date.now();\n\n if (now - this.debounceDoubleClickTimestamp < 200) {\n //handleCanvasDoubleClick click fires twice in case of touch.\n //Once from the onTouchStart event handler, once from the double click event handler\n return;\n }\n\n this.debounceDoubleClickTimestamp = now;\n this.updateScene(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.actionToggleEraserTool.perform([], this.state));\n return;\n } // zsviczian - end\n // we should only be able to double click when mode is selection\n\n\n if (this.state.activeTool.type !== \"selection\") {\n return;\n }\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n let {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(selectedElements[0])) {\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && (!this.state.editingLinearElement || this.state.editingLinearElement.elementId !== selectedElements[0].id) && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0])) {\n this.store.shouldCaptureIncrement();\n this.setState({\n editingLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(selectedElements[0], this.scene.getNonDeletedElementsMap())\n });\n return;\n } else if (this.state.selectedLinearElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0])) {\n const hitCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(this.state.selectedLinearElement, {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const midPoint = hitCoords ? _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, hitCoords, this.scene.getNonDeletedElementsMap()) : -1;\n\n if (midPoint && midPoint > -1) {\n this.store.shouldCaptureIncrement();\n _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.deleteFixedSegment(selectedElements[0], this.scene, midPoint);\n const nextCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const nextIndex = nextCoords ? _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : null;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: Object.assign(Object.assign({}, this.state.selectedLinearElement.pointerDownState), {\n segmentMidpoint: {\n index: nextIndex,\n value: hitCoords,\n added: false\n }\n }),\n segmentMidPointHoveredCoords: nextCoords\n })\n });\n return;\n }\n }\n }\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(selectedElements[0])) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n const selectedGroupIds = (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getSelectedGroupIds)(this.state);\n\n if (selectedGroupIds.length > 0) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n const selectedGroupId = hitElement && (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getSelectedGroupIdForElement)(hitElement, this.state.selectedGroupIds);\n\n if (selectedGroupId) {\n this.store.shouldCaptureIncrement();\n this.setState(prevState => Object.assign(Object.assign({}, prevState), (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: selectedGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)));\n return;\n }\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && !this.state.viewModeEnabled) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement)) {\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"active\"\n }\n });\n return;\n }\n\n const container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if (container) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.hasBoundTextElement)(container) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isTransparent)(container.backgroundColor) || (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x: sceneX,\n y: sceneY,\n element: container,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(container, this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold()\n })) {\n const midPoint = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerCenter)(container, this.state, this.scene.getNonDeletedElementsMap());\n sceneX = midPoint.x;\n sceneY = midPoint.y;\n }\n } //zsviczian Disable double click text create, but allow double click edit\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.disableDoubleClickTextEditing)()) {\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n if (!existingTextElement) {\n return;\n }\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container\n });\n }\n };\n\n this.getElementLinkAtPosition = (scenePointer, hitElement) => {\n const elements = this.scene.getNonDeletedElements();\n let hitElementIndex = -1;\n\n for (let index = elements.length - 1; index >= 0; index--) {\n const element = elements[index];\n\n if (hitElement && element.id === hitElement.id) {\n hitElementIndex = index;\n }\n\n if (element.link && index >= hitElementIndex && (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_96__.isPointHittingLink)(element, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.device.editor.isMobile)) {\n return element;\n }\n }\n };\n\n this.redirectToLink = (event, isTouchScreen) => {\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerDownEvent.clientX, this.lastPointerDownEvent.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerUpEvent.clientX, this.lastPointerUpEvent.clientY));\n\n if (!this.hitLinkElement || draggedDistance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD) {\n return;\n }\n\n const lastPointerDownCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(this.lastPointerDownEvent, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const lastPointerDownHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_96__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerDownCoords.x, lastPointerDownCoords.y), this.device.editor.isMobile);\n const lastPointerUpCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(this.lastPointerUpEvent, this.state);\n const lastPointerUpHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_96__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerUpCoords.x, lastPointerUpCoords.y), this.device.editor.isMobile);\n\n if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.hideHyperlinkToolip)();\n let url = this.hitLinkElement.link;\n\n if (url) {\n url = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeLink)(url);\n let customEvent;\n\n if (this.props.onLinkOpen) {\n customEvent = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.wrapEvent)(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.EXCALIDRAW_LINK, event.nativeEvent);\n this.props.onLinkOpen(Object.assign(Object.assign({}, this.hitLinkElement), {\n link: url\n }), customEvent);\n }\n\n if (!(customEvent === null || customEvent === void 0 ? void 0 : customEvent.defaultPrevented)) {\n const target = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isLocalLink)(url) ? \"_self\" : \"_blank\";\n const newWindow = window.open(undefined, target); // https://mathiasbynens.github.io/rel-noopener/\n\n if (newWindow) {\n newWindow.opener = null;\n newWindow.location = url;\n }\n }\n }\n }\n };\n\n this.getTopLayerFrameAtSceneCoords = sceneCoords => {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const frames = this.scene.getNonDeletedFramesLikes().filter(frame => (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isCursorInFrame)(sceneCoords, frame, elementsMap));\n return frames.length ? frames[frames.length - 1] : null;\n };\n\n this.handleCanvasPointerMove = event => {\n var _a, _b, _c, _d, _e, _f, _g;\n\n this.savePointer(event.clientX, event.clientY, this.state.cursorButton);\n this.lastPointerMoveEvent = event.nativeEvent;\n\n if (gesture.pointers.has(event.pointerId)) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n }\n\n const initialScale = gesture.initialScale;\n\n if (gesture.pointers.size === 2 && gesture.lastCenter && initialScale && gesture.initialDistance) {\n const center = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getCenter)(gesture.pointers);\n const deltaX = center.x - gesture.lastCenter.x;\n const deltaY = center.y - gesture.lastCenter.y;\n gesture.lastCenter = center;\n const distance = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getDistance)(Array.from(gesture.pointers.values()));\n const scaleFactor = !this.state.allowPinchZoom && //zsviczian\n this.state.activeTool.type === \"freedraw\" && this.state.penMode ? 1 : distance / gesture.initialDistance;\n const nextZoom = scaleFactor ? (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(initialScale * scaleFactor) : this.state.zoom.value;\n this.setState(state => {\n const zoomState = (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: center.x,\n viewportY: center.y,\n nextZoom\n }, state);\n this.translateCanvas({\n zoom: zoomState.zoom,\n // 2x multiplier is just a magic number that makes this work correctly\n // on touchscreen devices (note: if we get report that panning is slower/faster\n // than actual movement, consider swapping with devicePixelRatio)\n scrollX: zoomState.scrollX + 2 * (deltaX / nextZoom),\n scrollY: zoomState.scrollY + 2 * (deltaY / nextZoom),\n shouldCacheIgnoreZoom: true\n });\n });\n this.resetShouldCacheIgnoreZoomDebounced();\n } else {\n gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null;\n }\n\n if (isHoldingSpace || isPanning || isDraggingScrollBar || (0,_appState__WEBPACK_IMPORTED_MODULE_54__.isHandToolActive)(this.state)) {\n return;\n }\n\n const isPointerOverScrollBars = (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_80__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop);\n const isOverScrollBar = isPointerOverScrollBars.isOverEither;\n const isPenFreedraw = this.state.activeTool.type === \"freedraw\" && event.pointerType === \"pen\"; //zsviczian\n\n if (!this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged && !this.state.multiElement) {\n if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n } else if (isPenFreedraw && this.interactiveCanvas && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.hideFreedrawPenmodeCursor)()) {\n //zsviczian https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1659\n this.interactiveCanvas.style.cursor = \"none\";\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n\n if (!this.state.newElement && (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isActiveToolNonLinearSnappable)(this.state.activeTool.type)) {\n const {\n originOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.getSnapLinesAtPointer)(this.scene.getNonDeletedElements(), this, {\n x: scenePointerX,\n y: scenePointerY\n }, event, this.scene.getNonDeletedElementsMap());\n this.setState(prevState => {\n const nextSnapLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.snapLines, snapLines);\n const nextOriginOffset = prevState.originSnapOffset ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.originSnapOffset, originOffset) : originOffset;\n\n if (prevState.snapLines === nextSnapLines && prevState.originSnapOffset === nextOriginOffset) {\n return null;\n }\n\n return {\n snapLines: nextSnapLines,\n originSnapOffset: nextOriginOffset\n };\n });\n } else if (!this.state.newElement && !this.state.selectedElementsAreBeingDragged && !this.state.selectionElement) {\n this.setState(prevState => {\n if (prevState.snapLines.length) {\n return {\n snapLines: []\n };\n }\n\n return null;\n });\n }\n\n if (this.state.editingLinearElement && !this.state.editingLinearElement.isDragging) {\n const editingLinearElement = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerMove(event, scenePointerX, scenePointerY, this);\n\n if (editingLinearElement && editingLinearElement !== this.state.editingLinearElement) {\n // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n editingLinearElement\n });\n });\n }\n\n if ((editingLinearElement === null || editingLinearElement === void 0 ? void 0 : editingLinearElement.lastUncommittedPoint) != null) {\n this.maybeSuggestBindingAtCursor(scenePointer, editingLinearElement.elbowed);\n } else {\n // causes stack overflow if not sync\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n suggestedBindings: []\n });\n });\n }\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElementType)(this.state.activeTool.type)) {\n // Hovering with a selected tool or creating new linear element via click\n // and point\n const {\n newElement\n } = this.state;\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(newElement, false)) {\n this.maybeSuggestBindingsForLinearElementAtCoords(newElement, [scenePointer], this.state.startBoundElement);\n } else {\n this.maybeSuggestBindingAtCursor(scenePointer, false);\n }\n }\n\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state;\n const {\n x: rx,\n y: ry\n } = multiElement;\n const {\n points,\n lastCommittedPoint\n } = multiElement;\n const lastPoint = points[points.length - 1];\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n\n if (lastPoint === lastCommittedPoint) {\n // if we haven't yet created a temp point and we're beyond commit-zone\n // threshold, add a point\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastPoint) >= _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.LINE_CONFIRM_THRESHOLD) {\n this.scene.mutateElement(multiElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER); // in this branch, we're inside the commit zone, and no uncommitted\n // point exists. Thus do nothing (don't add/remove points).\n }\n } else if (points.length > 2 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.LINE_CONFIRM_THRESHOLD) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n this.scene.mutateElement(multiElement, {\n points: points.slice(0, -1)\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(scenePointerX, scenePointerY, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(multiElement) ? null : this.getEffectiveGridSize());\n const [lastCommittedX, lastCommittedY] = (_a = multiElement === null || multiElement === void 0 ? void 0 : multiElement.lastCommittedPoint) !== null && _a !== void 0 ? _a : [0, 0];\n let dxFromLastCommitted = gridX - rx - lastCommittedX;\n let dyFromLastCommitted = gridY - ry - lastCommittedY;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldRotateWithDiscreteAngle)(event)) {\n ({\n width: dxFromLastCommitted,\n height: dyFromLastCommitted\n } = (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.getLockedLinearCursorAlignSize)( // actual coordinate of the last committed point\n lastCommittedX + rx, lastCommittedY + ry, // cursor-grid coordinate\n gridX, gridY));\n }\n\n if ((0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.isPathALoop)(points, this.state.zoom.value)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n } // update last uncommitted point\n\n\n this.scene.mutateElement(multiElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastCommittedX + dxFromLastCommitted, lastCommittedY + dyFromLastCommitted)]\n }, {\n isDragging: true,\n informMutation: false\n }); // in this path, we're mutating multiElement to reflect\n // how it will be after adding pointer position as the next point\n // trigger update here so that new element canvas renders again to reflect this\n\n this.triggerRender(false);\n }\n\n return;\n }\n\n const hasDeselectedButton = Boolean(event.buttons);\n\n if (hasDeselectedButton || this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"text\" && this.state.activeTool.type !== \"eraser\") {\n return;\n }\n\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !isOverScrollBar && !this.state.editingLinearElement) {\n // for linear elements, we'd like to prioritize point dragging over edge resizing\n // therefore, we update and check hovered point index first\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n\n if ((!this.state.selectedLinearElement || this.state.selectedLinearElement.hoverPointIndex === -1) && ((_b = this.state.openDialog) === null || _b === void 0 ? void 0 : _b.name) !== \"elementLinkSelector\" && !(selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0]))) {\n const elementWithTransformHandleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getElementWithTransformHandleType)(elements, this.state, scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType && elementWithTransformHandleType.transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getCursorForResizingElement)(elementWithTransformHandleType));\n return;\n }\n }\n } else if (selectedElements.length > 1 && !isOverScrollBar && ((_c = this.state.openDialog) === null || _c === void 0 ? void 0 : _c.name) !== \"elementLinkSelector\") {\n const transformHandleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getTransformHandleTypeFromCoords)((0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements), scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.device);\n\n if (transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getCursorForResizingElement)({\n transformHandleType\n }));\n return;\n }\n }\n\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n return;\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.showHyperlinkTooltip)(this.hitLinkElement, this.state, this.scene.getNonDeletedElementsMap());\n\n if (this.props.onLinkHover) {\n this.props.onLinkHover(this.hitLinkElement, event);\n } //zsviczian\n\n } else {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.hideHyperlinkToolip)();\n\n if (hitElement && (hitElement.link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(hitElement)) && this.state.selectedElementIds[hitElement.id] && !this.state.contextMenu && !this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: \"info\"\n });\n } else if (this.state.activeTool.type === \"text\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(hitElement) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.TEXT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.CROSSHAIR);\n } else if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else if (((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n } else if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n } else if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n } else if ( // if using cmd/ctrl, we're not dragging\n !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) && !(hitElement === null || hitElement === void 0 ? void 0 : hitElement.locked)) {\n if (hitElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointerX, scenePointerY)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"hover\"\n }\n });\n } else if (!hitElement || // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(hitElement) || !(hitElement.startBinding || hitElement.endBinding)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE);\n\n if (((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.state) === \"hover\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n }\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n }\n }\n\n if (((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\" && hitElement) {\n this.setState(prevState => {\n return {\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.hoveredElementIds, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this).selectedElementIds)\n };\n });\n } else if (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\" && !hitElement) {\n this.setState(prevState => ({\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.hoveredElementIds, {})\n }));\n }\n };\n\n this.handleEraser = (event, scenePointer) => {\n const elementsToErase = this.eraserTrail.addPointToPath(scenePointer.x, scenePointer.y, event.altKey);\n this.elementsPendingErasure = new Set(elementsToErase);\n this.triggerRender();\n }; // set touch moving for mobile context menu\n\n\n this.handleTouchMove = event => {\n this.resetContextMenuTimer(); //zsviczian\n };\n\n this.handleCanvasPointerDown = event => {\n var _a, _b, _c;\n\n this.focusContainer(); //zsviczian\n\n const target = event.target; // capture subsequent pointer events to the canvas\n // this makes other elements non-interactive until pointer up\n\n if (target.setPointerCapture) {\n target.setPointerCapture(event.pointerId);\n }\n\n this.maybeCleanupAfterMissingPointerUp(event.nativeEvent);\n this.maybeUnfollowRemoteUser();\n\n if (this.state.searchMatches) {\n this.setState(state => ({\n searchMatches: state.searchMatches.map(searchMatch => Object.assign(Object.assign({}, searchMatch), {\n focus: false\n }))\n }));\n _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.set(_SearchMenu__WEBPACK_IMPORTED_MODULE_92__.searchItemInFocusAtom, null);\n } // since contextMenu options are potentially evaluated on each render,\n // and an contextMenu action may depend on selection state, we must\n // close the contextMenu before we update the selection on pointerDown\n // (e.g. resetting selection)\n\n\n if (this.state.contextMenu) {\n this.setState({\n contextMenu: null\n });\n }\n\n if (this.state.snapLines) {\n this.setAppState({\n snapLines: []\n });\n }\n\n this.updateGestureOnPointerDown(event); // if dragging element is freedraw and another pointerdown event occurs\n // a second finger is on the screen\n // discard the freedraw element if it is very short because it is likely\n // just a spike, otherwise finalize the freedraw element when the second\n // finger is lifted\n\n if (event.pointerType === \"touch\" && this.state.newElement && this.state.newElement.type === \"freedraw\") {\n const element = this.state.newElement;\n this.updateScene(Object.assign(Object.assign({}, element.points.length < 10 ? {\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== element.id)\n } : {}), {\n appState: {\n newElement: null,\n editingTextElement: null,\n startBoundElement: null,\n suggestedBindings: [],\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.keys(this.state.selectedElementIds).filter(key => key !== element.id).reduce((obj, key) => {\n obj[key] = this.state.selectedElementIds[key];\n return obj;\n }, {}), this.state)\n },\n captureUpdate: ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\" ? _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.EVENTUALLY : _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n }));\n return;\n } // remove any active selection when we start to interact with canvas\n // (mainly, we care about removing selection outside the component which\n // would prevent our copy handling otherwise)\n\n\n const selection = document.getSelection();\n\n if (selection === null || selection === void 0 ? void 0 : selection.anchorNode) {\n selection.removeAllRanges();\n }\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(event); //fires only once, if pen is detected, penMode is enabled\n //the user can disable this by toggling the penMode button\n\n if (!this.state.penDetected && event.pointerType === \"pen\") {\n this.setState(prevState => {\n return {\n penMode: true,\n penDetected: true\n };\n });\n }\n\n if (!this.device.isTouchScreen && [\"pen\", \"touch\"].includes(event.pointerType)) {\n this.device = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(this.device, {\n isTouchScreen: true\n });\n }\n\n if (isPanning) {\n return;\n }\n\n this.lastPointerDownEvent = event; // we must exit before we set `cursorButton` state and `savePointer`\n // else it will send pointer state & laser pointer events in collab when\n // panning\n\n /*if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\r\n return;\r\n }*/\n //zsviczian this broke on pointer down in onPointerUpdate\n\n this.setState({\n lastPointerDownWith: event.pointerType,\n cursorButton: \"down\"\n });\n this.savePointer(event.clientX, event.clientY, \"down\");\n\n if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\n return;\n } //zsviczian moved it here, because else pointer down in onPointerUpdate did not work\n\n\n if (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.ERASER && this.state.activeTool.type !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.eraser) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.eraser,\n lastActiveToolBeforeEraser: this.state.activeTool\n })\n }, () => {\n this.handleCanvasPointerDown(event);\n\n const onPointerUp = () => {\n unsubPointerUp();\n unsubCleanup === null || unsubCleanup === void 0 ? void 0 : unsubCleanup();\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, Object.assign(Object.assign({}, this.state.activeTool.lastActiveTool || {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.selection\n }), {\n lastActiveToolBeforeEraser: null\n }))\n });\n }\n };\n\n const unsubPointerUp = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp, {\n once: true\n });\n let unsubCleanup; // subscribe inside rAF lest it'd be triggered on the same pointerdown\n // if we start erasing while coming from blurred document since\n // we cleanup pointer events on focus\n\n requestAnimationFrame(() => {\n unsubCleanup = this.missingPointerEventCleanupEmitter.once(onPointerUp);\n });\n });\n return;\n } // only handle left mouse button or touch\n\n\n if (event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.MAIN && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.TOUCH && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.ERASER) {\n return;\n } // don't select while panning\n\n\n if (gesture.pointers.size > 1) {\n return;\n } // State for the duration of a pointer interaction, which starts with a\n // pointerDown event, ends with a pointerUp event (or another pointerDown)\n\n\n const pointerDownState = this.initialPointerDownState(event);\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n\n if (this.handleDraggingScrollBar(event, pointerDownState)) {\n return;\n }\n\n this.clearSelectionIfNotUsingSelection();\n this.updateBindingEnabledOnPointerMove(event);\n\n if (this.handleSelectionOnPointerDown(event, pointerDownState)) {\n return;\n }\n\n const allowOnPointerDown = !this.state.penMode || event.pointerType !== \"touch\" || this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\" || this.state.activeTool.type === \"text\" || this.state.activeTool.type === \"image\";\n\n if (!allowOnPointerDown) {\n return;\n }\n\n if (this.state.activeTool.type === \"lasso\") {\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n } else if (this.state.activeTool.type === \"text\") {\n this.handleTextOnPointerDown(event, pointerDownState);\n } else if (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\") {\n this.handleLinearElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"image\") {\n // reset image preview on pointerdown\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.CROSSHAIR); // retrieve the latest element as the state may be stale\n\n const pendingImageElement = this.state.pendingImageElementId && this.scene.getElement(this.state.pendingImageElementId);\n\n if (!pendingImageElement) {\n return;\n }\n\n this.setState({\n newElement: pendingImageElement,\n pendingImageElementId: null,\n multiElement: null\n });\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const frame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n this.scene.mutateElement(pendingImageElement, {\n x,\n y,\n frameId: frame ? frame.id : null\n });\n } else if (this.state.activeTool.type === \"freedraw\") {\n this.handleFreeDrawElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"custom\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n } else if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe) {\n this.createFrameElementOnPointerDown(pointerDownState, this.state.activeTool.type);\n } else if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n } else if (this.state.activeTool.type !== \"eraser\" && this.state.activeTool.type !== \"hand\" && this.state.activeTool.type !== \"mermaid\") {\n this.createGenericElementOnPointerDown(this.state.activeTool.type, pointerDownState);\n }\n\n (_c = (_b = this.props) === null || _b === void 0 ? void 0 : _b.onPointerDown) === null || _c === void 0 ? void 0 : _c.call(_b, this.state.activeTool, pointerDownState);\n this.onPointerDownEmitter.trigger(this.state.activeTool, pointerDownState, event);\n\n if (this.state.activeTool.type === \"eraser\") {\n this.eraserTrail.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n }\n\n const onPointerMove = this.onPointerMoveFromPointerDownHandler(pointerDownState);\n const onPointerUp = this.onPointerUpFromPointerDownHandler(pointerDownState);\n const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState);\n const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState);\n this.missingPointerEventCleanupEmitter.once(_event => onPointerUp(_event || event.nativeEvent));\n\n if (!this.state.viewModeEnabled || this.state.activeTool.type === \"laser\") {\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYDOWN, onKeyDown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYUP, onKeyUp);\n pointerDownState.eventListeners.onMove = onPointerMove;\n pointerDownState.eventListeners.onUp = onPointerUp;\n pointerDownState.eventListeners.onKeyUp = onKeyUp;\n pointerDownState.eventListeners.onKeyDown = onKeyDown;\n }\n };\n\n this.handleCanvasPointerUp = event => {\n var _a, _b;\n\n this.removePointer(event);\n this.lastPointerUpEvent = event;\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: event.clientX,\n clientY: event.clientY\n }, this.state);\n const clicklength = event.timeStamp - ((_b = (_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.timeStamp) !== null && _b !== void 0 ? _b : 0);\n\n if (this.device.editor.isMobile && clicklength < 300) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointer.x, scenePointer.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n return;\n }\n }\n\n if (this.device.isTouchScreen) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n if (clicklength < 300 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(this.hitLinkElement) && !(0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_96__.isPointHittingLinkIcon)(this.hitLinkElement, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y))) {\n this.handleEmbeddableCenterClick(this.hitLinkElement);\n } else {\n this.redirectToLink(event, this.device.isTouchScreen);\n }\n } else if (this.state.viewModeEnabled) {\n this.setState({\n activeEmbeddable: null,\n selectedElementIds: {}\n });\n }\n };\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices = event => {\n // deal with opening context menu on touch devices\n if (event.pointerType === \"touch\") {\n invalidateContextMenu = false;\n\n if (touchTimeout) {\n // If there's already a touchTimeout, this means that there's another\n // touch down and we are doing another touch, so we shouldn't open the\n // context menu.\n invalidateContextMenu = true;\n } else {\n // open the context menu with the first touch's clientX and clientY\n // if the touch is not moving\n touchTimeout = window.setTimeout(() => {\n touchTimeout = 0;\n\n if (!invalidateContextMenu) {\n this.handleCanvasContextMenu(event);\n }\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOUCH_CTX_MENU_TIMEOUT);\n }\n }\n };\n\n this.resetContextMenuTimer = () => {\n clearTimeout(touchTimeout);\n touchTimeout = 0;\n invalidateContextMenu = false;\n };\n /**\r\n * pointerup may not fire in certian cases (user tabs away...), so in order\r\n * to properly cleanup pointerdown state, we need to fire any hanging\r\n * pointerup handlers manually\r\n */\n\n\n this.maybeCleanupAfterMissingPointerUp = event => {\n lastPointerUp === null || lastPointerUp === void 0 ? void 0 : lastPointerUp();\n this.missingPointerEventCleanupEmitter.trigger(event).clear();\n }; // Returns whether the event is a panning\n\n\n this.handleCanvasPanUsingWheelOrSpaceDrag = event => {\n if (!(gesture.pointers.size <= 1 && (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.WHEEL || event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.MAIN && isHoldingSpace || (0,_appState__WEBPACK_IMPORTED_MODULE_54__.isHandToolActive)(this.state) || //zsviczian\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.isTouchInPenMode)(this.state, event) || //!isLaserPointerActive added by zsviczian (but don't remember why....)\n this.state.viewModeEnabled && !(0,_appState__WEBPACK_IMPORTED_MODULE_54__.isLaserPointerActive)(this.state)))) {\n return false;\n }\n\n isPanning = true; // due to event.preventDefault below, container wouldn't get focus\n // automatically\n\n this.focusContainer(); // preventing defualt while text editing messes with cursor/focus\n\n if (!this.state.editingTextElement) {\n // necessary to prevent browser from scrolling the page if excalidraw\n // not full-page #4489\n //\n // as such, the above is broken when panning canvas while in wysiwyg\n event.preventDefault();\n }\n\n let nextPastePrevented = false;\n const isLinux = typeof window === undefined ? false : /Linux/.test(window.navigator.platform);\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n /*\r\n * Prevent paste event if we move while middle clicking on Linux.\r\n * See issue #1383.\r\n */\n\n if (isLinux && !nextPastePrevented && (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1)) {\n nextPastePrevented = true;\n /* Prevent the next paste event */\n\n const preventNextPaste = event => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, preventNextPaste);\n event.stopPropagation();\n };\n /*\r\n * Reenable next paste in case of disabled middle click paste for\r\n * any reason:\r\n * - right click paste\r\n * - empty clipboard\r\n */\n\n\n const enableNextPaste = () => {\n setTimeout(() => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, preventNextPaste);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, enableNextPaste);\n }, 100);\n };\n\n document.body.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, preventNextPaste);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, enableNextPaste);\n }\n\n this.translateCanvas({\n scrollX: this.state.scrollX - deltaX / this.state.zoom.value,\n scrollY: this.state.scrollY - deltaY / this.state.zoom.value\n });\n });\n const teardown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(lastPointerUp = () => {\n lastPointerUp = null;\n isPanning = false;\n\n if (!isHoldingSpace) {\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, teardown);\n return true;\n };\n\n this.clearSelectionIfNotUsingSelection = () => {\n if (this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\") {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n };\n /**\r\n * @returns whether the pointer event has been completely handled\r\n */\n\n\n this.handleSelectionOnPointerDown = (event, pointerDownState) => {\n var _a, _b;\n\n if (this.state.activeTool.type === \"selection\") {\n const elements = this.scene.getNonDeletedElements();\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !this.state.editingLinearElement && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0]) && !(this.state.selectedLinearElement && this.state.selectedLinearElement.hoverPointIndex !== -1)) {\n const elementWithTransformHandleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getElementWithTransformHandleType)(elements, this.state, pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType != null) {\n if (elementWithTransformHandleType.transformHandleType === \"rotation\") {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else if (this.state.croppingElementId) {\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n }\n }\n } else if (selectedElements.length > 1) {\n pointerDownState.resize.handleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getTransformHandleTypeFromCoords)((0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements), pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.device);\n }\n\n if (pointerDownState.resize.handleType) {\n pointerDownState.resize.isResizing = true;\n pointerDownState.resize.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)((0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.getResizeOffsetXY)(pointerDownState.resize.handleType, selectedElements, elementsMap, pointerDownState.origin.x, pointerDownState.origin.y));\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(selectedElements[0]) && selectedElements[0].points.length === 2) {\n pointerDownState.resize.arrowDirection = (0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.getResizeArrowDirection)(pointerDownState.resize.handleType, selectedElements[0]);\n }\n } else {\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.editingLinearElement || this.state.selectedLinearElement;\n const ret = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerDown(event, this, this.store, pointerDownState.origin, linearElementEditor, this.scene);\n\n if (ret.hitElement) {\n pointerDownState.hit.element = ret.hitElement;\n }\n\n if (ret.linearElementEditor) {\n this.setState({\n selectedLinearElement: ret.linearElementEditor\n });\n\n if (this.state.editingLinearElement) {\n this.setState({\n editingLinearElement: ret.linearElementEditor\n });\n }\n }\n\n if (ret.didAddPoint) {\n return true;\n }\n } // hitElement may already be set above, so check first\n\n\n pointerDownState.hit.element = (_a = pointerDownState.hit.element) !== null && _a !== void 0 ? _a : this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n this.hitLinkElement = this.getElementLinkAtPosition(pointerDownState.origin, pointerDownState.hit.element);\n\n if (this.hitLinkElement) {\n return true;\n }\n\n if (this.state.croppingElementId && ((_b = pointerDownState.hit.element) === null || _b === void 0 ? void 0 : _b.id) !== this.state.croppingElementId) {\n this.finishImageCropping();\n }\n\n if (pointerDownState.hit.element) {\n // Early return if pointer is hitting link icon\n const hitLinkElement = this.getElementLinkAtPosition({\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }, pointerDownState.hit.element);\n\n if (hitLinkElement) {\n return false;\n }\n } // For overlapped elements one position may hit\n // multiple elements\n\n\n pointerDownState.hit.allHitElements = this.getElementsAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n const hitElement = pointerDownState.hit.element;\n const someHitElementIsSelected = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n\n if ((hitElement === null || !someHitElementIsSelected) && !event.shiftKey && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.clearSelection(hitElement);\n }\n\n if (this.state.editingLinearElement) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [this.state.editingLinearElement.elementId]: true\n }, this.state)\n }); // If we click on something\n } else if (hitElement != null) {\n // on CMD/CTRL, drill down to hit element regardless of groups etc.\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if (!this.state.selectedElementIds[hitElement.id]) {\n pointerDownState.hit.wasAddedToSelection = true;\n }\n\n this.setState(prevState => Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.editGroupForSelectedElement)(prevState, hitElement)), {\n previousSelectedElementIds: this.state.selectedElementIds\n })); // mark as not completely handled so as to allow dragging etc.\n\n return false;\n } // deselect if item is selected\n // if shift is not clicked, this will always return true\n // otherwise, it will trigger selection based on current\n // state of the box\n\n\n if (!this.state.selectedElementIds[hitElement.id]) {\n // if we are currently editing a group, exiting editing mode and deselect the group.\n if (this.state.editingGroupId && !(0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.isElementInGroup)(hitElement, this.state.editingGroupId)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // Add hit element to selection. At this point if we're not holding\n // SHIFT the previously selected element(s) were deselected above\n // (make sure you use setState updater to use latest state)\n // With shift-selection, we want to make sure that frames and their containing\n // elements are not selected at the same time.\n\n\n if (!someHitElementIsSelected && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.setState(prevState => {\n var _a;\n\n let nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n });\n const previouslySelectedElements = [];\n Object.keys(prevState.selectedElementIds).forEach(id => {\n const element = this.scene.getElement(id);\n element && previouslySelectedElements.push(element);\n }); // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getFrameChildren)(previouslySelectedElements, hitElement.id).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n } else if (hitElement.frameId) {\n // if hitElement is in a frame and its frame has been selected\n // disable selection for the given element\n if (nextSelectedElementIds[hitElement.frameId]) {\n delete nextSelectedElementIds[hitElement.id];\n }\n } else {\n // hitElement is neither a frame nor an element in a frame\n // but since hitElement could be in a group with some frames\n // this means selecting hitElement will have the frames selected as well\n // because we want to keep the invariant:\n // - frames and their elements are not selected at the same time\n // we deselect elements in those frames that were previously selected\n const groupIds = hitElement.groupIds;\n const framesInGroups = new Set(groupIds.flatMap(gid => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element)).map(frame => frame.id));\n\n if (framesInGroups.size > 0) {\n previouslySelectedElements.forEach(element => {\n if (element.frameId && framesInGroups.has(element.frameId)) {\n // deselect element and groups containing the element\n delete nextSelectedElementIds[element.id];\n element.groupIds.flatMap(gid => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n } // Finally, in shape selection mode, we'd like to\n // keep only one shape or group selected at a time.\n // This means, if the hitElement is a different shape or group\n // than the previously selected ones, we deselect the previous ones\n // and select the hitElement\n\n\n if (((_a = prevState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n if (!hitElement.groupIds.some(gid => prevState.selectedGroupIds[gid])) {\n nextSelectedElementIds = {\n [hitElement.id]: true\n };\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\n }\n }\n\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n }\n\n return false;\n };\n\n this.handleTextOnPointerDown = (event, pointerDownState) => {\n // if we're currently still editing text, clicking outside\n // should only finalize it, not create another (irrespective\n // of state.activeTool.locked)\n if (this.state.editingTextElement) {\n return;\n }\n\n let sceneX = pointerDownState.origin.x;\n let sceneY = pointerDownState.origin.y;\n const element = this.getElementAtPosition(sceneX, sceneY, {\n includeBoundTextElement: true\n }); // FIXME\n\n let container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.hasBoundTextElement)(element)) {\n container = element;\n sceneX = element.x + element.width / 2;\n sceneY = element.y + element.height / 2;\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container,\n autoEdit: false\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n\n if (!this.state.activeTool.locked) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n }\n };\n\n this.handleFreeDrawElementOnPointerDown = (event, elementType, pointerDownState) => {\n // Begin a mark capture. This does not have to update state yet.\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, null);\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const simulatePressure = (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure //zsviczian\n ) ? false : event.pressure === 0.5;\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newFreeDrawElement)(Object.assign(Object.assign({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: null,\n simulatePressure,\n locked: false\n }, strokeOptions //zsviczian\n ? {\n customData: {\n strokeOptions\n }\n } : {}), {\n frameId: topLayerFrame ? topLayerFrame.id : null,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)],\n pressures: simulatePressure ? [] : [(strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure]\n })); //zsviczian\n\n if (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.highlighter) {\n this.scene.insertElement(element, 0);\n } else {\n this.scene.insertElement(element);\n }\n\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n const boundElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n };\n\n this.insertIframeElement = ({\n sceneX,\n sceneY,\n width,\n height\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newIframeElement)({\n type: \"iframe\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"iframe\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width,\n height\n });\n this.scene.insertElement(element);\n return element;\n }; //create rectangle element with youtube top left on nearest grid point width / hight 640/360\n\n\n this.insertEmbeddableElement = ({\n sceneX,\n sceneY,\n link\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const embedLink = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)(link);\n\n if (!embedLink) {\n return;\n }\n\n if (embedLink.error instanceof URIError) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"toast.unrecognizedLinkFormat\"),\n closable: true\n });\n }\n\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newEmbeddableElement)({\n type: \"embeddable\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"embeddable\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width: embedLink.intrinsicSize.w,\n height: embedLink.intrinsicSize.h,\n link\n });\n this.scene.insertElement(element);\n return element;\n };\n\n this.createImageElement = ({\n sceneX,\n sceneY,\n addToFrameUnderCursor = true\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = addToFrameUnderCursor ? this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n }) : null;\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newImageElement)({\n type: \"image\",\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: null,\n opacity: this.state.currentItemOpacity,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n return element;\n };\n\n this.handleLinearElementOnPointerDown = (event, elementType, pointerDownState) => {\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state; // finalize if completing a loop\n\n if (multiElement.type === \"line\" && (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.isPathALoop)(multiElement.points, this.state.zoom.value)) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n } // Elbow arrows cannot be created by putting down points\n // only the start and end points can be defined\n\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(multiElement) && multiElement.points.length > 1) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n }\n\n const {\n x: rx,\n y: ry,\n lastCommittedPoint\n } = multiElement; // clicking inside commit zone → finalize arrow\n\n if (multiElement.points.length > 1 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x - rx, pointerDownState.origin.y - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.LINE_CONFIRM_THRESHOLD) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n }\n\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState)\n })); // clicking outside commit zone → update reference for last committed\n // point\n\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n /* If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.\r\n If so, we want it to be null for start and \"arrow\" for end. If the linear item is not\r\n an arrow, we want it to be null for both. Otherwise, we want it to use the\r\n values from appState. */\n\n const {\n currentItemStartArrowhead,\n currentItemEndArrowhead\n } = this.state;\n const [startArrowhead, endArrowhead] = elementType === \"arrow\" ? [currentItemStartArrowhead, currentItemEndArrowhead] : [null, null];\n const element = elementType === \"arrow\" ? (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newArrowElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.round ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : // note, roundness doesn't have any effect for elbow arrows,\n // but it's best to set it to null as well\n null,\n startArrowhead,\n endArrowhead,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null,\n elbowed: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.elbow,\n fixedSegments: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.elbow ? [] : null\n }) : (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newLinearElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemRoundness === \"round\" ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n this.scene.mutateElement(element, {\n points: [...element.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)]\n });\n const boundElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element), (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element));\n this.scene.insertElement(element);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n }\n };\n\n this.createGenericElementOnPointerDown = (elementType, pointerDownState) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const baseElementAttributes = {\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.getCurrentItemRoundness(elementType),\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n };\n let element;\n\n if (elementType === \"embeddable\") {\n element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newEmbeddableElement)(Object.assign({\n type: \"embeddable\"\n }, baseElementAttributes));\n } else {\n element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newElement)(Object.assign({\n type: elementType\n }, baseElementAttributes));\n }\n\n if (element.type === \"selection\") {\n this.setState({\n selectionElement: element\n });\n } else {\n this.scene.insertElement(element);\n this.setState({\n multiElement: null,\n newElement: element\n });\n }\n };\n\n this.createFrameElementOnPointerDown = (pointerDownState, type) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const constructorOpts = Object.assign(Object.assign({\n x: gridX,\n y: gridY,\n opacity: this.state.currentItemOpacity,\n locked: false\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE), this.state.frameColor ? {\n //zsviczian\n customData: {\n frameColor: this.state.frameColor\n }\n } : {});\n const frame = type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe ? (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newMagicFrameElement)(constructorOpts) : (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newFrameElement)(constructorOpts);\n this.scene.insertElement(frame);\n this.setState({\n multiElement: null,\n newElement: frame\n });\n };\n\n this.restoreReadyToEraseElements = () => {\n this.elementsPendingErasure = new Set();\n this.triggerRender();\n };\n\n this.eraseElements = () => {\n let didChange = false;\n const elements = this.scene.getElementsIncludingDeleted().map(ele => {\n if (this.elementsPendingErasure.has(ele.id) || ele.frameId && this.elementsPendingErasure.has(ele.frameId) || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(ele) && this.elementsPendingErasure.has(ele.containerId)) {\n didChange = true;\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(ele, {\n isDeleted: true\n });\n }\n\n return ele;\n });\n this.elementsPendingErasure = new Set();\n\n if (didChange) {\n this.store.shouldCaptureIncrement();\n this.scene.replaceAllElements(elements);\n }\n };\n\n this.initializeImage = async ({\n imageFile,\n imageElement: _imageElement,\n showCursorImagePreview = false\n }) => {\n var _a, _b, _c, _d; // at this point this should be guaranteed image file, but we do this check\n // to satisfy TS down the line\n\n\n if (!(0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isSupportedImageFile)(imageFile)) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.unsupportedFileType\"));\n }\n\n const mimeType = imageFile.type;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, \"wait\");\n\n if (mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n try {\n imageFile = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.SVGStringToFile)((0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.normalizeSVG)(await imageFile.text()), imageFile.name);\n } catch (error) {\n console.warn(error);\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.svgImageInsertError\"));\n }\n } // generate image id (by default the file digest) before any\n // resizing/compression takes place to keep it more portable\n\n\n const fileId = await (((_b = (_a = this.props).generateIdForFile) === null || _b === void 0 ? void 0 : _b.call(_a, imageFile)) || (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.generateIdFromFile)(imageFile));\n\n if (!fileId) {\n console.warn(\"Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one.\");\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageInsertError\"));\n }\n\n const existingFileData = this.files[fileId];\n\n if (!(existingFileData === null || existingFileData === void 0 ? void 0 : existingFileData.dataURL)) {\n try {\n imageFile = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.resizeImageFile)(imageFile, {\n maxWidthOrHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT\n });\n } catch (error) {\n console.error(\"Error trying to resizing image file on insertion\", error);\n }\n\n if (imageFile.size > _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MAX_ALLOWED_FILE_BYTES) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.fileTooBig\", {\n maxSize: `${Math.trunc(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MAX_ALLOWED_FILE_BYTES / 1024 / 1024)}MB`\n }));\n }\n }\n\n if (showCursorImagePreview) {\n const dataURL = (_c = this.files[fileId]) === null || _c === void 0 ? void 0 : _c.dataURL; // optimization so that we don't unnecessarily resize the original\n // full-size file for cursor preview\n // (it's much faster to convert the resized dataURL to File)\n\n const resizedFile = dataURL && (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.dataURLToFile)(dataURL);\n this.setImagePreviewCursor(resizedFile || imageFile);\n }\n\n const dataURL = ((_d = this.files[fileId]) === null || _d === void 0 ? void 0 : _d.dataURL) || (await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getDataURL)(imageFile));\n const imageElement = this.scene.mutateElement(_imageElement, {\n fileId\n }, {\n informMutation: false,\n isDragging: false\n });\n return new Promise(async (resolve, reject) => {\n var _a;\n\n try {\n this.addMissingFiles([{\n mimeType,\n id: fileId,\n dataURL,\n created: Date.now(),\n lastRetrieved: Date.now(),\n //@ts-ignore\n name: (imageFile === null || imageFile === void 0 ? void 0 : imageFile.name) && imageFile.name !== \"image.png\" ? imageFile.name : undefined // zsviczian\n\n }]);\n const cachedImageData = this.imageCache.get(fileId);\n\n if (!cachedImageData) {\n this.addNewImagesToImageCache();\n await this.updateImageCache([imageElement]);\n }\n\n if ((cachedImageData === null || cachedImageData === void 0 ? void 0 : cachedImageData.image) instanceof Promise) {\n await cachedImageData.image;\n }\n\n if (this.state.pendingImageElementId !== imageElement.id && ((_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.id) !== imageElement.id) {\n this.initializeImageDimensions(imageElement, true);\n }\n\n resolve(imageElement);\n } catch (error) {\n console.error(error);\n reject(new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageInsertError\")));\n } finally {\n if (!showCursorImagePreview) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n }\n }\n });\n };\n /**\r\n * inserts image into elements array and rerenders\r\n */\n\n\n this.insertImageElement = async (imageElement, imageFile, showCursorImagePreview) => {\n // we should be handling all cases upstream, but in case we forget to handle\n // a future case, let's throw here\n if (!this.isToolSupported(\"image\")) {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n this.scene.insertElement(imageElement);\n\n try {\n return await this.initializeImage({\n imageFile,\n imageElement,\n showCursorImagePreview\n });\n } catch (error) {\n this.scene.mutateElement(imageElement, {\n isDeleted: true\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n this.setState({\n errorMessage: error.message || (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageInsertError\")\n });\n return null;\n }\n };\n\n this.setImagePreviewCursor = async imageFile => {\n // mustn't be larger than 128 px\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property\n const cursorImageSizePx = 96;\n let imagePreview;\n\n try {\n imagePreview = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.resizeImageFile)(imageFile, {\n maxWidthOrHeight: cursorImageSizePx\n });\n } catch (e) {\n if (e.cause === \"UNSUPPORTED\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.unsupportedFileType\"));\n }\n\n throw e;\n }\n\n let previewDataURL = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getDataURL)(imagePreview); // SVG cannot be resized via `resizeImageFile` so we resize by rendering to\n // a small canvas\n\n if (imageFile.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n const img = await (0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.loadHTMLImageElement)(previewDataURL);\n let height = Math.min(img.height, cursorImageSizePx);\n let width = height * (img.width / img.height);\n\n if (width > cursorImageSizePx) {\n width = cursorImageSizePx;\n height = width * (img.height / img.width);\n }\n\n const canvas = document.createElement(\"canvas\");\n canvas.height = height;\n canvas.width = width;\n const context = canvas.getContext(\"2d\");\n context.drawImage(img, 0, 0, width, height);\n previewDataURL = canvas.toDataURL(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg);\n }\n\n if (this.state.pendingImageElementId) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, `url(${previewDataURL}) 4 4, auto`);\n }\n };\n\n this.onImageAction = async ({\n insertOnCanvasDirectly\n }) => {\n var _a;\n\n try {\n const clientX = this.state.width / 2 + this.state.offsetLeft;\n const clientY = this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n let imageFile = await (0,_data_filesystem__WEBPACK_IMPORTED_MODULE_65__.fileOpen)({\n description: \"Image\",\n extensions: Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.IMAGE_MIME_TYPES)\n }); //zsviczian - temporary fix: https://github.com/excalidraw/excalidraw/issues/9091\n\n if (imageFile && !imageFile.type) {\n const extension = (_a = imageFile.name.split(\".\").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();\n const mimeType = _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.IMAGE_MIME_TYPES[extension];\n\n if (mimeType) {\n imageFile = new File([imageFile], imageFile.name, {\n type: mimeType\n });\n }\n }\n\n const imageElement = this.createImageElement({\n sceneX: x,\n sceneY: y,\n addToFrameUnderCursor: false\n });\n\n if (insertOnCanvasDirectly) {\n this.insertImageElement(imageElement, imageFile);\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n } else {\n this.setState({\n pendingImageElementId: imageElement.id\n }, () => {\n this.insertImageElement(imageElement, imageFile,\n /* showCursorImagePreview */\n true);\n });\n }\n } catch (error) {\n if (error.name !== \"AbortError\") {\n console.error(error);\n } else {\n console.warn(error);\n }\n\n this.setState({\n pendingImageElementId: null,\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n }\n };\n\n this.initializeImageDimensions = (imageElement, forceNaturalSize = false) => {\n var _a;\n\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(imageElement) && ((_a = this.imageCache.get(imageElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (!image || image instanceof Promise) {\n if (imageElement.width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value && imageElement.height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value) {\n const placeholderSize = 100 / this.state.zoom.value;\n this.scene.mutateElement(imageElement, {\n x: imageElement.x - placeholderSize / 2,\n y: imageElement.y - placeholderSize / 2,\n width: placeholderSize,\n height: placeholderSize\n });\n }\n\n return;\n }\n\n if (forceNaturalSize || // if user-created bounding box is below threshold, assume the\n // intention was to click instead of drag, and use the image's\n // intrinsic size\n imageElement.width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value && imageElement.height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value) {\n const minHeight = Math.max(this.state.height - 120, 160); // max 65% of canvas height, clamped to <300px, vh - 120px>\n\n const maxHeight = Math.min(minHeight, Math.floor(this.state.height * 0.5) / this.state.zoom.value);\n const height = Math.min(image.naturalHeight, maxHeight);\n const width = height * (image.naturalWidth / image.naturalHeight); // add current imageElement width/height to account for previous centering\n // of the placeholder image\n\n const x = imageElement.x + imageElement.width / 2 - width / 2;\n const y = imageElement.y + imageElement.height / 2 - height / 2;\n this.scene.mutateElement(imageElement, {\n x,\n y,\n width,\n height,\n crop: null\n });\n }\n };\n /** updates image cache, refreshing updated elements and/or setting status\r\n to error for images that fail during <img> element creation */\n\n\n this.updateImageCache = async (elements, files = this.files) => {\n const {\n updatedFiles,\n erroredFiles\n } = await (0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.updateImageCache)({\n imageCache: this.imageCache,\n fileIds: elements.map(element => element.fileId),\n files\n });\n\n if (updatedFiles.size || erroredFiles.size) {\n for (const element of elements) {\n if (updatedFiles.has(element.fileId)) {\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element);\n }\n }\n }\n\n if (erroredFiles.size) {\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(element) && erroredFiles.has(element.fileId)) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(element, {\n status: \"error\"\n });\n }\n\n return element;\n }));\n }\n\n return {\n updatedFiles,\n erroredFiles\n };\n };\n /** adds new images to imageCache and re-renders if needed */\n\n\n this.addNewImagesToImageCache = async (imageElements = (0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.getInitializedImageElements)(this.scene.getNonDeletedElements()), files = this.files) => {\n const uncachedImageElements = imageElements.filter(element => !element.isDeleted && !this.imageCache.has(element.fileId));\n\n if (uncachedImageElements.length) {\n const {\n updatedFiles\n } = await this.updateImageCache(uncachedImageElements, files);\n\n if (updatedFiles.size) {\n this.scene.triggerUpdate();\n }\n }\n };\n /** generally you should use `addNewImagesToImageCache()` directly if you need\r\n * to render new images. This is just a failsafe */\n\n\n this.scheduleImageRefresh = lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default()(() => {\n this.addNewImagesToImageCache();\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.IMAGE_RENDER_TIMEOUT);\n\n this.updateBindingEnabledOnPointerMove = event => {\n const shouldEnableBinding = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.shouldEnableBindingForPointerEvent)(event);\n\n if (this.state.isBindingEnabled !== shouldEnableBinding) {\n this.setState({\n isBindingEnabled: shouldEnableBinding\n });\n }\n };\n\n this.maybeSuggestBindingAtCursor = (pointerCoords, considerAll) => {\n const hoveredBindableElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(pointerCoords, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, false, considerAll);\n this.setState({\n suggestedBindings: hoveredBindableElement != null ? [hoveredBindableElement] : []\n });\n };\n\n this.maybeSuggestBindingsForLinearElementAtCoords = (linearElement,\n /** scene coords */\n pointerCoords, // During line creation the start binding hasn't been written yet\n // into `linearElement`\n oppositeBindingBoundElement) => {\n if (!pointerCoords.length) {\n return;\n }\n\n const suggestedBindings = pointerCoords.reduce((acc, coords) => {\n const hoveredBindableElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(coords, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(linearElement), (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(linearElement));\n\n if (hoveredBindableElement != null && !(0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isLinearElementSimpleAndAlreadyBound)(linearElement, oppositeBindingBoundElement === null || oppositeBindingBoundElement === void 0 ? void 0 : oppositeBindingBoundElement.id, hoveredBindableElement)) {\n acc.push(hoveredBindableElement);\n }\n\n return acc;\n }, []);\n this.setState({\n suggestedBindings\n });\n };\n\n this.handleInteractiveCanvasRef = canvas => {\n var _a, _b; // canvas is null when unmounting\n\n\n if (canvas !== null) {\n this.interactiveCanvas = canvas; // -----------------------------------------------------------------------\n // NOTE wheel, touchstart, touchend events must be registered outside\n // of react because react binds them them passively (so we can't prevent\n // default on them)\n\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_START, this.onTouchStart, {\n passive: false\n });\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_END, this.onTouchEnd); // -----------------------------------------------------------------------\n } else {\n (_a = this.interactiveCanvas) === null || _a === void 0 ? void 0 : _a.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_START, this.onTouchStart);\n (_b = this.interactiveCanvas) === null || _b === void 0 ? void 0 : _b.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_END, this.onTouchEnd);\n }\n };\n\n this.handleAppOnDrop = async event => {\n var _a, _b, _c, _d;\n\n if (this.props.onDrop) {\n try {\n if ((await this.props.onDrop(event)) === false) {\n return;\n }\n } catch (e) {\n console.error(e);\n }\n } // must be retrieved first, in the same frame\n\n\n const {\n file,\n fileHandle\n } = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getFileFromEvent)(event);\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n\n try {\n // if image tool not supported, don't show an error here and let it fall\n // through so we still support importing scene data from images. If no\n // scene data encoded, we'll show an error then\n if ((0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isSupportedImageFile)(file) && this.isToolSupported(\"image\")) {\n // first attempt to decode scene from the image if it's embedded\n // ---------------------------------------------------------------------\n if ((file === null || file === void 0 ? void 0 : file.type) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.png || (file === null || file === void 0 ? void 0 : file.type) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n try {\n const scene = await (0,_data__WEBPACK_IMPORTED_MODULE_56__.loadFromBlob)(file, this.state, this.scene.getElementsIncludingDeleted(), fileHandle);\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n appState: Object.assign(Object.assign({}, scene.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n }));\n return;\n } catch (error) {\n // Don't throw for image scene daa\n if (error.name !== \"EncodingError\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"alerts.couldNotLoadInvalidFile\"));\n }\n }\n } // if no scene is embedded or we fail for whatever reason, fall back\n // to importing as regular image\n // ---------------------------------------------------------------------\n\n\n const imageElement = this.createImageElement({\n sceneX,\n sceneY\n });\n this.insertImageElement(imageElement, file);\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n });\n return;\n }\n } catch (error) {\n return this.setState({\n isLoading: false,\n errorMessage: error.message\n });\n }\n\n const libraryJSON = event.dataTransfer.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.excalidrawlib);\n\n if (libraryJSON && typeof libraryJSON === \"string\") {\n try {\n const libraryItems = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.parseLibraryJSON)(libraryJSON);\n this.addElementsFromPasteOrLibrary({\n elements: (0,_data_library__WEBPACK_IMPORTED_MODULE_57__.distributeLibraryItemsOnSquareGrid)(libraryItems),\n position: event,\n files: null\n });\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n\n return;\n }\n\n if (file) {\n // Attempt to parse an excalidraw/excalidrawlib file\n await this.loadFileToCanvas(file, fileHandle);\n }\n\n if ((_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) === null || _b === void 0 ? void 0 : _b.includes(\"text/plain\")) {\n const text = (_c = event.dataTransfer) === null || _c === void 0 ? void 0 : _c.getData(\"text\");\n\n if (text && (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.embeddableURLValidator)(text, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(text) || ((_d = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)(text)) === null || _d === void 0 ? void 0 : _d.type) === \"video\")) {\n const embeddable = this.insertEmbeddableElement({\n sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeLink)(text)\n });\n\n if (embeddable) {\n this.setState({\n selectedElementIds: {\n [embeddable.id]: true\n }\n });\n }\n }\n }\n };\n\n this.loadFileToCanvas = async (file, fileHandle) => {\n file = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.normalizeFile)(file);\n\n try {\n const elements = this.scene.getElementsIncludingDeleted();\n let ret;\n\n try {\n ret = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.loadSceneOrLibraryFromBlob)(file, this.state, elements, fileHandle);\n } catch (error) {\n const imageSceneDataError = error instanceof _errors__WEBPACK_IMPORTED_MODULE_69__.ImageSceneDataError;\n\n if (imageSceneDataError && error.code === \"IMAGE_NOT_CONTAINS_SCENE_DATA\" && !this.isToolSupported(\"image\")) {\n this.setState({\n isLoading: false,\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const errorMessage = imageSceneDataError ? (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"alerts.cannotRestoreFromImage\") : (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"alerts.couldNotLoadInvalidFile\");\n this.setState({\n isLoading: false,\n errorMessage\n });\n }\n\n if (!ret) {\n return;\n }\n\n if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.excalidraw) {\n // restore the fractional indices by mutating elements\n (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncInvalidIndices)(elements.concat(ret.data.elements)); // update the store snapshot for old elements, otherwise we would end up with duplicated fractional indices on undo\n\n this.store.updateSnapshot((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(elements), this.state);\n this.setState({\n isLoading: true\n });\n this.syncActionResult(Object.assign(Object.assign({}, ret.data), {\n appState: Object.assign(Object.assign({}, ret.data.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n }));\n } else if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.excalidrawlib) {\n await this.library.updateLibrary({\n libraryItems: file,\n merge: true,\n openLibraryMenu: true\n }).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.importLibraryError\")\n });\n });\n }\n } catch (error) {\n this.setState({\n isLoading: false,\n errorMessage: error.message\n });\n }\n };\n\n this.handleCanvasContextMenu = event => {\n event.preventDefault();\n\n if ((\"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"touch\" || \"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"pen\" && // always allow if user uses a pen secondary button\n event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.SECONDARY) && this.state.activeTool.type !== \"selection\") {\n return;\n }\n\n if (this.state.isResizing) {\n return; //zsviczian - avoid context menu during resizing on Mobiles\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const element = this.getElementAtPosition(x, y, {\n preferSelected: true,\n includeLockedElements: true\n });\n const selectedElements = this.scene.getSelectedElements(this.state);\n const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements({\n x,\n y\n }, selectedElements);\n const type = element || isHittingCommonBoundBox ? \"element\" : \"canvas\";\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = event.clientX - offsetLeft;\n const top = event.clientY - offsetTop;\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"contextMenu\", \"openContextMenu\", type);\n this.setState(Object.assign(Object.assign({}, element && !this.state.selectedElementIds[element.id] ? Object.assign(Object.assign(Object.assign({}, this.state), (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: this.state.editingGroupId,\n selectedElementIds: {\n [element.id]: true\n }\n }, this.scene.getNonDeletedElements(), this.state, this)), {\n selectedLinearElement: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(element) ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(element, this.scene.getNonDeletedElementsMap()) : null\n }) : this.state), {\n showHyperlinkPopup: false\n }), () => {\n this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n });\n };\n\n this.maybeDragNewGenericElement = (pointerDownState, event, informMutation = true) => {\n var _a, _b, _c, _d, _e;\n\n const selectionElement = this.state.selectionElement;\n const pointerCoords = pointerDownState.lastCoords;\n\n if (selectionElement && this.state.activeTool.type !== \"eraser\") {\n (0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.dragNewElement)({\n newElement: selectionElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.origin.x,\n originY: pointerDownState.origin.y,\n x: pointerCoords.x,\n y: pointerCoords.y,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.origin.x, pointerCoords.x),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.origin.y, pointerCoords.y),\n shouldMaintainAspectRatio: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: false,\n scene: this.scene,\n zoom: this.state.zoom.value,\n informMutation: false\n });\n return;\n }\n\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n let [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(newElement) && ((_a = this.imageCache.get(newElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n const aspectRatio = image && !(image instanceof Promise) ? image.width / image.height : null;\n this.maybeCacheReferenceSnapPoints(event, [newElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapNewElement)(newElement, this, event, {\n x: pointerDownState.originInGrid.x + ((_c = (_b = this.state.originSnapOffset) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 0),\n y: pointerDownState.originInGrid.y + ((_e = (_d = this.state.originSnapOffset) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 0)\n }, {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n }, this.scene.getNonDeletedElementsMap());\n gridX += snapOffset.x;\n gridY += snapOffset.y;\n this.setState({\n snapLines\n });\n (0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.dragNewElement)({\n newElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.originInGrid.x,\n originY: pointerDownState.originInGrid.y,\n x: gridX,\n y: gridY,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.originInGrid.x, gridX),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.originInGrid.y, gridY),\n shouldMaintainAspectRatio: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(newElement) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldResizeFromCenter)(event),\n zoom: this.state.zoom.value,\n scene: this.scene,\n widthAspectRatio: aspectRatio,\n originOffset: this.state.originSnapOffset,\n informMutation\n });\n this.setState({\n newElement\n }); // highlight elements that are to be added to frames on frames creation\n\n if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe) {\n this.setState({\n elementsToHighlight: (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), newElement, this.state, this.scene.getNonDeletedElementsMap())\n });\n }\n };\n\n this.maybeHandleCrop = (pointerDownState, event) => {\n var _a; // to crop, we must already be in the cropping mode, where croppingElement has been set\n\n\n if (!this.state.croppingElementId) {\n return false;\n }\n\n const transformHandleType = pointerDownState.resize.handleType;\n const pointerCoords = pointerDownState.lastCoords;\n const [x, y] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (transformHandleType && croppingElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(croppingElement)) {\n const croppingAtStateStart = pointerDownState.originalElements.get(croppingElement.id);\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(croppingElement) && ((_a = this.imageCache.get(croppingElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (croppingAtStateStart && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(croppingAtStateStart) && image && !(image instanceof Promise)) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n this.maybeCacheReferenceSnapPoints(event, [croppingElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapResizingElements)([croppingElement], [croppingAtStateStart], this, event, dragOffset, transformHandleType);\n this.scene.mutateElement(croppingElement, (0,_excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_25__.cropElement)(croppingElement, transformHandleType, image.naturalWidth, image.naturalHeight, x + snapOffset.x, y + snapOffset.y, event.shiftKey ? croppingAtStateStart.width / croppingAtStateStart.height : undefined));\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.updateBoundElements)(croppingElement, this.scene, {\n newSize: {\n width: croppingElement.width,\n height: croppingElement.height\n }\n });\n this.setState({\n isCropping: transformHandleType && transformHandleType !== \"rotation\",\n snapLines\n });\n }\n\n return true;\n }\n\n return false;\n };\n\n this.maybeHandleResize = (pointerDownState, event) => {\n const selectedElements = this.scene.getSelectedElements(this.state);\n const selectedFrames = selectedElements.filter(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element));\n const transformHandleType = pointerDownState.resize.handleType;\n\n if ( // Frames cannot be rotated.\n selectedFrames.length > 0 && transformHandleType === \"rotation\" || // Elbow arrows cannot be transformed (resized or rotated).\n selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0]) || // Do not resize when in crop mode\n this.state.croppingElementId) {\n return false;\n }\n\n this.setState({\n // TODO: rename this state field to \"isScaling\" to distinguish\n // it from the generic \"isResizing\" which includes scaling and\n // rotating\n isResizing: transformHandleType && transformHandleType !== \"rotation\",\n isRotating: transformHandleType === \"rotation\",\n activeEmbeddable: null\n });\n const pointerCoords = pointerDownState.lastCoords;\n let [resizeX, resizeY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const frameElementsOffsetsMap = new Map();\n selectedFrames.forEach(frame => {\n const elementsInFrame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getFrameChildren)(this.scene.getNonDeletedElements(), frame.id);\n elementsInFrame.forEach(element => {\n frameElementsOffsetsMap.set(frame.id + element.id, {\n x: element.x - frame.x,\n y: element.y - frame.y\n });\n });\n }); // check needed for avoiding flickering when a key gets pressed\n // during dragging\n\n if (!this.state.selectedElementsAreBeingDragged) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n const originalElements = [...pointerDownState.originalElements.values()];\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapResizingElements)(selectedElements, (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(originalElements, this.state), this, event, dragOffset, transformHandleType);\n resizeX += snapOffset.x;\n resizeY += snapOffset.y;\n this.setState({\n snapLines\n });\n }\n\n if ((0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.transformElements)(pointerDownState.originalElements, transformHandleType, selectedElements, this.scene, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldRotateWithDiscreteAngle)(event), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldResizeFromCenter)(event), selectedElements.some(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(element)) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event), resizeX, resizeY, pointerDownState.resize.center.x, pointerDownState.resize.center.y)) {\n const suggestedBindings = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom);\n const elementsToHighlight = new Set();\n selectedFrames.forEach(frame => {\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), frame, this.state, this.scene.getNonDeletedElementsMap()).forEach(element => elementsToHighlight.add(element));\n });\n this.setState({\n elementsToHighlight: [...elementsToHighlight],\n suggestedBindings\n });\n return true;\n }\n\n return false;\n };\n\n this.getContextMenuItems = type => {\n const options = [];\n options.push(_actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsSvg); // canvas contextMenu\n // -------------------------------------------------------------------------\n\n if (type === \"canvas\") {\n if (this.state.viewModeEnabled) {\n return [...options, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_48__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleStats, _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.actionToggleLaserPointer];\n }\n\n return [_actions_actionClipboard__WEBPACK_IMPORTED_MODULE_42__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsSvg, _actions__WEBPACK_IMPORTED_MODULE_39__.copyText, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionSelectAll, _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_44__.actionUnlockAllElements, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleObjectsSnapMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_48__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleStats];\n } // element contextMenu\n // -------------------------------------------------------------------------\n\n\n options.push(_actions__WEBPACK_IMPORTED_MODULE_39__.copyText);\n\n if (this.state.viewModeEnabled) {\n return [_actions__WEBPACK_IMPORTED_MODULE_39__.actionCopy, ...options];\n }\n\n return [_ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCut, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopy, _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_42__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__.actionSelectAllElementsInFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__.actionRemoveAllElementsFromFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__.actionWrapSelectionInFrame, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleCropEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, ...options, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyStyles, _actions__WEBPACK_IMPORTED_MODULE_39__.actionPasteStyles, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionGroup, _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_47__.actionTextAutoResize, _actions__WEBPACK_IMPORTED_MODULE_39__.actionUnbindText, _actions__WEBPACK_IMPORTED_MODULE_39__.actionBindText, _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_40__.actionWrapTextInContainer, _actions__WEBPACK_IMPORTED_MODULE_39__.actionUngroup, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionAddToLibrary, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionSendBackward, _actions__WEBPACK_IMPORTED_MODULE_39__.actionBringForward, _actions__WEBPACK_IMPORTED_MODULE_39__.actionSendToBack, _actions__WEBPACK_IMPORTED_MODULE_39__.actionBringToFront, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionFlipHorizontal, _actions__WEBPACK_IMPORTED_MODULE_39__.actionFlipVertical, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleLinearEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_43__.actionCopyElementLink, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionDuplicateSelection, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleElementLock, _ContextMenu__WEBPACK_IMPORTED_MODULE_86__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionDeleteSelected];\n };\n\n this.handleWheel = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n // if not scrolling on canvas/wysiwyg, ignore\n if (!(event.target instanceof HTMLCanvasElement || event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLIFrameElement)) {\n // prevent zooming the browser (but allow scrolling DOM)\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n }\n\n return;\n }\n\n event.preventDefault();\n\n if (isPanning) {\n return;\n }\n\n const {\n deltaX,\n deltaY\n } = event; // note that event.ctrlKey is necessary to handle pinch zooming\n\n if ( //zsviczian\n (event.metaKey || event.ctrlKey) && !this.state.allowWheelZoom || !(event.metaKey || event.ctrlKey) && this.state.allowWheelZoom) {\n const sign = Math.sign(deltaY);\n const MAX_STEP = _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ZOOM_STEP * 100;\n const absDelta = Math.abs(deltaY);\n let delta = deltaY;\n\n if (absDelta > MAX_STEP) {\n delta = MAX_STEP * sign;\n }\n\n let newZoom = this.state.zoom.value - delta / 100; // increase zoom steps the more zoomed-in we are (applies to >100% only)\n\n newZoom += Math.log10(Math.max(1, this.state.zoom.value)) * -sign * // reduced amplification for small deltas (small movements on a trackpad)\n Math.min(1, absDelta / 20);\n this.translateCanvas(state => Object.assign(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(newZoom)\n }, state)), {\n shouldCacheIgnoreZoom: true\n }));\n this.resetShouldCacheIgnoreZoomDebounced();\n return;\n } // scroll horizontally when shift pressed\n\n\n if (event.shiftKey) {\n this.translateCanvas(({\n zoom,\n scrollX\n }) => ({\n // on Mac, shift+wheel tends to result in deltaX\n scrollX: scrollX - (deltaY || deltaX) / zoom.value\n }));\n return;\n }\n\n this.translateCanvas(({\n zoom,\n scrollX,\n scrollY\n }) => ({\n scrollX: scrollX - deltaX / zoom.value,\n scrollY: scrollY - deltaY / zoom.value\n }));\n });\n\n this.savePointer = (x, y, button) => {\n var _a, _b;\n\n if (!x || !y) {\n return;\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: x,\n clientY: y\n }, this.state);\n\n if (isNaN(sceneX) || isNaN(sceneY)) {// sometimes the pointer goes off screen\n }\n\n const pointer = {\n x: sceneX,\n y: sceneY,\n tool: this.state.activeTool.type === \"laser\" ? \"laser\" : \"pointer\"\n };\n (_b = (_a = this.props).onPointerUpdate) === null || _b === void 0 ? void 0 : _b.call(_a, {\n pointer,\n button,\n pointersMap: gesture.pointers\n });\n };\n\n this.resetShouldCacheIgnoreZoomDebounced = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.debounce)(() => {\n if (!this.unmounted) {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n }\n }, 300);\n\n this.updateDOMRect = cb => {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n width,\n height,\n left: offsetLeft,\n top: offsetTop\n } = excalidrawContainer.getBoundingClientRect();\n const {\n width: currentWidth,\n height: currentHeight,\n offsetTop: currentOffsetTop,\n offsetLeft: currentOffsetLeft\n } = this.state;\n\n if (width === currentWidth && height === currentHeight && offsetLeft === currentOffsetLeft && offsetTop === currentOffsetTop) {\n if (cb) {\n cb();\n }\n\n return;\n } //zsviczian\n\n\n if (width === 0 || height === 0) {\n if (cb) {\n cb();\n }\n\n return;\n }\n\n this.setState({\n width,\n height,\n offsetLeft,\n offsetTop\n }, () => {\n cb && cb();\n });\n }\n };\n\n this.refresh = () => {\n this.setState(Object.assign({}, this.getCanvasOffsets()));\n };\n\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_54__.getDefaultAppState)();\n const {\n excalidrawAPI,\n viewModeEnabled = false,\n zenModeEnabled = false,\n gridModeEnabled = false,\n objectsSnapModeEnabled = false,\n theme = defaultAppState.theme,\n initState,\n //zsviczian\n name = `${(0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getDateTime)()}`\n } = props;\n this.state = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultAppState), {\n theme,\n isLoading: true\n }), this.getCanvasOffsets()), {\n viewModeEnabled,\n zenModeEnabled,\n objectsSnapModeEnabled,\n gridModeEnabled: gridModeEnabled !== null && gridModeEnabled !== void 0 ? gridModeEnabled : defaultAppState.gridModeEnabled,\n name,\n width: window.innerWidth,\n height: window.innerHeight\n }), initState !== null && initState !== void 0 ? initState : {});\n this.id = (0,nanoid__WEBPACK_IMPORTED_MODULE_103__.nanoid)();\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_100__.initializeObsidianUtils)();\n this.library = new _data_library__WEBPACK_IMPORTED_MODULE_57__[\"default\"](this);\n this.actionManager = new _actions_manager__WEBPACK_IMPORTED_MODULE_49__.ActionManager(this.syncActionResult, () => this.state, () => this.scene.getElementsIncludingDeleted(), this);\n this.scene = new _excalidraw_element_Scene__WEBPACK_IMPORTED_MODULE_38__[\"default\"]();\n this.canvas = document.createElement(\"canvas\");\n this.rc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__[\"default\"].canvas(this.canvas);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_72__.Renderer(this.scene);\n this.visibleElements = [];\n this.store = new _store__WEBPACK_IMPORTED_MODULE_76__.Store();\n this.history = new _history__WEBPACK_IMPORTED_MODULE_60__.History();\n\n if (excalidrawAPI) {\n const api = {\n updateScene: this.updateScene,\n mutateElement: this.mutateElement,\n updateLibrary: this.library.updateLibrary,\n addFiles: this.addFiles,\n resetScene: this.resetScene,\n getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,\n history: {\n clear: this.resetHistory\n },\n scrollToContent: this.scrollToContent,\n setForceRenderAllEmbeddables: this.setForceRenderAllEmbeddables,\n zoomToFit: this.zoomToFit,\n getColorAtScenePoint: this.getColorAtScenePoint,\n startLineEditor: this.startLineEditor,\n getSceneElements: this.getSceneElements,\n getAppState: () => this.state,\n getFiles: () => this.files,\n getName: this.getName,\n registerAction: action => {\n this.actionManager.registerAction(action);\n },\n refresh: this.refresh,\n setToast: this.setToast,\n updateContainerSize: this.updateContainerSize,\n id: this.id,\n selectElements: this.selectElements,\n sendBackward: this.sendBackward,\n bringForward: this.bringForward,\n sendToBack: this.sendToBack,\n bringToFront: this.bringToFront,\n setMobileModeAllowed: this.setMobileModeAllowed,\n setActiveTool: this.setActiveTool,\n setCursor: this.setCursor,\n resetCursor: this.resetCursor,\n updateFrameRendering: this.updateFrameRendering,\n toggleSidebar: this.toggleSidebar,\n getHTMLIFrameElement: id => this.getHTMLIFrameElement(id),\n onChange: cb => this.onChangeEmitter.on(cb),\n onPointerDown: cb => this.onPointerDownEmitter.on(cb),\n onPointerUp: cb => this.onPointerUpEmitter.on(cb),\n onScrollChange: cb => this.onScrollChangeEmitter.on(cb),\n onUserFollow: cb => this.onUserFollowEmitter.on(cb)\n };\n\n if (typeof excalidrawAPI === \"function\") {\n excalidrawAPI(api);\n } else {\n console.error(\"excalidrawAPI should be a function!\");\n }\n }\n\n this.excalidrawContainerValue = {\n container: this.excalidrawContainerRef.current,\n id: this.id\n };\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_67__.Fonts(this.scene);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_60__.History();\n this.actionManager.registerAll(_actions_register__WEBPACK_IMPORTED_MODULE_50__.actions);\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_46__.createUndoAction)(this.history, this.store));\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_46__.createRedoAction)(this.history, this.store));\n }\n\n onWindowMessage(event) {\n if (event.origin !== \"https://player.vimeo.com\" && event.origin !== \"https://www.youtube.com\") {\n return;\n }\n\n let data = null;\n\n try {\n data = JSON.parse(event.data);\n } catch (e) {}\n\n if (!data) {\n return;\n }\n\n switch (event.origin) {\n case \"https://player.vimeo.com\":\n //Allowing for multiple instances of Excalidraw running in the window\n if (data.method === \"paused\") {\n let source = null;\n const iframes = document.body.querySelectorAll(\"iframe.excalidraw__embeddable\");\n\n if (!iframes) {\n break;\n }\n\n for (const iframe of iframes) {\n if (iframe.contentWindow === event.source) {\n source = iframe.contentWindow;\n }\n }\n\n source === null || source === void 0 ? void 0 : source.postMessage(JSON.stringify({\n method: data.value ? \"play\" : \"pause\",\n value: true\n }), \"*\");\n }\n\n break;\n\n case \"https://www.youtube.com\":\n if (data.event === \"infoDelivery\" && data.info && data.id && typeof data.info.playerState === \"number\") {\n const id = data.id;\n const playerState = data.info.playerState;\n\n if (Object.values(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES).includes(playerState)) {\n YOUTUBE_VIDEO_STATES.set(id, playerState);\n }\n }\n\n break;\n }\n }\n\n cacheEmbeddableRef(element, ref) {\n if (ref) {\n this.iFrameRefs.set(element.id, ref);\n }\n }\n\n getHTMLIFrameElement(element) {\n //zsviczian\n if (typeof element === \"string\") {\n return this.iFrameRefs.get(element);\n }\n\n return this.iFrameRefs.get(element.id);\n }\n\n handleEmbeddableCenterClick(element) {\n var _a, _b, _c, _d;\n\n if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) === element && ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"active\") {\n return;\n } // The delay serves two purposes\n // 1. To prevent first click propagating to iframe on mobile,\n // else the click will immediately start and stop the video\n // 2. If the user double clicks the frame center to activate it\n // without the delay youtube will immediately open the video\n // in fullscreen mode\n\n\n setTimeout(() => {\n this.setState({\n activeEmbeddable: {\n element,\n state: \"active\"\n },\n selectedElementIds: {\n [element.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n }, 100);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(element)) {\n return;\n }\n\n const iframe = this.getHTMLIFrameElement(element);\n\n if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {\n return;\n }\n\n if (iframe.src.includes(\"youtube\")) {\n const state = YOUTUBE_VIDEO_STATES.get(element.id);\n\n if (!state) {\n YOUTUBE_VIDEO_STATES.set(element.id, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES.UNSTARTED);\n iframe.contentWindow.postMessage(JSON.stringify({\n event: \"listening\",\n id: element.id\n }), \"*\");\n }\n\n switch (state) {\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES.PLAYING:\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES.BUFFERING:\n (_c = iframe.contentWindow) === null || _c === void 0 ? void 0 : _c.postMessage(JSON.stringify({\n event: \"command\",\n func: \"pauseVideo\",\n args: \"\"\n }), \"*\");\n break;\n\n default:\n (_d = iframe.contentWindow) === null || _d === void 0 ? void 0 : _d.postMessage(JSON.stringify({\n event: \"command\",\n func: \"playVideo\",\n args: \"\"\n }), \"*\");\n }\n }\n\n if (iframe.src.includes(\"player.vimeo.com\")) {\n iframe.contentWindow.postMessage(JSON.stringify({\n method: \"paused\" //video play/pause in onWindowMessage handler\n\n }), \"*\");\n }\n }\n\n isIframeLikeElementCenter(el, event, sceneX, sceneY) {\n var _a, _b;\n\n return el && !event.altKey && !event.shiftKey && !event.metaKey && !event.ctrlKey && (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) !== el || ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"hover\" || !this.state.activeEmbeddable) && sceneX >= el.x + el.width / 3 && sceneX <= el.x + 2 * el.width / 3 && sceneY >= el.y + el.height / 3 && sceneY <= el.y + 2 * el.height / 3;\n }\n\n renderEmbeddables() {\n const scale = this.state.zoom.value;\n const normalizedWidth = this.state.width;\n const normalizedHeight = this.state.height;\n const embeddableElements = this.scene.getNonDeletedElements().filter(el => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(el) && this.embedsValidationStatus.get(el.id) === true || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), null, embeddableElements.map(el => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: el.x,\n sceneY: el.y\n }, this.state); //zsviczian - shouldRenderAllEmbeddables\n\n const isVisible = this.shouldRenderAllEmbeddables || (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementInViewport)(el, normalizedWidth, normalizedHeight, this.state, this.scene.getNonDeletedElementsMap());\n const hasBeenInitialized = this.initializedEmbeds.has(el.id);\n\n if (isVisible && !hasBeenInitialized) {\n this.initializedEmbeds.add(el.id);\n }\n\n const shouldRender = isVisible || hasBeenInitialized;\n\n if (!shouldRender) {\n return null;\n }\n\n let src;\n const embedLink = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.toValidURL)(el.link || \"\")); //zsviczian\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el)) {\n src = null;\n const data = ((_b = (_a = el.customData) === null || _a === void 0 ? void 0 : _a.generationData) !== null && _b !== void 0 ? _b : this.magicGenerations.get(el.id)) || {\n status: \"error\",\n message: \"No generation data\",\n code: \"ERR_NO_GENERATION_DATA\"\n };\n\n if (data.status === \"done\") {\n const html = data.html;\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return html;\n }\n };\n } else if (data.status === \"pending\") {\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.createSrcDoc)(`\n <style>\n html, body {\n width: 100%;\n height: 100%;\n color: ${this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.DARK ? \"white\" : \"black\"};\n }\n body {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 1rem;\n }\n\n .Spinner {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n margin-right: auto;\n }\n\n .Spinner svg {\n animation: rotate 1.6s linear infinite;\n transform-origin: center center;\n width: 40px;\n height: 40px;\n }\n\n .Spinner circle {\n stroke: currentColor;\n animation: dash 1.6s linear 0s infinite;\n stroke-linecap: round;\n }\n\n @keyframes rotate {\n 100% {\n transform: rotate(360deg);\n }\n }\n\n @keyframes dash {\n 0% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 150, 300;\n stroke-dashoffset: -200;\n }\n 100% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: -280;\n }\n }\n </style>\n <div class=\"Spinner\">\n <svg\n viewBox=\"0 0 100 100\"\n >\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"46\"\n stroke-width=\"8\"\n fill=\"none\"\n stroke-miter-limit=\"10\"\n />\n </svg>\n </div>\n <div>Generating...</div>\n `);\n }\n };\n } else {\n let message;\n\n if (data.code === \"ERR_GENERATION_INTERRUPTED\") {\n message = \"Generation was interrupted...\";\n } else {\n message = data.message || \"Generation failed\";\n }\n\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.createSrcDoc)(`\n <style>\n html, body {\n height: 100%;\n }\n body {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: ${_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.COLOR_PALETTE.red[3]};\n }\n h1, h3 {\n margin-top: 0;\n margin-bottom: 0.5rem;\n }\n </style>\n <h1>Error!</h1>\n <h3>${message}</h3>\n `);\n }\n };\n }\n } else {\n src = embedLink; //zsviczian getEmbedLink(toValidURL(el.link || \"\"));\n }\n\n const isActive = ((_c = this.state.activeEmbeddable) === null || _c === void 0 ? void 0 : _c.element) === el && ((_d = this.state.activeEmbeddable) === null || _d === void 0 ? void 0 : _d.state) === \"active\";\n const isHovered = ((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.element) === el && ((_f = this.state.activeEmbeddable) === null || _f === void 0 ? void 0 : _f.state) === \"hover\";\n const isWebview = //zsviczian\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el) && this.props.renderWebview && (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) !== \"document\" && !((_h = (_g = embedLink === null || embedLink === void 0 ? void 0 : embedLink.link) === null || _g === void 0 ? void 0 : _g.startsWith) === null || _h === void 0 ? void 0 : _h.call(_g, \"https://player.vimeo.com\")); // Modify the scale based on el.scale property\n\n const [xScale, yScale] = (_j = el.scale) !== null && _j !== void 0 ? _j : [1, 1]; //zsviczian\n\n const scaledTransform = `scale(${scale * xScale}, ${scale * yScale})`;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n key: el.id,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw__embeddable-container\", {\n \"is-hovered\": isHovered\n }),\n style: {\n transform: isVisible ? `translate(${x - this.state.offsetLeft}px, ${y - this.state.offsetTop}px) ${scaledTransform}` : \"none\",\n display: isVisible ? \"block\" : \"none\",\n opacity: (0,_excalidraw_element_renderElement__WEBPACK_IMPORTED_MODULE_30__.getRenderOpacity)(el, (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getContainingFrame)(el, this.scene.getNonDeletedElementsMap()), this.elementsPendingErasure, null, ((_k = this.state.openDialog) === null || _k === void 0 ? void 0 : _k.name) === \"elementLinkSelector\" ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1),\n [\"--embeddable-radius\"]: `${(0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getCornerRadius)(Math.min(el.width, el.height), el) / xScale //zsviczian\n }px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n //this is a hack that addresses isse with embedded excalidraw.com embeddable\n //https://github.com/excalidraw/excalidraw/pull/6691#issuecomment-1607383938\n\n /*ref={(ref) => {\r\n if (!this.excalidrawContainerRef.current) {\r\n return;\r\n }\r\n const container = this.excalidrawContainerRef.current;\r\n const sh = container.scrollHeight;\r\n const ch = container.clientHeight;\r\n if (sh !== ch) {\r\n container.style.height = `${sh}px`;\r\n setTimeout(() => {\r\n container.style.height = `100%`;\r\n });\r\n }\r\n }}*/\n className: \"excalidraw__embeddable-container__inner\",\n style: {\n width: isVisible ? `${el.width / xScale}px` : 0,\n height: isVisible ? `${el.height / yScale}px` : 0,\n transform: isVisible ? `rotate(${el.angle}rad)` : \"none\",\n pointerEvents: isActive ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.enabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.disabled\n }\n }, isHovered && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable-hint\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"buttons.embeddableInteractionButton\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable__outer\",\n style: {\n padding: `${el.strokeWidth / (4 * el.scale[0])}px` //zsviczian MDEmbeddable round border cutoff issue\n\n }\n }, (_o = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(el) ? (_m = (_l = this.props).renderEmbeddable) === null || _m === void 0 ? void 0 : _m.call(_l, el, this.state) //zsviczian\n : null) !== null && _o !== void 0 ? _o : isWebview ?\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"webview\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n src: (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"generic\" || (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"video\" ? embedLink.link : \"\",\n title: \"Excalidraw Embedded Content\",\n allowFullScreen: true\n }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"iframe\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n srcDoc: (src === null || src === void 0 ? void 0 : src.type) === \"document\" ? src.srcdoc(this.state.theme) : undefined,\n src: (src === null || src === void 0 ? void 0 : src.type) !== \"document\" ? (_p = src === null || src === void 0 ? void 0 : src.link) !== null && _p !== void 0 ? _p : \"\" : undefined,\n // https://stackoverflow.com/q/18470015\n scrolling: \"no\",\n referrerPolicy: \"no-referrer-when-downgrade\",\n title: \"Excalidraw Embedded Content\",\n allow: \"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\",\n allowFullScreen: true,\n sandbox: `${((_q = src === null || src === void 0 ? void 0 : src.sandbox) === null || _q === void 0 ? void 0 : _q.allowSameOrigin) ? \"allow-same-origin\" : \"\"} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`\n }))));\n }));\n }\n\n toggleOverscrollBehavior(event) {\n // when pointer inside editor, disable overscroll behavior to prevent\n // panning to trigger history back/forward on MacOS Chrome\n document.documentElement.style.overscrollBehaviorX = event.type === \"pointerenter\" ? \"none\" : \"auto\";\n }\n\n render() {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n const {\n renderTopRightUI,\n renderCustomStats\n } = this.props;\n const sceneNonce = this.scene.getSceneNonce();\n const {\n elementsMap,\n visibleElements\n } = this.renderer.getRenderableElements({\n sceneNonce,\n zoom: this.state.zoom,\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n height: this.state.height,\n width: this.state.width,\n editingTextElement: this.state.editingTextElement,\n newElementId: (_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.id,\n pendingImageElementId: this.state.pendingImageElementId\n });\n this.visibleElements = visibleElements;\n const allElementsMap = this.scene.getNonDeletedElementsMap();\n const shouldBlockPointerEvents = // default back to `--ui-pointerEvents` flow if setPointerCapture\n // not supported\n \"setPointerCapture\" in HTMLElement.prototype ? false : this.state.selectionElement || this.state.newElement || this.state.selectedElementsAreBeingDragged || this.state.resizingElement || this.state.activeTool.type === \"laser\" && // technically we can just test on this once we make it more safe\n this.state.cursorButton === \"down\";\n const firstSelectedElement = selectedElements[0]; //zsviczian\n\n const isHighlighter = (_d = (_c = (_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.highlighter;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw excalidraw-container\", {\n \"excalidraw--view-mode\": this.state.viewModeEnabled || ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) === \"elementLinkSelector\",\n \"excalidraw--mobile\": this.device.editor.isMobile || !(this.state.viewModeEnabled || this.state.zenModeEnabled) && this.state.trayModeEnabled //zsviczian\n\n }),\n style: Object.assign(Object.assign({\n //zsviczian\n [\"--ui-pointerEvents\"]: shouldBlockPointerEvents ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.enabled\n }, this.state.dynamicStyle || {}), {\n [\"--right-sidebar-width\"]: \"302px\"\n }),\n ref: this.excalidrawContainerRef,\n onDrop: this.handleAppOnDrop,\n tabIndex: 0,\n onKeyDown: this.props.handleKeyboardGlobally ? undefined : this.onKeyDown,\n onPointerEnter: this.toggleOverscrollBehavior,\n onPointerLeave: this.toggleOverscrollBehavior\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppContext.Provider, {\n value: this\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppPropsContext.Provider, {\n value: this.props\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawContainerContext.Provider, {\n value: this.excalidrawContainerValue\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(DeviceContext.Provider, {\n value: this.device\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawSetAppStateContext.Provider, {\n value: this.setAppState\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawAppStateContext.Provider, {\n value: this.state\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawElementsContext.Provider, {\n value: this.scene.getNonDeletedElements()\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawActionManagerContext.Provider, {\n value: this.actionManager\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_LayerUI__WEBPACK_IMPORTED_MODULE_89__[\"default\"], {\n canvas: this.canvas,\n appState: this.state,\n files: this.files,\n setAppState: this.setAppState,\n actionManager: this.actionManager,\n elements: this.scene.getNonDeletedElements(),\n onLockToggle: this.toggleLock,\n onPenModeToggle: this.togglePenMode,\n onHandToolToggle: this.onHandToolToggle,\n langCode: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.getLanguage)().code,\n renderTopRightUI: renderTopRightUI,\n renderCustomStats: renderCustomStats,\n showExitZenModeBtn: typeof ((_f = this.props) === null || _f === void 0 ? void 0 : _f.zenModeEnabled) === \"undefined\" && this.state.zenModeEnabled,\n UIOptions: this.props.UIOptions,\n onExportImage: this.onExportImage,\n renderWelcomeScreen: !this.state.isLoading && this.state.showWelcomeScreen && this.state.activeTool.type === \"selection\" && !this.state.zenModeEnabled && !this.scene.getElementsIncludingDeleted().length,\n app: this,\n isCollaborating: this.props.isCollaborating,\n generateLinkForSelection: this.props.generateLinkForSelection\n }, this.props.children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-textEditorContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-contextMenuContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-eye-dropper-container\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_SVGLayer__WEBPACK_IMPORTED_MODULE_91__.SVGLayer, {\n trails: [this.laserTrails, this.lassoTrail, this.eraserTrail]\n }), selectedElements.length === 1 && ((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) !== \"elementLinkSelector\" && this.state.showHyperlinkPopup && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.Hyperlink, {\n key: firstSelectedElement.id,\n element: firstSelectedElement,\n scene: this.scene,\n setAppState: this.setAppState,\n onLinkOpen: this.props.onLinkOpen,\n setToast: this.setToast,\n updateEmbedValidationStatus: this.updateEmbedValidationStatus\n }), this.props.aiEnabled !== false && selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isMagicFrameElement)(firstSelectedElement) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_75__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_90__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.convertToCode\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_97__.MagicIcon,\n checked: false,\n onChange: () => this.onMagicFrameGenerate(firstSelectedElement, \"button\")\n })), selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(firstSelectedElement) && ((_j = (_h = firstSelectedElement.customData) === null || _h === void 0 ? void 0 : _h.generationData) === null || _j === void 0 ? void 0 : _j.status) === \"done\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_75__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_90__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.copySource\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_97__.copyIcon,\n checked: false,\n onChange: () => this.onIframeSrcCopy(firstSelectedElement)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_90__.ElementCanvasButton, {\n title: \"Enter fullscreen\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_97__.fullscreenIcon,\n checked: false,\n onChange: () => {\n const iframe = this.getHTMLIFrameElement(firstSelectedElement);\n\n if (iframe) {\n try {\n iframe.requestFullscreen();\n this.setState({\n activeEmbeddable: {\n element: firstSelectedElement,\n state: \"active\"\n },\n selectedElementIds: {\n [firstSelectedElement.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n } catch (err) {\n console.warn(err);\n this.setState({\n errorMessage: \"Couldn't enter fullscreen\"\n });\n }\n }\n }\n })), this.state.toast !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_Toast__WEBPACK_IMPORTED_MODULE_98__.Toast, {\n message: this.state.toast.message,\n onClose: () => this.setToast(null),\n duration: this.state.toast.duration,\n closable: this.state.toast.closable\n }), this.state.contextMenu && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ContextMenu__WEBPACK_IMPORTED_MODULE_86__.ContextMenu, {\n items: this.state.contextMenu.items,\n top: this.state.contextMenu.top,\n left: this.state.contextMenu.left,\n actionManager: this.actionManager,\n onClose: callback => {\n this.setState({\n contextMenu: null\n }, () => {\n this.focusContainer();\n callback === null || callback === void 0 ? void 0 : callback();\n });\n }\n }), this.state.newElement && isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_95__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_94__.StaticCanvas, {\n canvas: this.canvas,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n visibleElements: visibleElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_k = this.state.selectionElement) === null || _k === void 0 ? void 0 : _k.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isGridModeEnabled)(this),\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: this.flowChartCreator.pendingNodes,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), this.state.newElement && !isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_95__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_94__.InteractiveCanvas, {\n containerRef: this.excalidrawContainerRef,\n canvas: this.interactiveCanvas,\n elementsMap: elementsMap,\n visibleElements: visibleElements,\n allElementsMap: allElementsMap,\n selectedElements: selectedElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_l = this.state.selectionElement) === null || _l === void 0 ? void 0 : _l.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderScrollbars: this.props.renderScrollbars === true,\n device: this.device,\n renderInteractiveSceneCallback: this.renderInteractiveSceneCallback,\n handleCanvasRef: this.handleInteractiveCanvasRef,\n onContextMenu: this.handleCanvasContextMenu,\n onPointerMove: this.handleCanvasPointerMove,\n onPointerUp: this.handleCanvasPointerUp,\n onPointerCancel: this.removePointer,\n onTouchMove: this.handleTouchMove,\n onPointerDown: this.handleCanvasPointerDown,\n onDoubleClick: this.handleCanvasDoubleClick\n }), this.state.userToFollow && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_88__[\"default\"], {\n width: this.state.width,\n height: this.state.height,\n userToFollow: this.state.userToFollow,\n onDisconnect: this.maybeUnfollowRemoteUser\n }), this.renderFrameNames(), ((_m = this.state.activeEmbeddable) === null || _m === void 0 ? void 0 : _m.state) === \"active\" && ( //zsviczian\n (_p = (_o = this.props).renderEmbeddableMenu) === null || _p === void 0 ? void 0 : _p.call(_o, this.state))), this.renderEmbeddables()))))))));\n }\n\n setPlugins(plugins) {\n Object.assign(this.plugins, plugins);\n }\n\n async onMagicFrameGenerate(magicFrame, source) {\n var _a;\n\n const generateDiagramToCode = (_a = this.plugins.diagramToCode) === null || _a === void 0 ? void 0 : _a.generate;\n\n if (!generateDiagramToCode) {\n this.setState({\n errorMessage: \"No diagram to code plugin found\"\n });\n return;\n }\n\n const magicFrameChildren = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsOverlappingFrame)(this.scene.getNonDeletedElements(), magicFrame).filter(el => !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isMagicFrameElement)(el));\n\n if (!magicFrameChildren.length) {\n if (source === \"button\") {\n this.setState({\n errorMessage: \"Cannot generate from an empty frame\"\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (no-children)\", \"d2c\");\n } else {\n this.setActiveTool({\n type: \"magicframe\"\n });\n }\n\n return;\n }\n\n const frameElement = this.insertIframeElement({\n sceneX: magicFrame.x + magicFrame.width + 30,\n sceneY: magicFrame.y,\n width: magicFrame.width,\n height: magicFrame.height\n });\n\n if (!frameElement) {\n return;\n }\n\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"pending\"\n }\n });\n this.setState({\n selectedElementIds: {\n [frameElement.id]: true\n }\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (start)\", \"d2c\");\n\n try {\n const {\n html\n } = await generateDiagramToCode({\n frame: magicFrame,\n children: magicFrameChildren\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (success)\", \"d2c\");\n\n if (!html.trim()) {\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: \"Nothing genereated :(\"\n }\n });\n return;\n }\n\n const parsedHtml = html.includes(\"<!DOCTYPE html>\") && html.includes(\"</html>\") ? html.slice(html.indexOf(\"<!DOCTYPE html>\"), html.indexOf(\"</html>\") + \"</html>\".length) : html;\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"done\",\n html: parsedHtml\n }\n });\n } catch (error) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (failed)\", \"d2c\");\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: error.message || \"Unknown error during generation\"\n }\n });\n }\n }\n\n onIframeSrcCopy(element) {\n var _a, _b;\n\n if (((_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.generationData) === null || _b === void 0 ? void 0 : _b.status) === \"done\") {\n (0,_clipboard__WEBPACK_IMPORTED_MODULE_55__.copyTextToSystemClipboard)(element.customData.generationData.html);\n this.setToast({\n message: \"copied to clipboard\",\n closable: false,\n duration: 1500\n });\n }\n }\n\n clearImageShapeCache(filesMap) {\n const files = filesMap !== null && filesMap !== void 0 ? filesMap : this.files;\n this.scene.getNonDeletedElements().forEach(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(element) && files[element.fileId]) {\n this.imageCache.delete(element.fileId);\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element);\n }\n });\n }\n\n async componentDidMount() {\n var _a;\n\n this.unmounted = false;\n this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; //zsviczian disabling this code\n\n /*\r\n if (false && (isTestEnv() || isDevEnv())) {\r\n const setState = this.setState.bind(this);\r\n Object.defineProperties(window.h, {\r\n state: {\r\n configurable: true,\r\n get: () => {\r\n return this.state;\r\n },\r\n },\r\n setState: {\r\n configurable: true,\r\n value: (...args: Parameters<typeof setState>) => {\r\n return this.setState(...args);\r\n },\r\n },\r\n app: {\r\n configurable: true,\r\n value: this,\r\n },\r\n history: {\r\n configurable: true,\r\n value: this.history,\r\n },\r\n store: {\r\n configurable: true,\r\n value: this.store,\r\n },\r\n fonts: {\r\n configurable: true,\r\n value: this.fonts,\r\n },\r\n });\r\n }*/\n\n this.store.onStoreIncrementEmitter.on(increment => {\n this.history.record(increment.elementsChange, increment.appStateChange);\n });\n this.scene.onUpdate(this.triggerRender);\n this.addEventListeners();\n\n if (this.props.autoFocus && this.excalidrawContainerRef.current) {\n this.focusContainer();\n }\n\n if ( // bounding rects don't work in tests so updating\n // the state on init would result in making the test enviro run\n // in mobile breakpoint (0 width/height), making everything fail\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isTestEnv)()) {\n this.refreshViewportBreakpoints();\n this.refreshEditorBreakpoints();\n }\n\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.supportsResizeObserver && this.excalidrawContainerRef.current) {\n this.resizeObserver = new ResizeObserver(() => {\n this.refreshEditorBreakpoints();\n this.updateDOMRect();\n });\n (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.excalidrawContainerRef.current);\n }\n\n const searchParams = new URLSearchParams(window.location.search.slice(1));\n\n if (searchParams.has(\"web-share-target\")) {\n // Obtain a file that was shared via the Web Share Target API.\n this.restoreFileFromShare();\n } else {\n this.updateDOMRect(this.initializeScene);\n } // note that this check seems to always pass in localhost\n\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isBrave)() && !(0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.isMeasureTextSupported)()) {\n this.setState({\n errorMessage: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_85__[\"default\"], null)\n });\n }\n }\n\n componentWillUnmount() {\n var _a, _b;\n\n (_a = window.launchQueue) === null || _a === void 0 ? void 0 : _a.setConsumer(() => {});\n this.renderer.destroy();\n this.scene.destroy();\n this.scene = new _excalidraw_element_Scene__WEBPACK_IMPORTED_MODULE_38__[\"default\"]();\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_67__.Fonts(this.scene);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_72__.Renderer(this.scene);\n this.files = {};\n this.imageCache.clear();\n (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n this.unmounted = true;\n this.removeEventListeners();\n this.library.destroy();\n this.laserTrails.stop();\n this.eraserTrail.stop();\n this.onChangeEmitter.clear();\n this.store.onStoreIncrementEmitter.clear();\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.destroy();\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.destroy();\n clearTimeout(touchTimeout);\n _scene__WEBPACK_IMPORTED_MODULE_62__.isSomeElementSelected.clearCache();\n _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements.clearCache();\n touchTimeout = 0;\n document.documentElement.style.overscrollBehaviorX = \"\";\n document.body.removeChild((0,_Tooltip__WEBPACK_IMPORTED_MODULE_101__.getTooltipDiv)()); //clearRenderCache(); //zsviczian\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.clearEraserCanvasCache)(); //zsviczian\n\n this.interactiveCanvas = null; //zsviczian\n\n this.iFrameRefs.clear(); //zsviczian\n //@ts-ignore\n\n this.iFrameRefs = null; //zsviczian\n\n this.embedsValidationStatus.clear(); //zsviczian\n //@ts-ignore\n\n this.embedsValidationStatus = null; //zsviczian\n\n this.initializedEmbeds.clear(); //zsviczian\n //@ts-ignore\n\n this.initializedEmbeds = null; //zsviczian\n\n this.elementsPendingErasure.clear(); //zsviczian\n //@ts-ignore\n\n this.elementsPendingErasure = null; //zsviczian\n\n this.lastPointerDownEvent = null; //zsviczian\n\n this.lastPointerUpEvent = null; //zsviczian\n\n this.lastPointerMoveEvent = null; //zsviczian\n //@ts-ignore\n\n this.actionManager.app = null; //zsviczian\n\n this.actionManager.actions = {}; //zsviczian\n\n this.history.clear(); //zsviczian\n\n this.store.clear(); //zsviczian\n //@ts-ignore\n\n this.store = null; //zsviczian\n //@ts-ignore\n\n this.library = null; //zsviczian\n //@ts-ignore\n\n this.canvas = null; //zsviczian\n //@ts-ignore\n\n this.rc = null; //zsviczian\n //@ts-ignore\n\n this.excalidrawContainerRef.current = undefined; //zsviczian\n\n this.nearestScrollableContainer = undefined; //zsviczian\n\n this.excalidrawContainerValue = {\n container: null,\n id: \"unknown\"\n }; //zsviczian\n //@ts-ignore\n // this.laserTrails.terminate(); //zsviczian\n // this.eraserTrail.terminate(); //zsviczian\n\n /*\r\n Object.keys(this).forEach((key) => {\r\n //@ts-ignore\r\n delete this[key];\r\n });*/\n }\n\n removeEventListeners() {\n this.onRemoveEventListenersEmitter.trigger();\n }\n\n addEventListeners() {\n // remove first as we can add event listeners multiple times\n this.removeEventListeners(); // -------------------------------------------------------------------------\n // view+edit mode listeners\n // -------------------------------------------------------------------------\n\n if (this.props.handleKeyboardGlobally) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYDOWN, this.onKeyDown, false));\n }\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.MESSAGE, this.onWindowMessage, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, this.removePointer, {\n passive: false\n }), // #3553\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.COPY, this.onCopy, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYUP, this.onKeyUp, {\n passive: true\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, \"focus\", () => this.triggerRender(true), {\n passive: true\n }), //zsviczian\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, this.updateCurrentCursorPosition, {\n passive: false\n }), // rerender text elements on font load to fix #637 && #1553\n // zsviczian In Obsidian this is not needed as I manage font load separately\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document.fonts, \"loadingdone\", event => {\n const fontFaces = event.fontfaces;\n this.fonts.onLoaded(fontFaces);\n }, {\n passive: false\n }), // Safari-only desktop pinch zoom\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.GESTURE_START, this.onGestureStart, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.GESTURE_CHANGE, this.onGestureChange, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.GESTURE_END, this.onGestureEnd, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.FOCUS, () => {\n this.maybeCleanupAfterMissingPointerUp(null); // browsers (chrome?) tend to free up memory a lot, which results\n // in canvas context being cleared. Thus re-render on focus.\n\n this.triggerRender(true);\n }, {\n passive: false\n }));\n\n if (this.state.viewModeEnabled) {\n return;\n } // -------------------------------------------------------------------------\n // edit-mode listeners only\n // -------------------------------------------------------------------------\n\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.FULLSCREENCHANGE, this.onFullscreenChange, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, this.pasteFromClipboard, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.CUT, this.onCut, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.RESIZE, this.onResize, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.UNLOAD, this.onUnload, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.BLUR, this.onBlur, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.DRAG_OVER, this.disableEvent, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.DROP, this.disableEvent, false));\n\n if (this.props.detectScroll) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getNearestScrollableContainer)(this.excalidrawContainerRef.current), _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.SCROLL, this.onScroll, {\n passive: false\n }));\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;\n\n this.updateEmbeddables();\n const elements = this.scene.getElementsIncludingDeleted();\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n const nonDeletedElementsMap = this.scene.getNonDeletedElementsMap();\n\n if (!this.state.showWelcomeScreen && !elements.length) {\n this.setState({\n showWelcomeScreen: true\n });\n }\n\n if (prevProps.UIOptions.dockedSidebarBreakpoint !== this.props.UIOptions.dockedSidebarBreakpoint) {\n this.refreshEditorBreakpoints();\n }\n\n const hasFollowedPersonLeft = prevState.userToFollow && !this.state.collaborators.has(prevState.userToFollow.socketId);\n\n if (hasFollowedPersonLeft) {\n this.maybeUnfollowRemoteUser();\n }\n\n if (prevState.zoom.value !== this.state.zoom.value || prevState.scrollX !== this.state.scrollX || prevState.scrollY !== this.state.scrollY) {\n (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.onScrollChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.scrollX, this.state.scrollY, this.state.zoom);\n this.onScrollChangeEmitter.trigger(this.state.scrollX, this.state.scrollY, this.state.zoom);\n }\n\n if (prevState.userToFollow !== this.state.userToFollow) {\n if (prevState.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: prevState.userToFollow,\n action: \"UNFOLLOW\"\n });\n }\n\n if (this.state.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: this.state.userToFollow,\n action: \"FOLLOW\"\n });\n }\n } // zsviczian\n\n\n if (this.state.highlightSearchResult && !this.debounceClearHighlightSearchResults && prevState.selectedElementIds !== this.state.selectedElementIds) {\n this.setState({\n highlightSearchResult: false\n });\n }\n\n if (Object.keys(this.state.selectedElementIds).length && (0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n }\n\n if (this.state.activeTool.type === \"eraser\" && prevState.theme !== this.state.theme) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setEraserCursor)(this.interactiveCanvas, this.state.theme);\n } // Hide hyperlink popup if shown when element type is not selection\n\n\n if (prevState.activeTool.type === \"selection\" && this.state.activeTool.type !== \"selection\" && this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: false\n });\n }\n\n if (prevProps.langCode !== this.props.langCode) {\n this.updateLanguage();\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(prevState) && !(0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.eraserTrail.endPath();\n }\n\n if (prevProps.viewModeEnabled !== this.props.viewModeEnabled) {\n this.setState({\n viewModeEnabled: !!this.props.viewModeEnabled\n });\n }\n\n if (prevState.viewModeEnabled !== this.state.viewModeEnabled) {\n this.addEventListeners();\n this.deselectElements();\n } // cleanup\n\n\n if ((((_c = prevState.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" || ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) === \"elementLinkSelector\") && ((_e = prevState.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name)) {\n this.deselectElements();\n this.setState({\n hoveredElementIds: {}\n });\n }\n\n if (prevProps.zenModeEnabled !== this.props.zenModeEnabled) {\n this.setState({\n zenModeEnabled: !!this.props.zenModeEnabled\n });\n }\n\n if (prevProps.theme !== this.props.theme && this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n (_g = this.excalidrawContainerRef.current) === null || _g === void 0 ? void 0 : _g.classList.toggle(\"theme--dark\", this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.DARK);\n\n if (this.state.editingLinearElement && !this.state.selectedElementIds[this.state.editingLinearElement.elementId]) {\n // defer so that the shouldCaptureIncrement flag isn't reset via current update\n setTimeout(() => {\n // execute only if the condition still holds when the deferred callback\n // executes (it can be scheduled multiple times depending on how\n // many times the component renders)\n this.state.editingLinearElement && this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n } // failsafe in case the state is being updated in incorrect order resulting\n // in the editingTextElement being now a deleted element\n\n\n if ((_h = this.state.editingTextElement) === null || _h === void 0 ? void 0 : _h.isDeleted) {\n this.setState({\n editingTextElement: null\n });\n }\n\n if (this.state.selectedLinearElement && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // To make sure `selectedLinearElement` is in sync with `selectedElementIds`, however this shouldn't be needed once\n // we have a single API to update `selectedElementIds`\n this.setState({\n selectedLinearElement: null\n });\n }\n\n const {\n multiElement\n } = prevState;\n\n if (prevState.activeTool !== this.state.activeTool && multiElement != null && (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(multiElement, false)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.maybeBindLinearElement)(multiElement, this.state, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)(_excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getPointAtIndexGlobalCoordinates(multiElement, -1, nonDeletedElementsMap)), this.scene);\n }\n\n this.store.commit(elementsMap, this.state); // Do not notify consumers if we're still loading the scene. Among other\n // potential issues, this fixes a case where the tab isn't focused during\n // init, which would trigger onChange with empty elements, which would then\n // override whatever is in localStorage currently.\n\n if (!this.state.isLoading) {\n (_k = (_j = this.props).onChange) === null || _k === void 0 ? void 0 : _k.call(_j, elements, this.state, this.files);\n this.onChangeEmitter.trigger(elements, this.state, this.files);\n }\n }\n\n static resetTapTwice() {\n didTapTwice = false;\n } // TODO rewrite this to paste both text & images at the same time if\n // pasted data contains both\n\n\n async addElementsFromMixedContentPaste(mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n }) {\n if (!isPlainPaste && mixedContent.some(node => node.type === \"imageUrl\") && this.isToolSupported(\"image\")) {\n const imageURLs = mixedContent.filter(node => node.type === \"imageUrl\").map(node => node.value);\n const responses = await Promise.all(imageURLs.map(async url => {\n try {\n return {\n file: await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.ImageURLToFile)(url)\n };\n } catch (error) {\n let errorMessage = error.message;\n\n if (error.cause === \"FETCH_ERROR\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.failedToFetchImage\");\n } else if (error.cause === \"UNSUPPORTED\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.unsupportedFileType\");\n }\n\n return {\n errorMessage\n };\n }\n }));\n let y = sceneY;\n let firstImageYOffsetDone = false;\n const nextSelectedIds = {};\n\n for (const response of responses) {\n if (response.file) {\n const imageElement = this.createImageElement({\n sceneX,\n sceneY: y\n });\n const initializedImageElement = await this.insertImageElement(imageElement, response.file);\n\n if (initializedImageElement) {\n // vertically center first image in the batch\n if (!firstImageYOffsetDone) {\n firstImageYOffsetDone = true;\n y -= initializedImageElement.height / 2;\n } // hack to reset the `y` coord because we vertically center during\n // insertImageElement\n\n\n this.scene.mutateElement(initializedImageElement, {\n y\n }, {\n informMutation: false,\n isDragging: false\n });\n y = imageElement.y + imageElement.height + 25;\n nextSelectedIds[imageElement.id] = true;\n }\n }\n }\n\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedIds, this.state)\n });\n const error = responses.find(response => !!response.errorMessage);\n\n if (error && error.errorMessage) {\n this.setState({\n errorMessage: error.errorMessage\n });\n }\n } else {\n const textNodes = mixedContent.filter(node => node.type === \"text\");\n\n if (textNodes.length) {\n this.addTextFromPaste(textNodes.map(node => node.value).join(\"\\n\\n\"), isPlainPaste);\n }\n }\n }\n\n addTextFromPaste(text, isPlainPaste = false) {\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state);\n const textElementProps = {\n x,\n y,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roundness: null,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text,\n rawText: text,\n fontSize: (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_102__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value),\n fontFamily: this.state.currentItemFontFamily,\n textAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_TEXT_ALIGN,\n verticalAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_VERTICAL_ALIGN,\n locked: false\n };\n const fontString = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getFontString)({\n fontSize: textElementProps.fontSize,\n fontFamily: textElementProps.fontFamily\n });\n const lineHeight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getLineHeight)(textElementProps.fontFamily);\n const [x1,, x2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getVisibleSceneBounds)(this.state); // long texts should not go beyond 800 pixels in width nor should it go below 200 px\n\n const maxTextWidth = Math.max(Math.min((x2 - x1) * 0.5, 800), 200);\n const LINE_GAP = 10;\n let currentY = y;\n const lines = isPlainPaste ? [text] : text.split(\"\\n\");\n const textElements = lines.reduce((acc, line, idx) => {\n var _a;\n\n const originalText = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.normalizeText)(line).trim();\n\n if (originalText.length) {\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y: currentY\n });\n let metrics = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.measureText)(originalText, fontString, lineHeight);\n const isTextUnwrapped = metrics.width > maxTextWidth;\n const text = isTextUnwrapped ? (0,_excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_26__.wrapText)(originalText, fontString, maxTextWidth) : originalText;\n metrics = isTextUnwrapped ? (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.measureText)(text, fontString, lineHeight) : metrics;\n const startX = x - metrics.width / 2;\n const startY = currentY - metrics.height / 2;\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newTextElement)(Object.assign(Object.assign({}, textElementProps), {\n x: startX,\n y: startY,\n text,\n rawText: originalText,\n //zsviczian\n originalText,\n lineHeight,\n autoResize: !isTextUnwrapped,\n frameId: topLayerFrame ? topLayerFrame.id : null\n }));\n acc.push(element);\n currentY += element.height + LINE_GAP;\n } else {\n const prevLine = (_a = lines[idx - 1]) === null || _a === void 0 ? void 0 : _a.trim(); // add paragraph only if previous line was not empty, IOW don't add\n // more than one empty line\n\n if (prevLine) {\n currentY += (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getLineHeightInPx)(textElementProps.fontSize, lineHeight) + LINE_GAP;\n }\n }\n\n return acc;\n }, []);\n\n if (textElements.length === 0) {\n return;\n }\n\n this.scene.insertElements(textElements);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.fromEntries(textElements.map(el => [el.id, true])), this.state)\n });\n\n if (!isPlainPaste && textElements.length > 1 && PLAIN_PASTE_TOAST_SHOWN === false && !this.device.editor.isMobile) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"toast.pasteAsSingleElement\", {\n shortcut: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")\n }),\n duration: 5000\n });\n PLAIN_PASTE_TOAST_SHOWN = true;\n }\n\n this.store.shouldCaptureIncrement();\n }\n\n handleTextWysiwyg(element, {\n isExistingElement = false\n }) {\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n const updateElement = (nextOriginalText, isDeleted, rawText, //zsviczian\n link) => {\n this.scene.replaceAllElements([// Not sure why we include deleted elements as well hence using deleted elements map\n ...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(_element)) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(_element, Object.assign({\n originalText: nextOriginalText,\n rawText: rawText !== null && rawText !== void 0 ? rawText : nextOriginalText,\n //zsviczian\n link,\n isDeleted: isDeleted !== null && isDeleted !== void 0 ? isDeleted : _element.isDeleted\n }, (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.refreshTextDimensions)(_element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText)));\n }\n\n return _element;\n })]);\n }; //zsviczian\n\n\n if (this.props.onBeforeTextEdit) {\n const text = this.props.onBeforeTextEdit(element, isExistingElement);\n\n if (text && text !== element.originalText) {\n this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(_element)) {\n //changing the value of element so this gets edited by textWysiwyg\n element = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(_element, Object.assign({\n originalText: text,\n rawText: text,\n isDeleted: false\n }, (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.refreshTextDimensions)(_element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(_element, elementsMap), elementsMap, text)));\n return element;\n }\n\n return _element;\n })]);\n }\n }\n\n (0,_wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_79__.textWysiwyg)({\n id: element.id,\n canvas: this.canvas,\n getViewportCoords: (x, y) => {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: x,\n sceneY: y\n }, this.state);\n return [viewportX - this.state.offsetLeft, viewportY - this.state.offsetTop];\n },\n onChange: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(nextOriginalText => {\n updateElement(nextOriginalText, false);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_37__.isNonDeletedElement)(element)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.updateBoundElements)(element, this.scene);\n }\n }),\n onSubmit: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(({\n viaKeyboard,\n nextOriginalText\n }) => {\n var _a;\n\n const isDeleted = !nextOriginalText.trim(); //zsviczian insert start\n\n const rawText = nextOriginalText; //should this be originalText??\n\n let link = undefined;\n\n if (this.props.onBeforeTextSubmit) {\n const _element = this.scene.getElementsIncludingDeleted().find(el => el.id === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(el));\n\n if (_element) {\n const dismensionsData = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.refreshTextDimensions)(_element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText);\n const {\n updatedNextOriginalText,\n nextLink\n } = this.props.onBeforeTextSubmit(element, (_a = dismensionsData === null || dismensionsData === void 0 ? void 0 : dismensionsData.text) !== null && _a !== void 0 ? _a : nextOriginalText, //should never be undefined\n nextOriginalText, isDeleted);\n nextOriginalText = updatedNextOriginalText !== null && updatedNextOriginalText !== void 0 ? updatedNextOriginalText : nextOriginalText;\n link = nextLink;\n }\n } //zsviczian insert end\n\n\n updateElement(nextOriginalText, isDeleted, rawText, link); //zsviczian (added rawText, link, text)\n // select the created text element only if submitting via keyboard\n // (when submitting via click it should act as signal to deselect)\n\n if (!isDeleted && viaKeyboard) {\n const elementIdToSelect = element.containerId ? element.containerId : element.id; // needed to ensure state is updated before \"finalize\" action\n // that's invoked on keyboard-submit as well\n // TODO either move this into finalize as well, or handle all state\n // updates in one place, skipping finalize action\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [elementIdToSelect]: true\n }), prevState)\n }));\n });\n }\n\n if (isDeleted) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.fixBindingsAfterDeletion)(this.scene.getNonDeletedElements(), [element]);\n }\n\n if (!isDeleted || isExistingElement) {\n this.store.shouldCaptureIncrement();\n }\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n newElement: null,\n editingTextElement: null\n });\n });\n\n if (this.state.activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.focusContainer();\n }),\n element,\n excalidrawContainer: this.excalidrawContainerRef.current,\n app: this,\n // when text is selected, it's hard (at least on iOS) to re-position the\n // caret (i.e. deselect). There's not much use for always selecting\n // the text on edit anyway (and users can select-all from contextmenu\n // if needed)\n autoSelect: !this.device.isTouchScreen\n }); // deselect all other elements when inserting text\n\n this.deselectElements(); // do an initial update to re-initialize element position since we were\n // modifying element's x/y for sake of editor (case: syncing to remote)\n\n updateElement(element.originalText, false);\n }\n\n deselectElements() {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n getTextElementAtPosition(x, y) {\n const element = this.getElementAtPosition(x, y, {\n includeBoundTextElement: true\n });\n\n if (element && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element) && !element.isDeleted) {\n return element;\n }\n\n return null;\n }\n\n getElementAtPosition(x, y, opts) {\n const allHitElements = this.getElementsAtPosition(x, y, opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement, opts === null || opts === void 0 ? void 0 : opts.includeLockedElements);\n\n if (allHitElements.length > 1) {\n if (opts === null || opts === void 0 ? void 0 : opts.preferSelected) {\n for (let index = allHitElements.length - 1; index > -1; index--) {\n if (this.state.selectedElementIds[allHitElements[index].id]) {\n return allHitElements[index];\n }\n }\n }\n\n const elementWithHighestZIndex = allHitElements[allHitElements.length - 1]; // If we're hitting element with highest z-index only on its bounding box\n // while also hitting other element figure, the latter should be considered.\n\n return (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x,\n y,\n element: elementWithHighestZIndex,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(elementWithHighestZIndex, this.scene.getNonDeletedElementsMap()),\n // when overlapping, we would like to be more precise\n // this also avoids the need to update past tests\n threshold: this.getElementHitThreshold() / 2,\n frameNameBound: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(elementWithHighestZIndex) ? this.frameNameBoundsCache.get(elementWithHighestZIndex) : null\n }) ? elementWithHighestZIndex : allHitElements[allHitElements.length - 2];\n }\n\n if (allHitElements.length === 1) {\n return allHitElements[0];\n }\n\n return null;\n }\n\n getElementsAtPosition(x, y, includeBoundTextElement = false, includeLockedElements = false) {\n const iframeLikes = [];\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const elements = (includeBoundTextElement && includeLockedElements ? this.scene.getNonDeletedElements() : this.scene.getNonDeletedElements().filter(element => (includeLockedElements || !element.locked) && (includeBoundTextElement || !((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element) && element.containerId)))).filter(el => this.hitElement(x, y, el)).filter(element => {\n // hitting a frame's element from outside the frame is not considered a hit\n const containingFrame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getContainingFrame)(element, elementsMap);\n return containingFrame && this.state.frameRendering.enabled && this.state.frameRendering.clip ? (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isCursorInFrame)({\n x,\n y\n }, containingFrame, elementsMap) : true;\n }).filter(el => {\n // The parameter elements comes ordered from lower z-index to higher.\n // We want to preserve that order on the returned array.\n // Exception being embeddables which should be on top of everything else in\n // terms of hit testing.\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el)) {\n iframeLikes.push(el);\n return false;\n }\n\n return true;\n }).concat(iframeLikes);\n return elements;\n }\n\n getElementHitThreshold() {\n return _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value;\n }\n\n hitElement(x, y, element, considerBoundingBox = true) {\n // if the element is selected, then hit test is done against its bounding box\n if (considerBoundingBox && this.state.selectedElementIds[element.id] && (0,_excalidraw_element_transformHandles__WEBPACK_IMPORTED_MODULE_21__.shouldShowBoundingBox)([element], this.state)) {\n const selectionShape = (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_7__.getSelectionBoxShape)(element, this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(element) ? 0 : this.getElementHitThreshold()); // if hitting the bounding box, return early\n // but if not, we should check for other cases as well (e.g. frame name)\n\n if ((0,_excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_6__.isPointInShape)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), selectionShape)) {\n return true;\n }\n } // take bound text element into consideration for hit collision as well\n\n\n const hitBoundTextOfElement = (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementBoundText)(x, y, (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getBoundTextShape)(element, this.scene.getNonDeletedElementsMap()));\n\n if (hitBoundTextOfElement) {\n return true;\n }\n\n return (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x,\n y,\n element,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(element, this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold(),\n frameNameBound: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element) ? this.frameNameBoundsCache.get(element) : null\n });\n }\n\n getTextBindableContainerAtPosition(x, y) {\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextBindableContainer)(selectedElements[0], false) ? selectedElements[0] : null;\n }\n\n let hitElement = null; // We need to do hit testing from front (end of the array) to back (beginning of the array)\n\n for (let index = elements.length - 1; index >= 0; --index) {\n if (elements[index].isDeleted) {\n continue;\n }\n\n const [x1, y1, x2, y2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getElementAbsoluteCoords)(elements[index], this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isArrowElement)(elements[index]) && (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x,\n y,\n element: elements[index],\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(elements[index], this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold()\n })) {\n hitElement = elements[index];\n break;\n } else if (x1 < x && x < x2 && y1 < y && y < y2) {\n hitElement = elements[index];\n break;\n }\n }\n\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextBindableContainer)(hitElement, false) ? hitElement : null;\n }\n\n handleHoverSelectedLinearElement(linearElementEditor, scenePointerX, scenePointerY) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const element = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (!element) {\n return;\n }\n\n if (this.state.selectedLinearElement) {\n let hoverPointIndex = -1;\n let segmentMidPointHoveredCoords = null;\n\n if ((0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x: scenePointerX,\n y: scenePointerY,\n element,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(element, this.scene.getNonDeletedElementsMap())\n })) {\n hoverPointIndex = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getPointIndexUnderCursor(element, elementsMap, this.state.zoom, scenePointerX, scenePointerY);\n segmentMidPointHoveredCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, {\n x: scenePointerX,\n y: scenePointerY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const isHoveringAPointHandle = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element) ? hoverPointIndex === 0 || hoverPointIndex === element.points.length - 1 : hoverPointIndex >= 0;\n\n if (isHoveringAPointHandle || segmentMidPointHoveredCoords) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE);\n }\n }\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE);\n }\n }\n\n if (this.state.selectedLinearElement.hoverPointIndex !== hoverPointIndex) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n hoverPointIndex\n })\n });\n }\n\n if (!_excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords, segmentMidPointHoveredCoords)) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords\n })\n });\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n }\n }\n\n updateGestureOnPointerDown(event) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n\n if (gesture.pointers.size === 2) {\n gesture.lastCenter = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getCenter)(gesture.pointers);\n gesture.initialScale = this.state.zoom.value;\n gesture.initialDistance = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getDistance)(Array.from(gesture.pointers.values()));\n }\n }\n\n initialPointerDownState(event) {\n const origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const selectedElements = this.scene.getSelectedElements(this.state);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements);\n const isElbowArrowOnly = selectedElements.findIndex(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow) === 0;\n return {\n origin,\n withCmdOrCtrl: event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD],\n originInGrid: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(origin.x, origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] || isElbowArrowOnly ? null : this.getEffectiveGridSize())),\n scrollbars: (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_80__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop),\n // we need to duplicate because we'll be updating this state\n lastCoords: Object.assign({}, origin),\n originalElements: this.scene.getNonDeletedElements().reduce((acc, element) => {\n acc.set(element.id, (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.deepCopyElement)(element));\n return acc;\n }, new Map()),\n resize: {\n handleType: false,\n isResizing: false,\n offset: {\n x: 0,\n y: 0\n },\n arrowDirection: \"origin\",\n center: {\n x: (maxX + minX) / 2,\n y: (maxY + minY) / 2\n }\n },\n hit: {\n element: null,\n allHitElements: [],\n wasAddedToSelection: false,\n hasBeenDuplicated: false,\n hasHitCommonBoundingBoxOfSelectedElements: this.isHittingCommonBoundingBoxOfSelectedElements(origin, selectedElements)\n },\n drag: {\n hasOccurred: false,\n offset: null,\n origin: Object.assign({}, origin)\n },\n eventListeners: {\n onMove: null,\n onUp: null,\n onKeyUp: null,\n onKeyDown: null\n },\n boxSelection: {\n hasOccurred: false\n }\n };\n } // Returns whether the event is a dragging a scrollbar\n\n\n handleDraggingScrollBar(event, pointerDownState) {\n if (!(pointerDownState.scrollbars.isOverEither && !this.state.multiElement)) {\n return false;\n }\n\n isDraggingScrollBar = true;\n pointerDownState.lastCoords.x = event.clientX;\n pointerDownState.lastCoords.y = event.clientY;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdatesThrottled)(event => {\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n this.handlePointerMoveOverScrollbars(event, pointerDownState);\n });\n const onPointerUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(() => {\n lastPointerUp = null;\n isDraggingScrollBar = false;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp);\n onPointerMove.flush();\n });\n lastPointerUp = onPointerUp;\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp);\n return true;\n }\n\n isASelectedElement(hitElement) {\n return hitElement != null && this.state.selectedElementIds[hitElement.id];\n }\n\n isHittingCommonBoundingBoxOfSelectedElements(point, selectedElements) {\n if (selectedElements.length < 2) {\n return false;\n } // How many pixels off the shape boundary we still consider a hit\n\n\n const threshold = this.getElementHitThreshold();\n const [x1, y1, x2, y2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements);\n return point.x > x1 - threshold && point.x < x2 + threshold && point.y > y1 - threshold && point.y < y2 + threshold;\n }\n\n getCurrentItemRoundness(elementType) {\n return this.state.currentItemRoundness === \"round\" ? {\n type: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isUsingAdaptiveRadius)(elementType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null;\n }\n\n maybeCacheReferenceSnapPoints(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.getReferenceSnapPoints())) {\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setReferenceSnapPoints((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.getReferenceSnapPoints)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n maybeCacheVisibleGaps(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.getVisibleGaps())) {\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setVisibleGaps((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.getVisibleGaps)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n onKeyDownFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onKeyUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n // Prevents focus from escaping excalidraw tab\n event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ALT && event.preventDefault();\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onPointerMoveFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdatesThrottled)(event => {\n var _a, _b, _c, _d, _e, _f, _g; //To avoid pointerMove canceling the selection of locked elements on mobile //zsviczian\n\n\n if (Boolean(this.state.contextMenu) || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n return;\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.elbowed && this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n let index = this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;\n\n if (index < 0) {\n const nextCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: gridX,\n y: gridY\n }, this.state, this.scene.getNonDeletedElementsMap());\n index = nextCoords ? _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : -1;\n }\n\n const ret = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.moveFixedSegment(this.state.selectedLinearElement, index, gridX, gridY, this.scene);\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: ret.segmentMidPointHoveredCoords,\n pointerDownState: ret.pointerDownState\n })\n });\n }\n });\n return;\n }\n\n const lastPointerCoords = (_b = this.lastPointerMoveCoords) !== null && _b !== void 0 ? _b : pointerDownState.origin;\n this.lastPointerMoveCoords = pointerCoords; // We need to initialize dragOffsetXY only after we've updated\n // `state.selectedElementIds` on pointerDown. Doing it here in pointerMove\n // event handler should hopefully ensure we're already working with\n // the updated state.\n\n if (pointerDownState.drag.offset === null) {\n pointerDownState.drag.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)((0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.getDragOffsetXY)(this.scene.getSelectedElements(this.state), pointerDownState.origin.x, pointerDownState.origin.y));\n }\n\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n if (this.handlePointerMoveOverScrollbars(event, pointerDownState)) {\n return;\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.handleEraser(event, pointerCoords);\n return;\n }\n\n if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.addPointToPath(pointerCoords.x, pointerCoords.y);\n }\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize()); // for arrows/lines, don't start dragging until a given threshold\n // to ensure we don't create a 2-point arrow by mistake when\n // user clicks mouse in a way that it moves a tiny bit (thus\n // triggering pointermove)\n\n if (!pointerDownState.drag.hasOccurred && (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\")) {\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD) {\n return;\n }\n }\n\n if (pointerDownState.resize.isResizing) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (this.maybeHandleCrop(pointerDownState, event)) {\n return true;\n }\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return true;\n }\n }\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.editingLinearElement || this.state.selectedLinearElement;\n\n if (_excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.shouldAddMidpoint(this.state.selectedLinearElement, pointerCoords, this.state, elementsMap)) {\n const ret = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.addMidpoint(this.state.selectedLinearElement, pointerCoords, this, !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD], this.scene);\n\n if (!ret) {\n return;\n } // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n\n if (this.state.editingLinearElement) {\n this.setState({\n editingLinearElement: Object.assign(Object.assign({}, this.state.editingLinearElement), {\n pointerDownState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n });\n return;\n } else if (linearElementEditor.pointerDownState.segmentMidpoint.value !== null && !linearElementEditor.pointerDownState.segmentMidpoint.added) {\n return;\n }\n\n const newLinearElementEditor = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointDragging(event, this, pointerCoords.x, pointerCoords.y, (element, pointsSceneCoords) => {\n this.maybeSuggestBindingsForLinearElementAtCoords(element, pointsSceneCoords);\n }, linearElementEditor, this.scene);\n\n if (newLinearElementEditor) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n pointerDownState.drag.hasOccurred = true;\n this.setState({\n editingLinearElement: this.state.editingLinearElement ? newLinearElementEditor : null,\n selectedLinearElement: newLinearElementEditor\n });\n return;\n }\n }\n\n const hasHitASelectedElement = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n const isSelectingPointsInLineEditor = this.state.editingLinearElement && event.shiftKey && this.state.editingLinearElement.elementId === ((_c = pointerDownState.hit.element) === null || _c === void 0 ? void 0 : _c.id);\n\n if ((hasHitASelectedElement || pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && !isSelectingPointsInLineEditor && this.state.activeTool.type !== \"lasso\") {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.every(element => element.locked)) {\n return;\n }\n\n const selectedElementsHasAFrame = selectedElements.find(e => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(e));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(pointerCoords);\n const frameToHighlight = topLayerFrame && !selectedElementsHasAFrame ? topLayerFrame : null; // Only update the state if there is a difference\n\n if (this.state.frameToHighlight !== frameToHighlight) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n frameToHighlight\n });\n });\n } // Marking that click was used for dragging to check\n // if elements should be deselected on pointerup\n\n\n pointerDownState.drag.hasOccurred = true; // prevent dragging even if we're no longer holding cmd/ctrl otherwise\n // it would have weird results (stuff jumping all over the screen)\n // Checking for editingTextElement to avoid jump while editing on mobile #6503\n\n if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl && !this.state.editingTextElement && ((_d = this.state.activeEmbeddable) === null || _d === void 0 ? void 0 : _d.state) !== \"active\") {\n const dragOffset = {\n x: pointerCoords.x - pointerDownState.drag.origin.x,\n y: pointerCoords.y - pointerDownState.drag.origin.y\n };\n const originalElements = [...pointerDownState.originalElements.values()]; // We only drag in one direction if shift is pressed\n\n const lockDirection = event.shiftKey;\n\n if (lockDirection) {\n const distanceX = Math.abs(dragOffset.x);\n const distanceY = Math.abs(dragOffset.y);\n const lockX = lockDirection && distanceX < distanceY;\n const lockY = lockDirection && distanceX > distanceY;\n\n if (lockX) {\n dragOffset.x = 0;\n }\n\n if (lockY) {\n dragOffset.y = 0;\n }\n } // #region move crop region\n\n\n if (this.state.croppingElementId) {\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (croppingElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(croppingElement) && croppingElement.crop !== null && pointerDownState.hit.element === croppingElement) {\n const crop = croppingElement.crop;\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(croppingElement) && ((_e = this.imageCache.get(croppingElement.fileId)) === null || _e === void 0 ? void 0 : _e.image);\n\n if (image && !(image instanceof Promise)) {\n const instantDragOffset = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)(pointerCoords.x - lastPointerCoords.x, pointerCoords.y - lastPointerCoords.y), Math.max(this.state.zoom.value, 2));\n const [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getElementAbsoluteCoords)(croppingElement, elementsMap);\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(topRight, topLeft));\n const leftEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(bottomLeft, topLeft)); // project instantDrafOffset onto leftEdge and topEdge to decompose\n\n const offsetVector = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, topEdge), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, leftEdge));\n const nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.x - offsetVector[0] * Math.sign(croppingElement.scale[0]), 0, image.naturalWidth - crop.width),\n y: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.y - offsetVector[1] * Math.sign(croppingElement.scale[1]), 0, image.naturalHeight - crop.height)\n });\n this.scene.mutateElement(croppingElement, {\n crop: nextCrop\n });\n return;\n }\n }\n } // Snap cache *must* be synchronously popuplated before initial drag,\n // otherwise the first drag even will not snap, causing a jump before\n // it snaps to its position if previously snapped already.\n\n\n this.maybeCacheVisibleGaps(event, selectedElements);\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapDraggedElements)(originalElements, dragOffset, this, event, this.scene.getNonDeletedElementsMap());\n this.setState({\n snapLines\n }); // when we're editing the name of a frame, we want the user to be\n // able to select and interact with the text input\n\n if (!this.state.editingFrame) {\n (0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.dragSelectedElements)(pointerDownState, selectedElements, dragOffset, this.scene, snapOffset, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n }\n\n this.setState({\n selectedElementsAreBeingDragged: true,\n // element is being dragged and selectionElement that was created on pointer down\n // should be removed\n selectionElement: null\n });\n\n if (selectedElements.length !== 1 || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0])) {\n this.setState({\n suggestedBindings: (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n } // We duplicate the selected element if alt is pressed on pointer move\n\n\n if (event.altKey && !pointerDownState.hit.hasBeenDuplicated) {\n // Move the currently selected elements to the top of the z index stack, and\n // put the duplicates where the selected elements used to be.\n // (the origin point where the dragging started)\n pointerDownState.hit.hasBeenDuplicated = true;\n const elements = this.scene.getElementsIncludingDeleted();\n const hitElement = pointerDownState.hit.element;\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n\n if (hitElement && // hit element may not end up being selected\n // if we're alt-dragging a common bounding box\n // over the hit element\n pointerDownState.hit.wasAddedToSelection && !selectedElements.find(el => el.id === hitElement.id)) {\n selectedElements.push(hitElement);\n }\n\n const idsOfElementsToDuplicate = new Map(selectedElements.map(el => [el.id, el]));\n const {\n duplicatedElements,\n duplicateElementsMap,\n elementsWithDuplicates,\n origIdToDuplicateId\n } = (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElements)({\n type: \"in-place\",\n elements,\n appState: this.state,\n randomizeSeed: true,\n idsOfElementsToDuplicate,\n overrides: ({\n duplicateElement,\n origElement\n }) => {\n var _a;\n\n return {\n // reset to the original element's frameId (unless we've\n // duplicated alongside a frame in which case we need to\n // keep the duplicate frame's id) so that the element\n // frame membership is refreshed on pointerup\n // NOTE this is a hacky solution and should be done\n // differently\n frameId: (_a = duplicateElement.frameId) !== null && _a !== void 0 ? _a : origElement.frameId,\n seed: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.randomInteger)()\n };\n }\n });\n duplicatedElements.forEach(element => {\n pointerDownState.originalElements.set(element.id, (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.deepCopyElement)(element));\n });\n const mappedClonedElements = elementsWithDuplicates.map(el => {\n if (idsOfElementsToDuplicate.has(el.id)) {\n const origEl = pointerDownState.originalElements.get(el.id);\n\n if (origEl) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(el, {\n x: origEl.x,\n y: origEl.y\n });\n }\n }\n\n return el;\n });\n const mappedNewSceneElements = (_g = (_f = this.props).onDuplicate) === null || _g === void 0 ? void 0 : _g.call(_f, mappedClonedElements, elements);\n const elementsWithIndices = (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncMovedIndices)(mappedNewSceneElements || mappedClonedElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(duplicatedElements)); // we need to update synchronously so as to keep pointerDownState,\n // appState, and scene elements in sync\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n // swap hit element with the duplicated one\n if (pointerDownState.hit.element) {\n const cloneId = origIdToDuplicateId.get(pointerDownState.hit.element.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n pointerDownState.hit.element = clonedElement || null;\n } // swap hit elements with the duplicated ones\n\n\n pointerDownState.hit.allHitElements = pointerDownState.hit.allHitElements.reduce((acc, origHitElement) => {\n const cloneId = origIdToDuplicateId.get(origHitElement.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n\n if (clonedElement) {\n acc.push(clonedElement);\n }\n\n return acc;\n }, []); // update drag origin to the position at which we started\n // the duplication so that the drag offset is correct\n\n pointerDownState.drag.origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state); // switch selected elements to the duplicated ones\n\n this.setState(prevState => Object.assign({}, (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.getSelectionStateForElements)(duplicatedElements, this.scene.getNonDeletedElements(), prevState)));\n this.scene.replaceAllElements(elementsWithIndices);\n this.maybeCacheVisibleGaps(event, selectedElements, true);\n this.maybeCacheReferenceSnapPoints(event, selectedElements, true);\n });\n }\n\n return;\n }\n }\n\n if (this.state.selectionElement) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (event.altKey) {\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n }, event.shiftKey);\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setAppState({\n selectionElement: null\n });\n } else {\n this.maybeDragNewGenericElement(pointerDownState, event);\n }\n } else if (this.state.activeTool.type === \"lasso\") {\n if (!event.altKey && this.state.activeTool.fromSelection) {\n this.setActiveTool({\n type: \"selection\"\n });\n this.createGenericElementOnPointerDown(\"selection\", pointerDownState);\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event);\n this.lassoTrail.endPath();\n } else {\n this.lassoTrail.addPointToPath(pointerCoords.x, pointerCoords.y, event.shiftKey);\n }\n } else {\n // It is very important to read this.state within each move event,\n // otherwise we would read a stale one!\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n if (newElement.type === \"freedraw\") {\n const points = newElement.points;\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n const lastPoint = points.length > 0 && points[points.length - 1];\n const discardPoint = lastPoint && lastPoint[0] === dx && lastPoint[1] === dy;\n\n if (!discardPoint) {\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const pressures = newElement.simulatePressure ? newElement.pressures : [//zsviczian\n ...newElement.pressures, (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n newElement\n });\n }\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(newElement)) {\n pointerDownState.drag.hasOccurred = true;\n const points = newElement.points;\n let dx = gridX - newElement.x;\n let dy = gridY - newElement.y;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldRotateWithDiscreteAngle)(event) && points.length === 2) {\n ({\n width: dx,\n height: dy\n } = (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.getLockedLinearCursorAlignSize)(newElement.x, newElement.y, pointerCoords.x, pointerCoords.y));\n }\n\n if (points.length === 1) {\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else if (points.length === 2 || points.length > 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(newElement)) {\n this.scene.mutateElement(newElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n isDragging: true,\n informMutation: false\n });\n }\n\n this.setState({\n newElement\n });\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(newElement, false)) {\n // When creating a linear element by dragging\n this.maybeSuggestBindingsForLinearElementAtCoords(newElement, [pointerCoords], this.state.startBoundElement);\n }\n } else {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event, false);\n }\n }\n\n if (this.state.activeTool.type === \"selection\") {\n pointerDownState.boxSelection.hasOccurred = true;\n const elements = this.scene.getNonDeletedElements(); // box-select line editor points\n\n if (this.state.editingLinearElement) {\n _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handleBoxSelection(event, this.state, this.setState.bind(this), this.scene.getNonDeletedElementsMap()); // regular box-select\n } else {\n let shouldReuseSelection = true;\n\n if (!event.shiftKey && (0,_scene__WEBPACK_IMPORTED_MODULE_62__.isSomeElementSelected)(elements, this.state)) {\n if (pointerDownState.withCmdOrCtrl && pointerDownState.hit.element) {\n this.setState(prevState => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)(Object.assign(Object.assign({}, prevState), {\n selectedElementIds: {\n [pointerDownState.hit.element.id]: true\n }\n }), this.scene.getNonDeletedElements(), prevState, this));\n } else {\n shouldReuseSelection = false;\n }\n }\n\n const elementsWithinSelection = this.state.selectionElement ? (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getElementsWithinSelection)(elements, this.state.selectionElement, this.scene.getNonDeletedElementsMap(), false) : [];\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, shouldReuseSelection && prevState.selectedElementIds), elementsWithinSelection.reduce((acc, element) => {\n acc[element.id] = true;\n return acc;\n }, {}));\n\n if (pointerDownState.hit.element) {\n // if using ctrl/cmd, select the hitElement only if we\n // haven't box-selected anything else\n if (!elementsWithinSelection.length) {\n nextSelectedElementIds[pointerDownState.hit.element.id] = true;\n } else {\n delete nextSelectedElementIds[pointerDownState.hit.element.id];\n }\n }\n\n prevState = !shouldReuseSelection ? Object.assign(Object.assign({}, prevState), {\n selectedGroupIds: {},\n editingGroupId: null\n }) : prevState;\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // select linear element only when we haven't box-selected anything else\n selectedLinearElement: elementsWithinSelection.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(elementsWithinSelection[0]) ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(elementsWithinSelection[0], this.scene.getNonDeletedElementsMap()) : null,\n showHyperlinkPopup: elementsWithinSelection.length === 1 && (elementsWithinSelection[0].link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(elementsWithinSelection[0])) ? \"info\" : false\n });\n });\n }\n }\n });\n } // Returns whether the pointer move happened over either scrollbar\n\n\n handlePointerMoveOverScrollbars(event, pointerDownState) {\n var _a, _b;\n\n if (pointerDownState.scrollbars.isOverHorizontal) {\n const x = event.clientX;\n const dx = x - pointerDownState.lastCoords.x;\n this.translateCanvas({\n scrollX: this.state.scrollX - dx * (((_a = currentScrollBars.horizontal) === null || _a === void 0 ? void 0 : _a.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.x = x;\n return true;\n }\n\n if (pointerDownState.scrollbars.isOverVertical) {\n const y = event.clientY;\n const dy = y - pointerDownState.lastCoords.y;\n this.translateCanvas({\n scrollY: this.state.scrollY - dy * (((_b = currentScrollBars.vertical) === null || _b === void 0 ? void 0 : _b.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.y = y;\n return true;\n }\n\n return false;\n }\n\n onPointerUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(childEvent => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;\n\n this.removePointer(childEvent);\n\n if (pointerDownState.eventListeners.onMove) {\n pointerDownState.eventListeners.onMove.flush();\n }\n\n const {\n newElement,\n resizingElement,\n croppingElementId,\n multiElement,\n activeTool,\n isResizing,\n isRotating,\n isCropping\n } = this.state;\n this.setState(prevState => ({\n isResizing: false,\n isRotating: false,\n isCropping: false,\n resizingElement: null,\n selectionElement: null,\n frameToHighlight: null,\n elementsToHighlight: null,\n cursorButton: \"up\",\n snapLines: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.snapLines, []),\n originSnapOffset: null\n })); // just in case, tool changes mid drag, always clean up\n\n this.lassoTrail.endPath();\n this.lastPointerMoveCoords = null;\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setReferenceSnapPoints(null);\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setVisibleGaps(null);\n this.savePointer(childEvent.clientX, childEvent.clientY, \"up\");\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (pointerDownState.drag.hasOccurred && ((_b = (_a = pointerDownState.hit) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.id)) {\n const element = elementsMap.get(pointerDownState.hit.element.id);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindableElement)(element)) {\n // Renormalize elbow arrows when they are changed via indirect move\n (_c = element.boundElements) === null || _c === void 0 ? void 0 : _c.filter(e => e.type === \"arrow\").map(e => elementsMap.get(e.id)).filter(e => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(e)).forEach(e => {\n !!e && this.scene.mutateElement(e, {});\n });\n }\n } // Handle end of dragging a point of a linear element, might close a loop\n // and sets binding element\n\n\n if (this.state.editingLinearElement) {\n if (!pointerDownState.boxSelection.hasOccurred && ((_e = (_d = pointerDownState.hit) === null || _d === void 0 ? void 0 : _d.element) === null || _e === void 0 ? void 0 : _e.id) !== this.state.editingLinearElement.elementId) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n } else {\n const editingLinearElement = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerUp(childEvent, this.state.editingLinearElement, this.state, this.scene);\n\n if (editingLinearElement !== this.state.editingLinearElement) {\n this.setState({\n editingLinearElement,\n suggestedBindings: []\n });\n }\n }\n } else if (this.state.selectedLinearElement) {\n // Normalize elbow arrow points, remove close parallel segments\n if (this.state.selectedLinearElement.elbowed) {\n const element = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if (element) {\n this.scene.mutateElement(element, {});\n }\n }\n\n if (((_g = (_f = pointerDownState.hit) === null || _f === void 0 ? void 0 : _f.element) === null || _g === void 0 ? void 0 : _g.id) !== this.state.selectedLinearElement.elementId) {\n const selectedELements = this.scene.getSelectedElements(this.state); // set selectedLinearElement to null if there is more than one element selected since we don't want to show linear element handles\n\n if (selectedELements.length > 1) {\n this.setState({\n selectedLinearElement: null\n });\n }\n } else {\n const linearElementEditor = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerUp(childEvent, this.state.selectedLinearElement, this.state, this.scene);\n const {\n startBindingElement,\n endBindingElement\n } = linearElementEditor;\n const element = this.scene.getElement(linearElementEditor.elementId);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(element)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.bindOrUnbindLinearElement)(element, startBindingElement, endBindingElement, this.scene);\n }\n\n if (linearElementEditor !== this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n selectedPointsIndices: null\n }),\n suggestedBindings: []\n });\n }\n }\n }\n\n this.missingPointerEventCleanupEmitter.clear();\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, pointerDownState.eventListeners.onMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, pointerDownState.eventListeners.onUp);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYDOWN, pointerDownState.eventListeners.onKeyDown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYUP, pointerDownState.eventListeners.onKeyUp);\n\n if (this.state.pendingImageElementId) {\n this.setState({\n pendingImageElementId: null\n });\n }\n\n (_j = (_h = this.props) === null || _h === void 0 ? void 0 : _h.onPointerUp) === null || _j === void 0 ? void 0 : _j.call(_h, activeTool, pointerDownState);\n this.onPointerUpEmitter.trigger(this.state.activeTool, pointerDownState, childEvent);\n\n if ((newElement === null || newElement === void 0 ? void 0 : newElement.type) === \"freedraw\") {\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const points = newElement.points;\n let dx = pointerCoords.x - newElement.x;\n let dy = pointerCoords.y - newElement.y; // Allows dots to avoid being flagged as infinitely small\n\n if (dx === points[0][0] && dy === points[0][1]) {\n dy += 0.0001;\n dx += 0.0001;\n }\n\n const pressures = newElement.simulatePressure ? [] : [...newElement.pressures, childEvent.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures,\n lastCommittedPoint: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(newElement)) {\n const imageElement = newElement;\n\n try {\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n } catch (error) {\n console.error(error);\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(el => el.id !== imageElement.id));\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n }\n\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(newElement)) {\n if (newElement.points.length > 1) {\n this.store.shouldCaptureIncrement();\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(childEvent, this.state);\n\n if (!pointerDownState.drag.hasOccurred && newElement && !multiElement) {\n this.scene.mutateElement(newElement, {\n points: [...newElement.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x - newElement.x, pointerCoords.y - newElement.y)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n multiElement: newElement,\n newElement\n });\n } else if (pointerDownState.drag.hasOccurred && !multiElement) {\n if ((0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(newElement, false)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.maybeBindLinearElement)(newElement, this.state, pointerCoords, this.scene);\n }\n\n this.setState({\n suggestedBindings: [],\n startBoundElement: null\n });\n\n if (!activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n }),\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap())\n }));\n } else {\n this.setState(prevState => ({\n newElement: null\n }));\n } // so that the scene gets rendered again to display the newly drawn linear as well\n\n\n this.scene.triggerUpdate();\n }\n\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(newElement)) {\n const minWidth = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getMinTextElementWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getFontString)({\n fontSize: newElement.fontSize,\n fontFamily: newElement.fontFamily\n }), newElement.lineHeight);\n\n if (newElement.width < minWidth) {\n this.scene.mutateElement(newElement, {\n autoResize: true\n });\n }\n\n this.resetCursor();\n this.handleTextWysiwyg(newElement, {\n isExistingElement: true\n });\n }\n\n if (activeTool.type !== \"selection\" && newElement && (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isInvisiblySmallElement)(newElement)) {\n // remove invisible element which was added in onPointerDown\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== newElement.id),\n appState: {\n newElement: null\n },\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n });\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(newElement)) {\n const elementsInsideFrame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInNewFrame)(this.scene.getElementsIncludingDeleted(), newElement, this.scene.getNonDeletedElementsMap());\n this.scene.replaceAllElements((0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.addElementsToFrame)(this.scene.getElementsMapIncludingDeleted(), elementsInsideFrame, newElement, this.state));\n }\n\n if (newElement) {\n this.scene.mutateElement(newElement, (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.getNormalizedDimensions)(newElement), {\n informMutation: false,\n isDragging: false\n }); // the above does not guarantee the scene to be rendered again, hence the trigger below\n\n this.scene.triggerUpdate();\n }\n\n if (pointerDownState.drag.hasOccurred) {\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(childEvent, this.state); // when editing the points of a linear element, we check if the\n // linear element still is in the frame afterwards\n // if not, the linear element will be removed from its frame (if any)\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.isDragging) {\n const linearElement = this.scene.getElement(this.state.selectedLinearElement.elementId);\n\n if (linearElement === null || linearElement === void 0 ? void 0 : linearElement.frameId) {\n const frame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getContainingFrame)(linearElement, elementsMap);\n\n if (frame && linearElement) {\n if (!(0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.elementOverlapsWithFrame)(linearElement, frame, this.scene.getNonDeletedElementsMap())) {\n // remove the linear element from all groups\n // before removing it from the frame as well\n this.scene.mutateElement(linearElement, {\n groupIds: []\n });\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.removeElementsFromFrame)([linearElement], this.scene.getNonDeletedElementsMap());\n this.scene.triggerUpdate();\n }\n }\n }\n } else {\n // update the relationships between selected elements and frames\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(sceneCoords);\n const selectedElements = this.scene.getSelectedElements(this.state);\n let nextElements = this.scene.getElementsMapIncludingDeleted();\n\n const updateGroupIdsAfterEditingGroup = elements => {\n if (elements.length > 0) {\n for (const element of elements) {\n const index = element.groupIds.indexOf(this.state.editingGroupId);\n this.scene.mutateElement(element, {\n groupIds: element.groupIds.slice(0, index)\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n nextElements.forEach(element => {\n if (element.groupIds.length && (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(nextElements, element.groupIds[element.groupIds.length - 1]).length < 2) {\n this.scene.mutateElement(element, {\n groupIds: []\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n });\n this.setState({\n editingGroupId: null\n });\n }\n };\n\n if (topLayerFrame && !this.state.selectedElementIds[topLayerFrame.id]) {\n const elementsToAdd = selectedElements.filter(element => element.frameId !== topLayerFrame.id && (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isElementInFrame)(element, nextElements, this.state));\n\n if (this.state.editingGroupId) {\n updateGroupIdsAfterEditingGroup(elementsToAdd);\n }\n\n nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.addElementsToFrame)(nextElements, elementsToAdd, topLayerFrame, this.state);\n } else if (!topLayerFrame) {\n if (this.state.editingGroupId) {\n const elementsToRemove = selectedElements.filter(element => element.frameId && !(0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isElementInFrame)(element, nextElements, this.state));\n updateGroupIdsAfterEditingGroup(elementsToRemove);\n }\n }\n\n nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.updateFrameMembershipOfSelectedElements)(nextElements, this.state, this);\n this.scene.replaceAllElements(nextElements);\n }\n }\n\n if (resizingElement) {\n this.store.shouldCaptureIncrement();\n }\n\n if (resizingElement && (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isInvisiblySmallElement)(resizingElement)) {\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== resizingElement.id),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n });\n } // handle frame membership for resizing frames and/or selected elements\n\n\n if (pointerDownState.resize.isResizing) {\n let nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.updateFrameMembershipOfSelectedElements)(this.scene.getElementsIncludingDeleted(), this.state, this);\n const selectedFrames = this.scene.getSelectedElements(this.state).filter(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element));\n\n for (const frame of selectedFrames) {\n nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.replaceAllElementsInFrame)(nextElements, (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInResizingFrame)(this.scene.getElementsIncludingDeleted(), frame, this.state, elementsMap), frame, this);\n }\n\n this.scene.replaceAllElements(nextElements);\n } // Code below handles selection when element(s) weren't\n // drag or added to selection on pointer down phase.\n\n\n const hitElement = pointerDownState.hit.element;\n\n if (((_k = this.state.selectedLinearElement) === null || _k === void 0 ? void 0 : _k.elementId) !== (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(hitElement)) {\n const selectedElements = this.scene.getSelectedElements(this.state); // set selectedLinearElement when no other element selected except\n // the one we've hit\n\n if (selectedElements.length === 1) {\n this.setState({\n selectedLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap())\n });\n }\n } // click outside the cropping region to exit\n\n\n if ( // not in the cropping mode at all\n !croppingElementId || // in the cropping mode\n croppingElementId && ( // not cropping and no hit element\n !hitElement && !isCropping || // hitting something else\n hitElement && hitElement.id !== croppingElementId)) {\n this.finishImageCropping();\n }\n\n const pointerStart = this.lastPointerDownEvent;\n const pointerEnd = this.lastPointerUpEvent || this.lastPointerMoveEvent;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state) && pointerStart && pointerEnd) {\n this.eraserTrail.endPath();\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerStart.clientX, pointerStart.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerEnd.clientX, pointerEnd.clientY));\n\n if (draggedDistance === 0) {\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: pointerEnd.clientX,\n clientY: pointerEnd.clientY\n }, this.state);\n const hitElements = this.getElementsAtPosition(scenePointer.x, scenePointer.y);\n hitElements.forEach(hitElement => this.elementsPendingErasure.add(hitElement.id));\n }\n\n this.eraseElements();\n return;\n } else if (this.elementsPendingErasure.size) {\n this.restoreReadyToEraseElements();\n }\n\n if (hitElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && ( // if we're editing a line, pointerup shouldn't switch selection if\n // box selected\n !this.state.editingLinearElement || !pointerDownState.boxSelection.hasOccurred)) {\n // when inside line editor, shift selects points instead\n if (childEvent.shiftKey && !this.state.editingLinearElement) {\n if (this.state.selectedElementIds[hitElement.id]) {\n if ((0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.isSelectedViaGroup)(this.state, hitElement)) {\n this.setState(_prevState => {\n const nextSelectedElementIds = Object.assign({}, _prevState.selectedElementIds); // We want to unselect all groups hitElement is part of\n // as well as all elements that are part of the groups\n // hitElement is part of\n\n for (const groupedElement of hitElement.groupIds.flatMap(groupId => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), groupId))) {\n delete nextSelectedElementIds[groupedElement.id];\n }\n\n return {\n selectedGroupIds: Object.assign(Object.assign({}, _prevState.selectedElementIds), hitElement.groupIds.map(gId => ({\n [gId]: false\n })).reduce((prev, acc) => Object.assign(Object.assign({}, prev), acc), {})),\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedElementIds, _prevState)\n };\n }); // if not dragging a linear element point (outside editor)\n } else if (!((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.isDragging)) {\n // remove element from selection while\n // keeping prev elements selected\n this.setState(prevState => {\n const newSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete newSelectedElementIds[hitElement.id];\n const newSelectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElements(), {\n selectedElementIds: newSelectedElementIds\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: newSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // set selectedLinearElement only if thats the only element selected\n selectedLinearElement: newSelectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(newSelectedElements[0]) ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(newSelectedElements[0], this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n } else if (hitElement.frameId && this.state.selectedElementIds[hitElement.frameId]) {\n // when hitElement is part of a selected frame, deselect the frame\n // to avoid frame and containing elements selected simultaneously\n this.setState(prevState => {\n var _a, _b;\n\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n }); // deselect the frame\n\n delete nextSelectedElementIds[hitElement.frameId]; // deselect groups containing the frame\n\n ((_b = (_a = this.scene.getElement(hitElement.frameId)) === null || _a === void 0 ? void 0 : _a.groupIds) !== null && _b !== void 0 ? _b : []).flatMap(gid => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n } else {\n // add element to selection while keeping prev elements selected\n this.setState(_prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, _prevState.selectedElementIds), {\n [hitElement.id]: true\n }), _prevState)\n }));\n }\n } else {\n this.setState(prevState => {\n var _a;\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n selectedLinearElement: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(hitElement) && // Don't set `selectedLinearElement` if its same as the hitElement, this is mainly to prevent resetting the `hoverPointIndex` to -1.\n // Future we should update the API to take care of setting the correct `hoverPointIndex` when initialized\n ((_a = prevState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId) !== hitElement.id ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n }\n\n if ( // do not clear selection if lasso is active\n this.state.activeTool.type !== \"lasso\" && // not elbow midpoint dragged\n !(hitElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(hitElement)) && // not dragged\n !pointerDownState.drag.hasOccurred && // not resized\n !this.state.isResizing && ( // only hitting the bounding box of the previous hit element\n hitElement && (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementBoundingBoxOnly)({\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y,\n element: hitElement,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(hitElement, this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold(),\n frameNameBound: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(hitElement) ? this.frameNameBoundsCache.get(hitElement) : null\n }, elementsMap) || !hitElement && pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements)) {\n if (this.state.editingLinearElement) {\n this.setState({\n editingLinearElement: null\n });\n } else {\n // Deselect selected elements\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // reset cursor\n\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && newElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n showHyperlinkPopup: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(newElement) && !newElement.link ? \"editor\" : prevState.showHyperlinkPopup\n }));\n }\n\n if (activeTool.type !== \"selection\" || (0,_scene__WEBPACK_IMPORTED_MODULE_62__.isSomeElementSelected)(this.scene.getNonDeletedElements(), this.state) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isShallowEqual)(this.state.previousSelectedElementIds, this.state.selectedElementIds)) {\n this.store.shouldCaptureIncrement();\n }\n\n if (pointerDownState.drag.hasOccurred || isResizing || isRotating || isCropping) {\n // We only allow binding via linear elements, specifically via dragging\n // the endpoints (\"start\" or \"end\").\n const linearElements = this.scene.getSelectedElements(this.state).filter(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement);\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.bindOrUnbindLinearElements)(linearElements, (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state), (_o = (_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.selectedPointsIndices) !== null && _o !== void 0 ? _o : [], this.scene, this.state.zoom);\n }\n\n if (activeTool.type === \"laser\") {\n this.laserTrails.endPath();\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && (activeTool.type !== \"lasso\" || // if lasso is turned on but from selection => reset to selection\n activeTool.type === \"lasso\" && activeTool.fromSelection)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n this.setState({\n newElement: null,\n suggestedBindings: [],\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n } else {\n this.setState({\n newElement: null,\n suggestedBindings: []\n });\n }\n\n if (hitElement && this.lastPointerUpEvent && this.lastPointerDownEvent && this.lastPointerUpEvent.timeStamp - this.lastPointerDownEvent.timeStamp < 300 && gesture.pointers.size <= 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, this.lastPointerUpEvent, pointerDownState.origin.x, pointerDownState.origin.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n }\n });\n } //zsviczian - published on API\n\n\n setSelection(elements) {\n const selectedElementIds = {};\n const selectedGroupIds = {};\n elements.forEach(ele => {\n if (ele.groupIds.length) {\n selectedElementIds[ele.id] = true;\n ele.groupIds.forEach(id => {\n selectedGroupIds[id] = true;\n });\n } // exclude bound text elements as we don't mark them as selected when\n // container is selected unless in group\n else if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(ele)) {\n selectedElementIds[ele.id] = true;\n }\n });\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds,\n selectedElementIds,\n selectedGroupIds\n });\n }\n\n clearSelection(hitElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n activeEmbeddable: null,\n selectedGroupIds: {},\n // Continue editing the same group if the user selected a different\n // element from it\n editingGroupId: prevState.editingGroupId && hitElement != null && (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.isElementInGroup)(hitElement, prevState.editingGroupId) ? prevState.editingGroupId : null\n }));\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null,\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n\n getTextWysiwygSnappedToCenterPosition(x, y, appState, container) {\n if (container) {\n let elementCenterX = container.x + container.width / 2;\n let elementCenterY = container.y + container.height / 2;\n const elementCenter = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerCenter)(container, appState, this.scene.getNonDeletedElementsMap());\n\n if (elementCenter) {\n elementCenterX = elementCenter.x;\n elementCenterY = elementCenter.y;\n }\n\n const distanceToCenter = Math.hypot(x - elementCenterX, y - elementCenterY);\n const isSnappedToCenter = distanceToCenter < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TEXT_TO_CENTER_SNAP_THRESHOLD;\n\n if (isSnappedToCenter) {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: elementCenterX,\n sceneY: elementCenterY\n }, appState);\n return {\n viewportX,\n viewportY,\n elementCenterX,\n elementCenterY\n };\n }\n }\n }\n\n getCanvasOffsets() {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n left,\n top\n } = excalidrawContainer.getBoundingClientRect();\n return {\n offsetLeft: left,\n offsetTop: top\n };\n }\n\n return {\n offsetLeft: 0,\n offsetTop: 0\n };\n }\n\n async updateLanguage() {\n const currentLang = _i18n__WEBPACK_IMPORTED_MODULE_61__.languages.find(lang => lang.code === this.props.langCode) || _i18n__WEBPACK_IMPORTED_MODULE_61__.defaultLang;\n await (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.setLanguage)(currentLang);\n this.setAppState({});\n }\n\n} // -----------------------------------------------------------------------------\n// TEST HOOKS\n// -----------------------------------------------------------------------------\n\n/* //zsviczian - I get a type error on h, but anyway I don't need this test hook\r\ndeclare global {\r\n interface Window {\r\n h: {\r\n scene: Scene;\r\n elements: readonly ExcalidrawElement[];\r\n state: AppState;\r\n setState: React.Component<any, AppState>[\"setState\"];\r\n app: InstanceType<typeof App>;\r\n history: History;\r\n store: Store;\r\n };\r\n }\r\n}\r\n\r\nexport const createTestHook = () => {\r\n if (isTestEnv() || isDevEnv()) {\r\n window.h = window.h || ({} as Window[\"h\"]);\r\n\r\n Object.defineProperties(window.h, {\r\n elements: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene.getElementsIncludingDeleted();\r\n },\r\n set(elements: ExcalidrawElement[]) {\r\n return this.app?.scene.replaceAllElements(\r\n syncInvalidIndices(elements),\r\n );\r\n },\r\n },\r\n scene: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene;\r\n },\r\n },\r\n });\r\n }\r\n};\r\n\r\ncreateTestHook();\r\n*/\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/App.tsx?");
|
|
14271
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawContainerContext: () => (/* binding */ ExcalidrawContainerContext),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ useApp: () => (/* binding */ useApp),\n/* harmony export */ useAppProps: () => (/* binding */ useAppProps),\n/* harmony export */ useDevice: () => (/* binding */ useDevice),\n/* harmony export */ useExcalidrawActionManager: () => (/* binding */ useExcalidrawActionManager),\n/* harmony export */ useExcalidrawAppState: () => (/* binding */ useExcalidrawAppState),\n/* harmony export */ useExcalidrawContainer: () => (/* binding */ useExcalidrawContainer),\n/* harmony export */ useExcalidrawElements: () => (/* binding */ useExcalidrawElements),\n/* harmony export */ useExcalidrawSetAppState: () => (/* binding */ useExcalidrawSetAppState)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.throttle */ \"../../node_modules/lodash.throttle/index.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_throttle__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-dom */ \"react-dom\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_104__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/utils/collision */ \"../utils/src/collision.ts\");\n/* harmony import */ var _excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/utils/shape */ \"../utils/src/shape.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @excalidraw/element/binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @excalidraw/element/duplicate */ \"../element/src/duplicate.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @excalidraw/element/sizeHelpers */ \"../element/src/sizeHelpers.ts\");\n/* harmony import */ var _excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @excalidraw/element/shapes */ \"../element/src/shapes.ts\");\n/* harmony import */ var _excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @excalidraw/element/embeddable */ \"../element/src/embeddable.ts\");\n/* harmony import */ var _excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @excalidraw/element/image */ \"../element/src/image.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_transformHandles__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @excalidraw/element/transformHandles */ \"../element/src/transformHandles.ts\");\n/* harmony import */ var _excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @excalidraw/element/frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @excalidraw/element/collision */ \"../element/src/collision.ts\");\n/* harmony import */ var _excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! @excalidraw/element/flowchart */ \"../element/src/flowchart.ts\");\n/* harmony import */ var _excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! @excalidraw/element/cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @excalidraw/element/elementLink */ \"../element/src/elementLink.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! @excalidraw/element/ShapeCache */ \"../element/src/ShapeCache.ts\");\n/* harmony import */ var _excalidraw_element_renderElement__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! @excalidraw/element/renderElement */ \"../element/src/renderElement.ts\");\n/* harmony import */ var _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! @excalidraw/element/groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! @excalidraw/element/fractionalIndex */ \"../element/src/fractionalIndex.ts\");\n/* harmony import */ var _excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! @excalidraw/element/selection */ \"../element/src/selection.ts\");\n/* harmony import */ var _excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @excalidraw/element/resizeElements */ \"../element/src/resizeElements.ts\");\n/* harmony import */ var _excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! @excalidraw/element/resizeTest */ \"../element/src/resizeTest.ts\");\n/* harmony import */ var _excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! @excalidraw/element/dragElements */ \"../element/src/dragElements.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _excalidraw_element_Scene__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! @excalidraw/element/Scene */ \"../element/src/Scene.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ../actions/actionBoundText */ \"./actions/actionBoundText.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ../actions/actionClipboard */ \"./actions/actionClipboard.tsx\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ../actions/actionElementLock */ \"./actions/actionElementLock.ts\");\n/* harmony import */ var _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ../actions/actionFrame */ \"./actions/actionFrame.ts\");\n/* harmony import */ var _actions_actionHistory__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ../actions/actionHistory */ \"./actions/actionHistory.tsx\");\n/* harmony import */ var _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ../actions/actionTextAutoResize */ \"./actions/actionTextAutoResize.ts\");\n/* harmony import */ var _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ../actions/actionToggleViewMode */ \"./actions/actionToggleViewMode.tsx\");\n/* harmony import */ var _actions_manager__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ../actions/manager */ \"./actions/manager.tsx\");\n/* harmony import */ var _actions_register__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ../actions/register */ \"./actions/register.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _animation_frame_handler__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ../animation-frame-handler */ \"./animation-frame-handler.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ../data */ \"./data/index.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ../data/library */ \"./data/library.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ../data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _gesture__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ../gesture */ \"./gesture.ts\");\n/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ../history */ \"./history.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_filesystem__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ../data/filesystem */ \"./data/filesystem.ts\");\n/* harmony import */ var _components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ../components/hyperlink/Hyperlink */ \"./components/hyperlink/Hyperlink.tsx\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _snapping__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ../snapping */ \"./snapping.ts\");\n/* harmony import */ var _data_transform__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ../data/transform */ \"./data/transform.ts\");\n/* harmony import */ var _scene_Renderer__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(/*! ../scene/Renderer */ \"./scene/Renderer.ts\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_73__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _emitter__WEBPACK_IMPORTED_MODULE_74__ = __webpack_require__(/*! ../emitter */ \"./emitter.ts\");\n/* harmony import */ var _components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_75__ = __webpack_require__(/*! ../components/ElementCanvasButtons */ \"./components/ElementCanvasButtons.tsx\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_76__ = __webpack_require__(/*! ../store */ \"./store.ts\");\n/* harmony import */ var _laser_trails__WEBPACK_IMPORTED_MODULE_77__ = __webpack_require__(/*! ../laser-trails */ \"./laser-trails.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_78__ = __webpack_require__(/*! ../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_79__ = __webpack_require__(/*! ../wysiwyg/textWysiwyg */ \"./wysiwyg/textWysiwyg.tsx\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_80__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _mermaid__WEBPACK_IMPORTED_MODULE_81__ = __webpack_require__(/*! ../mermaid */ \"./mermaid.ts\");\n/* harmony import */ var _lasso__WEBPACK_IMPORTED_MODULE_82__ = __webpack_require__(/*! ../lasso */ \"./lasso/index.ts\");\n/* harmony import */ var _eraser__WEBPACK_IMPORTED_MODULE_83__ = __webpack_require__(/*! ../eraser */ \"./eraser/index.ts\");\n/* harmony import */ var _ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__ = __webpack_require__(/*! ./ConvertElementTypePopup */ \"./components/ConvertElementTypePopup.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_85__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_86__ = __webpack_require__(/*! ./BraveMeasureTextError */ \"./components/BraveMeasureTextError.tsx\");\n/* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_87__ = __webpack_require__(/*! ./ContextMenu */ \"./components/ContextMenu.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_88__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_89__ = __webpack_require__(/*! ./FollowMode/FollowMode */ \"./components/FollowMode/FollowMode.tsx\");\n/* harmony import */ var _LayerUI__WEBPACK_IMPORTED_MODULE_90__ = __webpack_require__(/*! ./LayerUI */ \"./components/LayerUI.tsx\");\n/* harmony import */ var _MagicButton__WEBPACK_IMPORTED_MODULE_91__ = __webpack_require__(/*! ./MagicButton */ \"./components/MagicButton.tsx\");\n/* harmony import */ var _SVGLayer__WEBPACK_IMPORTED_MODULE_92__ = __webpack_require__(/*! ./SVGLayer */ \"./components/SVGLayer.tsx\");\n/* harmony import */ var _SearchMenu__WEBPACK_IMPORTED_MODULE_93__ = __webpack_require__(/*! ./SearchMenu */ \"./components/SearchMenu.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_94__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _canvases__WEBPACK_IMPORTED_MODULE_95__ = __webpack_require__(/*! ./canvases */ \"./components/canvases/index.tsx\");\n/* harmony import */ var _canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_96__ = __webpack_require__(/*! ./canvases/NewElementCanvas */ \"./components/canvases/NewElementCanvas.tsx\");\n/* harmony import */ var _hyperlink_helpers__WEBPACK_IMPORTED_MODULE_97__ = __webpack_require__(/*! ./hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_98__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _Toast__WEBPACK_IMPORTED_MODULE_99__ = __webpack_require__(/*! ./Toast */ \"./components/Toast.tsx\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_100__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_101__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_102__ = __webpack_require__(/*! ./Tooltip */ \"./components/Tooltip.tsx\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_103__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst AppContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst AppPropsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst deviceContextInitialValue = {\n viewport: {\n isMobile: false,\n isLandscape: false\n },\n editor: {\n isMobile: false,\n canFitSidebar: false\n },\n isTouchScreen: false\n};\nconst DeviceContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(deviceContextInitialValue);\nDeviceContext.displayName = \"DeviceContext\";\nconst ExcalidrawContainerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext({\n container: null,\n id: null\n});\nExcalidrawContainerContext.displayName = \"ExcalidrawContainerContext\";\nconst ExcalidrawElementsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext([]);\nExcalidrawElementsContext.displayName = \"ExcalidrawElementsContext\";\nconst ExcalidrawAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_54__.getDefaultAppState)()), {\n width: 0,\n height: 0,\n offsetLeft: 0,\n offsetTop: 0\n}));\nExcalidrawAppStateContext.displayName = \"ExcalidrawAppStateContext\";\nconst ExcalidrawSetAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(() => {\n console.warn(\"Uninitialized ExcalidrawSetAppStateContext context!\");\n});\nExcalidrawSetAppStateContext.displayName = \"ExcalidrawSetAppStateContext\";\nconst ExcalidrawActionManagerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawActionManagerContext.displayName = \"ExcalidrawActionManagerContext\";\nconst useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppContext);\nconst useAppProps = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppPropsContext);\nconst useDevice = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(DeviceContext);\nconst useExcalidrawContainer = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawContainerContext);\nconst useExcalidrawElements = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawElementsContext);\nconst useExcalidrawAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawAppStateContext);\nconst useExcalidrawSetAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawSetAppStateContext);\nconst useExcalidrawActionManager = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawActionManagerContext);\nlet didTapTwice = false;\nlet tappedTwiceTimer = 0;\nlet isHoldingSpace = false;\nlet isPanning = false;\nlet isDraggingScrollBar = false;\nlet currentScrollBars = {\n horizontal: null,\n vertical: null\n};\nlet touchTimeout = 0;\nlet invalidateContextMenu = false;\n/**\r\n * Map of youtube embed video states\r\n */\n\nconst YOUTUBE_VIDEO_STATES = new Map();\nlet IS_PLAIN_PASTE = false;\nlet IS_PLAIN_PASTE_TIMER = 0;\nlet PLAIN_PASTE_TOAST_SHOWN = false;\nlet lastPointerUp = null;\nconst gesture = {\n pointers: new Map(),\n lastCenter: null,\n initialDistance: null,\n initialScale: null\n};\n\nclass App extends (react__WEBPACK_IMPORTED_MODULE_2___default().Component) {\n constructor(props) {\n super(props);\n this.interactiveCanvas = null;\n this.unmounted = false;\n this.device = deviceContextInitialValue;\n this.excalidrawContainerRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createRef();\n this.shouldRenderAllEmbeddables = false; //zsviczian\n\n this.files = {};\n this.imageCache = new Map();\n this.iFrameRefs = new Map();\n /**\r\n * Indicates whether the embeddable's url has been validated for rendering.\r\n * If value not set, indicates that the validation is pending.\r\n * Initially or on url change the flag is not reset so that we can guarantee\r\n * the validation came from a trusted source (the editor).\r\n **/\n\n this.embedsValidationStatus = new Map();\n /** embeds that have been inserted to DOM (as a perf optim, we don't want to\r\n * insert to DOM before user initially scrolls to them) */\n\n this.initializedEmbeds = new Set();\n this.elementsPendingErasure = new Set();\n this.flowChartCreator = new _excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.FlowChartCreator();\n this.flowChartNavigator = new _excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.FlowChartNavigator();\n this.lastPointerDownEvent = null;\n this.lastPointerUpEvent = null;\n this.lastPointerMoveEvent = null;\n this.lastPointerMoveCoords = null;\n this.lastViewportPosition = {\n x: 0,\n y: 0\n };\n this.allowMobileMode = true; //zsviczian\n\n this.animationFrameHandler = new _animation_frame_handler__WEBPACK_IMPORTED_MODULE_53__.AnimationFrameHandler();\n this.laserTrails = new _laser_trails__WEBPACK_IMPORTED_MODULE_77__.LaserTrails(this.animationFrameHandler, this);\n this.eraserTrail = new _eraser__WEBPACK_IMPORTED_MODULE_83__.EraserTrail(this.animationFrameHandler, this);\n this.lassoTrail = new _lasso__WEBPACK_IMPORTED_MODULE_82__.LassoTrail(this.animationFrameHandler, this);\n this.onChangeEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onPointerDownEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onPointerUpEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onUserFollowEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onScrollChangeEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.missingPointerEventCleanupEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n this.onRemoveEventListenersEmitter = new _emitter__WEBPACK_IMPORTED_MODULE_74__.Emitter();\n\n this.updateEditorAtom = (atom, ...args) => {\n const result = _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.set(atom, ...args);\n this.triggerRender();\n return result;\n };\n /**\r\n * Returns gridSize taking into account `gridModeEnabled`.\r\n * If disabled, returns null.\r\n */\n\n\n this.getEffectiveGridSize = () => {\n return (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isGridModeEnabled)(this) ? this.state.gridSize : null;\n };\n\n this.updateEmbedValidationStatus = (element, status) => {\n this.embedsValidationStatus.set(element.id, status);\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element);\n };\n\n this.updateEmbeddables = () => {\n const iframeLikes = new Set();\n let updated = false;\n this.scene.getNonDeletedElements().filter(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(element)) {\n iframeLikes.add(element.id);\n\n if (!this.embedsValidationStatus.has(element.id)) {\n updated = true;\n const validated = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.embeddableURLValidator)(element.link, this.props.validateEmbeddable);\n this.updateEmbedValidationStatus(element, validated);\n }\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(element)) {\n iframeLikes.add(element.id);\n }\n\n return false;\n });\n\n if (updated) {\n this.scene.triggerUpdate();\n } // GC\n\n\n this.iFrameRefs.forEach((ref, id) => {\n if (!iframeLikes.has(id)) {\n this.iFrameRefs.delete(id);\n }\n });\n };\n\n this.getFrameNameDOMId = frameElement => {\n return `${this.id}-frame-name-${frameElement.id}`;\n };\n\n this.frameNameBoundsCache = {\n get: frameElement => {\n let bounds = this.frameNameBoundsCache._cache.get(frameElement.id);\n\n if (!bounds || bounds.zoom !== this.state.zoom.value || bounds.versionNonce !== frameElement.versionNonce) {\n const frameNameDiv = document.getElementById(this.getFrameNameDOMId(frameElement));\n\n if (frameNameDiv) {\n const box = frameNameDiv.getBoundingClientRect();\n const boxSceneTopLeft = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: box.x,\n clientY: box.y\n }, this.state);\n const boxSceneBottomRight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: box.right,\n clientY: box.bottom\n }, this.state);\n bounds = {\n x: boxSceneTopLeft.x,\n y: boxSceneTopLeft.y,\n width: boxSceneBottomRight.x - boxSceneTopLeft.x,\n height: boxSceneBottomRight.y - boxSceneTopLeft.y,\n angle: 0,\n zoom: this.state.zoom.value,\n versionNonce: frameElement.versionNonce\n };\n\n this.frameNameBoundsCache._cache.set(frameElement.id, bounds);\n\n return bounds;\n }\n\n return null;\n }\n\n return bounds;\n },\n\n /**\r\n * @private\r\n */\n _cache: new Map()\n };\n\n this.resetEditingFrame = frame => {\n var _a;\n\n if (frame) {\n this.scene.mutateElement(frame, {\n name: ((_a = frame.name) === null || _a === void 0 ? void 0 : _a.trim()) || null\n });\n }\n\n this.setState({\n editingFrame: null\n });\n };\n\n this.renderFrameNames = () => {\n if (!this.state.frameRendering.enabled || !this.state.frameRendering.name) {\n if (this.state.editingFrame) {\n this.resetEditingFrame(null);\n }\n\n return null;\n }\n\n const isDarkTheme = this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.DARK;\n return this.scene.getNonDeletedFramesLikes().map(f => {\n var _a, _b;\n\n if (!(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementInViewport)(f, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap())) {\n if (this.state.editingFrame === f.id) {\n this.resetEditingFrame(f);\n } // if frame not visible, don't render its name\n\n\n return null;\n }\n\n const {\n x: x1,\n y: y1\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: f.x,\n sceneY: f.y\n }, this.state);\n const FRAME_NAME_EDIT_PADDING = 6;\n let frameNameJSX;\n const frameName = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getFrameLikeTitle)(f);\n\n if (f.id === this.state.editingFrame) {\n const frameNameInEdit = frameName;\n frameNameJSX = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"input\", {\n autoFocus: true,\n value: frameNameInEdit,\n onChange: e => {\n this.scene.mutateElement(f, {\n name: e.target.value\n });\n },\n onFocus: e => e.target.select(),\n onBlur: () => this.resetEditingFrame(f),\n onKeyDown: event => {\n // for some inexplicable reason, `onBlur` triggered on ESC\n // does not reset `state.editingFrame` despite being called,\n // and we need to reset it here as well\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) {\n this.resetEditingFrame(f);\n }\n },\n style: {\n background: this.state.viewBackgroundColor,\n filter: isDarkTheme ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME_FILTER : \"none\",\n zIndex: 2,\n border: \"none\",\n display: \"block\",\n padding: `${FRAME_NAME_EDIT_PADDING}px`,\n borderRadius: 4,\n boxShadow: \"inset 0 0 0 2px var(--color-on-primary-container)\",\n fontFamily: \"Assistant\",\n fontSize: \"14px\",\n transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`,\n color: \"var(--color-gray-80)\",\n overflow: \"hidden\",\n maxWidth: `${(0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.getExcalidrawContentEl)().clientWidth - x1 - FRAME_NAME_EDIT_PADDING //zsviczian was document.body\n }px`\n },\n size: frameNameInEdit.length + 1 || 1,\n dir: \"auto\",\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n autoCorrect: \"off\"\n });\n } else {\n frameNameJSX = frameName;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n id: this.getFrameNameDOMId(f),\n key: f.id,\n style: {\n position: \"absolute\",\n // Positioning from bottom so that we don't to either\n // calculate text height or adjust using transform (which)\n // messes up input position when editing the frame name.\n // This makes the positioning deterministic and we can calculate\n // the same position when rendering to canvas / svg.\n bottom: `${this.state.height + _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameOffsetY - y1 + this.state.offsetTop}px`,\n left: `${x1 - this.state.offsetLeft}px`,\n zIndex: 2,\n fontSize: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameFontSize,\n color: (_b = (_a = this.state.frameColor) === null || _a === void 0 ? void 0 : _a.nameColor) !== null && _b !== void 0 ? _b : isDarkTheme //zsviczian\n ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameColorLightTheme,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE.nameLineHeight,\n width: \"max-content\",\n maxWidth: `${f.width}px`,\n overflow: f.id === this.state.editingFrame ? \"visible\" : \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n cursor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE,\n pointerEvents: this.state.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.enabled\n },\n onPointerDown: event => this.handleCanvasPointerDown(event),\n onWheel: event => this.handleWheel(event),\n onContextMenu: this.handleCanvasContextMenu,\n onDoubleClick: () => {\n this.setState({\n editingFrame: f.id\n });\n }\n }, frameNameJSX);\n });\n };\n\n this.focusContainer = () => {\n var _a;\n\n (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n };\n\n this.getSceneElementsIncludingDeleted = () => {\n return this.scene.getElementsIncludingDeleted();\n };\n\n this.getSceneElements = () => {\n return this.scene.getNonDeletedElements();\n };\n\n this.onInsertElements = elements => {\n this.addElementsFromPasteOrLibrary({\n elements,\n position: \"center\",\n files: null\n });\n };\n\n this.onExportImage = async (type, elements, opts) => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"export\", type, \"ui\");\n const fileHandle = await (0,_data__WEBPACK_IMPORTED_MODULE_56__.exportCanvas)(type, elements, this.state, this.files, {\n exportBackground: this.state.exportBackground,\n name: this.getName(),\n viewBackgroundColor: this.state.viewBackgroundColor,\n exportingFrame: opts.exportingFrame\n }).catch(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.muteFSAbortError).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: error.message\n });\n });\n\n if (this.state.exportEmbedScene && fileHandle && (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isImageFileHandle)(fileHandle)) {\n this.setState({\n fileHandle\n });\n }\n };\n\n this.magicGenerations = new Map();\n\n this.updateMagicGeneration = ({\n frameElement,\n data\n }) => {\n if (data.status === \"pending\") {\n // We don't wanna persist pending state to storage. It should be in-app\n // state only.\n // Thus reset so that we prefer local cache (if there was some\n // generationData set previously)\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: undefined\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: data\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n this.magicGenerations.set(frameElement.id, data);\n this.triggerRender();\n };\n\n this.plugins = {};\n\n this.onMagicframeToolSelect = () => {\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds\n });\n\n if (selectedElements.length === 0) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"tool-select (empty-selection)\", \"d2c\");\n } else {\n const selectedMagicFrame = selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isMagicFrameElement)(selectedElements[0]) && selectedElements[0]; // case: user selected elements containing frame-like(s) or are frame\n // members, we don't want to wrap into another magicframe\n // (unless the only selected element is a magic frame which we reuse)\n\n if (!selectedMagicFrame && selectedElements.some(el => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(el) || el.frameId)) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe\n });\n return;\n }\n\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"tool-select (existing selection)\", \"d2c\");\n let frame;\n\n if (selectedMagicFrame) {\n // a single magicframe already selected -> use it\n frame = selectedMagicFrame;\n } else {\n // selected elements aren't wrapped in magic frame yet -> wrap now\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements);\n const padding = 50;\n frame = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newMagicFrameElement)(Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE), {\n x: minX - padding,\n y: minY - padding,\n width: maxX - minX + padding * 2,\n height: maxY - minY + padding * 2,\n opacity: 100,\n locked: false\n }));\n this.scene.insertElement(frame);\n\n for (const child of selectedElements) {\n this.scene.mutateElement(child, {\n frameId: frame.id\n });\n }\n\n this.setState({\n selectedElementIds: {\n [frame.id]: true\n }\n });\n }\n\n this.onMagicFrameGenerate(frame, \"upstream\");\n }\n };\n\n this.openEyeDropper = ({\n type\n }) => {\n this.updateEditorAtom(_EyeDropper__WEBPACK_IMPORTED_MODULE_88__.activeEyeDropperAtom, {\n swapPreviewOnAlt: true,\n colorPickerType: type === \"stroke\" ? \"elementStroke\" : \"elementBackground\",\n onSelect: (color, event) => {\n const shouldUpdateStrokeColor = type === \"background\" && event.altKey || type === \"stroke\" && !event.altKey;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (!selectedElements.length || this.state.activeTool.type !== \"selection\") {\n if (shouldUpdateStrokeColor) {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemStrokeColor: color\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n } else {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemBackgroundColor: color\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n } else {\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().map(el => {\n if (this.state.selectedElementIds[el.id]) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(el, {\n [shouldUpdateStrokeColor ? \"strokeColor\" : \"backgroundColor\"]: color\n });\n }\n\n return el;\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n },\n keepOpenOnAlt: false\n });\n };\n\n this.dismissLinearEditor = () => {\n setTimeout(() => {\n this.setState({\n editingLinearElement: null\n });\n });\n };\n\n this.syncActionResult = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(actionResult => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.unmounted || actionResult === false) {\n return;\n }\n\n if (actionResult.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER) {\n this.store.shouldUpdateSnapshot();\n } else if (actionResult.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY) {\n this.store.shouldCaptureIncrement();\n }\n\n let didUpdate = false;\n let editingTextElement = null;\n\n if (actionResult.elements) {\n this.scene.replaceAllElements(actionResult.elements);\n didUpdate = true;\n }\n\n if (actionResult.files) {\n this.addMissingFiles(actionResult.files, actionResult.replaceFiles);\n this.addNewImagesToImageCache();\n }\n\n if (actionResult.appState || editingTextElement || this.state.contextMenu) {\n let viewModeEnabled = ((_a = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _a === void 0 ? void 0 : _a.viewModeEnabled) || false;\n let zenModeEnabled = ((_b = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _b === void 0 ? void 0 : _b.zenModeEnabled) || false;\n const theme = ((_c = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _c === void 0 ? void 0 : _c.theme) || this.props.theme || _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.LIGHT;\n const name = (_e = (_d = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : this.state.name;\n const errorMessage = (_g = (_f = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _f === void 0 ? void 0 : _f.errorMessage) !== null && _g !== void 0 ? _g : this.state.errorMessage;\n\n if (typeof this.props.viewModeEnabled !== \"undefined\") {\n viewModeEnabled = this.props.viewModeEnabled;\n }\n\n if (typeof this.props.zenModeEnabled !== \"undefined\") {\n zenModeEnabled = this.props.zenModeEnabled;\n }\n\n editingTextElement = ((_h = actionResult.appState) === null || _h === void 0 ? void 0 : _h.editingTextElement) || null; // make sure editingTextElement points to latest element reference\n\n if (actionResult.elements && editingTextElement) {\n actionResult.elements.forEach(element => {\n if ((editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.id) === element.id && editingTextElement !== element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_37__.isNonDeletedElement)(element) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element)) {\n editingTextElement = element;\n }\n });\n }\n\n if (editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.isDeleted) {\n editingTextElement = null;\n }\n\n this.setState(prevAppState => {\n const actionAppState = actionResult.appState || {};\n return Object.assign(Object.assign(Object.assign({}, prevAppState), actionAppState), {\n // NOTE this will prevent opening context menu using an action\n // or programmatically from the host, so it will need to be\n // rewritten later\n contextMenu: null,\n editingTextElement,\n viewModeEnabled,\n zenModeEnabled,\n theme,\n name,\n errorMessage\n });\n });\n didUpdate = true;\n }\n\n if (!didUpdate && actionResult.captureUpdate !== _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.EVENTUALLY) {\n this.scene.triggerUpdate();\n }\n }); // Lifecycle\n\n this.onBlur = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(() => {\n isHoldingSpace = false;\n this.setState({\n isBindingEnabled: true\n });\n });\n\n this.onUnload = () => {\n this.onBlur();\n };\n\n this.disableEvent = event => {\n event.preventDefault();\n };\n\n this.resetHistory = () => {\n this.history.clear();\n };\n\n this.resetStore = () => {\n this.store.clear();\n };\n /**\r\n * Resets scene & history.\r\n * ! Do not use to clear scene user action !\r\n */\n\n\n this.resetScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(opts => {\n this.scene.replaceAllElements([]);\n this.setState(state => Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_54__.getDefaultAppState)()), {\n isLoading: (opts === null || opts === void 0 ? void 0 : opts.resetLoadingState) ? false : state.isLoading,\n theme: this.state.theme\n }));\n this.resetStore();\n this.resetHistory();\n });\n\n this.initializeScene = async () => {\n var _a;\n\n if (\"launchQueue\" in window && \"LaunchParams\" in window) {\n window.launchQueue.setConsumer(async launchParams => {\n if (!launchParams.files.length) {\n return;\n }\n\n const fileHandle = launchParams.files[0];\n const blob = await fileHandle.getFile();\n this.loadFileToCanvas(new File([blob], blob.name || \"\", {\n type: blob.type\n }), fileHandle);\n });\n }\n\n if (this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n if (!this.state.isLoading) {\n this.setState({\n isLoading: true\n });\n }\n\n let initialData = null;\n\n try {\n if (typeof this.props.initialData === \"function\") {\n initialData = (await this.props.initialData()) || null;\n } else {\n initialData = (await this.props.initialData) || null;\n }\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.libraryItems) {\n this.library.updateLibrary({\n libraryItems: initialData.libraryItems,\n merge: true\n }).catch(error => {\n console.error(error);\n });\n }\n } catch (error) {\n console.error(error);\n initialData = {\n appState: {\n errorMessage: error.message || \"Encountered an error during importing or restoring scene data\"\n }\n };\n }\n\n const scene = (0,_data_restore__WEBPACK_IMPORTED_MODULE_58__.restore)(initialData, null, null, {\n repairBindings: true\n });\n scene.appState = Object.assign(Object.assign({}, scene.appState), {\n theme: this.props.theme || scene.appState.theme,\n // we're falling back to current (pre-init) state when deciding\n // whether to open the library, to handle a case where we\n // update the state outside of initialData (e.g. when loading the app\n // with a library install link, which should auto-open the library)\n openSidebar: ((_a = scene.appState) === null || _a === void 0 ? void 0 : _a.openSidebar) || this.state.openSidebar,\n activeTool: scene.appState.activeTool.type === \"image\" ? Object.assign(Object.assign({}, scene.appState.activeTool), {\n type: \"selection\"\n }) : scene.appState.activeTool,\n isLoading: false,\n toast: this.state.toast\n });\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.scrollToContent) {\n scene.appState = Object.assign(Object.assign({}, scene.appState), (0,_scene__WEBPACK_IMPORTED_MODULE_62__.calculateScrollCenter)(scene.elements, Object.assign(Object.assign({}, scene.appState), {\n width: this.state.width,\n height: this.state.height,\n offsetTop: this.state.offsetTop,\n offsetLeft: this.state.offsetLeft\n })));\n }\n\n this.resetStore();\n this.resetHistory();\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n })); // clear the shape and image cache so that any images in initialData\n // can be loaded fresh\n\n this.clearImageShapeCache(); // manually loading the font faces seems faster even in browsers that do fire the loadingdone event\n\n this.fonts.loadSceneFonts().then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n\n if ((0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.isElementLink)(window.location.href)) {\n this.scrollToContent(window.location.href, {\n animate: false\n });\n }\n };\n\n this.isMobileBreakpoint = (width, height) => {\n return width !== 0 && //zsviczian changing tabs in Obsidian causes MobileMenu to be rendered\n this.allowMobileMode && ( //zsviczian\n width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_MAX_WIDTH_PORTRAIT || height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_MAX_HEIGHT_LANDSCAPE && width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_MAX_WIDTH_LANDSCAPE);\n };\n\n this.refreshViewportBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n clientWidth: viewportWidth,\n clientHeight: viewportHeight\n } = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.getExcalidrawContentEl)(); //zsviczian was document.body;\n\n const prevViewportState = this.device.viewport;\n const nextViewportState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevViewportState, {\n isLandscape: viewportWidth > viewportHeight,\n isMobile: this.isMobileBreakpoint(viewportWidth, viewportHeight)\n });\n\n if (prevViewportState !== nextViewportState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n viewport: nextViewportState\n });\n return true;\n }\n\n return false;\n };\n\n this.refreshEditorBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n width: editorWidth,\n height: editorHeight\n } = container.getBoundingClientRect();\n const sidebarBreakpoint = this.props.UIOptions.dockedSidebarBreakpoint != null ? this.props.UIOptions.dockedSidebarBreakpoint : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MQ_RIGHT_SIDEBAR_MIN_WIDTH;\n const prevEditorState = this.device.editor;\n const nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight),\n canFitSidebar: editorWidth > sidebarBreakpoint\n });\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n return true;\n }\n\n return false;\n };\n\n this.onResize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(() => {\n this.scene.getElementsIncludingDeleted().forEach(element => _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element));\n this.refreshViewportBreakpoints();\n this.updateDOMRect();\n\n if (!_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.supportsResizeObserver) {\n this.refreshEditorBreakpoints();\n }\n\n this.setState({});\n });\n /** generally invoked only if fullscreen was invoked programmatically */\n\n this.onFullscreenChange = () => {\n var _a;\n\n if ( // points to the iframe element we fullscreened\n !document.fullscreenElement && ((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.state) === \"active\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n };\n\n this.renderInteractiveSceneCallback = ({\n atLeastOneVisibleElement,\n scrollBars,\n elementsMap\n }) => {\n if (!document.querySelector(\".excalidraw\")) {\n return;\n } //zsviczian - address issue when moving excalidraw to a new window/document\n\n\n if (scrollBars) {\n currentScrollBars = scrollBars;\n }\n\n const scrolledOutside = // hide when editing text\n this.state.editingTextElement ? false : !atLeastOneVisibleElement && elementsMap.size > 0;\n\n if (this.state.scrolledOutside !== scrolledOutside) {\n this.setState({\n scrolledOutside\n });\n }\n\n this.scheduleImageRefresh();\n };\n\n this.onScroll = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.debounce)(() => {\n const {\n offsetTop,\n offsetLeft\n } = this.getCanvasOffsets();\n this.setState(state => {\n if (state.offsetLeft === offsetLeft && state.offsetTop === offsetTop) {\n return null;\n }\n\n return {\n offsetTop,\n offsetLeft\n };\n });\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.SCROLL_TIMEOUT); // Copy/paste\n\n this.onCut = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionCut, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n this.onCopy = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionCopy, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n\n this.onTouchStart = event => {\n // fix for Apple Pencil Scribble (do not prevent for other devices)\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isIOS) {\n event.preventDefault();\n }\n\n if (!didTapTwice) {\n didTapTwice = true;\n clearTimeout(tappedTwiceTimer);\n tappedTwiceTimer = window.setTimeout(App.resetTapTwice, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TAP_TWICE_TIMEOUT);\n return;\n } // insert text only if we tapped twice with a single finger\n // event.touches.length === 1 will also prevent inserting text when user's zooming\n\n\n if (didTapTwice && event.touches.length === 1) {\n const touch = event.touches[0]; // @ts-ignore\n\n this.handleCanvasDoubleClick({\n clientX: touch.clientX,\n clientY: touch.clientY\n });\n didTapTwice = false;\n clearTimeout(tappedTwiceTimer);\n }\n\n if (event.touches.length === 2) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n };\n\n this.onTouchEnd = event => {\n this.resetContextMenuTimer();\n\n if (event.touches.length > 0) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n } else {\n gesture.pointers.clear();\n }\n };\n\n this.pasteFromClipboard = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(async event => {\n var _a, _b;\n\n const isPlainPaste = !!IS_PLAIN_PASTE; // #686\n\n const target = document.activeElement;\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(target);\n\n if (event && !isExcalidrawActive) {\n return;\n }\n\n const elementUnderCursor = document.elementFromPoint(this.lastViewportPosition.x, this.lastViewportPosition.y);\n\n if (event && (!(elementUnderCursor instanceof HTMLCanvasElement) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(target))) {\n return;\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state); // must be called in the same frame (thus before any awaits) as the paste\n // event else some browsers (FF...) will clear the clipboardData\n // (something something security)\n\n let file = (_b = event === null || event === void 0 ? void 0 : event.clipboardData) === null || _b === void 0 ? void 0 : _b.files[0];\n const data = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_55__.parseClipboard)(event, isPlainPaste);\n\n if (!file && !isPlainPaste) {\n if (data.mixedContent) {\n return this.addElementsFromMixedContentPaste(data.mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n });\n } else if (data.text) {\n const string = data.text.trim();\n\n if (string.startsWith(\"<svg\") && string.endsWith(\"</svg>\")) {\n // ignore SVG validation/normalization which will be done during image\n // initialization\n file = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.SVGStringToFile)(string);\n }\n }\n } // prefer spreadsheet data over image file (MS Office/Libre Office)\n\n\n if ((0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isSupportedImageFile)(file) && !data.spreadsheet) {\n if (!this.isToolSupported(\"image\")) {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const imageElement = this.createImageElement({\n sceneX,\n sceneY\n });\n this.insertImageElement(imageElement, file);\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n });\n return;\n }\n\n if (this.props.onPaste) {\n try {\n if ((await this.props.onPaste(data, event)) === false) {\n return;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n if (data.errorMessage) {\n this.setState({\n errorMessage: data.errorMessage\n });\n } else if (data.spreadsheet && !isPlainPaste) {\n this.setState({\n pasteDialog: {\n data: data.spreadsheet,\n shown: true\n }\n });\n } else if (data.elements) {\n const elements = data.programmaticAPI ? (0,_data_transform__WEBPACK_IMPORTED_MODULE_71__.convertToExcalidrawElements)(data.elements) : data.elements; // TODO remove formatting from elements if isPlainPaste\n\n this.addElementsFromPasteOrLibrary({\n elements,\n files: data.files || null,\n position: \"cursor\",\n retainSeed: isPlainPaste\n });\n } else if (data.text) {\n if (data.text && (0,_mermaid__WEBPACK_IMPORTED_MODULE_81__.isMaybeMermaidDefinition)(data.text)) {\n const api = await Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! @zsviczian/mermaid-to-excalidraw */ \"../../node_modules/@zsviczian/mermaid-to-excalidraw/dist/index.js\"));\n\n try {\n const {\n elements: skeletonElements,\n files\n } = await api.parseMermaidToExcalidraw(data.text);\n const elements = (0,_data_transform__WEBPACK_IMPORTED_MODULE_71__.convertToExcalidrawElements)(skeletonElements, {\n regenerateIds: true\n });\n this.addElementsFromPasteOrLibrary({\n elements,\n files,\n position: \"cursor\"\n });\n return;\n } catch (err) {\n console.warn(`parsing pasted text as mermaid definition failed: ${err.message}`);\n }\n }\n\n const nonEmptyLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeEOL)(data.text).split(/\\n+/).map(s => s.trim()).filter(Boolean);\n const embbeddableUrls = nonEmptyLines.map(str => (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.maybeParseEmbedSrc)(str)).filter(string => {\n var _a;\n\n return (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.embeddableURLValidator)(string, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(string) || ((_a = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)(string)) === null || _a === void 0 ? void 0 : _a.type) === \"video\");\n });\n\n if (!IS_PLAIN_PASTE && embbeddableUrls.length > 0 && // if there were non-embeddable text (lines) mixed in with embeddable\n // urls, ignore and paste as text\n embbeddableUrls.length === nonEmptyLines.length) {\n const embeddables = [];\n\n for (const url of embbeddableUrls) {\n const prevEmbeddable = embeddables[embeddables.length - 1];\n const embeddable = this.insertEmbeddableElement({\n sceneX: prevEmbeddable ? prevEmbeddable.x + prevEmbeddable.width + 20 : sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeLink)(url)\n });\n\n if (embeddable) {\n embeddables.push(embeddable);\n }\n }\n\n if (embeddables.length) {\n this.setState({\n selectedElementIds: Object.fromEntries(embeddables.map(embeddable => [embeddable.id, true]))\n });\n }\n\n return;\n }\n\n this.addTextFromPaste(data.text, isPlainPaste);\n }\n\n this.setActiveTool({\n type: \"selection\"\n });\n event === null || event === void 0 ? void 0 : event.preventDefault();\n });\n\n this.addElementsFromPasteOrLibrary = opts => {\n var _a, _b;\n\n const elements = (0,_data_restore__WEBPACK_IMPORTED_MODULE_58__.restoreElements)(opts.elements, null, undefined);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(elements);\n const elementsCenterX = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(minX, maxX) / 2;\n const elementsCenterY = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(minY, maxY) / 2;\n const clientX = typeof opts.position === \"object\" ? opts.position.clientX : opts.position === \"cursor\" ? this.lastViewportPosition.x : this.state.width / 2 + this.state.offsetLeft;\n const clientY = typeof opts.position === \"object\" ? opts.position.clientY : opts.position === \"cursor\" ? this.lastViewportPosition.y : this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const dx = x - elementsCenterX;\n const dy = y - elementsCenterY;\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(dx, dy, this.getEffectiveGridSize());\n const {\n duplicatedElements\n } = (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElements)({\n type: \"everything\",\n elements: elements.map(element => {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(element, {\n x: element.x + gridX - minX,\n y: element.y + gridY - minY\n });\n }),\n randomizeSeed: !opts.retainSeed\n });\n const prevElements = this.scene.getElementsIncludingDeleted();\n let nextElements = [...prevElements, ...duplicatedElements];\n const mappedNewSceneElements = (_b = (_a = this.props).onDuplicate) === null || _b === void 0 ? void 0 : _b.call(_a, nextElements, prevElements);\n nextElements = mappedNewSceneElements || nextElements;\n (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncMovedIndices)(nextElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(duplicatedElements));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n\n if (topLayerFrame) {\n const eligibleElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.filterElementsEligibleAsFrameChildren)(duplicatedElements, topLayerFrame);\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.addElementsToFrame)(nextElements, eligibleElements, topLayerFrame, this.state);\n }\n\n this.scene.replaceAllElements(nextElements);\n duplicatedElements.forEach(newElement => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(newElement) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(newElement)) {\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(newElement, this.scene.getElementsMapIncludingDeleted());\n (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.redrawTextBoundingBox)(newElement, container, this.scene);\n }\n }); // paste event may not fire FontFace loadingdone event in Safari, hence loading font faces manually\n\n if (true) {\n //zsviczian - isSafari\n _fonts__WEBPACK_IMPORTED_MODULE_67__.Fonts.loadElementsFonts(duplicatedElements).then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n }\n\n if (opts.files) {\n this.addMissingFiles(opts.files);\n }\n\n this.store.shouldCaptureIncrement();\n const nextElementsToSelect = (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.excludeElementsInFramesFromSelection)(duplicatedElements);\n this.setState(Object.assign(Object.assign(Object.assign({}, this.state), {\n // keep sidebar (presumably the library) open if it's docked and\n // can fit.\n //\n // Note, we should close the sidebar only if we're dropping items\n // from library, not when pasting from clipboard. Alas.\n openSidebar: this.state.openSidebar && this.device.editor.canFitSidebar && _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.get(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_94__.isSidebarDockedAtom) ? this.state.openSidebar : null\n }), (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: null,\n selectedElementIds: nextElementsToSelect.reduce((acc, element) => {\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(element)) {\n acc[element.id] = true;\n }\n\n return acc;\n }, {})\n }, this.scene.getNonDeletedElements(), this.state, this)), () => {\n if (opts.files) {\n this.addNewImagesToImageCache();\n }\n });\n this.setActiveTool({\n type: \"selection\"\n });\n\n if (opts.fitToContent) {\n this.scrollToContent(duplicatedElements, {\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n };\n\n this.setAppState = (state, callback) => {\n this.setState(state, callback);\n };\n\n this.removePointer = event => {\n if (touchTimeout) {\n this.resetContextMenuTimer();\n }\n\n gesture.pointers.delete(event.pointerId);\n };\n\n this.toggleLock = (source = \"ui\") => {\n if (!this.state.activeTool.locked) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"toolbar\", \"toggleLock\", `${source} (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n this.setState(prevState => {\n return {\n activeTool: Object.assign(Object.assign(Object.assign({}, prevState.activeTool), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, prevState.activeTool.locked ? {\n type: \"selection\"\n } : prevState.activeTool)), {\n locked: !prevState.activeTool.locked\n })\n };\n });\n };\n\n this.updateFrameRendering = opts => {\n this.setState(prevState => {\n var _a, _b, _c, _d;\n\n const next = typeof opts === \"function\" ? opts(prevState.frameRendering) : opts;\n return {\n frameRendering: {\n enabled: (_a = next === null || next === void 0 ? void 0 : next.enabled) !== null && _a !== void 0 ? _a : prevState.frameRendering.enabled,\n clip: (_b = next === null || next === void 0 ? void 0 : next.clip) !== null && _b !== void 0 ? _b : prevState.frameRendering.clip,\n name: (_c = next === null || next === void 0 ? void 0 : next.name) !== null && _c !== void 0 ? _c : prevState.frameRendering.name,\n outline: (_d = next === null || next === void 0 ? void 0 : next.outline) !== null && _d !== void 0 ? _d : prevState.frameRendering.outline\n }\n };\n });\n };\n\n this.togglePenMode = force => {\n this.setState(prevState => {\n return {\n penMode: force !== null && force !== void 0 ? force : !prevState.penMode,\n penDetected: true\n };\n });\n };\n\n this.onHandToolToggle = () => {\n //zsviczian added timeout because button won't select otherwise\n setTimeout(() => this.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.actionToggleHandTool));\n };\n /**\r\n * Zooms on canvas viewport center\r\n */\n\n\n this.zoomCanvas = (\n /**\r\n * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.\r\n * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom\r\n */\n value) => {\n this.setState(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: this.state.width / 2 + this.state.offsetLeft,\n viewportY: this.state.height / 2 + this.state.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(value)\n }, this.state)));\n };\n\n this.cancelInProgressAnimation = null;\n\n this.scrollToContent = (\n /**\r\n * target to scroll to\r\n *\r\n * - string - id of element or group, or url containing elementLink\r\n * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects\r\n */\n target = this.scene.getNonDeletedElements(), opts) => {\n var _a, _b, _c, _d;\n\n if (typeof target === \"string\") {\n let id;\n\n if ((0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.isElementLink)(target)) {\n id = (0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.parseElementLinkFromURL)(target);\n } else {\n id = target;\n }\n\n if (id) {\n const elements = this.scene.getElementsFromId(id);\n\n if (elements === null || elements === void 0 ? void 0 : elements.length) {\n this.scrollToContent(elements, {\n fitToContent: (_a = opts === null || opts === void 0 ? void 0 : opts.fitToContent) !== null && _a !== void 0 ? _a : true,\n animate: (_b = opts === null || opts === void 0 ? void 0 : opts.animate) !== null && _b !== void 0 ? _b : true\n });\n } else if ((0,_excalidraw_element_elementLink__WEBPACK_IMPORTED_MODULE_27__.isElementLink)(target)) {\n this.setState({\n toast: {\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"elementLink.notFound\"),\n duration: 3000,\n closable: true\n }\n });\n }\n }\n\n return;\n }\n\n (_c = this.cancelInProgressAnimation) === null || _c === void 0 ? void 0 : _c.call(this); // convert provided target into ExcalidrawElement[] if necessary\n\n const targetElements = Array.isArray(target) ? target : [target];\n let zoom = this.state.zoom;\n let scrollX = this.state.scrollX;\n let scrollY = this.state.scrollY;\n\n if ((opts === null || opts === void 0 ? void 0 : opts.fitToContent) || (opts === null || opts === void 0 ? void 0 : opts.fitToViewport)) {\n const {\n appState\n } = (0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.zoomToFit)({\n canvasOffsets: opts.canvasOffsets,\n targetElements,\n appState: this.state,\n fitToViewport: !!(opts === null || opts === void 0 ? void 0 : opts.fitToViewport),\n viewportZoomFactor: opts === null || opts === void 0 ? void 0 : opts.viewportZoomFactor,\n minZoom: opts === null || opts === void 0 ? void 0 : opts.minZoom,\n maxZoom: opts === null || opts === void 0 ? void 0 : opts.maxZoom\n });\n zoom = appState.zoom;\n scrollX = appState.scrollX;\n scrollY = appState.scrollY;\n } else {\n // compute only the viewport location, without any zoom adjustment\n const scroll = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.calculateScrollCenter)(targetElements, this.state);\n scrollX = scroll.scrollX;\n scrollY = scroll.scrollY;\n } // when animating, we use RequestAnimationFrame to prevent the animation\n // from slowing down other processes\n\n\n if (opts === null || opts === void 0 ? void 0 : opts.animate) {\n const origScrollX = this.state.scrollX;\n const origScrollY = this.state.scrollY;\n const origZoom = this.state.zoom.value;\n const cancel = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.easeToValuesRAF)({\n fromValues: {\n scrollX: origScrollX,\n scrollY: origScrollY,\n zoom: origZoom\n },\n toValues: {\n scrollX,\n scrollY,\n zoom: zoom.value\n },\n interpolateValue: (from, to, progress, key) => {\n // for zoom, use different easing\n if (key === \"zoom\") {\n return from * Math.pow(to / from, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.easeOut)(progress));\n } // handle using default\n\n\n return undefined;\n },\n onStep: ({\n scrollX,\n scrollY,\n zoom\n }) => {\n this.setState({\n scrollX,\n scrollY,\n zoom: {\n value: zoom\n }\n });\n },\n onStart: () => {\n this.setState({\n shouldCacheIgnoreZoom: true\n });\n },\n onEnd: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n onCancel: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n duration: (_d = opts === null || opts === void 0 ? void 0 : opts.duration) !== null && _d !== void 0 ? _d : 500\n });\n\n this.cancelInProgressAnimation = () => {\n cancel();\n this.cancelInProgressAnimation = null;\n };\n } else {\n this.setState({\n scrollX,\n scrollY,\n zoom\n });\n }\n };\n\n this.maybeUnfollowRemoteUser = () => {\n if (this.state.userToFollow) {\n this.setState({\n userToFollow: null\n });\n }\n };\n /** use when changing scrollX/scrollY/zoom based on user interaction */\n\n\n this.translateCanvas = state => {\n var _a;\n\n (_a = this.cancelInProgressAnimation) === null || _a === void 0 ? void 0 : _a.call(this);\n this.maybeUnfollowRemoteUser();\n this.setState(state);\n }; //zsviczian\n\n\n this.setForceRenderAllEmbeddables = force => {\n this.shouldRenderAllEmbeddables = force;\n\n if (force) {\n this.setState({});\n }\n }; //zsviczian\n\n\n this.zoomToFit = (target = this.scene.getNonDeletedElements(), maxZoom, //null will zoom to max based on viewport\n margin = 0.03) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.getMaxZoom)();\n }\n\n if (!target) {\n target = this.scene.getNonDeletedElements();\n }\n\n if (target.length === 0) {\n maxZoom = 1;\n }\n\n this.setState((0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.zoomToFitElements)(target, this.state, false, this, maxZoom, margin).appState);\n }; //zsviczian\n\n\n this.getColorAtScenePoint = ({\n sceneX,\n sceneY\n }) => {\n if (!this.canvas) {\n console.error(\"Canvas not available\");\n return null;\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX,\n sceneY\n }, this.state);\n const context = this.canvas.getContext(\"2d\");\n\n if (!context) {\n console.error(\"2D context not available\");\n return null;\n } // Get pixel data directly from the given scene coordinates\n\n\n const pixelData = context.getImageData(x, y, 1, 1).data;\n const [r, g, b, a] = pixelData; // Check for transparency\n\n if (a === 0) {\n return this.state.theme === \"light\" ? \"rgba(255,255,255,1)\" : \"rgba(0,0,0,1)\";\n } // Return the color in rgba format\n\n\n return `rgba(${r}, ${g}, ${b}, ${a / 255})`;\n }; //zsviczian\n\n\n this.startLineEditor = (el, selectedPointsIndices = null) => {\n if (!el || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(el)) {\n return;\n }\n\n const editingLinearElement = new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(el, this.scene.getNonDeletedElementsMap());\n this.setState({\n selectedLinearElement: editingLinearElement,\n editingLinearElement: Object.assign(Object.assign({}, editingLinearElement), {\n selectedPointsIndices\n })\n });\n }; //zsviczian\n\n\n this.updateContainerSize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(containers => {\n containers.forEach(element => {\n // Get absolute coordinates for the bottom-right corner\n const [x1, y1, x2, y2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getResizedElementAbsoluteCoords)(element, element.width, element.height, true); // Get rotated pointer position at bottom-right corner\n\n const [pointerX, pointerY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((x1 + x2) / 2, (y1 + y2) / 2), element.angle);\n const {\n nextWidth,\n nextHeight\n } = (0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.getNextSingleWidthAndHeightFromPointer)(element, element, \"se\", pointerX, pointerY);\n (0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.resizeSingleElement)(nextWidth, nextHeight, element, element, this.scene.getElementsMapIncludingDeleted(), this.scene, \"se\", {\n shouldMaintainAspectRatio: true,\n shouldResizeFromCenter: false\n });\n });\n });\n\n this.setToast = toast => {\n this.setState({\n toast\n });\n };\n\n this.restoreFileFromShare = async () => {\n try {\n const webShareTargetCache = await caches.open(\"web-share-target\");\n const response = await webShareTargetCache.match(\"shared-file\");\n\n if (response) {\n const blob = await response.blob();\n const file = new File([blob], blob.name || \"\", {\n type: blob.type\n });\n this.loadFileToCanvas(file, null);\n await webShareTargetCache.delete(\"shared-file\");\n window.history.replaceState(null, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.APP_NAME, window.location.pathname);\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n };\n /**\r\n * adds supplied files to existing files in the appState.\r\n * NOTE if file already exists in editor state, the file data is not updated\r\n * */\n\n\n this.addFiles = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(files => {\n const {\n addedFiles\n } = this.addMissingFiles(files, undefined, true); //zsviczian\n\n this.clearImageShapeCache(addedFiles);\n this.scene.triggerUpdate();\n this.addNewImagesToImageCache();\n }); //zsviczian https://github.com/zsviczian/excalibrain/issues/9\n\n this.setMobileModeAllowed = allow => {\n const {\n width: editorWidth,\n height: editorHeight\n } = this.excalidrawContainerRef.current.getBoundingClientRect();\n this.allowMobileMode = allow;\n const prevEditorState = this.device.editor;\n let nextEditorState;\n\n if (allow) {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight)\n });\n } else {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(prevEditorState, {\n isMobile: false //must test this\n\n });\n }\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n this.forceUpdate();\n }\n }; //zsviczian\n\n\n this.debounceClearHighlightSearchResults = false;\n\n this.selectElements = (elements, highlightSearchResult = false) => {\n //zsviczian\n if (highlightSearchResult) {\n this.debounceClearHighlightSearchResults = true;\n setTimeout(() => {\n this.debounceClearHighlightSearchResults = false;\n }, 500);\n }\n\n this.updateScene({\n appState: Object.assign(Object.assign({}, this.state), {\n editingGroupId: null,\n selectedElementIds: elements.reduce((map, element) => {\n map[element.id] = true;\n return map;\n }, {}),\n highlightSearchResult\n }),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER,\n forceFlushSync: true\n });\n }; //zsviczian\n\n\n this.bringToFront = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionBringToFront.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.bringForward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionBringForward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n }; //zsviczian\n\n\n this.sendToBack = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionSendToBack.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.sendBackward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_39__.actionSendBackward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n };\n\n this.addMissingFiles = (files, replace = false, force = false) => {\n var _a;\n\n const nextFiles = replace ? {} : Object.assign({}, this.files);\n const addedFiles = {};\n\n const _files = Array.isArray(files) ? files : Object.values(files);\n\n for (const fileData of _files) {\n if (!force && nextFiles[fileData.id]) {\n //zsviczian\n continue;\n }\n\n addedFiles[fileData.id] = fileData;\n nextFiles[fileData.id] = fileData;\n\n if (fileData.mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n try {\n const restoredDataURL = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getDataURL_sync)((0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.normalizeSVG)((0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.dataURLToString)(fileData.dataURL)), _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg);\n\n if (fileData.dataURL !== restoredDataURL) {\n // bump version so persistence layer can update the store\n fileData.version = ((_a = fileData.version) !== null && _a !== void 0 ? _a : 1) + 1;\n fileData.dataURL = restoredDataURL;\n }\n } catch (error) {\n console.error(error);\n }\n }\n }\n\n this.files = nextFiles;\n return {\n addedFiles\n };\n };\n\n this.updateScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(sceneData => {\n var _a;\n\n const nextElements = (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncInvalidIndices)((_a = sceneData.elements) !== null && _a !== void 0 ? _a : []);\n\n if (sceneData.captureUpdate && sceneData.captureUpdate !== _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.EVENTUALLY) {\n const prevCommittedAppState = this.store.snapshot.appState;\n const prevCommittedElements = this.store.snapshot.elements;\n const nextCommittedAppState = sceneData.appState ? Object.assign({}, prevCommittedAppState, sceneData.appState) // new instance, with partial appstate applied to previously captured one, including hidden prop inside `prevCommittedAppState`\n : prevCommittedAppState;\n const nextCommittedElements = sceneData.elements ? this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(), // Only used to detect uncomitted local elements\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(nextElements)) : prevCommittedElements; // WARN: store action always performs deep clone of changed elements, for ephemeral remote updates (i.e. remote dragging, resizing, drawing) we might consider doing something smarter\n // do NOT schedule store actions (execute after re-render), as it might cause unexpected concurrency issues if not handled well\n\n if (sceneData.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY) {\n this.store.captureIncrement(nextCommittedElements, nextCommittedAppState);\n } else if (sceneData.captureUpdate === _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER) {\n this.store.updateSnapshot(nextCommittedElements, nextCommittedAppState);\n }\n } //zsviczian forceFlushSync is set to true in ExcalidrawView.updateScene.\n //without this e.g. text search did not select the elements\n\n\n if (sceneData.forceFlushSync === true) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (sceneData.appState) {\n this.setState(sceneData.appState);\n }\n });\n } else if (sceneData.appState) {\n this.setState(sceneData.appState);\n }\n\n if (sceneData.elements) {\n this.scene.replaceAllElements(nextElements);\n }\n\n if (sceneData.collaborators) {\n this.setState({\n collaborators: sceneData.collaborators\n });\n }\n });\n\n this.mutateElement = (element, updates, informMutation = true) => {\n return this.scene.mutateElement(element, updates, {\n informMutation,\n isDragging: false\n });\n };\n\n this.triggerRender = (\n /** force always re-renders canvas even if no change */\n force) => {\n if (force === true) {\n this.scene.triggerUpdate();\n } else {\n this.setState({});\n }\n };\n /**\r\n * @returns whether the menu was toggled on or off\r\n */\n\n\n this.toggleSidebar = ({\n name,\n tab,\n force\n }) => {\n var _a, _b;\n\n let nextName;\n\n if (force === undefined) {\n nextName = ((_a = this.state.openSidebar) === null || _a === void 0 ? void 0 : _a.name) === name && ((_b = this.state.openSidebar) === null || _b === void 0 ? void 0 : _b.tab) === tab ? null : name;\n } else {\n nextName = force ? name : null;\n }\n\n const nextState = nextName ? {\n name: nextName\n } : null;\n\n if (nextState && tab) {\n nextState.tab = tab;\n }\n\n this.setState({\n openSidebar: nextState\n });\n return !!nextName;\n };\n\n this.updateCurrentCursorPosition = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n this.lastViewportPosition.x = event.clientX;\n this.lastViewportPosition.y = event.clientY;\n });\n\n this.getEditorUIOffsets = () => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n const toolbarBottom = ((_e = (_d = (_c = (_b = (_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.querySelector(\".App-toolbar\")) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) === null || _d === void 0 ? void 0 : _d.bottom) !== null && _e !== void 0 ? _e : 0) - this.state.offsetTop;\n const sidebarRect = (_h = (_g = (_f = this.excalidrawContainerRef) === null || _f === void 0 ? void 0 : _f.current) === null || _g === void 0 ? void 0 : _g.querySelector(\".sidebar\")) === null || _h === void 0 ? void 0 : _h.getBoundingClientRect();\n const propertiesPanelRect = (_l = (_k = (_j = this.excalidrawContainerRef) === null || _j === void 0 ? void 0 : _j.current) === null || _k === void 0 ? void 0 : _k.querySelector(\".App-menu__left\")) === null || _l === void 0 ? void 0 : _l.getBoundingClientRect();\n const PADDING = 16;\n\n const adjustRectValueForOffset = ( //zsviczian https://github.com/excalidraw/excalidraw/issues/8561\n value, fallback) => (value !== null && value !== void 0 ? value : fallback + this.state.offsetLeft) - this.state.offsetLeft;\n\n return (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.getLanguage)().rtl ? {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset( //zsivczian\n propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.left, this.state.width), 0) + PADDING,\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.right, 0), 0) + PADDING\n } : {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.left, this.state.width) + //zsivczian\n PADDING, 0),\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.right, 0), 0) + PADDING\n };\n }; // Input handling\n\n\n this.onKeyDown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e;\n\n if (this.state.activeTool.type === \"selection\" && this.state.resizingElement && (event.shiftKey || event.altKey)) {\n event.stopPropagation(); //zsviczian shift fires repeatedly causing slowdown when resizing sticky notes\n\n return;\n } // normalize `event.key` when CapsLock is pressed #2372\n\n\n if (\"Proxy\" in window && (!event.shiftKey && /^[A-Z]$/.test(event.key) || event.shiftKey && /^[a-z]$/.test(event.key))) {\n event = new Proxy(event, {\n get(ev, prop) {\n const value = ev[prop];\n\n if (typeof value === \"function\") {\n // fix for Proxies hijacking `this`\n return value.bind(ev);\n }\n\n return prop === \"key\" ? // CapsLock inverts capitalization based on ShiftKey, so invert\n // it back\n event.shiftKey ? ev.key.toUpperCase() : ev.key.toLowerCase() : value;\n }\n\n });\n }\n\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isInputLike)(event.target)) {\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) && this.state.croppingElementId) {\n this.finishImageCropping();\n return;\n }\n\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(selectedElements[0]) && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) {\n this.startImageCropping(selectedElements[0]);\n return;\n } // Shape switching\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypePopupAtom, null);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.TAB && (document.activeElement === ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) || ((_b = document.activeElement) === null || _b === void 0 ? void 0 : _b.classList.contains(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CLASSES.CONVERT_ELEMENT_TYPE_POPUP)))) {\n event.preventDefault();\n const conversionType = (0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.getConversionTypeFromElements)(selectedElements);\n\n if (((_c = _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypePopupAtom)) === null || _c === void 0 ? void 0 : _c.type) === \"panel\") {\n if ((0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypes)(this, {\n conversionType,\n direction: event.shiftKey ? \"left\" : \"right\"\n })) {\n this.store.shouldCaptureIncrement();\n }\n }\n\n if (conversionType) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypePopupAtom, {\n type: \"panel\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE && this.flowChartCreator.isCreatingChart) {\n this.flowChartCreator.clear();\n this.triggerRender(true);\n return;\n }\n\n const arrowKeyPressed = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key);\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && arrowKeyPressed && !event.shiftKey) {\n event.preventDefault();\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFlowchartNodeElement)(selectedElements[0])) {\n this.flowChartCreator.createNodes(selectedElements[0], this.state, (0,_excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.getLinkDirectionFromKey)(event.key), this.scene);\n }\n\n if (((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) && !(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementCompletelyInViewport)(this.flowChartCreator.pendingNodes, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(this.flowChartCreator.pendingNodes, {\n animate: true,\n duration: 300,\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n\n return;\n }\n\n if (event.altKey) {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && arrowKeyPressed) {\n event.preventDefault();\n const nextId = this.flowChartNavigator.exploreByDirection(selectedElements[0], this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element_flowchart__WEBPACK_IMPORTED_MODULE_24__.getLinkDirectionFromKey)(event.key));\n\n if (nextId) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [nextId]: true\n }, prevState)\n }));\n const nextNode = this.scene.getNonDeletedElementsMap().get(nextId);\n\n if (nextNode && !(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementCompletelyInViewport)([nextNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(nextNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n return;\n }\n }\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.P && !event.shiftKey && !event.altKey) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"commandPalette.shortcutHint\", {\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_51__.getShortcutFromShortcutName)(\"commandPalette\")\n })\n });\n event.preventDefault();\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.V) {\n IS_PLAIN_PASTE = event.shiftKey;\n clearTimeout(IS_PLAIN_PASTE_TIMER); // reset (100ms to be safe that we it runs after the ensuing\n // paste event). Though, technically unnecessary to reset since we\n // (re)set the flag before each paste event.\n\n IS_PLAIN_PASTE_TIMER = window.setTimeout(() => {\n IS_PLAIN_PASTE = false;\n }, 100);\n } // prevent browser zoom in input fields\n\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target)) {\n if (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CODES.EQUAL) {\n event.preventDefault();\n return;\n }\n } // bail if\n\n\n if ( // inside an input\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isWritableElement)(event.target) && // unless pressing escape (finalize action)\n event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ESCAPE || // or unless using arrows (to move between buttons)\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isInputLike)(event.target)) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.QUESTION_MARK) {\n this.setState({\n openDialog: {\n name: \"help\"\n }\n });\n return;\n } else if (event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.E && event.shiftKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n this.setState({\n openDialog: {\n name: \"imageExport\"\n }\n });\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.PAGE_UP || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.PAGE_DOWN) {\n let offset = (event.shiftKey ? this.state.width : this.state.height) / this.state.zoom.value;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.PAGE_DOWN) {\n offset = -offset;\n }\n\n if (event.shiftKey) {\n this.translateCanvas(state => ({\n scrollX: state.scrollX + offset\n }));\n } else {\n this.translateCanvas(state => ({\n scrollY: state.scrollY + offset\n }));\n }\n }\n\n if (((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) === \"elementLinkSelector\") {\n return;\n }\n\n if (this.actionManager.handleKeyDown(event)) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isLaserPointerActive)(this.state)) {\n this.setActiveTool({\n type: \"selection\"\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (this.state.viewModeEnabled) {\n //revert to hand in case a key is pressed (K is handled above)\n if (event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.K) {\n this.setActiveTool({\n type: \"selection\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: false\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key)) {\n let selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n const elbowArrow = selectedElements.find(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow);\n const arrowIdsToRemove = new Set();\n selectedElements.filter(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow).filter(arrow => {\n const startElementNotInSelection = arrow.startBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.startBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n const endElementNotInSelection = arrow.endBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.endBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n return startElementNotInSelection || endElementNotInSelection;\n }).forEach(arrow => arrowIdsToRemove.add(arrow.id));\n selectedElements = selectedElements.filter(el => !arrowIdsToRemove.has(el.id));\n const step = this.getEffectiveGridSize() && (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_TRANSLATE_AMOUNT : this.getEffectiveGridSize()) || (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_SHIFT_TRANSLATE_AMOUNT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_TRANSLATE_AMOUNT);\n let offsetX = 0;\n let offsetY = 0;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_LEFT) {\n offsetX = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_RIGHT) {\n offsetX = step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_UP) {\n offsetY = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ARROW_DOWN) {\n offsetY = step;\n }\n\n selectedElements.forEach(element => {\n this.scene.mutateElement(element, {\n x: element.x + offsetX,\n y: element.y + offsetY\n }, {\n informMutation: false,\n isDragging: false\n });\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.updateBoundElements)(element, this.scene, {\n simultaneouslyUpdated: selectedElements\n });\n });\n this.setState({\n suggestedBindings: (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getSuggestedBindingsForArrows)(selectedElements.filter(element => element.id !== (elbowArrow === null || elbowArrow === void 0 ? void 0 : elbowArrow.id) || step !== 0), this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n this.scene.triggerUpdate();\n event.preventDefault();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ENTER) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n const selectedElement = selectedElements[0];\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(selectedElement)) {\n if (!this.state.editingLinearElement || this.state.editingLinearElement.elementId !== selectedElements[0].id) {\n this.store.shouldCaptureIncrement();\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElement)) {\n this.setState({\n editingLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(selectedElement, this.scene.getNonDeletedElementsMap())\n });\n }\n }\n }\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElement) || (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.isValidTextContainer)(selectedElement)) {\n let container;\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElement)) {\n container = selectedElement;\n }\n\n const midPoint = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerCenter)(selectedElement, this.state, this.scene.getNonDeletedElementsMap());\n const sceneX = midPoint.x;\n const sceneY = midPoint.y;\n this.startTextEditing({\n sceneX,\n sceneY,\n container\n });\n event.preventDefault();\n return;\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(selectedElement)) {\n this.setState({\n editingFrame: selectedElement.id\n });\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(selectedElement)) {\n //zsviczian\n this.setState({\n activeEmbeddable: {\n element: selectedElement,\n state: \"active\"\n }\n });\n }\n }\n } else if (!event.ctrlKey && !event.altKey && !event.metaKey && !this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged) {\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_100__.findShapeByKey)(event.key);\n\n if (shape) {\n if (this.state.activeTool.type !== shape) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"toolbar\", shape, `keyboard (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n if (shape === \"arrow\" && this.state.activeTool.type === \"arrow\") {\n this.setState(prevState => ({\n currentItemArrowType: prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.sharp ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.round : prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.round ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.elbow : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.sharp\n }));\n }\n\n this.setActiveTool({\n type: shape\n });\n event.stopPropagation();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.Q) {\n this.toggleLock(\"keyboard\");\n event.stopPropagation();\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.SPACE && gesture.pointers.size === 0) {\n isHoldingSpace = true;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n event.preventDefault();\n }\n\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.G || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.S) && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.G && ((0,_scene__WEBPACK_IMPORTED_MODULE_62__.hasBackground)(this.state.activeTool.type) || selectedElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_62__.hasBackground)(element.type)))) {\n this.setState({\n openPopup: \"elementBackground\"\n });\n event.stopPropagation();\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.S) {\n this.setState({\n openPopup: \"elementStroke\"\n });\n event.stopPropagation();\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.F) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (this.state.activeTool.type === \"text\" || selectedElements.find(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element) || (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(element, this.scene.getNonDeletedElementsMap()))) {\n event.preventDefault();\n this.setState({\n openPopup: \"fontFamily\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if (this.state.activeTool.type === \"laser\") {\n this.setActiveTool({\n type: \"selection\"\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.BACKSPACE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.DELETE)) {\n this.updateEditorAtom(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_85__.activeConfirmDialogAtom, \"clearCanvas\");\n } // eye dropper\n // -----------------------------------------------------------------------\n\n\n const lowerCased = event.key.toLocaleLowerCase();\n const isPickingStroke = lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.S && event.shiftKey;\n const isPickingBackground = event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.I || lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.G && event.shiftKey;\n\n if (isPickingStroke || isPickingBackground) {\n this.openEyeDropper({\n type: isPickingStroke ? \"stroke\" : \"background\"\n });\n } // -----------------------------------------------------------------------\n\n });\n this.onKeyUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.SPACE) {\n if (this.state.viewModeEnabled || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else if (this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n isHoldingSpace = false;\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && !this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: true\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isArrowKey)(event.key)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.bindOrUnbindLinearElements)(this.scene.getSelectedElements(this.state).filter(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement), (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state), (_c = (_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) !== null && _c !== void 0 ? _c : [], this.scene, this.state.zoom);\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (!event.altKey) {\n if (this.flowChartNavigator.isExploring) {\n this.flowChartNavigator.clear();\n this.syncActionResult({\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if (this.flowChartCreator.isCreatingChart) {\n if ((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) {\n this.scene.insertElements(this.flowChartCreator.pendingNodes);\n }\n\n const firstNode = (_e = this.flowChartCreator.pendingNodes) === null || _e === void 0 ? void 0 : _e[0];\n\n if (firstNode) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [firstNode.id]: true\n }, prevState)\n }));\n\n if (!(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementCompletelyInViewport)([firstNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(firstNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n this.flowChartCreator.clear();\n this.syncActionResult({\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n }); // We purposely widen the `tool` type so this helper can be called with\n // any tool without having to type check it\n\n this.isToolSupported = tool => {\n var _a;\n\n return ((_a = this.props.UIOptions.tools) === null || _a === void 0 ? void 0 : _a[tool]) !== false;\n };\n\n this.setActiveTool = (tool, keepSelection = false) => {\n var _a;\n\n if (!this.isToolSupported(tool.type)) {\n console.warn(`\"${tool.type}\" tool is disabled via \"UIOptions.canvasActions.tools.${tool.type}\"`);\n return;\n }\n\n const nextActiveTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, tool);\n\n if (nextActiveTool.type === \"hand\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else if (!isHoldingSpace) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, Object.assign(Object.assign({}, this.state), {\n activeTool: nextActiveTool\n }));\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isToolIcon)(document.activeElement)) {\n this.focusContainer();\n }\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElementType)(nextActiveTool.type)) {\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (nextActiveTool.type === \"image\") {\n this.onImageAction({\n insertOnCanvasDirectly: (_a = tool.type === \"image\" && tool.insertOnCanvasDirectly) !== null && _a !== void 0 ? _a : false\n });\n }\n\n setTimeout(() => {\n this.setState(prevState => {\n const commonResets = {\n snapLines: prevState.snapLines.length ? [] : prevState.snapLines,\n originSnapOffset: null,\n activeEmbeddable: null\n };\n\n if (nextActiveTool.type === \"freedraw\") {\n this.store.shouldCaptureIncrement();\n }\n\n if (nextActiveTool.type === \"lasso\") {\n return Object.assign(Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), keepSelection ? {} : {\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n selectedGroupIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n } else if (nextActiveTool.type !== \"selection\") {\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool,\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextActiveTool.type === \"mermaid\" //zsviczian\n ? this.state.selectedElementIds : {}, prevState),\n selectedGroupIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n }\n\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), commonResets);\n });\n }); //zsviczian added timeout because button won't select otherwise\n };\n\n this.setOpenDialog = dialogType => {\n this.setState({\n openDialog: dialogType\n });\n };\n\n this.setCursor = cursor => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, cursor);\n };\n\n this.resetCursor = () => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n };\n /**\r\n * returns whether user is making a gesture with >= 2 fingers (points)\r\n * on o touch screen (not on a trackpad). Currently only relates to Darwin\r\n * (iOS/iPadOS,MacOS), but may work on other devices in the future if\r\n * GestureEvent is standardized.\r\n */\n\n\n this.isTouchScreenMultiTouchGesture = () => {\n // we don't want to deselect when using trackpad, and multi-point gestures\n // only work on touch screens, so checking for >= pointers means we're on a\n // touchscreen\n return gesture.pointers.size >= 2;\n };\n\n this.getName = () => {\n return this.state.name || this.props.name || `${(0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getDateTime)()}`;\n }; // fires only on Safari\n\n\n this.onGestureStart = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n event.preventDefault(); // we only want to deselect on touch screens because user may have selected\n // elements by mistake while zooming\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n\n gesture.initialScale = this.state.zoom.value;\n }); // fires only on Safari\n\n this.onGestureChange = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n event.preventDefault(); // onGestureChange only has zoom factor but not the center.\n // If we're on iPad or iPhone, then we recognize multi-touch and will\n // zoom in at the right location in the touchmove handler\n // (handleCanvasPointerMove).\n //\n // On Macbook trackpad, we don't have those events so will zoom in at the\n // current location instead.\n //\n // As such, bail from this handler on touch devices.\n\n if (this.isTouchScreenMultiTouchGesture()) {\n return;\n }\n\n const initialScale = gesture.initialScale;\n\n if (initialScale) {\n this.setState(state => Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(initialScale * event.scale)\n }, state)));\n }\n }); // fires only on Safari\n\n this.onGestureEnd = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n event.preventDefault(); // reselect elements only on touch screens (see onGestureStart)\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n }\n\n gesture.initialScale = null;\n });\n\n this.startTextEditing = ({\n sceneX,\n sceneY,\n insertAtParentCenter = true,\n container,\n autoEdit = true\n }) => {\n var _a;\n\n let shouldBindToContainer = false;\n let parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n\n if (container && parentCenterPosition) {\n const boundTextElementToContainer = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(container, this.scene.getNonDeletedElementsMap());\n\n if (!boundTextElementToContainer) {\n shouldBindToContainer = true;\n }\n }\n\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n const fontFamily = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.fontFamily) || this.state.currentItemFontFamily;\n const lineHeight = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.lineHeight) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getLineHeight)(fontFamily);\n const fontSize = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_103__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value); //zsviczian\n\n if (!existingTextElement && shouldBindToContainer && container && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isArrowElement)(container)) {\n const fontString = {\n fontSize,\n fontFamily\n };\n const minWidth = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getApproxMinLineWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getFontString)(fontString), lineHeight);\n const minHeight = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getApproxMinLineHeight)(fontSize, lineHeight);\n const newHeight = Math.max(container.height, minHeight);\n const newWidth = Math.max(container.width, minWidth);\n this.scene.mutateElement(container, {\n height: newHeight,\n width: newWidth\n });\n sceneX = container.x + newWidth / 2;\n sceneY = container.y + newHeight / 2;\n\n if (parentCenterPosition) {\n parentCenterPosition = this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n }\n }\n\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: sceneX,\n y: sceneY\n });\n const element = existingTextElement || (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newTextElement)({\n x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX,\n y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text: \"\",\n rawText: \"\",\n fontSize,\n fontFamily,\n textAlign: parentCenterPosition ? \"center\" : this.state.currentItemTextAlign,\n verticalAlign: parentCenterPosition ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.VERTICAL_ALIGN.MIDDLE : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_VERTICAL_ALIGN,\n containerId: shouldBindToContainer ? container === null || container === void 0 ? void 0 : container.id : undefined,\n groupIds: (_a = container === null || container === void 0 ? void 0 : container.groupIds) !== null && _a !== void 0 ? _a : [],\n lineHeight,\n angle: container ? (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isArrowElement)(container) ? 0 : container.angle : 0,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n\n if (!existingTextElement && shouldBindToContainer && container) {\n this.scene.mutateElement(container, {\n boundElements: (container.boundElements || []).concat({\n type: \"text\",\n id: element.id\n })\n });\n }\n\n this.setState({\n editingTextElement: element\n });\n\n if (!existingTextElement) {\n if (container && shouldBindToContainer) {\n const containerIndex = this.scene.getElementIndex(container.id);\n this.scene.insertElementAtIndex(element, containerIndex + 1);\n } else {\n this.scene.insertElement(element);\n }\n }\n\n if (autoEdit || existingTextElement || container) {\n this.handleTextWysiwyg(element, {\n isExistingElement: !!existingTextElement\n });\n } else {\n this.setState({\n newElement: element,\n multiElement: null\n });\n }\n };\n\n this.debounceDoubleClickTimestamp = 0; //zsviczian\n\n this.startImageCropping = image => {\n this.store.shouldCaptureIncrement();\n this.setState({\n croppingElementId: image.id\n });\n };\n\n this.finishImageCropping = () => {\n if (this.state.croppingElementId) {\n this.store.shouldCaptureIncrement();\n this.setState({\n croppingElementId: null\n });\n }\n };\n\n this.handleCanvasDoubleClick = event => {\n var _a; // case: double-clicking with arrow/line tool selected would both create\n // text and enter multiElement mode\n\n\n if (this.state.multiElement) {\n return;\n }\n\n if ( //zsviczian - double click eraser\n this.state.penMode && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.allowDoubleTapEraser)() && ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.pointerType) === \"touch\" && this.state.activeTool.type !== \"selection\") {\n const now = Date.now();\n\n if (now - this.debounceDoubleClickTimestamp < 200) {\n //handleCanvasDoubleClick click fires twice in case of touch.\n //Once from the onTouchStart event handler, once from the double click event handler\n return;\n }\n\n this.debounceDoubleClickTimestamp = now;\n this.updateScene(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.actionToggleEraserTool.perform([], this.state));\n return;\n } // zsviczian - end\n // we should only be able to double click when mode is selection\n\n\n if (this.state.activeTool.type !== \"selection\") {\n return;\n }\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n let {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(selectedElements[0])) {\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && (!this.state.editingLinearElement || this.state.editingLinearElement.elementId !== selectedElements[0].id) && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0])) {\n this.store.shouldCaptureIncrement();\n this.setState({\n editingLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(selectedElements[0], this.scene.getNonDeletedElementsMap())\n });\n return;\n } else if (this.state.selectedLinearElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0])) {\n const hitCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(this.state.selectedLinearElement, {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const midPoint = hitCoords ? _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, hitCoords, this.scene.getNonDeletedElementsMap()) : -1;\n\n if (midPoint && midPoint > -1) {\n this.store.shouldCaptureIncrement();\n _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.deleteFixedSegment(selectedElements[0], this.scene, midPoint);\n const nextCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const nextIndex = nextCoords ? _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : null;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: Object.assign(Object.assign({}, this.state.selectedLinearElement.pointerDownState), {\n segmentMidpoint: {\n index: nextIndex,\n value: hitCoords,\n added: false\n }\n }),\n segmentMidPointHoveredCoords: nextCoords\n })\n });\n return;\n }\n }\n }\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(selectedElements[0])) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n const selectedGroupIds = (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getSelectedGroupIds)(this.state);\n\n if (selectedGroupIds.length > 0) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n const selectedGroupId = hitElement && (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getSelectedGroupIdForElement)(hitElement, this.state.selectedGroupIds);\n\n if (selectedGroupId) {\n this.store.shouldCaptureIncrement();\n this.setState(prevState => Object.assign(Object.assign({}, prevState), (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: selectedGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)));\n return;\n }\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] && !this.state.viewModeEnabled) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement)) {\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"active\"\n }\n });\n return;\n }\n\n const container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if (container) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.hasBoundTextElement)(container) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isTransparent)(container.backgroundColor) || (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x: sceneX,\n y: sceneY,\n element: container,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(container, this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold()\n })) {\n const midPoint = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerCenter)(container, this.state, this.scene.getNonDeletedElementsMap());\n sceneX = midPoint.x;\n sceneY = midPoint.y;\n }\n } //zsviczian Disable double click text create, but allow double click edit\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.disableDoubleClickTextEditing)()) {\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n if (!existingTextElement) {\n return;\n }\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container\n });\n }\n };\n\n this.getElementLinkAtPosition = (scenePointer, hitElement) => {\n const elements = this.scene.getNonDeletedElements();\n let hitElementIndex = -1;\n\n for (let index = elements.length - 1; index >= 0; index--) {\n const element = elements[index];\n\n if (hitElement && element.id === hitElement.id) {\n hitElementIndex = index;\n }\n\n if (element.link && index >= hitElementIndex && (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_97__.isPointHittingLink)(element, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.device.editor.isMobile)) {\n return element;\n }\n }\n };\n\n this.redirectToLink = (event, isTouchScreen) => {\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerDownEvent.clientX, this.lastPointerDownEvent.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerUpEvent.clientX, this.lastPointerUpEvent.clientY));\n\n if (!this.hitLinkElement || draggedDistance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD) {\n return;\n }\n\n const lastPointerDownCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(this.lastPointerDownEvent, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const lastPointerDownHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_97__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerDownCoords.x, lastPointerDownCoords.y), this.device.editor.isMobile);\n const lastPointerUpCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(this.lastPointerUpEvent, this.state);\n const lastPointerUpHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_97__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerUpCoords.x, lastPointerUpCoords.y), this.device.editor.isMobile);\n\n if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.hideHyperlinkToolip)();\n let url = this.hitLinkElement.link;\n\n if (url) {\n url = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeLink)(url);\n let customEvent;\n\n if (this.props.onLinkOpen) {\n customEvent = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.wrapEvent)(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.EXCALIDRAW_LINK, event.nativeEvent);\n this.props.onLinkOpen(Object.assign(Object.assign({}, this.hitLinkElement), {\n link: url\n }), customEvent);\n }\n\n if (!(customEvent === null || customEvent === void 0 ? void 0 : customEvent.defaultPrevented)) {\n const target = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isLocalLink)(url) ? \"_self\" : \"_blank\";\n const newWindow = window.open(undefined, target); // https://mathiasbynens.github.io/rel-noopener/\n\n if (newWindow) {\n newWindow.opener = null;\n newWindow.location = url;\n }\n }\n }\n }\n };\n\n this.getTopLayerFrameAtSceneCoords = sceneCoords => {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const frames = this.scene.getNonDeletedFramesLikes().filter(frame => (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isCursorInFrame)(sceneCoords, frame, elementsMap));\n return frames.length ? frames[frames.length - 1] : null;\n };\n\n this.handleCanvasPointerMove = event => {\n var _a, _b, _c, _d, _e, _f, _g;\n\n this.savePointer(event.clientX, event.clientY, this.state.cursorButton);\n this.lastPointerMoveEvent = event.nativeEvent;\n\n if (gesture.pointers.has(event.pointerId)) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n }\n\n const initialScale = gesture.initialScale;\n\n if (gesture.pointers.size === 2 && gesture.lastCenter && initialScale && gesture.initialDistance) {\n const center = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getCenter)(gesture.pointers);\n const deltaX = center.x - gesture.lastCenter.x;\n const deltaY = center.y - gesture.lastCenter.y;\n gesture.lastCenter = center;\n const distance = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getDistance)(Array.from(gesture.pointers.values()));\n const scaleFactor = !this.state.allowPinchZoom && //zsviczian\n this.state.activeTool.type === \"freedraw\" && this.state.penMode ? 1 : distance / gesture.initialDistance;\n const nextZoom = scaleFactor ? (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(initialScale * scaleFactor) : this.state.zoom.value;\n this.setState(state => {\n const zoomState = (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: center.x,\n viewportY: center.y,\n nextZoom\n }, state);\n this.translateCanvas({\n zoom: zoomState.zoom,\n // 2x multiplier is just a magic number that makes this work correctly\n // on touchscreen devices (note: if we get report that panning is slower/faster\n // than actual movement, consider swapping with devicePixelRatio)\n scrollX: zoomState.scrollX + 2 * (deltaX / nextZoom),\n scrollY: zoomState.scrollY + 2 * (deltaY / nextZoom),\n shouldCacheIgnoreZoom: true\n });\n });\n this.resetShouldCacheIgnoreZoomDebounced();\n } else {\n gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null;\n }\n\n if (isHoldingSpace || isPanning || isDraggingScrollBar || (0,_appState__WEBPACK_IMPORTED_MODULE_54__.isHandToolActive)(this.state)) {\n return;\n }\n\n const isPointerOverScrollBars = (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_80__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop);\n const isOverScrollBar = isPointerOverScrollBars.isOverEither;\n const isPenFreedraw = this.state.activeTool.type === \"freedraw\" && event.pointerType === \"pen\"; //zsviczian\n\n if (!this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged && !this.state.multiElement) {\n if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n } else if (isPenFreedraw && this.interactiveCanvas && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.hideFreedrawPenmodeCursor)()) {\n //zsviczian https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1659\n this.interactiveCanvas.style.cursor = \"none\";\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n\n if (!this.state.newElement && (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isActiveToolNonLinearSnappable)(this.state.activeTool.type)) {\n const {\n originOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.getSnapLinesAtPointer)(this.scene.getNonDeletedElements(), this, {\n x: scenePointerX,\n y: scenePointerY\n }, event, this.scene.getNonDeletedElementsMap());\n this.setState(prevState => {\n const nextSnapLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.snapLines, snapLines);\n const nextOriginOffset = prevState.originSnapOffset ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.originSnapOffset, originOffset) : originOffset;\n\n if (prevState.snapLines === nextSnapLines && prevState.originSnapOffset === nextOriginOffset) {\n return null;\n }\n\n return {\n snapLines: nextSnapLines,\n originSnapOffset: nextOriginOffset\n };\n });\n } else if (!this.state.newElement && !this.state.selectedElementsAreBeingDragged && !this.state.selectionElement) {\n this.setState(prevState => {\n if (prevState.snapLines.length) {\n return {\n snapLines: []\n };\n }\n\n return null;\n });\n }\n\n if (this.state.editingLinearElement && !this.state.editingLinearElement.isDragging) {\n const editingLinearElement = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerMove(event, scenePointerX, scenePointerY, this);\n\n if (editingLinearElement && editingLinearElement !== this.state.editingLinearElement) {\n // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n editingLinearElement\n });\n });\n }\n\n if ((editingLinearElement === null || editingLinearElement === void 0 ? void 0 : editingLinearElement.lastUncommittedPoint) != null) {\n this.maybeSuggestBindingAtCursor(scenePointer, editingLinearElement.elbowed);\n } else {\n // causes stack overflow if not sync\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n suggestedBindings: []\n });\n });\n }\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElementType)(this.state.activeTool.type)) {\n // Hovering with a selected tool or creating new linear element via click\n // and point\n const {\n newElement\n } = this.state;\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(newElement, false)) {\n this.maybeSuggestBindingsForLinearElementAtCoords(newElement, [scenePointer], this.state.startBoundElement);\n } else {\n this.maybeSuggestBindingAtCursor(scenePointer, false);\n }\n }\n\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state;\n const {\n x: rx,\n y: ry\n } = multiElement;\n const {\n points,\n lastCommittedPoint\n } = multiElement;\n const lastPoint = points[points.length - 1];\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n\n if (lastPoint === lastCommittedPoint) {\n // if we haven't yet created a temp point and we're beyond commit-zone\n // threshold, add a point\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastPoint) >= _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.LINE_CONFIRM_THRESHOLD) {\n this.scene.mutateElement(multiElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER); // in this branch, we're inside the commit zone, and no uncommitted\n // point exists. Thus do nothing (don't add/remove points).\n }\n } else if (points.length > 2 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.LINE_CONFIRM_THRESHOLD) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n this.scene.mutateElement(multiElement, {\n points: points.slice(0, -1)\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(scenePointerX, scenePointerY, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(multiElement) ? null : this.getEffectiveGridSize());\n const [lastCommittedX, lastCommittedY] = (_a = multiElement === null || multiElement === void 0 ? void 0 : multiElement.lastCommittedPoint) !== null && _a !== void 0 ? _a : [0, 0];\n let dxFromLastCommitted = gridX - rx - lastCommittedX;\n let dyFromLastCommitted = gridY - ry - lastCommittedY;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldRotateWithDiscreteAngle)(event)) {\n ({\n width: dxFromLastCommitted,\n height: dyFromLastCommitted\n } = (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.getLockedLinearCursorAlignSize)( // actual coordinate of the last committed point\n lastCommittedX + rx, lastCommittedY + ry, // cursor-grid coordinate\n gridX, gridY));\n }\n\n if ((0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.isPathALoop)(points, this.state.zoom.value)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n } // update last uncommitted point\n\n\n this.scene.mutateElement(multiElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastCommittedX + dxFromLastCommitted, lastCommittedY + dyFromLastCommitted)]\n }, {\n isDragging: true,\n informMutation: false\n }); // in this path, we're mutating multiElement to reflect\n // how it will be after adding pointer position as the next point\n // trigger update here so that new element canvas renders again to reflect this\n\n this.triggerRender(false);\n }\n\n return;\n }\n\n const hasDeselectedButton = Boolean(event.buttons);\n\n if (hasDeselectedButton || this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"text\" && this.state.activeTool.type !== \"eraser\") {\n return;\n }\n\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !isOverScrollBar && !this.state.editingLinearElement) {\n // for linear elements, we'd like to prioritize point dragging over edge resizing\n // therefore, we update and check hovered point index first\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n\n if ((!this.state.selectedLinearElement || this.state.selectedLinearElement.hoverPointIndex === -1) && ((_b = this.state.openDialog) === null || _b === void 0 ? void 0 : _b.name) !== \"elementLinkSelector\" && !(selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0]))) {\n const elementWithTransformHandleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getElementWithTransformHandleType)(elements, this.state, scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType && elementWithTransformHandleType.transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getCursorForResizingElement)(elementWithTransformHandleType));\n return;\n }\n }\n } else if (selectedElements.length > 1 && !isOverScrollBar && ((_c = this.state.openDialog) === null || _c === void 0 ? void 0 : _c.name) !== \"elementLinkSelector\") {\n const transformHandleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getTransformHandleTypeFromCoords)((0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements), scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.device);\n\n if (transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getCursorForResizingElement)({\n transformHandleType\n }));\n return;\n }\n }\n\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n return;\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.showHyperlinkTooltip)(this.hitLinkElement, this.state, this.scene.getNonDeletedElementsMap());\n\n if (this.props.onLinkHover) {\n this.props.onLinkHover(this.hitLinkElement, event);\n } //zsviczian\n\n } else {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.hideHyperlinkToolip)();\n\n if (hitElement && (hitElement.link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(hitElement)) && this.state.selectedElementIds[hitElement.id] && !this.state.contextMenu && !this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: \"info\"\n });\n } else if (this.state.activeTool.type === \"text\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(hitElement) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.TEXT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.CROSSHAIR);\n } else if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else if (((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n } else if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n } else if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n } else if ( // if using cmd/ctrl, we're not dragging\n !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) && !(hitElement === null || hitElement === void 0 ? void 0 : hitElement.locked)) {\n if (hitElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointerX, scenePointerY)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"hover\"\n }\n });\n } else if (!hitElement || // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(hitElement) || !(hitElement.startBinding || hitElement.endBinding)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE);\n\n if (((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.state) === \"hover\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n }\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n }\n }\n\n if (((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\" && hitElement) {\n this.setState(prevState => {\n return {\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.hoveredElementIds, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this).selectedElementIds)\n };\n });\n } else if (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\" && !hitElement) {\n this.setState(prevState => ({\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.hoveredElementIds, {})\n }));\n }\n };\n\n this.handleEraser = (event, scenePointer) => {\n const elementsToErase = this.eraserTrail.addPointToPath(scenePointer.x, scenePointer.y, event.altKey);\n this.elementsPendingErasure = new Set(elementsToErase);\n this.triggerRender();\n }; // set touch moving for mobile context menu\n\n\n this.handleTouchMove = event => {\n this.resetContextMenuTimer(); //zsviczian\n };\n\n this.handleCanvasPointerDown = event => {\n var _a, _b, _c;\n\n this.focusContainer(); //zsviczian\n\n const target = event.target; // capture subsequent pointer events to the canvas\n // this makes other elements non-interactive until pointer up\n\n if (target.setPointerCapture) {\n target.setPointerCapture(event.pointerId);\n }\n\n this.maybeCleanupAfterMissingPointerUp(event.nativeEvent);\n this.maybeUnfollowRemoteUser();\n\n if (this.state.searchMatches) {\n this.setState(state => ({\n searchMatches: state.searchMatches.map(searchMatch => Object.assign(Object.assign({}, searchMatch), {\n focus: false\n }))\n }));\n this.updateEditorAtom(_SearchMenu__WEBPACK_IMPORTED_MODULE_93__.searchItemInFocusAtom, null);\n }\n\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypePopupAtom)) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypePopupAtom, null);\n } // since contextMenu options are potentially evaluated on each render,\n // and an contextMenu action may depend on selection state, we must\n // close the contextMenu before we update the selection on pointerDown\n // (e.g. resetting selection)\n\n\n if (this.state.contextMenu) {\n this.setState({\n contextMenu: null\n });\n }\n\n if (this.state.snapLines) {\n this.setAppState({\n snapLines: []\n });\n }\n\n this.updateGestureOnPointerDown(event); // if dragging element is freedraw and another pointerdown event occurs\n // a second finger is on the screen\n // discard the freedraw element if it is very short because it is likely\n // just a spike, otherwise finalize the freedraw element when the second\n // finger is lifted\n\n if (event.pointerType === \"touch\" && this.state.newElement && this.state.newElement.type === \"freedraw\") {\n const element = this.state.newElement;\n this.updateScene(Object.assign(Object.assign({}, element.points.length < 10 ? {\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== element.id)\n } : {}), {\n appState: {\n newElement: null,\n editingTextElement: null,\n startBoundElement: null,\n suggestedBindings: [],\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.keys(this.state.selectedElementIds).filter(key => key !== element.id).reduce((obj, key) => {\n obj[key] = this.state.selectedElementIds[key];\n return obj;\n }, {}), this.state)\n },\n captureUpdate: ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\" ? _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.EVENTUALLY : _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n }));\n return;\n } // remove any active selection when we start to interact with canvas\n // (mainly, we care about removing selection outside the component which\n // would prevent our copy handling otherwise)\n\n\n const selection = document.getSelection();\n\n if (selection === null || selection === void 0 ? void 0 : selection.anchorNode) {\n selection.removeAllRanges();\n }\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(event); //fires only once, if pen is detected, penMode is enabled\n //the user can disable this by toggling the penMode button\n\n if (!this.state.penDetected && event.pointerType === \"pen\") {\n this.setState(prevState => {\n return {\n penMode: true,\n penDetected: true\n };\n });\n }\n\n if (!this.device.isTouchScreen && [\"pen\", \"touch\"].includes(event.pointerType)) {\n this.device = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateObject)(this.device, {\n isTouchScreen: true\n });\n }\n\n if (isPanning) {\n return;\n }\n\n this.lastPointerDownEvent = event; // we must exit before we set `cursorButton` state and `savePointer`\n // else it will send pointer state & laser pointer events in collab when\n // panning\n\n /*if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\r\n return;\r\n }*/\n //zsviczian this broke on pointer down in onPointerUpdate\n\n this.setState({\n lastPointerDownWith: event.pointerType,\n cursorButton: \"down\"\n });\n this.savePointer(event.clientX, event.clientY, \"down\");\n\n if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\n return;\n } //zsviczian moved it here, because else pointer down in onPointerUpdate did not work\n\n\n if (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.ERASER && this.state.activeTool.type !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.eraser) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.eraser,\n lastActiveToolBeforeEraser: this.state.activeTool\n })\n }, () => {\n this.handleCanvasPointerDown(event);\n\n const onPointerUp = () => {\n unsubPointerUp();\n unsubCleanup === null || unsubCleanup === void 0 ? void 0 : unsubCleanup();\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, Object.assign(Object.assign({}, this.state.activeTool.lastActiveTool || {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.selection\n }), {\n lastActiveToolBeforeEraser: null\n }))\n });\n }\n };\n\n const unsubPointerUp = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp, {\n once: true\n });\n let unsubCleanup; // subscribe inside rAF lest it'd be triggered on the same pointerdown\n // if we start erasing while coming from blurred document since\n // we cleanup pointer events on focus\n\n requestAnimationFrame(() => {\n unsubCleanup = this.missingPointerEventCleanupEmitter.once(onPointerUp);\n });\n });\n return;\n } // only handle left mouse button or touch\n\n\n if (event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.MAIN && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.TOUCH && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.ERASER) {\n return;\n } // don't select while panning\n\n\n if (gesture.pointers.size > 1) {\n return;\n } // State for the duration of a pointer interaction, which starts with a\n // pointerDown event, ends with a pointerUp event (or another pointerDown)\n\n\n const pointerDownState = this.initialPointerDownState(event);\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n\n if (this.handleDraggingScrollBar(event, pointerDownState)) {\n return;\n }\n\n this.clearSelectionIfNotUsingSelection();\n this.updateBindingEnabledOnPointerMove(event);\n\n if (this.handleSelectionOnPointerDown(event, pointerDownState)) {\n return;\n }\n\n const allowOnPointerDown = !this.state.penMode || event.pointerType !== \"touch\" || this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\" || this.state.activeTool.type === \"text\" || this.state.activeTool.type === \"image\";\n\n if (!allowOnPointerDown) {\n return;\n }\n\n if (this.state.activeTool.type === \"lasso\") {\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n } else if (this.state.activeTool.type === \"text\") {\n this.handleTextOnPointerDown(event, pointerDownState);\n } else if (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\") {\n this.handleLinearElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"image\") {\n // reset image preview on pointerdown\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.CROSSHAIR); // retrieve the latest element as the state may be stale\n\n const pendingImageElement = this.state.pendingImageElementId && this.scene.getElement(this.state.pendingImageElementId);\n\n if (!pendingImageElement) {\n return;\n }\n\n this.setState({\n newElement: pendingImageElement,\n pendingImageElementId: null,\n multiElement: null\n });\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const frame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n this.scene.mutateElement(pendingImageElement, {\n x,\n y,\n frameId: frame ? frame.id : null\n });\n } else if (this.state.activeTool.type === \"freedraw\") {\n this.handleFreeDrawElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"custom\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n } else if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe) {\n this.createFrameElementOnPointerDown(pointerDownState, this.state.activeTool.type);\n } else if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n } else if (this.state.activeTool.type !== \"eraser\" && this.state.activeTool.type !== \"hand\" && this.state.activeTool.type !== \"mermaid\") {\n this.createGenericElementOnPointerDown(this.state.activeTool.type, pointerDownState);\n }\n\n (_c = (_b = this.props) === null || _b === void 0 ? void 0 : _b.onPointerDown) === null || _c === void 0 ? void 0 : _c.call(_b, this.state.activeTool, pointerDownState);\n this.onPointerDownEmitter.trigger(this.state.activeTool, pointerDownState, event);\n\n if (this.state.activeTool.type === \"eraser\") {\n this.eraserTrail.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n }\n\n const onPointerMove = this.onPointerMoveFromPointerDownHandler(pointerDownState);\n const onPointerUp = this.onPointerUpFromPointerDownHandler(pointerDownState);\n const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState);\n const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState);\n this.missingPointerEventCleanupEmitter.once(_event => onPointerUp(_event || event.nativeEvent));\n\n if (!this.state.viewModeEnabled || this.state.activeTool.type === \"laser\") {\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYDOWN, onKeyDown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYUP, onKeyUp);\n pointerDownState.eventListeners.onMove = onPointerMove;\n pointerDownState.eventListeners.onUp = onPointerUp;\n pointerDownState.eventListeners.onKeyUp = onKeyUp;\n pointerDownState.eventListeners.onKeyDown = onKeyDown;\n }\n };\n\n this.handleCanvasPointerUp = event => {\n var _a, _b;\n\n this.removePointer(event);\n this.lastPointerUpEvent = event;\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: event.clientX,\n clientY: event.clientY\n }, this.state);\n const clicklength = event.timeStamp - ((_b = (_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.timeStamp) !== null && _b !== void 0 ? _b : 0);\n\n if (this.device.editor.isMobile && clicklength < 300) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointer.x, scenePointer.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n return;\n }\n }\n\n if (this.device.isTouchScreen) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n if (clicklength < 300 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(this.hitLinkElement) && !(0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_97__.isPointHittingLinkIcon)(this.hitLinkElement, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y))) {\n this.handleEmbeddableCenterClick(this.hitLinkElement);\n } else {\n this.redirectToLink(event, this.device.isTouchScreen);\n }\n } else if (this.state.viewModeEnabled) {\n this.setState({\n activeEmbeddable: null,\n selectedElementIds: {}\n });\n }\n };\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices = event => {\n // deal with opening context menu on touch devices\n if (event.pointerType === \"touch\") {\n invalidateContextMenu = false;\n\n if (touchTimeout) {\n // If there's already a touchTimeout, this means that there's another\n // touch down and we are doing another touch, so we shouldn't open the\n // context menu.\n invalidateContextMenu = true;\n } else {\n // open the context menu with the first touch's clientX and clientY\n // if the touch is not moving\n touchTimeout = window.setTimeout(() => {\n touchTimeout = 0;\n\n if (!invalidateContextMenu) {\n this.handleCanvasContextMenu(event);\n }\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOUCH_CTX_MENU_TIMEOUT);\n }\n }\n };\n\n this.resetContextMenuTimer = () => {\n clearTimeout(touchTimeout);\n touchTimeout = 0;\n invalidateContextMenu = false;\n };\n /**\r\n * pointerup may not fire in certian cases (user tabs away...), so in order\r\n * to properly cleanup pointerdown state, we need to fire any hanging\r\n * pointerup handlers manually\r\n */\n\n\n this.maybeCleanupAfterMissingPointerUp = event => {\n lastPointerUp === null || lastPointerUp === void 0 ? void 0 : lastPointerUp();\n this.missingPointerEventCleanupEmitter.trigger(event).clear();\n }; // Returns whether the event is a panning\n\n\n this.handleCanvasPanUsingWheelOrSpaceDrag = event => {\n if (!(gesture.pointers.size <= 1 && (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.WHEEL || event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.MAIN && isHoldingSpace || (0,_appState__WEBPACK_IMPORTED_MODULE_54__.isHandToolActive)(this.state) || //zsviczian\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.isTouchInPenMode)(this.state, event) || //!isLaserPointerActive added by zsviczian (but don't remember why....)\n this.state.viewModeEnabled && !(0,_appState__WEBPACK_IMPORTED_MODULE_54__.isLaserPointerActive)(this.state)))) {\n return false;\n }\n\n isPanning = true; // due to event.preventDefault below, container wouldn't get focus\n // automatically\n\n this.focusContainer(); // preventing defualt while text editing messes with cursor/focus\n\n if (!this.state.editingTextElement) {\n // necessary to prevent browser from scrolling the page if excalidraw\n // not full-page #4489\n //\n // as such, the above is broken when panning canvas while in wysiwyg\n event.preventDefault();\n }\n\n let nextPastePrevented = false;\n const isLinux = typeof window === undefined ? false : /Linux/.test(window.navigator.platform);\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n /*\r\n * Prevent paste event if we move while middle clicking on Linux.\r\n * See issue #1383.\r\n */\n\n if (isLinux && !nextPastePrevented && (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1)) {\n nextPastePrevented = true;\n /* Prevent the next paste event */\n\n const preventNextPaste = event => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, preventNextPaste);\n event.stopPropagation();\n };\n /*\r\n * Reenable next paste in case of disabled middle click paste for\r\n * any reason:\r\n * - right click paste\r\n * - empty clipboard\r\n */\n\n\n const enableNextPaste = () => {\n setTimeout(() => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, preventNextPaste);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, enableNextPaste);\n }, 100);\n };\n\n document.body.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, preventNextPaste);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, enableNextPaste);\n }\n\n this.translateCanvas({\n scrollX: this.state.scrollX - deltaX / this.state.zoom.value,\n scrollY: this.state.scrollY - deltaY / this.state.zoom.value\n });\n });\n const teardown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(lastPointerUp = () => {\n lastPointerUp = null;\n isPanning = false;\n\n if (!isHoldingSpace) {\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, teardown);\n return true;\n };\n\n this.clearSelectionIfNotUsingSelection = () => {\n if (this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\") {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n };\n /**\r\n * @returns whether the pointer event has been completely handled\r\n */\n\n\n this.handleSelectionOnPointerDown = (event, pointerDownState) => {\n var _a, _b;\n\n if (this.state.activeTool.type === \"selection\") {\n const elements = this.scene.getNonDeletedElements();\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !this.state.editingLinearElement && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0]) && !(this.state.selectedLinearElement && this.state.selectedLinearElement.hoverPointIndex !== -1)) {\n const elementWithTransformHandleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getElementWithTransformHandleType)(elements, this.state, pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType != null) {\n if (elementWithTransformHandleType.transformHandleType === \"rotation\") {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else if (this.state.croppingElementId) {\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n }\n }\n } else if (selectedElements.length > 1) {\n pointerDownState.resize.handleType = (0,_excalidraw_element_resizeTest__WEBPACK_IMPORTED_MODULE_35__.getTransformHandleTypeFromCoords)((0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements), pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.device);\n }\n\n if (pointerDownState.resize.handleType) {\n pointerDownState.resize.isResizing = true;\n pointerDownState.resize.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)((0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.getResizeOffsetXY)(pointerDownState.resize.handleType, selectedElements, elementsMap, pointerDownState.origin.x, pointerDownState.origin.y));\n\n if (selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(selectedElements[0]) && selectedElements[0].points.length === 2) {\n pointerDownState.resize.arrowDirection = (0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.getResizeArrowDirection)(pointerDownState.resize.handleType, selectedElements[0]);\n }\n } else {\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.editingLinearElement || this.state.selectedLinearElement;\n const ret = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerDown(event, this, this.store, pointerDownState.origin, linearElementEditor, this.scene);\n\n if (ret.hitElement) {\n pointerDownState.hit.element = ret.hitElement;\n }\n\n if (ret.linearElementEditor) {\n this.setState({\n selectedLinearElement: ret.linearElementEditor\n });\n\n if (this.state.editingLinearElement) {\n this.setState({\n editingLinearElement: ret.linearElementEditor\n });\n }\n }\n\n if (ret.didAddPoint) {\n return true;\n }\n } // hitElement may already be set above, so check first\n\n\n pointerDownState.hit.element = (_a = pointerDownState.hit.element) !== null && _a !== void 0 ? _a : this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n this.hitLinkElement = this.getElementLinkAtPosition(pointerDownState.origin, pointerDownState.hit.element);\n\n if (this.hitLinkElement) {\n return true;\n }\n\n if (this.state.croppingElementId && ((_b = pointerDownState.hit.element) === null || _b === void 0 ? void 0 : _b.id) !== this.state.croppingElementId) {\n this.finishImageCropping();\n }\n\n if (pointerDownState.hit.element) {\n // Early return if pointer is hitting link icon\n const hitLinkElement = this.getElementLinkAtPosition({\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }, pointerDownState.hit.element);\n\n if (hitLinkElement) {\n return false;\n }\n } // For overlapped elements one position may hit\n // multiple elements\n\n\n pointerDownState.hit.allHitElements = this.getElementsAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n const hitElement = pointerDownState.hit.element;\n const someHitElementIsSelected = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n\n if ((hitElement === null || !someHitElementIsSelected) && !event.shiftKey && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.clearSelection(hitElement);\n }\n\n if (this.state.editingLinearElement) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [this.state.editingLinearElement.elementId]: true\n }, this.state)\n }); // If we click on something\n } else if (hitElement != null) {\n // on CMD/CTRL, drill down to hit element regardless of groups etc.\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n if (!this.state.selectedElementIds[hitElement.id]) {\n pointerDownState.hit.wasAddedToSelection = true;\n }\n\n this.setState(prevState => Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.editGroupForSelectedElement)(prevState, hitElement)), {\n previousSelectedElementIds: this.state.selectedElementIds\n })); // mark as not completely handled so as to allow dragging etc.\n\n return false;\n } // deselect if item is selected\n // if shift is not clicked, this will always return true\n // otherwise, it will trigger selection based on current\n // state of the box\n\n\n if (!this.state.selectedElementIds[hitElement.id]) {\n // if we are currently editing a group, exiting editing mode and deselect the group.\n if (this.state.editingGroupId && !(0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.isElementInGroup)(hitElement, this.state.editingGroupId)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // Add hit element to selection. At this point if we're not holding\n // SHIFT the previously selected element(s) were deselected above\n // (make sure you use setState updater to use latest state)\n // With shift-selection, we want to make sure that frames and their containing\n // elements are not selected at the same time.\n\n\n if (!someHitElementIsSelected && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.setState(prevState => {\n var _a;\n\n let nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n });\n const previouslySelectedElements = [];\n Object.keys(prevState.selectedElementIds).forEach(id => {\n const element = this.scene.getElement(id);\n element && previouslySelectedElements.push(element);\n }); // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getFrameChildren)(previouslySelectedElements, hitElement.id).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n } else if (hitElement.frameId) {\n // if hitElement is in a frame and its frame has been selected\n // disable selection for the given element\n if (nextSelectedElementIds[hitElement.frameId]) {\n delete nextSelectedElementIds[hitElement.id];\n }\n } else {\n // hitElement is neither a frame nor an element in a frame\n // but since hitElement could be in a group with some frames\n // this means selecting hitElement will have the frames selected as well\n // because we want to keep the invariant:\n // - frames and their elements are not selected at the same time\n // we deselect elements in those frames that were previously selected\n const groupIds = hitElement.groupIds;\n const framesInGroups = new Set(groupIds.flatMap(gid => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element)).map(frame => frame.id));\n\n if (framesInGroups.size > 0) {\n previouslySelectedElements.forEach(element => {\n if (element.frameId && framesInGroups.has(element.frameId)) {\n // deselect element and groups containing the element\n delete nextSelectedElementIds[element.id];\n element.groupIds.flatMap(gid => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n } // Finally, in shape selection mode, we'd like to\n // keep only one shape or group selected at a time.\n // This means, if the hitElement is a different shape or group\n // than the previously selected ones, we deselect the previous ones\n // and select the hitElement\n\n\n if (((_a = prevState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n if (!hitElement.groupIds.some(gid => prevState.selectedGroupIds[gid])) {\n nextSelectedElementIds = {\n [hitElement.id]: true\n };\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\n }\n }\n\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n }\n\n return false;\n };\n\n this.handleTextOnPointerDown = (event, pointerDownState) => {\n // if we're currently still editing text, clicking outside\n // should only finalize it, not create another (irrespective\n // of state.activeTool.locked)\n if (this.state.editingTextElement) {\n return;\n }\n\n let sceneX = pointerDownState.origin.x;\n let sceneY = pointerDownState.origin.y;\n const element = this.getElementAtPosition(sceneX, sceneY, {\n includeBoundTextElement: true\n }); // FIXME\n\n let container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.hasBoundTextElement)(element)) {\n container = element;\n sceneX = element.x + element.width / 2;\n sceneY = element.y + element.height / 2;\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container,\n autoEdit: false\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n\n if (!this.state.activeTool.locked) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n }\n };\n\n this.handleFreeDrawElementOnPointerDown = (event, elementType, pointerDownState) => {\n // Begin a mark capture. This does not have to update state yet.\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, null);\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const simulatePressure = (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure //zsviczian\n ) ? false : event.pressure === 0.5;\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newFreeDrawElement)(Object.assign(Object.assign({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: null,\n simulatePressure,\n locked: false\n }, strokeOptions //zsviczian\n ? {\n customData: {\n strokeOptions\n }\n } : {}), {\n frameId: topLayerFrame ? topLayerFrame.id : null,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)],\n pressures: simulatePressure ? [] : [(strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure]\n })); //zsviczian\n\n if (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.highlighter) {\n this.scene.insertElement(element, 0);\n } else {\n this.scene.insertElement(element);\n }\n\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n const boundElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n };\n\n this.insertIframeElement = ({\n sceneX,\n sceneY,\n width,\n height\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newIframeElement)({\n type: \"iframe\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"iframe\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width,\n height\n });\n this.scene.insertElement(element);\n return element;\n }; //create rectangle element with youtube top left on nearest grid point width / hight 640/360\n\n\n this.insertEmbeddableElement = ({\n sceneX,\n sceneY,\n link\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const embedLink = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)(link);\n\n if (!embedLink) {\n return;\n }\n\n if (embedLink.error instanceof URIError) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"toast.unrecognizedLinkFormat\"),\n closable: true\n });\n }\n\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newEmbeddableElement)({\n type: \"embeddable\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"embeddable\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width: embedLink.intrinsicSize.w,\n height: embedLink.intrinsicSize.h,\n link\n });\n this.scene.insertElement(element);\n return element;\n };\n\n this.createImageElement = ({\n sceneX,\n sceneY,\n addToFrameUnderCursor = true\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = addToFrameUnderCursor ? this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n }) : null;\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newImageElement)({\n type: \"image\",\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: null,\n opacity: this.state.currentItemOpacity,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n return element;\n };\n\n this.handleLinearElementOnPointerDown = (event, elementType, pointerDownState) => {\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state; // finalize if completing a loop\n\n if (multiElement.type === \"line\" && (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.isPathALoop)(multiElement.points, this.state.zoom.value)) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n } // Elbow arrows cannot be created by putting down points\n // only the start and end points can be defined\n\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(multiElement) && multiElement.points.length > 1) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n }\n\n const {\n x: rx,\n y: ry,\n lastCommittedPoint\n } = multiElement; // clicking inside commit zone → finalize arrow\n\n if (multiElement.points.length > 1 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x - rx, pointerDownState.origin.y - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.LINE_CONFIRM_THRESHOLD) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n }\n\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState)\n })); // clicking outside commit zone → update reference for last committed\n // point\n\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n /* If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.\r\n If so, we want it to be null for start and \"arrow\" for end. If the linear item is not\r\n an arrow, we want it to be null for both. Otherwise, we want it to use the\r\n values from appState. */\n\n const {\n currentItemStartArrowhead,\n currentItemEndArrowhead\n } = this.state;\n const [startArrowhead, endArrowhead] = elementType === \"arrow\" ? [currentItemStartArrowhead, currentItemEndArrowhead] : [null, null];\n const element = elementType === \"arrow\" ? (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newArrowElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.round ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : // note, roundness doesn't have any effect for elbow arrows,\n // but it's best to set it to null as well\n null,\n startArrowhead,\n endArrowhead,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null,\n elbowed: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.elbow,\n fixedSegments: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ARROW_TYPE.elbow ? [] : null\n }) : (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newLinearElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemRoundness === \"round\" ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n this.scene.mutateElement(element, {\n points: [...element.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)]\n });\n const boundElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element), (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element));\n this.scene.insertElement(element);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n }\n };\n\n this.createGenericElementOnPointerDown = (elementType, pointerDownState) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const baseElementAttributes = {\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.getCurrentItemRoundness(elementType),\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n };\n let element;\n\n if (elementType === \"embeddable\") {\n element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newEmbeddableElement)(Object.assign({\n type: \"embeddable\"\n }, baseElementAttributes));\n } else {\n element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newElement)(Object.assign({\n type: elementType\n }, baseElementAttributes));\n }\n\n if (element.type === \"selection\") {\n this.setState({\n selectionElement: element\n });\n } else {\n this.scene.insertElement(element);\n this.setState({\n multiElement: null,\n newElement: element\n });\n }\n };\n\n this.createFrameElementOnPointerDown = (pointerDownState, type) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const constructorOpts = Object.assign(Object.assign({\n x: gridX,\n y: gridY,\n opacity: this.state.currentItemOpacity,\n locked: false\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.FRAME_STYLE), this.state.frameColor ? {\n //zsviczian\n customData: {\n frameColor: this.state.frameColor\n }\n } : {});\n const frame = type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe ? (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newMagicFrameElement)(constructorOpts) : (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newFrameElement)(constructorOpts);\n this.scene.insertElement(frame);\n this.setState({\n multiElement: null,\n newElement: frame\n });\n };\n\n this.restoreReadyToEraseElements = () => {\n this.elementsPendingErasure = new Set();\n this.triggerRender();\n };\n\n this.eraseElements = () => {\n let didChange = false;\n const elements = this.scene.getElementsIncludingDeleted().map(ele => {\n if (this.elementsPendingErasure.has(ele.id) || ele.frameId && this.elementsPendingErasure.has(ele.frameId) || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(ele) && this.elementsPendingErasure.has(ele.containerId)) {\n didChange = true;\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(ele, {\n isDeleted: true\n });\n }\n\n return ele;\n });\n this.elementsPendingErasure = new Set();\n\n if (didChange) {\n this.store.shouldCaptureIncrement();\n this.scene.replaceAllElements(elements);\n }\n };\n\n this.initializeImage = async ({\n imageFile,\n imageElement: _imageElement,\n showCursorImagePreview = false\n }) => {\n var _a, _b, _c, _d; // at this point this should be guaranteed image file, but we do this check\n // to satisfy TS down the line\n\n\n if (!(0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isSupportedImageFile)(imageFile)) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.unsupportedFileType\"));\n }\n\n const mimeType = imageFile.type;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, \"wait\");\n\n if (mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n try {\n imageFile = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.SVGStringToFile)((0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.normalizeSVG)(await imageFile.text()), imageFile.name);\n } catch (error) {\n console.warn(error);\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.svgImageInsertError\"));\n }\n } // generate image id (by default the file digest) before any\n // resizing/compression takes place to keep it more portable\n\n\n const fileId = await (((_b = (_a = this.props).generateIdForFile) === null || _b === void 0 ? void 0 : _b.call(_a, imageFile)) || (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.generateIdFromFile)(imageFile));\n\n if (!fileId) {\n console.warn(\"Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one.\");\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageInsertError\"));\n }\n\n const existingFileData = this.files[fileId];\n\n if (!(existingFileData === null || existingFileData === void 0 ? void 0 : existingFileData.dataURL)) {\n try {\n imageFile = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.resizeImageFile)(imageFile, {\n maxWidthOrHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT\n });\n } catch (error) {\n console.error(\"Error trying to resizing image file on insertion\", error);\n }\n\n if (imageFile.size > _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MAX_ALLOWED_FILE_BYTES) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.fileTooBig\", {\n maxSize: `${Math.trunc(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MAX_ALLOWED_FILE_BYTES / 1024 / 1024)}MB`\n }));\n }\n }\n\n if (showCursorImagePreview) {\n const dataURL = (_c = this.files[fileId]) === null || _c === void 0 ? void 0 : _c.dataURL; // optimization so that we don't unnecessarily resize the original\n // full-size file for cursor preview\n // (it's much faster to convert the resized dataURL to File)\n\n const resizedFile = dataURL && (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.dataURLToFile)(dataURL);\n this.setImagePreviewCursor(resizedFile || imageFile);\n }\n\n const dataURL = ((_d = this.files[fileId]) === null || _d === void 0 ? void 0 : _d.dataURL) || (await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getDataURL)(imageFile));\n const imageElement = this.scene.mutateElement(_imageElement, {\n fileId\n }, {\n informMutation: false,\n isDragging: false\n });\n return new Promise(async (resolve, reject) => {\n var _a;\n\n try {\n this.addMissingFiles([{\n mimeType,\n id: fileId,\n dataURL,\n created: Date.now(),\n lastRetrieved: Date.now(),\n //@ts-ignore\n name: (imageFile === null || imageFile === void 0 ? void 0 : imageFile.name) && imageFile.name !== \"image.png\" ? imageFile.name : undefined // zsviczian\n\n }]);\n const cachedImageData = this.imageCache.get(fileId);\n\n if (!cachedImageData) {\n this.addNewImagesToImageCache();\n await this.updateImageCache([imageElement]);\n }\n\n if ((cachedImageData === null || cachedImageData === void 0 ? void 0 : cachedImageData.image) instanceof Promise) {\n await cachedImageData.image;\n }\n\n if (this.state.pendingImageElementId !== imageElement.id && ((_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.id) !== imageElement.id) {\n this.initializeImageDimensions(imageElement, true);\n }\n\n resolve(imageElement);\n } catch (error) {\n console.error(error);\n reject(new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageInsertError\")));\n } finally {\n if (!showCursorImagePreview) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n }\n }\n });\n };\n /**\r\n * inserts image into elements array and rerenders\r\n */\n\n\n this.insertImageElement = async (imageElement, imageFile, showCursorImagePreview) => {\n // we should be handling all cases upstream, but in case we forget to handle\n // a future case, let's throw here\n if (!this.isToolSupported(\"image\")) {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n this.scene.insertElement(imageElement);\n\n try {\n return await this.initializeImage({\n imageFile,\n imageElement,\n showCursorImagePreview\n });\n } catch (error) {\n this.scene.mutateElement(imageElement, {\n isDeleted: true\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n this.setState({\n errorMessage: error.message || (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageInsertError\")\n });\n return null;\n }\n };\n\n this.setImagePreviewCursor = async imageFile => {\n // mustn't be larger than 128 px\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property\n const cursorImageSizePx = 96;\n let imagePreview;\n\n try {\n imagePreview = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.resizeImageFile)(imageFile, {\n maxWidthOrHeight: cursorImageSizePx\n });\n } catch (e) {\n if (e.cause === \"UNSUPPORTED\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.unsupportedFileType\"));\n }\n\n throw e;\n }\n\n let previewDataURL = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getDataURL)(imagePreview); // SVG cannot be resized via `resizeImageFile` so we resize by rendering to\n // a small canvas\n\n if (imageFile.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n const img = await (0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.loadHTMLImageElement)(previewDataURL);\n let height = Math.min(img.height, cursorImageSizePx);\n let width = height * (img.width / img.height);\n\n if (width > cursorImageSizePx) {\n width = cursorImageSizePx;\n height = width * (img.height / img.width);\n }\n\n const canvas = document.createElement(\"canvas\");\n canvas.height = height;\n canvas.width = width;\n const context = canvas.getContext(\"2d\");\n context.drawImage(img, 0, 0, width, height);\n previewDataURL = canvas.toDataURL(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg);\n }\n\n if (this.state.pendingImageElementId) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, `url(${previewDataURL}) 4 4, auto`);\n }\n };\n\n this.onImageAction = async ({\n insertOnCanvasDirectly\n }) => {\n var _a;\n\n try {\n const clientX = this.state.width / 2 + this.state.offsetLeft;\n const clientY = this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n let imageFile = await (0,_data_filesystem__WEBPACK_IMPORTED_MODULE_65__.fileOpen)({\n description: \"Image\",\n extensions: Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.IMAGE_MIME_TYPES)\n }); //zsviczian - temporary fix: https://github.com/excalidraw/excalidraw/issues/9091\n\n if (imageFile && !imageFile.type) {\n const extension = (_a = imageFile.name.split(\".\").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();\n const mimeType = _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.IMAGE_MIME_TYPES[extension];\n\n if (mimeType) {\n imageFile = new File([imageFile], imageFile.name, {\n type: mimeType\n });\n }\n }\n\n const imageElement = this.createImageElement({\n sceneX: x,\n sceneY: y,\n addToFrameUnderCursor: false\n });\n\n if (insertOnCanvasDirectly) {\n this.insertImageElement(imageElement, imageFile);\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n } else {\n this.setState({\n pendingImageElementId: imageElement.id\n }, () => {\n this.insertImageElement(imageElement, imageFile,\n /* showCursorImagePreview */\n true);\n });\n }\n } catch (error) {\n if (error.name !== \"AbortError\") {\n console.error(error);\n } else {\n console.warn(error);\n }\n\n this.setState({\n pendingImageElementId: null,\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n }\n };\n\n this.initializeImageDimensions = (imageElement, forceNaturalSize = false) => {\n var _a;\n\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(imageElement) && ((_a = this.imageCache.get(imageElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (!image || image instanceof Promise) {\n if (imageElement.width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value && imageElement.height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value) {\n const placeholderSize = 100 / this.state.zoom.value;\n this.scene.mutateElement(imageElement, {\n x: imageElement.x - placeholderSize / 2,\n y: imageElement.y - placeholderSize / 2,\n width: placeholderSize,\n height: placeholderSize\n });\n }\n\n return;\n }\n\n if (forceNaturalSize || // if user-created bounding box is below threshold, assume the\n // intention was to click instead of drag, and use the image's\n // intrinsic size\n imageElement.width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value && imageElement.height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD / this.state.zoom.value) {\n const minHeight = Math.max(this.state.height - 120, 160); // max 65% of canvas height, clamped to <300px, vh - 120px>\n\n const maxHeight = Math.min(minHeight, Math.floor(this.state.height * 0.5) / this.state.zoom.value);\n const height = Math.min(image.naturalHeight, maxHeight);\n const width = height * (image.naturalWidth / image.naturalHeight); // add current imageElement width/height to account for previous centering\n // of the placeholder image\n\n const x = imageElement.x + imageElement.width / 2 - width / 2;\n const y = imageElement.y + imageElement.height / 2 - height / 2;\n this.scene.mutateElement(imageElement, {\n x,\n y,\n width,\n height,\n crop: null\n });\n }\n };\n /** updates image cache, refreshing updated elements and/or setting status\r\n to error for images that fail during <img> element creation */\n\n\n this.updateImageCache = async (elements, files = this.files) => {\n const {\n updatedFiles,\n erroredFiles\n } = await (0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.updateImageCache)({\n imageCache: this.imageCache,\n fileIds: elements.map(element => element.fileId),\n files\n });\n\n if (updatedFiles.size || erroredFiles.size) {\n for (const element of elements) {\n if (updatedFiles.has(element.fileId)) {\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element);\n }\n }\n }\n\n if (erroredFiles.size) {\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(element) && erroredFiles.has(element.fileId)) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(element, {\n status: \"error\"\n });\n }\n\n return element;\n }));\n }\n\n return {\n updatedFiles,\n erroredFiles\n };\n };\n /** adds new images to imageCache and re-renders if needed */\n\n\n this.addNewImagesToImageCache = async (imageElements = (0,_excalidraw_element_image__WEBPACK_IMPORTED_MODULE_19__.getInitializedImageElements)(this.scene.getNonDeletedElements()), files = this.files) => {\n const uncachedImageElements = imageElements.filter(element => !element.isDeleted && !this.imageCache.has(element.fileId));\n\n if (uncachedImageElements.length) {\n const {\n updatedFiles\n } = await this.updateImageCache(uncachedImageElements, files);\n\n if (updatedFiles.size) {\n this.scene.triggerUpdate();\n }\n }\n };\n /** generally you should use `addNewImagesToImageCache()` directly if you need\r\n * to render new images. This is just a failsafe */\n\n\n this.scheduleImageRefresh = lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default()(() => {\n this.addNewImagesToImageCache();\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.IMAGE_RENDER_TIMEOUT);\n\n this.updateBindingEnabledOnPointerMove = event => {\n const shouldEnableBinding = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.shouldEnableBindingForPointerEvent)(event);\n\n if (this.state.isBindingEnabled !== shouldEnableBinding) {\n this.setState({\n isBindingEnabled: shouldEnableBinding\n });\n }\n };\n\n this.maybeSuggestBindingAtCursor = (pointerCoords, considerAll) => {\n const hoveredBindableElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(pointerCoords, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, false, considerAll);\n this.setState({\n suggestedBindings: hoveredBindableElement != null ? [hoveredBindableElement] : []\n });\n };\n\n this.maybeSuggestBindingsForLinearElementAtCoords = (linearElement,\n /** scene coords */\n pointerCoords, // During line creation the start binding hasn't been written yet\n // into `linearElement`\n oppositeBindingBoundElement) => {\n if (!pointerCoords.length) {\n return;\n }\n\n const suggestedBindings = pointerCoords.reduce((acc, coords) => {\n const hoveredBindableElement = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getHoveredElementForBinding)(coords, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(linearElement), (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(linearElement));\n\n if (hoveredBindableElement != null && !(0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isLinearElementSimpleAndAlreadyBound)(linearElement, oppositeBindingBoundElement === null || oppositeBindingBoundElement === void 0 ? void 0 : oppositeBindingBoundElement.id, hoveredBindableElement)) {\n acc.push(hoveredBindableElement);\n }\n\n return acc;\n }, []);\n this.setState({\n suggestedBindings\n });\n };\n\n this.handleInteractiveCanvasRef = canvas => {\n var _a, _b; // canvas is null when unmounting\n\n\n if (canvas !== null) {\n this.interactiveCanvas = canvas; // -----------------------------------------------------------------------\n // NOTE wheel, touchstart, touchend events must be registered outside\n // of react because react binds them them passively (so we can't prevent\n // default on them)\n\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_START, this.onTouchStart, {\n passive: false\n });\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_END, this.onTouchEnd); // -----------------------------------------------------------------------\n } else {\n (_a = this.interactiveCanvas) === null || _a === void 0 ? void 0 : _a.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_START, this.onTouchStart);\n (_b = this.interactiveCanvas) === null || _b === void 0 ? void 0 : _b.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.TOUCH_END, this.onTouchEnd);\n }\n };\n\n this.handleAppOnDrop = async event => {\n var _a, _b, _c, _d;\n\n if (this.props.onDrop) {\n try {\n if ((await this.props.onDrop(event)) === false) {\n return;\n }\n } catch (e) {\n console.error(e);\n }\n } // must be retrieved first, in the same frame\n\n\n const {\n file,\n fileHandle\n } = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.getFileFromEvent)(event);\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n\n try {\n // if image tool not supported, don't show an error here and let it fall\n // through so we still support importing scene data from images. If no\n // scene data encoded, we'll show an error then\n if ((0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.isSupportedImageFile)(file) && this.isToolSupported(\"image\")) {\n // first attempt to decode scene from the image if it's embedded\n // ---------------------------------------------------------------------\n if ((file === null || file === void 0 ? void 0 : file.type) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.png || (file === null || file === void 0 ? void 0 : file.type) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.svg) {\n try {\n const scene = await (0,_data__WEBPACK_IMPORTED_MODULE_56__.loadFromBlob)(file, this.state, this.scene.getElementsIncludingDeleted(), fileHandle);\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n appState: Object.assign(Object.assign({}, scene.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n }));\n return;\n } catch (error) {\n // Don't throw for image scene daa\n if (error.name !== \"EncodingError\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"alerts.couldNotLoadInvalidFile\"));\n }\n }\n } // if no scene is embedded or we fail for whatever reason, fall back\n // to importing as regular image\n // ---------------------------------------------------------------------\n\n\n const imageElement = this.createImageElement({\n sceneX,\n sceneY\n });\n this.insertImageElement(imageElement, file);\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n });\n return;\n }\n } catch (error) {\n return this.setState({\n isLoading: false,\n errorMessage: error.message\n });\n }\n\n const libraryJSON = event.dataTransfer.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.excalidrawlib);\n\n if (libraryJSON && typeof libraryJSON === \"string\") {\n try {\n const libraryItems = (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.parseLibraryJSON)(libraryJSON);\n this.addElementsFromPasteOrLibrary({\n elements: (0,_data_library__WEBPACK_IMPORTED_MODULE_57__.distributeLibraryItemsOnSquareGrid)(libraryItems),\n position: event,\n files: null\n });\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n\n return;\n }\n\n if (file) {\n // Attempt to parse an excalidraw/excalidrawlib file\n await this.loadFileToCanvas(file, fileHandle);\n }\n\n if ((_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) === null || _b === void 0 ? void 0 : _b.includes(\"text/plain\")) {\n const text = (_c = event.dataTransfer) === null || _c === void 0 ? void 0 : _c.getData(\"text\");\n\n if (text && (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.embeddableURLValidator)(text, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(text) || ((_d = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)(text)) === null || _d === void 0 ? void 0 : _d.type) === \"video\")) {\n const embeddable = this.insertEmbeddableElement({\n sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.normalizeLink)(text)\n });\n\n if (embeddable) {\n this.setState({\n selectedElementIds: {\n [embeddable.id]: true\n }\n });\n }\n }\n }\n };\n\n this.loadFileToCanvas = async (file, fileHandle) => {\n file = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.normalizeFile)(file);\n\n try {\n const elements = this.scene.getElementsIncludingDeleted();\n let ret;\n\n try {\n ret = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.loadSceneOrLibraryFromBlob)(file, this.state, elements, fileHandle);\n } catch (error) {\n const imageSceneDataError = error instanceof _errors__WEBPACK_IMPORTED_MODULE_69__.ImageSceneDataError;\n\n if (imageSceneDataError && error.code === \"IMAGE_NOT_CONTAINS_SCENE_DATA\" && !this.isToolSupported(\"image\")) {\n this.setState({\n isLoading: false,\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const errorMessage = imageSceneDataError ? (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"alerts.cannotRestoreFromImage\") : (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"alerts.couldNotLoadInvalidFile\");\n this.setState({\n isLoading: false,\n errorMessage\n });\n }\n\n if (!ret) {\n return;\n }\n\n if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.excalidraw) {\n // restore the fractional indices by mutating elements\n (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncInvalidIndices)(elements.concat(ret.data.elements)); // update the store snapshot for old elements, otherwise we would end up with duplicated fractional indices on undo\n\n this.store.updateSnapshot((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(elements), this.state);\n this.setState({\n isLoading: true\n });\n this.syncActionResult(Object.assign(Object.assign({}, ret.data), {\n appState: Object.assign(Object.assign({}, ret.data.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.IMMEDIATELY\n }));\n } else if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.MIME_TYPES.excalidrawlib) {\n await this.library.updateLibrary({\n libraryItems: file,\n merge: true,\n openLibraryMenu: true\n }).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.importLibraryError\")\n });\n });\n }\n } catch (error) {\n this.setState({\n isLoading: false,\n errorMessage: error.message\n });\n }\n };\n\n this.handleCanvasContextMenu = event => {\n event.preventDefault();\n\n if ((\"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"touch\" || \"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"pen\" && // always allow if user uses a pen secondary button\n event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_BUTTON.SECONDARY) && this.state.activeTool.type !== \"selection\") {\n return;\n }\n\n if (this.state.isResizing) {\n return; //zsviczian - avoid context menu during resizing on Mobiles\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const element = this.getElementAtPosition(x, y, {\n preferSelected: true,\n includeLockedElements: true\n });\n const selectedElements = this.scene.getSelectedElements(this.state);\n const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements({\n x,\n y\n }, selectedElements);\n const type = element || isHittingCommonBoundBox ? \"element\" : \"canvas\";\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = event.clientX - offsetLeft;\n const top = event.clientY - offsetTop;\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"contextMenu\", \"openContextMenu\", type);\n this.setState(Object.assign(Object.assign({}, element && !this.state.selectedElementIds[element.id] ? Object.assign(Object.assign(Object.assign({}, this.state), (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: this.state.editingGroupId,\n selectedElementIds: {\n [element.id]: true\n }\n }, this.scene.getNonDeletedElements(), this.state, this)), {\n selectedLinearElement: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(element) ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(element, this.scene.getNonDeletedElementsMap()) : null\n }) : this.state), {\n showHyperlinkPopup: false\n }), () => {\n this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n });\n };\n\n this.maybeDragNewGenericElement = (pointerDownState, event, informMutation = true) => {\n var _a, _b, _c, _d, _e;\n\n const selectionElement = this.state.selectionElement;\n const pointerCoords = pointerDownState.lastCoords;\n\n if (selectionElement && this.state.activeTool.type !== \"eraser\") {\n (0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.dragNewElement)({\n newElement: selectionElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.origin.x,\n originY: pointerDownState.origin.y,\n x: pointerCoords.x,\n y: pointerCoords.y,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.origin.x, pointerCoords.x),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.origin.y, pointerCoords.y),\n shouldMaintainAspectRatio: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: false,\n scene: this.scene,\n zoom: this.state.zoom.value,\n informMutation: false\n });\n return;\n }\n\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n let [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(newElement) && ((_a = this.imageCache.get(newElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n const aspectRatio = image && !(image instanceof Promise) ? image.width / image.height : null;\n this.maybeCacheReferenceSnapPoints(event, [newElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapNewElement)(newElement, this, event, {\n x: pointerDownState.originInGrid.x + ((_c = (_b = this.state.originSnapOffset) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 0),\n y: pointerDownState.originInGrid.y + ((_e = (_d = this.state.originSnapOffset) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 0)\n }, {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n }, this.scene.getNonDeletedElementsMap());\n gridX += snapOffset.x;\n gridY += snapOffset.y;\n this.setState({\n snapLines\n });\n (0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.dragNewElement)({\n newElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.originInGrid.x,\n originY: pointerDownState.originInGrid.y,\n x: gridX,\n y: gridY,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.originInGrid.x, gridX),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.distance)(pointerDownState.originInGrid.y, gridY),\n shouldMaintainAspectRatio: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(newElement) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldResizeFromCenter)(event),\n zoom: this.state.zoom.value,\n scene: this.scene,\n widthAspectRatio: aspectRatio,\n originOffset: this.state.originSnapOffset,\n informMutation\n });\n this.setState({\n newElement\n }); // highlight elements that are to be added to frames on frames creation\n\n if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TOOL_TYPE.magicframe) {\n this.setState({\n elementsToHighlight: (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), newElement, this.state, this.scene.getNonDeletedElementsMap())\n });\n }\n };\n\n this.maybeHandleCrop = (pointerDownState, event) => {\n var _a; // to crop, we must already be in the cropping mode, where croppingElement has been set\n\n\n if (!this.state.croppingElementId) {\n return false;\n }\n\n const transformHandleType = pointerDownState.resize.handleType;\n const pointerCoords = pointerDownState.lastCoords;\n const [x, y] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (transformHandleType && croppingElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(croppingElement)) {\n const croppingAtStateStart = pointerDownState.originalElements.get(croppingElement.id);\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(croppingElement) && ((_a = this.imageCache.get(croppingElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (croppingAtStateStart && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(croppingAtStateStart) && image && !(image instanceof Promise)) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n this.maybeCacheReferenceSnapPoints(event, [croppingElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapResizingElements)([croppingElement], [croppingAtStateStart], this, event, dragOffset, transformHandleType);\n this.scene.mutateElement(croppingElement, (0,_excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_25__.cropElement)(croppingElement, transformHandleType, image.naturalWidth, image.naturalHeight, x + snapOffset.x, y + snapOffset.y, event.shiftKey ? croppingAtStateStart.width / croppingAtStateStart.height : undefined));\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.updateBoundElements)(croppingElement, this.scene, {\n newSize: {\n width: croppingElement.width,\n height: croppingElement.height\n }\n });\n this.setState({\n isCropping: transformHandleType && transformHandleType !== \"rotation\",\n snapLines\n });\n }\n\n return true;\n }\n\n return false;\n };\n\n this.maybeHandleResize = (pointerDownState, event) => {\n const selectedElements = this.scene.getSelectedElements(this.state);\n const selectedFrames = selectedElements.filter(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element));\n const transformHandleType = pointerDownState.resize.handleType;\n\n if ( // Frames cannot be rotated.\n selectedFrames.length > 0 && transformHandleType === \"rotation\" || // Elbow arrows cannot be transformed (resized or rotated).\n selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0]) || // Do not resize when in crop mode\n this.state.croppingElementId) {\n return false;\n }\n\n this.setState({\n // TODO: rename this state field to \"isScaling\" to distinguish\n // it from the generic \"isResizing\" which includes scaling and\n // rotating\n isResizing: transformHandleType && transformHandleType !== \"rotation\",\n isRotating: transformHandleType === \"rotation\",\n activeEmbeddable: null\n });\n const pointerCoords = pointerDownState.lastCoords;\n let [resizeX, resizeY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const frameElementsOffsetsMap = new Map();\n selectedFrames.forEach(frame => {\n const elementsInFrame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getFrameChildren)(this.scene.getNonDeletedElements(), frame.id);\n elementsInFrame.forEach(element => {\n frameElementsOffsetsMap.set(frame.id + element.id, {\n x: element.x - frame.x,\n y: element.y - frame.y\n });\n });\n }); // check needed for avoiding flickering when a key gets pressed\n // during dragging\n\n if (!this.state.selectedElementsAreBeingDragged) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n const originalElements = [...pointerDownState.originalElements.values()];\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapResizingElements)(selectedElements, (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(originalElements, this.state), this, event, dragOffset, transformHandleType);\n resizeX += snapOffset.x;\n resizeY += snapOffset.y;\n this.setState({\n snapLines\n });\n }\n\n if ((0,_excalidraw_element_resizeElements__WEBPACK_IMPORTED_MODULE_34__.transformElements)(pointerDownState.originalElements, transformHandleType, selectedElements, this.scene, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldRotateWithDiscreteAngle)(event), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldResizeFromCenter)(event), selectedElements.some(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(element)) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldMaintainAspectRatio)(event), resizeX, resizeY, pointerDownState.resize.center.x, pointerDownState.resize.center.y)) {\n const suggestedBindings = (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom);\n const elementsToHighlight = new Set();\n selectedFrames.forEach(frame => {\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), frame, this.state, this.scene.getNonDeletedElementsMap()).forEach(element => elementsToHighlight.add(element));\n });\n this.setState({\n elementsToHighlight: [...elementsToHighlight],\n suggestedBindings\n });\n return true;\n }\n\n return false;\n };\n\n this.getContextMenuItems = type => {\n const options = [];\n options.push(_actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsSvg); // canvas contextMenu\n // -------------------------------------------------------------------------\n\n if (type === \"canvas\") {\n if (this.state.viewModeEnabled) {\n return [...options, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_48__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleStats, _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_41__.actionToggleLaserPointer];\n }\n\n return [_actions_actionClipboard__WEBPACK_IMPORTED_MODULE_42__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyAsSvg, _actions__WEBPACK_IMPORTED_MODULE_39__.copyText, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionSelectAll, _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_44__.actionUnlockAllElements, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleObjectsSnapMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_48__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleStats];\n } // element contextMenu\n // -------------------------------------------------------------------------\n\n\n options.push(_actions__WEBPACK_IMPORTED_MODULE_39__.copyText);\n\n if (this.state.viewModeEnabled) {\n return [_actions__WEBPACK_IMPORTED_MODULE_39__.actionCopy, ...options];\n }\n\n return [_ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCut, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopy, _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_42__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__.actionSelectAllElementsInFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__.actionRemoveAllElementsFromFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_45__.actionWrapSelectionInFrame, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleCropEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, ...options, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionCopyStyles, _actions__WEBPACK_IMPORTED_MODULE_39__.actionPasteStyles, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionGroup, _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_47__.actionTextAutoResize, _actions__WEBPACK_IMPORTED_MODULE_39__.actionUnbindText, _actions__WEBPACK_IMPORTED_MODULE_39__.actionBindText, _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_40__.actionWrapTextInContainer, _actions__WEBPACK_IMPORTED_MODULE_39__.actionUngroup, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionAddToLibrary, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionSendBackward, _actions__WEBPACK_IMPORTED_MODULE_39__.actionBringForward, _actions__WEBPACK_IMPORTED_MODULE_39__.actionSendToBack, _actions__WEBPACK_IMPORTED_MODULE_39__.actionBringToFront, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionFlipHorizontal, _actions__WEBPACK_IMPORTED_MODULE_39__.actionFlipVertical, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleLinearEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_43__.actionCopyElementLink, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionDuplicateSelection, _actions__WEBPACK_IMPORTED_MODULE_39__.actionToggleElementLock, _ContextMenu__WEBPACK_IMPORTED_MODULE_87__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_39__.actionDeleteSelected];\n };\n\n this.handleWheel = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n // if not scrolling on canvas/wysiwyg, ignore\n if (!(event.target instanceof HTMLCanvasElement || event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLIFrameElement)) {\n // prevent zooming the browser (but allow scrolling DOM)\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n }\n\n return;\n }\n\n event.preventDefault();\n\n if (isPanning) {\n return;\n }\n\n const {\n deltaX,\n deltaY\n } = event; // note that event.ctrlKey is necessary to handle pinch zooming\n\n if ( //zsviczian\n (event.metaKey || event.ctrlKey) && !this.state.allowWheelZoom || !(event.metaKey || event.ctrlKey) && this.state.allowWheelZoom) {\n const sign = Math.sign(deltaY);\n const MAX_STEP = _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ZOOM_STEP * 100;\n const absDelta = Math.abs(deltaY);\n let delta = deltaY;\n\n if (absDelta > MAX_STEP) {\n delta = MAX_STEP * sign;\n }\n\n let newZoom = this.state.zoom.value - delta / 100; // increase zoom steps the more zoomed-in we are (applies to >100% only)\n\n newZoom += Math.log10(Math.max(1, this.state.zoom.value)) * -sign * // reduced amplification for small deltas (small movements on a trackpad)\n Math.min(1, absDelta / 20);\n this.translateCanvas(state => Object.assign(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_63__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getNormalizedZoom)(newZoom)\n }, state)), {\n shouldCacheIgnoreZoom: true\n }));\n this.resetShouldCacheIgnoreZoomDebounced();\n return;\n } // scroll horizontally when shift pressed\n\n\n if (event.shiftKey) {\n this.translateCanvas(({\n zoom,\n scrollX\n }) => ({\n // on Mac, shift+wheel tends to result in deltaX\n scrollX: scrollX - (deltaY || deltaX) / zoom.value\n }));\n return;\n }\n\n this.translateCanvas(({\n zoom,\n scrollX,\n scrollY\n }) => ({\n scrollX: scrollX - deltaX / zoom.value,\n scrollY: scrollY - deltaY / zoom.value\n }));\n });\n\n this.savePointer = (x, y, button) => {\n var _a, _b;\n\n if (!x || !y) {\n return;\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: x,\n clientY: y\n }, this.state);\n\n if (isNaN(sceneX) || isNaN(sceneY)) {// sometimes the pointer goes off screen\n }\n\n const pointer = {\n x: sceneX,\n y: sceneY,\n tool: this.state.activeTool.type === \"laser\" ? \"laser\" : \"pointer\"\n };\n (_b = (_a = this.props).onPointerUpdate) === null || _b === void 0 ? void 0 : _b.call(_a, {\n pointer,\n button,\n pointersMap: gesture.pointers\n });\n };\n\n this.resetShouldCacheIgnoreZoomDebounced = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.debounce)(() => {\n if (!this.unmounted) {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n }\n }, 300);\n\n this.updateDOMRect = cb => {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n width,\n height,\n left: offsetLeft,\n top: offsetTop\n } = excalidrawContainer.getBoundingClientRect();\n const {\n width: currentWidth,\n height: currentHeight,\n offsetTop: currentOffsetTop,\n offsetLeft: currentOffsetLeft\n } = this.state;\n\n if (width === currentWidth && height === currentHeight && offsetLeft === currentOffsetLeft && offsetTop === currentOffsetTop) {\n if (cb) {\n cb();\n }\n\n return;\n } //zsviczian\n\n\n if (width === 0 || height === 0) {\n if (cb) {\n cb();\n }\n\n return;\n }\n\n this.setState({\n width,\n height,\n offsetLeft,\n offsetTop\n }, () => {\n cb && cb();\n });\n }\n };\n\n this.refresh = () => {\n this.setState(Object.assign({}, this.getCanvasOffsets()));\n };\n\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_54__.getDefaultAppState)();\n const {\n excalidrawAPI,\n viewModeEnabled = false,\n zenModeEnabled = false,\n gridModeEnabled = false,\n objectsSnapModeEnabled = false,\n theme = defaultAppState.theme,\n initState,\n //zsviczian\n name = `${(0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getDateTime)()}`\n } = props;\n this.state = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultAppState), {\n theme,\n isLoading: true\n }), this.getCanvasOffsets()), {\n viewModeEnabled,\n zenModeEnabled,\n objectsSnapModeEnabled,\n gridModeEnabled: gridModeEnabled !== null && gridModeEnabled !== void 0 ? gridModeEnabled : defaultAppState.gridModeEnabled,\n name,\n width: window.innerWidth,\n height: window.innerHeight\n }), initState !== null && initState !== void 0 ? initState : {});\n this.id = (0,nanoid__WEBPACK_IMPORTED_MODULE_104__.nanoid)();\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_101__.initializeObsidianUtils)();\n this.library = new _data_library__WEBPACK_IMPORTED_MODULE_57__[\"default\"](this);\n this.actionManager = new _actions_manager__WEBPACK_IMPORTED_MODULE_49__.ActionManager(this.syncActionResult, () => this.state, () => this.scene.getElementsIncludingDeleted(), this);\n this.scene = new _excalidraw_element_Scene__WEBPACK_IMPORTED_MODULE_38__[\"default\"]();\n this.canvas = document.createElement(\"canvas\");\n this.rc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__[\"default\"].canvas(this.canvas);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_72__.Renderer(this.scene);\n this.visibleElements = [];\n this.store = new _store__WEBPACK_IMPORTED_MODULE_76__.Store();\n this.history = new _history__WEBPACK_IMPORTED_MODULE_60__.History();\n\n if (excalidrawAPI) {\n const api = {\n updateScene: this.updateScene,\n mutateElement: this.mutateElement,\n updateLibrary: this.library.updateLibrary,\n addFiles: this.addFiles,\n resetScene: this.resetScene,\n getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,\n history: {\n clear: this.resetHistory\n },\n scrollToContent: this.scrollToContent,\n setForceRenderAllEmbeddables: this.setForceRenderAllEmbeddables,\n zoomToFit: this.zoomToFit,\n getColorAtScenePoint: this.getColorAtScenePoint,\n startLineEditor: this.startLineEditor,\n getSceneElements: this.getSceneElements,\n getAppState: () => this.state,\n getFiles: () => this.files,\n getName: this.getName,\n registerAction: action => {\n this.actionManager.registerAction(action);\n },\n refresh: this.refresh,\n setToast: this.setToast,\n updateContainerSize: this.updateContainerSize,\n id: this.id,\n selectElements: this.selectElements,\n sendBackward: this.sendBackward,\n bringForward: this.bringForward,\n sendToBack: this.sendToBack,\n bringToFront: this.bringToFront,\n setMobileModeAllowed: this.setMobileModeAllowed,\n setActiveTool: this.setActiveTool,\n setCursor: this.setCursor,\n resetCursor: this.resetCursor,\n updateFrameRendering: this.updateFrameRendering,\n toggleSidebar: this.toggleSidebar,\n getHTMLIFrameElement: id => this.getHTMLIFrameElement(id),\n onChange: cb => this.onChangeEmitter.on(cb),\n onPointerDown: cb => this.onPointerDownEmitter.on(cb),\n onPointerUp: cb => this.onPointerUpEmitter.on(cb),\n onScrollChange: cb => this.onScrollChangeEmitter.on(cb),\n onUserFollow: cb => this.onUserFollowEmitter.on(cb)\n };\n\n if (typeof excalidrawAPI === \"function\") {\n excalidrawAPI(api);\n } else {\n console.error(\"excalidrawAPI should be a function!\");\n }\n }\n\n this.excalidrawContainerValue = {\n container: this.excalidrawContainerRef.current,\n id: this.id\n };\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_67__.Fonts(this.scene);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_60__.History();\n this.actionManager.registerAll(_actions_register__WEBPACK_IMPORTED_MODULE_50__.actions);\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_46__.createUndoAction)(this.history, this.store));\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_46__.createRedoAction)(this.history, this.store));\n }\n\n onWindowMessage(event) {\n if (event.origin !== \"https://player.vimeo.com\" && event.origin !== \"https://www.youtube.com\") {\n return;\n }\n\n let data = null;\n\n try {\n data = JSON.parse(event.data);\n } catch (e) {}\n\n if (!data) {\n return;\n }\n\n switch (event.origin) {\n case \"https://player.vimeo.com\":\n //Allowing for multiple instances of Excalidraw running in the window\n if (data.method === \"paused\") {\n let source = null;\n const iframes = document.body.querySelectorAll(\"iframe.excalidraw__embeddable\");\n\n if (!iframes) {\n break;\n }\n\n for (const iframe of iframes) {\n if (iframe.contentWindow === event.source) {\n source = iframe.contentWindow;\n }\n }\n\n source === null || source === void 0 ? void 0 : source.postMessage(JSON.stringify({\n method: data.value ? \"play\" : \"pause\",\n value: true\n }), \"*\");\n }\n\n break;\n\n case \"https://www.youtube.com\":\n if (data.event === \"infoDelivery\" && data.info && data.id && typeof data.info.playerState === \"number\") {\n const id = data.id;\n const playerState = data.info.playerState;\n\n if (Object.values(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES).includes(playerState)) {\n YOUTUBE_VIDEO_STATES.set(id, playerState);\n }\n }\n\n break;\n }\n }\n\n cacheEmbeddableRef(element, ref) {\n if (ref) {\n this.iFrameRefs.set(element.id, ref);\n }\n }\n\n getHTMLIFrameElement(element) {\n //zsviczian\n if (typeof element === \"string\") {\n return this.iFrameRefs.get(element);\n }\n\n return this.iFrameRefs.get(element.id);\n }\n\n handleEmbeddableCenterClick(element) {\n var _a, _b, _c, _d;\n\n if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) === element && ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"active\") {\n return;\n } // The delay serves two purposes\n // 1. To prevent first click propagating to iframe on mobile,\n // else the click will immediately start and stop the video\n // 2. If the user double clicks the frame center to activate it\n // without the delay youtube will immediately open the video\n // in fullscreen mode\n\n\n setTimeout(() => {\n this.setState({\n activeEmbeddable: {\n element,\n state: \"active\"\n },\n selectedElementIds: {\n [element.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n }, 100);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(element)) {\n return;\n }\n\n const iframe = this.getHTMLIFrameElement(element);\n\n if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {\n return;\n }\n\n if (iframe.src.includes(\"youtube\")) {\n const state = YOUTUBE_VIDEO_STATES.get(element.id);\n\n if (!state) {\n YOUTUBE_VIDEO_STATES.set(element.id, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES.UNSTARTED);\n iframe.contentWindow.postMessage(JSON.stringify({\n event: \"listening\",\n id: element.id\n }), \"*\");\n }\n\n switch (state) {\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES.PLAYING:\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.YOUTUBE_STATES.BUFFERING:\n (_c = iframe.contentWindow) === null || _c === void 0 ? void 0 : _c.postMessage(JSON.stringify({\n event: \"command\",\n func: \"pauseVideo\",\n args: \"\"\n }), \"*\");\n break;\n\n default:\n (_d = iframe.contentWindow) === null || _d === void 0 ? void 0 : _d.postMessage(JSON.stringify({\n event: \"command\",\n func: \"playVideo\",\n args: \"\"\n }), \"*\");\n }\n }\n\n if (iframe.src.includes(\"player.vimeo.com\")) {\n iframe.contentWindow.postMessage(JSON.stringify({\n method: \"paused\" //video play/pause in onWindowMessage handler\n\n }), \"*\");\n }\n }\n\n isIframeLikeElementCenter(el, event, sceneX, sceneY) {\n var _a, _b;\n\n return el && !event.altKey && !event.shiftKey && !event.metaKey && !event.ctrlKey && (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) !== el || ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"hover\" || !this.state.activeEmbeddable) && sceneX >= el.x + el.width / 3 && sceneX <= el.x + 2 * el.width / 3 && sceneY >= el.y + el.height / 3 && sceneY <= el.y + 2 * el.height / 3;\n }\n\n renderEmbeddables() {\n const scale = this.state.zoom.value;\n const normalizedWidth = this.state.width;\n const normalizedHeight = this.state.height;\n const embeddableElements = this.scene.getNonDeletedElements().filter(el => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(el) && this.embedsValidationStatus.get(el.id) === true || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), null, embeddableElements.map(el => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: el.x,\n sceneY: el.y\n }, this.state); //zsviczian - shouldRenderAllEmbeddables\n\n const isVisible = this.shouldRenderAllEmbeddables || (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isElementInViewport)(el, normalizedWidth, normalizedHeight, this.state, this.scene.getNonDeletedElementsMap());\n const hasBeenInitialized = this.initializedEmbeds.has(el.id);\n\n if (isVisible && !hasBeenInitialized) {\n this.initializedEmbeds.add(el.id);\n }\n\n const shouldRender = isVisible || hasBeenInitialized;\n\n if (!shouldRender) {\n return null;\n }\n\n let src;\n const embedLink = (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.toValidURL)(el.link || \"\")); //zsviczian\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el)) {\n src = null;\n const data = ((_b = (_a = el.customData) === null || _a === void 0 ? void 0 : _a.generationData) !== null && _b !== void 0 ? _b : this.magicGenerations.get(el.id)) || {\n status: \"error\",\n message: \"No generation data\",\n code: \"ERR_NO_GENERATION_DATA\"\n };\n\n if (data.status === \"done\") {\n const html = data.html;\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return html;\n }\n };\n } else if (data.status === \"pending\") {\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.createSrcDoc)(`\n <style>\n html, body {\n width: 100%;\n height: 100%;\n color: ${this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.DARK ? \"white\" : \"black\"};\n }\n body {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 1rem;\n }\n\n .Spinner {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n margin-right: auto;\n }\n\n .Spinner svg {\n animation: rotate 1.6s linear infinite;\n transform-origin: center center;\n width: 40px;\n height: 40px;\n }\n\n .Spinner circle {\n stroke: currentColor;\n animation: dash 1.6s linear 0s infinite;\n stroke-linecap: round;\n }\n\n @keyframes rotate {\n 100% {\n transform: rotate(360deg);\n }\n }\n\n @keyframes dash {\n 0% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 150, 300;\n stroke-dashoffset: -200;\n }\n 100% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: -280;\n }\n }\n </style>\n <div class=\"Spinner\">\n <svg\n viewBox=\"0 0 100 100\"\n >\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"46\"\n stroke-width=\"8\"\n fill=\"none\"\n stroke-miter-limit=\"10\"\n />\n </svg>\n </div>\n <div>Generating...</div>\n `);\n }\n };\n } else {\n let message;\n\n if (data.code === \"ERR_GENERATION_INTERRUPTED\") {\n message = \"Generation was interrupted...\";\n } else {\n message = data.message || \"Generation failed\";\n }\n\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_18__.createSrcDoc)(`\n <style>\n html, body {\n height: 100%;\n }\n body {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: ${_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.COLOR_PALETTE.red[3]};\n }\n h1, h3 {\n margin-top: 0;\n margin-bottom: 0.5rem;\n }\n </style>\n <h1>Error!</h1>\n <h3>${message}</h3>\n `);\n }\n };\n }\n } else {\n src = embedLink; //zsviczian getEmbedLink(toValidURL(el.link || \"\"));\n }\n\n const isActive = ((_c = this.state.activeEmbeddable) === null || _c === void 0 ? void 0 : _c.element) === el && ((_d = this.state.activeEmbeddable) === null || _d === void 0 ? void 0 : _d.state) === \"active\";\n const isHovered = ((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.element) === el && ((_f = this.state.activeEmbeddable) === null || _f === void 0 ? void 0 : _f.state) === \"hover\";\n const isWebview = //zsviczian\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el) && this.props.renderWebview && (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) !== \"document\" && !((_h = (_g = embedLink === null || embedLink === void 0 ? void 0 : embedLink.link) === null || _g === void 0 ? void 0 : _g.startsWith) === null || _h === void 0 ? void 0 : _h.call(_g, \"https://player.vimeo.com\")); // Modify the scale based on el.scale property\n\n const [xScale, yScale] = (_j = el.scale) !== null && _j !== void 0 ? _j : [1, 1]; //zsviczian\n\n const scaledTransform = `scale(${scale * xScale}, ${scale * yScale})`;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n key: el.id,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw__embeddable-container\", {\n \"is-hovered\": isHovered\n }),\n style: {\n transform: isVisible ? `translate(${x - this.state.offsetLeft}px, ${y - this.state.offsetTop}px) ${scaledTransform}` : \"none\",\n display: isVisible ? \"block\" : \"none\",\n opacity: (0,_excalidraw_element_renderElement__WEBPACK_IMPORTED_MODULE_30__.getRenderOpacity)(el, (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getContainingFrame)(el, this.scene.getNonDeletedElementsMap()), this.elementsPendingErasure, null, ((_k = this.state.openDialog) === null || _k === void 0 ? void 0 : _k.name) === \"elementLinkSelector\" ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1),\n [\"--embeddable-radius\"]: `${(0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getCornerRadius)(Math.min(el.width, el.height), el) / xScale //zsviczian\n }px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n //this is a hack that addresses isse with embedded excalidraw.com embeddable\n //https://github.com/excalidraw/excalidraw/pull/6691#issuecomment-1607383938\n\n /*ref={(ref) => {\r\n if (!this.excalidrawContainerRef.current) {\r\n return;\r\n }\r\n const container = this.excalidrawContainerRef.current;\r\n const sh = container.scrollHeight;\r\n const ch = container.clientHeight;\r\n if (sh !== ch) {\r\n container.style.height = `${sh}px`;\r\n setTimeout(() => {\r\n container.style.height = `100%`;\r\n });\r\n }\r\n }}*/\n className: \"excalidraw__embeddable-container__inner\",\n style: {\n width: isVisible ? `${el.width / xScale}px` : 0,\n height: isVisible ? `${el.height / yScale}px` : 0,\n transform: isVisible ? `rotate(${el.angle}rad)` : \"none\",\n pointerEvents: isActive ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.enabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.disabled\n }\n }, isHovered && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable-hint\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"buttons.embeddableInteractionButton\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable__outer\",\n style: {\n padding: `${el.strokeWidth / (4 * el.scale[0])}px` //zsviczian MDEmbeddable round border cutoff issue\n\n }\n }, (_o = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(el) ? (_m = (_l = this.props).renderEmbeddable) === null || _m === void 0 ? void 0 : _m.call(_l, el, this.state) //zsviczian\n : null) !== null && _o !== void 0 ? _o : isWebview ?\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"webview\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n src: (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"generic\" || (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"video\" ? embedLink.link : \"\",\n title: \"Excalidraw Embedded Content\",\n allowFullScreen: true\n }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"iframe\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n srcDoc: (src === null || src === void 0 ? void 0 : src.type) === \"document\" ? src.srcdoc(this.state.theme) : undefined,\n src: (src === null || src === void 0 ? void 0 : src.type) !== \"document\" ? (_p = src === null || src === void 0 ? void 0 : src.link) !== null && _p !== void 0 ? _p : \"\" : undefined,\n // https://stackoverflow.com/q/18470015\n scrolling: \"no\",\n referrerPolicy: \"no-referrer-when-downgrade\",\n title: \"Excalidraw Embedded Content\",\n allow: \"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\",\n allowFullScreen: true,\n sandbox: `${((_q = src === null || src === void 0 ? void 0 : src.sandbox) === null || _q === void 0 ? void 0 : _q.allowSameOrigin) ? \"allow-same-origin\" : \"\"} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`\n }))));\n }));\n }\n\n toggleOverscrollBehavior(event) {\n // when pointer inside editor, disable overscroll behavior to prevent\n // panning to trigger history back/forward on MacOS Chrome\n document.documentElement.style.overscrollBehaviorX = event.type === \"pointerenter\" ? \"none\" : \"auto\";\n }\n\n render() {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n const {\n renderTopRightUI,\n renderCustomStats\n } = this.props;\n const sceneNonce = this.scene.getSceneNonce();\n const {\n elementsMap,\n visibleElements\n } = this.renderer.getRenderableElements({\n sceneNonce,\n zoom: this.state.zoom,\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n height: this.state.height,\n width: this.state.width,\n editingTextElement: this.state.editingTextElement,\n newElementId: (_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.id,\n pendingImageElementId: this.state.pendingImageElementId\n });\n this.visibleElements = visibleElements;\n const allElementsMap = this.scene.getNonDeletedElementsMap();\n const shouldBlockPointerEvents = // default back to `--ui-pointerEvents` flow if setPointerCapture\n // not supported\n \"setPointerCapture\" in HTMLElement.prototype ? false : this.state.selectionElement || this.state.newElement || this.state.selectedElementsAreBeingDragged || this.state.resizingElement || this.state.activeTool.type === \"laser\" && // technically we can just test on this once we make it more safe\n this.state.cursorButton === \"down\";\n const firstSelectedElement = selectedElements[0]; //zsviczian\n\n const isHighlighter = (_d = (_c = (_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.highlighter;\n const showShapeSwitchPanel = ((_e = _editor_jotai__WEBPACK_IMPORTED_MODULE_68__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__.convertElementTypePopupAtom)) === null || _e === void 0 ? void 0 : _e.type) === \"panel\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw excalidraw-container\", {\n \"excalidraw--view-mode\": this.state.viewModeEnabled || ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\",\n \"excalidraw--mobile\": this.device.editor.isMobile || !(this.state.viewModeEnabled || this.state.zenModeEnabled) && this.state.trayModeEnabled //zsviczian\n\n }),\n style: Object.assign(Object.assign({\n //zsviczian\n [\"--ui-pointerEvents\"]: shouldBlockPointerEvents ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.POINTER_EVENTS.enabled\n }, this.state.dynamicStyle || {}), {\n [\"--right-sidebar-width\"]: \"302px\"\n }),\n ref: this.excalidrawContainerRef,\n onDrop: this.handleAppOnDrop,\n tabIndex: 0,\n onKeyDown: this.props.handleKeyboardGlobally ? undefined : this.onKeyDown,\n onPointerEnter: this.toggleOverscrollBehavior,\n onPointerLeave: this.toggleOverscrollBehavior\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppContext.Provider, {\n value: this\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppPropsContext.Provider, {\n value: this.props\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawContainerContext.Provider, {\n value: this.excalidrawContainerValue\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(DeviceContext.Provider, {\n value: this.device\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawSetAppStateContext.Provider, {\n value: this.setAppState\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawAppStateContext.Provider, {\n value: this.state\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawElementsContext.Provider, {\n value: this.scene.getNonDeletedElements()\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawActionManagerContext.Provider, {\n value: this.actionManager\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_LayerUI__WEBPACK_IMPORTED_MODULE_90__[\"default\"], {\n canvas: this.canvas,\n appState: this.state,\n files: this.files,\n setAppState: this.setAppState,\n actionManager: this.actionManager,\n elements: this.scene.getNonDeletedElements(),\n onLockToggle: this.toggleLock,\n onPenModeToggle: this.togglePenMode,\n onHandToolToggle: this.onHandToolToggle,\n langCode: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.getLanguage)().code,\n renderTopRightUI: renderTopRightUI,\n renderCustomStats: renderCustomStats,\n showExitZenModeBtn: typeof ((_g = this.props) === null || _g === void 0 ? void 0 : _g.zenModeEnabled) === \"undefined\" && this.state.zenModeEnabled,\n UIOptions: this.props.UIOptions,\n onExportImage: this.onExportImage,\n renderWelcomeScreen: !this.state.isLoading && this.state.showWelcomeScreen && this.state.activeTool.type === \"selection\" && !this.state.zenModeEnabled && !this.scene.getElementsIncludingDeleted().length,\n app: this,\n isCollaborating: this.props.isCollaborating,\n generateLinkForSelection: this.props.generateLinkForSelection\n }, this.props.children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-textEditorContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-contextMenuContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-eye-dropper-container\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_SVGLayer__WEBPACK_IMPORTED_MODULE_92__.SVGLayer, {\n trails: [this.laserTrails, this.lassoTrail, this.eraserTrail]\n }), selectedElements.length === 1 && ((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) !== \"elementLinkSelector\" && this.state.showHyperlinkPopup && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_66__.Hyperlink, {\n key: firstSelectedElement.id,\n element: firstSelectedElement,\n scene: this.scene,\n setAppState: this.setAppState,\n onLinkOpen: this.props.onLinkOpen,\n setToast: this.setToast,\n updateEmbedValidationStatus: this.updateEmbedValidationStatus\n }), this.props.aiEnabled !== false && selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isMagicFrameElement)(firstSelectedElement) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_75__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_91__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.convertToCode\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_98__.MagicIcon,\n checked: false,\n onChange: () => this.onMagicFrameGenerate(firstSelectedElement, \"button\")\n })), selectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(firstSelectedElement) && ((_k = (_j = firstSelectedElement.customData) === null || _j === void 0 ? void 0 : _j.generationData) === null || _k === void 0 ? void 0 : _k.status) === \"done\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_75__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_91__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"labels.copySource\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_98__.copyIcon,\n checked: false,\n onChange: () => this.onIframeSrcCopy(firstSelectedElement)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_91__.ElementCanvasButton, {\n title: \"Enter fullscreen\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_98__.fullscreenIcon,\n checked: false,\n onChange: () => {\n const iframe = this.getHTMLIFrameElement(firstSelectedElement);\n\n if (iframe) {\n try {\n iframe.requestFullscreen();\n this.setState({\n activeEmbeddable: {\n element: firstSelectedElement,\n state: \"active\"\n },\n selectedElementIds: {\n [firstSelectedElement.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n } catch (err) {\n console.warn(err);\n this.setState({\n errorMessage: \"Couldn't enter fullscreen\"\n });\n }\n }\n }\n })), this.state.toast !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_Toast__WEBPACK_IMPORTED_MODULE_99__.Toast, {\n message: this.state.toast.message,\n onClose: () => this.setToast(null),\n duration: this.state.toast.duration,\n closable: this.state.toast.closable\n }), this.state.contextMenu && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ContextMenu__WEBPACK_IMPORTED_MODULE_87__.ContextMenu, {\n items: this.state.contextMenu.items,\n top: this.state.contextMenu.top,\n left: this.state.contextMenu.left,\n actionManager: this.actionManager,\n onClose: callback => {\n this.setState({\n contextMenu: null\n }, () => {\n this.focusContainer();\n callback === null || callback === void 0 ? void 0 : callback();\n });\n }\n }), this.state.newElement && isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_96__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_95__.StaticCanvas, {\n canvas: this.canvas,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n visibleElements: visibleElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_l = this.state.selectionElement) === null || _l === void 0 ? void 0 : _l.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isGridModeEnabled)(this),\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: this.flowChartCreator.pendingNodes,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), this.state.newElement && !isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_96__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_95__.InteractiveCanvas, {\n containerRef: this.excalidrawContainerRef,\n canvas: this.interactiveCanvas,\n elementsMap: elementsMap,\n visibleElements: visibleElements,\n allElementsMap: allElementsMap,\n selectedElements: selectedElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_m = this.state.selectionElement) === null || _m === void 0 ? void 0 : _m.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderScrollbars: this.props.renderScrollbars === true,\n device: this.device,\n renderInteractiveSceneCallback: this.renderInteractiveSceneCallback,\n handleCanvasRef: this.handleInteractiveCanvasRef,\n onContextMenu: this.handleCanvasContextMenu,\n onPointerMove: this.handleCanvasPointerMove,\n onPointerUp: this.handleCanvasPointerUp,\n onPointerCancel: this.removePointer,\n onTouchMove: this.handleTouchMove,\n onPointerDown: this.handleCanvasPointerDown,\n onDoubleClick: this.handleCanvasDoubleClick\n }), this.state.userToFollow && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_89__[\"default\"], {\n width: this.state.width,\n height: this.state.height,\n userToFollow: this.state.userToFollow,\n onDisconnect: this.maybeUnfollowRemoteUser\n }), this.renderFrameNames(), ((_o = this.state.activeEmbeddable) === null || _o === void 0 ? void 0 : _o.state) === \"active\" && ( //zsviczian\n (_q = (_p = this.props).renderEmbeddableMenu) === null || _q === void 0 ? void 0 : _q.call(_p, this.state)), showShapeSwitchPanel && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_84__[\"default\"], {\n app: this\n })), this.renderEmbeddables()))))))));\n }\n\n setPlugins(plugins) {\n Object.assign(this.plugins, plugins);\n }\n\n async onMagicFrameGenerate(magicFrame, source) {\n var _a;\n\n const generateDiagramToCode = (_a = this.plugins.diagramToCode) === null || _a === void 0 ? void 0 : _a.generate;\n\n if (!generateDiagramToCode) {\n this.setState({\n errorMessage: \"No diagram to code plugin found\"\n });\n return;\n }\n\n const magicFrameChildren = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsOverlappingFrame)(this.scene.getNonDeletedElements(), magicFrame).filter(el => !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isMagicFrameElement)(el));\n\n if (!magicFrameChildren.length) {\n if (source === \"button\") {\n this.setState({\n errorMessage: \"Cannot generate from an empty frame\"\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (no-children)\", \"d2c\");\n } else {\n this.setActiveTool({\n type: \"magicframe\"\n });\n }\n\n return;\n }\n\n const frameElement = this.insertIframeElement({\n sceneX: magicFrame.x + magicFrame.width + 30,\n sceneY: magicFrame.y,\n width: magicFrame.width,\n height: magicFrame.height\n });\n\n if (!frameElement) {\n return;\n }\n\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"pending\"\n }\n });\n this.setState({\n selectedElementIds: {\n [frameElement.id]: true\n }\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (start)\", \"d2c\");\n\n try {\n const {\n html\n } = await generateDiagramToCode({\n frame: magicFrame,\n children: magicFrameChildren\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (success)\", \"d2c\");\n\n if (!html.trim()) {\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: \"Nothing genereated :(\"\n }\n });\n return;\n }\n\n const parsedHtml = html.includes(\"<!DOCTYPE html>\") && html.includes(\"</html>\") ? html.slice(html.indexOf(\"<!DOCTYPE html>\"), html.indexOf(\"</html>\") + \"</html>\".length) : html;\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"done\",\n html: parsedHtml\n }\n });\n } catch (error) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_52__.trackEvent)(\"ai\", \"generate (failed)\", \"d2c\");\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: error.message || \"Unknown error during generation\"\n }\n });\n }\n }\n\n onIframeSrcCopy(element) {\n var _a, _b;\n\n if (((_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.generationData) === null || _b === void 0 ? void 0 : _b.status) === \"done\") {\n (0,_clipboard__WEBPACK_IMPORTED_MODULE_55__.copyTextToSystemClipboard)(element.customData.generationData.html);\n this.setToast({\n message: \"copied to clipboard\",\n closable: false,\n duration: 1500\n });\n }\n }\n\n clearImageShapeCache(filesMap) {\n const files = filesMap !== null && filesMap !== void 0 ? filesMap : this.files;\n this.scene.getNonDeletedElements().forEach(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(element) && files[element.fileId]) {\n this.imageCache.delete(element.fileId);\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.delete(element);\n }\n });\n }\n\n async componentDidMount() {\n var _a;\n\n this.unmounted = false;\n this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; //zsviczian disabling this code\n\n /*\r\n if (false && (isTestEnv() || isDevEnv())) {\r\n const setState = this.setState.bind(this);\r\n Object.defineProperties(window.h, {\r\n state: {\r\n configurable: true,\r\n get: () => {\r\n return this.state;\r\n },\r\n },\r\n setState: {\r\n configurable: true,\r\n value: (...args: Parameters<typeof setState>) => {\r\n return this.setState(...args);\r\n },\r\n },\r\n app: {\r\n configurable: true,\r\n value: this,\r\n },\r\n history: {\r\n configurable: true,\r\n value: this.history,\r\n },\r\n store: {\r\n configurable: true,\r\n value: this.store,\r\n },\r\n fonts: {\r\n configurable: true,\r\n value: this.fonts,\r\n },\r\n });\r\n }*/\n\n this.store.onStoreIncrementEmitter.on(increment => {\n this.history.record(increment.elementsChange, increment.appStateChange);\n });\n this.scene.onUpdate(this.triggerRender);\n this.addEventListeners();\n\n if (this.props.autoFocus && this.excalidrawContainerRef.current) {\n this.focusContainer();\n }\n\n if ( // bounding rects don't work in tests so updating\n // the state on init would result in making the test enviro run\n // in mobile breakpoint (0 width/height), making everything fail\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isTestEnv)()) {\n this.refreshViewportBreakpoints();\n this.refreshEditorBreakpoints();\n }\n\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.supportsResizeObserver && this.excalidrawContainerRef.current) {\n this.resizeObserver = new ResizeObserver(() => {\n this.refreshEditorBreakpoints();\n this.updateDOMRect();\n });\n (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.excalidrawContainerRef.current);\n }\n\n const searchParams = new URLSearchParams(window.location.search.slice(1));\n\n if (searchParams.has(\"web-share-target\")) {\n // Obtain a file that was shared via the Web Share Target API.\n this.restoreFileFromShare();\n } else {\n this.updateDOMRect(this.initializeScene);\n } // note that this check seems to always pass in localhost\n\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isBrave)() && !(0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.isMeasureTextSupported)()) {\n this.setState({\n errorMessage: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_86__[\"default\"], null)\n });\n }\n }\n\n componentWillUnmount() {\n var _a, _b;\n\n (_a = window.launchQueue) === null || _a === void 0 ? void 0 : _a.setConsumer(() => {});\n this.renderer.destroy();\n this.scene.destroy();\n this.scene = new _excalidraw_element_Scene__WEBPACK_IMPORTED_MODULE_38__[\"default\"]();\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_67__.Fonts(this.scene);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_72__.Renderer(this.scene);\n this.files = {};\n this.imageCache.clear();\n (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n this.unmounted = true;\n this.removeEventListeners();\n this.library.destroy();\n this.laserTrails.stop();\n this.eraserTrail.stop();\n this.onChangeEmitter.clear();\n this.store.onStoreIncrementEmitter.clear();\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_29__.ShapeCache.destroy();\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.destroy();\n clearTimeout(touchTimeout);\n _scene__WEBPACK_IMPORTED_MODULE_62__.isSomeElementSelected.clearCache();\n _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements.clearCache();\n touchTimeout = 0;\n document.documentElement.style.overscrollBehaviorX = \"\";\n document.body.removeChild((0,_Tooltip__WEBPACK_IMPORTED_MODULE_102__.getTooltipDiv)()); //clearRenderCache(); //zsviczian\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.clearEraserCanvasCache)(); //zsviczian\n\n this.interactiveCanvas = null; //zsviczian\n\n this.iFrameRefs.clear(); //zsviczian\n //@ts-ignore\n\n this.iFrameRefs = null; //zsviczian\n\n this.embedsValidationStatus.clear(); //zsviczian\n //@ts-ignore\n\n this.embedsValidationStatus = null; //zsviczian\n\n this.initializedEmbeds.clear(); //zsviczian\n //@ts-ignore\n\n this.initializedEmbeds = null; //zsviczian\n\n this.elementsPendingErasure.clear(); //zsviczian\n //@ts-ignore\n\n this.elementsPendingErasure = null; //zsviczian\n\n this.lastPointerDownEvent = null; //zsviczian\n\n this.lastPointerUpEvent = null; //zsviczian\n\n this.lastPointerMoveEvent = null; //zsviczian\n //@ts-ignore\n\n this.actionManager.app = null; //zsviczian\n\n this.actionManager.actions = {}; //zsviczian\n\n this.history.clear(); //zsviczian\n\n this.store.clear(); //zsviczian\n //@ts-ignore\n\n this.store = null; //zsviczian\n //@ts-ignore\n\n this.library = null; //zsviczian\n //@ts-ignore\n\n this.canvas = null; //zsviczian\n //@ts-ignore\n\n this.rc = null; //zsviczian\n //@ts-ignore\n\n this.excalidrawContainerRef.current = undefined; //zsviczian\n\n this.nearestScrollableContainer = undefined; //zsviczian\n\n this.excalidrawContainerValue = {\n container: null,\n id: \"unknown\"\n }; //zsviczian\n //@ts-ignore\n // this.laserTrails.terminate(); //zsviczian\n // this.eraserTrail.terminate(); //zsviczian\n\n /*\r\n Object.keys(this).forEach((key) => {\r\n //@ts-ignore\r\n delete this[key];\r\n });*/\n }\n\n removeEventListeners() {\n this.onRemoveEventListenersEmitter.trigger();\n }\n\n addEventListeners() {\n // remove first as we can add event listeners multiple times\n this.removeEventListeners(); // -------------------------------------------------------------------------\n // view+edit mode listeners\n // -------------------------------------------------------------------------\n\n if (this.props.handleKeyboardGlobally) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYDOWN, this.onKeyDown, false));\n }\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.MESSAGE, this.onWindowMessage, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, this.removePointer, {\n passive: false\n }), // #3553\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.COPY, this.onCopy, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYUP, this.onKeyUp, {\n passive: true\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, \"focus\", () => this.triggerRender(true), {\n passive: true\n }), //zsviczian\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, this.updateCurrentCursorPosition, {\n passive: false\n }), // rerender text elements on font load to fix #637 && #1553\n // zsviczian In Obsidian this is not needed as I manage font load separately\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document.fonts, \"loadingdone\", event => {\n const fontFaces = event.fontfaces;\n this.fonts.onLoaded(fontFaces);\n }, {\n passive: false\n }), // Safari-only desktop pinch zoom\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.GESTURE_START, this.onGestureStart, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.GESTURE_CHANGE, this.onGestureChange, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.GESTURE_END, this.onGestureEnd, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.FOCUS, () => {\n this.maybeCleanupAfterMissingPointerUp(null); // browsers (chrome?) tend to free up memory a lot, which results\n // in canvas context being cleared. Thus re-render on focus.\n\n this.triggerRender(true);\n }, {\n passive: false\n }));\n\n if (this.state.viewModeEnabled) {\n return;\n } // -------------------------------------------------------------------------\n // edit-mode listeners only\n // -------------------------------------------------------------------------\n\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.FULLSCREENCHANGE, this.onFullscreenChange, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.PASTE, this.pasteFromClipboard, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.CUT, this.onCut, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.RESIZE, this.onResize, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.UNLOAD, this.onUnload, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.BLUR, this.onBlur, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.DRAG_OVER, this.disableEvent, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.DROP, this.disableEvent, false));\n\n if (this.props.detectScroll) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.addEventListener)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getNearestScrollableContainer)(this.excalidrawContainerRef.current), _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.SCROLL, this.onScroll, {\n passive: false\n }));\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;\n\n this.updateEmbeddables();\n const elements = this.scene.getElementsIncludingDeleted();\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n const nonDeletedElementsMap = this.scene.getNonDeletedElementsMap();\n\n if (!this.state.showWelcomeScreen && !elements.length) {\n this.setState({\n showWelcomeScreen: true\n });\n }\n\n if (prevProps.UIOptions.dockedSidebarBreakpoint !== this.props.UIOptions.dockedSidebarBreakpoint) {\n this.refreshEditorBreakpoints();\n }\n\n const hasFollowedPersonLeft = prevState.userToFollow && !this.state.collaborators.has(prevState.userToFollow.socketId);\n\n if (hasFollowedPersonLeft) {\n this.maybeUnfollowRemoteUser();\n }\n\n if (prevState.zoom.value !== this.state.zoom.value || prevState.scrollX !== this.state.scrollX || prevState.scrollY !== this.state.scrollY) {\n (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.onScrollChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.scrollX, this.state.scrollY, this.state.zoom);\n this.onScrollChangeEmitter.trigger(this.state.scrollX, this.state.scrollY, this.state.zoom);\n }\n\n if (prevState.userToFollow !== this.state.userToFollow) {\n if (prevState.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: prevState.userToFollow,\n action: \"UNFOLLOW\"\n });\n }\n\n if (this.state.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: this.state.userToFollow,\n action: \"FOLLOW\"\n });\n }\n } // zsviczian\n\n\n if (this.state.highlightSearchResult && !this.debounceClearHighlightSearchResults && prevState.selectedElementIds !== this.state.selectedElementIds) {\n this.setState({\n highlightSearchResult: false\n });\n }\n\n if (Object.keys(this.state.selectedElementIds).length && (0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n }\n\n if (this.state.activeTool.type === \"eraser\" && prevState.theme !== this.state.theme) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setEraserCursor)(this.interactiveCanvas, this.state.theme);\n } // Hide hyperlink popup if shown when element type is not selection\n\n\n if (prevState.activeTool.type === \"selection\" && this.state.activeTool.type !== \"selection\" && this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: false\n });\n }\n\n if (prevProps.langCode !== this.props.langCode) {\n this.updateLanguage();\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(prevState) && !(0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.eraserTrail.endPath();\n }\n\n if (prevProps.viewModeEnabled !== this.props.viewModeEnabled) {\n this.setState({\n viewModeEnabled: !!this.props.viewModeEnabled\n });\n }\n\n if (prevState.viewModeEnabled !== this.state.viewModeEnabled) {\n this.addEventListeners();\n this.deselectElements();\n } // cleanup\n\n\n if ((((_c = prevState.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" || ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) === \"elementLinkSelector\") && ((_e = prevState.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name)) {\n this.deselectElements();\n this.setState({\n hoveredElementIds: {}\n });\n }\n\n if (prevProps.zenModeEnabled !== this.props.zenModeEnabled) {\n this.setState({\n zenModeEnabled: !!this.props.zenModeEnabled\n });\n }\n\n if (prevProps.theme !== this.props.theme && this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n (_g = this.excalidrawContainerRef.current) === null || _g === void 0 ? void 0 : _g.classList.toggle(\"theme--dark\", this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.THEME.DARK);\n\n if (this.state.editingLinearElement && !this.state.selectedElementIds[this.state.editingLinearElement.elementId]) {\n // defer so that the shouldCaptureIncrement flag isn't reset via current update\n setTimeout(() => {\n // execute only if the condition still holds when the deferred callback\n // executes (it can be scheduled multiple times depending on how\n // many times the component renders)\n this.state.editingLinearElement && this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n } // failsafe in case the state is being updated in incorrect order resulting\n // in the editingTextElement being now a deleted element\n\n\n if ((_h = this.state.editingTextElement) === null || _h === void 0 ? void 0 : _h.isDeleted) {\n this.setState({\n editingTextElement: null\n });\n }\n\n if (this.state.selectedLinearElement && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // To make sure `selectedLinearElement` is in sync with `selectedElementIds`, however this shouldn't be needed once\n // we have a single API to update `selectedElementIds`\n this.setState({\n selectedLinearElement: null\n });\n }\n\n const {\n multiElement\n } = prevState;\n\n if (prevState.activeTool !== this.state.activeTool && multiElement != null && (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(multiElement, false)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.maybeBindLinearElement)(multiElement, this.state, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)(_excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getPointAtIndexGlobalCoordinates(multiElement, -1, nonDeletedElementsMap)), this.scene);\n }\n\n this.store.commit(elementsMap, this.state); // Do not notify consumers if we're still loading the scene. Among other\n // potential issues, this fixes a case where the tab isn't focused during\n // init, which would trigger onChange with empty elements, which would then\n // override whatever is in localStorage currently.\n\n if (!this.state.isLoading) {\n (_k = (_j = this.props).onChange) === null || _k === void 0 ? void 0 : _k.call(_j, elements, this.state, this.files);\n this.onChangeEmitter.trigger(elements, this.state, this.files);\n }\n }\n\n static resetTapTwice() {\n didTapTwice = false;\n } // TODO rewrite this to paste both text & images at the same time if\n // pasted data contains both\n\n\n async addElementsFromMixedContentPaste(mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n }) {\n if (!isPlainPaste && mixedContent.some(node => node.type === \"imageUrl\") && this.isToolSupported(\"image\")) {\n const imageURLs = mixedContent.filter(node => node.type === \"imageUrl\").map(node => node.value);\n const responses = await Promise.all(imageURLs.map(async url => {\n try {\n return {\n file: await (0,_data_blob__WEBPACK_IMPORTED_MODULE_64__.ImageURLToFile)(url)\n };\n } catch (error) {\n let errorMessage = error.message;\n\n if (error.cause === \"FETCH_ERROR\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.failedToFetchImage\");\n } else if (error.cause === \"UNSUPPORTED\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"errors.unsupportedFileType\");\n }\n\n return {\n errorMessage\n };\n }\n }));\n let y = sceneY;\n let firstImageYOffsetDone = false;\n const nextSelectedIds = {};\n\n for (const response of responses) {\n if (response.file) {\n const imageElement = this.createImageElement({\n sceneX,\n sceneY: y\n });\n const initializedImageElement = await this.insertImageElement(imageElement, response.file);\n\n if (initializedImageElement) {\n // vertically center first image in the batch\n if (!firstImageYOffsetDone) {\n firstImageYOffsetDone = true;\n y -= initializedImageElement.height / 2;\n } // hack to reset the `y` coord because we vertically center during\n // insertImageElement\n\n\n this.scene.mutateElement(initializedImageElement, {\n y\n }, {\n informMutation: false,\n isDragging: false\n });\n y = imageElement.y + imageElement.height + 25;\n nextSelectedIds[imageElement.id] = true;\n }\n }\n }\n\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedIds, this.state)\n });\n const error = responses.find(response => !!response.errorMessage);\n\n if (error && error.errorMessage) {\n this.setState({\n errorMessage: error.errorMessage\n });\n }\n } else {\n const textNodes = mixedContent.filter(node => node.type === \"text\");\n\n if (textNodes.length) {\n this.addTextFromPaste(textNodes.map(node => node.value).join(\"\\n\\n\"), isPlainPaste);\n }\n }\n }\n\n addTextFromPaste(text, isPlainPaste = false) {\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state);\n const textElementProps = {\n x,\n y,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roundness: null,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text,\n rawText: text,\n fontSize: (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_103__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value),\n fontFamily: this.state.currentItemFontFamily,\n textAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_TEXT_ALIGN,\n verticalAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_VERTICAL_ALIGN,\n locked: false\n };\n const fontString = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getFontString)({\n fontSize: textElementProps.fontSize,\n fontFamily: textElementProps.fontFamily\n });\n const lineHeight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getLineHeight)(textElementProps.fontFamily);\n const [x1,, x2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getVisibleSceneBounds)(this.state); // long texts should not go beyond 800 pixels in width nor should it go below 200 px\n\n const maxTextWidth = Math.max(Math.min((x2 - x1) * 0.5, 800), 200);\n const LINE_GAP = 10;\n let currentY = y;\n const lines = isPlainPaste ? [text] : text.split(\"\\n\");\n const textElements = lines.reduce((acc, line, idx) => {\n var _a;\n\n const originalText = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.normalizeText)(line).trim();\n\n if (originalText.length) {\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y: currentY\n });\n let metrics = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.measureText)(originalText, fontString, lineHeight);\n const isTextUnwrapped = metrics.width > maxTextWidth;\n const text = isTextUnwrapped ? (0,_excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_26__.wrapText)(originalText, fontString, maxTextWidth) : originalText;\n metrics = isTextUnwrapped ? (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.measureText)(text, fontString, lineHeight) : metrics;\n const startX = x - metrics.width / 2;\n const startY = currentY - metrics.height / 2;\n const element = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.newTextElement)(Object.assign(Object.assign({}, textElementProps), {\n x: startX,\n y: startY,\n text,\n rawText: originalText,\n //zsviczian\n originalText,\n lineHeight,\n autoResize: !isTextUnwrapped,\n frameId: topLayerFrame ? topLayerFrame.id : null\n }));\n acc.push(element);\n currentY += element.height + LINE_GAP;\n } else {\n const prevLine = (_a = lines[idx - 1]) === null || _a === void 0 ? void 0 : _a.trim(); // add paragraph only if previous line was not empty, IOW don't add\n // more than one empty line\n\n if (prevLine) {\n currentY += (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getLineHeightInPx)(textElementProps.fontSize, lineHeight) + LINE_GAP;\n }\n }\n\n return acc;\n }, []);\n\n if (textElements.length === 0) {\n return;\n }\n\n this.scene.insertElements(textElements);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.fromEntries(textElements.map(el => [el.id, true])), this.state)\n });\n\n if (!isPlainPaste && textElements.length > 1 && PLAIN_PASTE_TOAST_SHOWN === false && !this.device.editor.isMobile) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.t)(\"toast.pasteAsSingleElement\", {\n shortcut: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")\n }),\n duration: 5000\n });\n PLAIN_PASTE_TOAST_SHOWN = true;\n }\n\n this.store.shouldCaptureIncrement();\n }\n\n handleTextWysiwyg(element, {\n isExistingElement = false\n }) {\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n const updateElement = (nextOriginalText, isDeleted, rawText, //zsviczian\n link) => {\n this.scene.replaceAllElements([// Not sure why we include deleted elements as well hence using deleted elements map\n ...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(_element)) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(_element, Object.assign({\n originalText: nextOriginalText,\n rawText: rawText !== null && rawText !== void 0 ? rawText : nextOriginalText,\n //zsviczian\n link,\n isDeleted: isDeleted !== null && isDeleted !== void 0 ? isDeleted : _element.isDeleted\n }, (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.refreshTextDimensions)(_element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText)));\n }\n\n return _element;\n })]);\n }; //zsviczian\n\n\n if (this.props.onBeforeTextEdit) {\n const text = this.props.onBeforeTextEdit(element, isExistingElement);\n\n if (text && text !== element.originalText) {\n this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(_element)) {\n //changing the value of element so this gets edited by textWysiwyg\n element = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(_element, Object.assign({\n originalText: text,\n rawText: text,\n isDeleted: false\n }, (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.refreshTextDimensions)(_element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(_element, elementsMap), elementsMap, text)));\n return element;\n }\n\n return _element;\n })]);\n }\n }\n\n (0,_wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_79__.textWysiwyg)({\n id: element.id,\n canvas: this.canvas,\n getViewportCoords: (x, y) => {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: x,\n sceneY: y\n }, this.state);\n return [viewportX - this.state.offsetLeft, viewportY - this.state.offsetTop];\n },\n onChange: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(nextOriginalText => {\n updateElement(nextOriginalText, false);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_37__.isNonDeletedElement)(element)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.updateBoundElements)(element, this.scene);\n }\n }),\n onSubmit: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(({\n viaKeyboard,\n nextOriginalText\n }) => {\n var _a;\n\n const isDeleted = !nextOriginalText.trim(); //zsviczian insert start\n\n const rawText = nextOriginalText; //should this be originalText??\n\n let link = undefined;\n\n if (this.props.onBeforeTextSubmit) {\n const _element = this.scene.getElementsIncludingDeleted().find(el => el.id === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(el));\n\n if (_element) {\n const dismensionsData = (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_13__.refreshTextDimensions)(_element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText);\n const {\n updatedNextOriginalText,\n nextLink\n } = this.props.onBeforeTextSubmit(element, (_a = dismensionsData === null || dismensionsData === void 0 ? void 0 : dismensionsData.text) !== null && _a !== void 0 ? _a : nextOriginalText, //should never be undefined\n nextOriginalText, isDeleted);\n nextOriginalText = updatedNextOriginalText !== null && updatedNextOriginalText !== void 0 ? updatedNextOriginalText : nextOriginalText;\n link = nextLink;\n }\n } //zsviczian insert end\n\n\n updateElement(nextOriginalText, isDeleted, rawText, link); //zsviczian (added rawText, link, text)\n // select the created text element only if submitting via keyboard\n // (when submitting via click it should act as signal to deselect)\n\n if (!isDeleted && viaKeyboard) {\n const elementIdToSelect = element.containerId ? element.containerId : element.id; // needed to ensure state is updated before \"finalize\" action\n // that's invoked on keyboard-submit as well\n // TODO either move this into finalize as well, or handle all state\n // updates in one place, skipping finalize action\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [elementIdToSelect]: true\n }), prevState)\n }));\n });\n }\n\n if (isDeleted) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.fixBindingsAfterDeletion)(this.scene.getNonDeletedElements(), [element]);\n }\n\n if (!isDeleted || isExistingElement) {\n this.store.shouldCaptureIncrement();\n }\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n newElement: null,\n editingTextElement: null\n });\n });\n\n if (this.state.activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.focusContainer();\n }),\n element,\n excalidrawContainer: this.excalidrawContainerRef.current,\n app: this,\n // when text is selected, it's hard (at least on iOS) to re-position the\n // caret (i.e. deselect). There's not much use for always selecting\n // the text on edit anyway (and users can select-all from contextmenu\n // if needed)\n autoSelect: !this.device.isTouchScreen\n }); // deselect all other elements when inserting text\n\n this.deselectElements(); // do an initial update to re-initialize element position since we were\n // modifying element's x/y for sake of editor (case: syncing to remote)\n\n updateElement(element.originalText, false);\n }\n\n deselectElements() {\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n getTextElementAtPosition(x, y) {\n const element = this.getElementAtPosition(x, y, {\n includeBoundTextElement: true\n });\n\n if (element && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element) && !element.isDeleted) {\n return element;\n }\n\n return null;\n }\n\n getElementAtPosition(x, y, opts) {\n const allHitElements = this.getElementsAtPosition(x, y, opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement, opts === null || opts === void 0 ? void 0 : opts.includeLockedElements);\n\n if (allHitElements.length > 1) {\n if (opts === null || opts === void 0 ? void 0 : opts.preferSelected) {\n for (let index = allHitElements.length - 1; index > -1; index--) {\n if (this.state.selectedElementIds[allHitElements[index].id]) {\n return allHitElements[index];\n }\n }\n }\n\n const elementWithHighestZIndex = allHitElements[allHitElements.length - 1]; // If we're hitting element with highest z-index only on its bounding box\n // while also hitting other element figure, the latter should be considered.\n\n return (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x,\n y,\n element: elementWithHighestZIndex,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(elementWithHighestZIndex, this.scene.getNonDeletedElementsMap()),\n // when overlapping, we would like to be more precise\n // this also avoids the need to update past tests\n threshold: this.getElementHitThreshold() / 2,\n frameNameBound: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(elementWithHighestZIndex) ? this.frameNameBoundsCache.get(elementWithHighestZIndex) : null\n }) ? elementWithHighestZIndex : allHitElements[allHitElements.length - 2];\n }\n\n if (allHitElements.length === 1) {\n return allHitElements[0];\n }\n\n return null;\n }\n\n getElementsAtPosition(x, y, includeBoundTextElement = false, includeLockedElements = false) {\n const iframeLikes = [];\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const elements = (includeBoundTextElement && includeLockedElements ? this.scene.getNonDeletedElements() : this.scene.getNonDeletedElements().filter(element => (includeLockedElements || !element.locked) && (includeBoundTextElement || !((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(element) && element.containerId)))).filter(el => this.hitElement(x, y, el)).filter(element => {\n // hitting a frame's element from outside the frame is not considered a hit\n const containingFrame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getContainingFrame)(element, elementsMap);\n return containingFrame && this.state.frameRendering.enabled && this.state.frameRendering.clip ? (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isCursorInFrame)({\n x,\n y\n }, containingFrame, elementsMap) : true;\n }).filter(el => {\n // The parameter elements comes ordered from lower z-index to higher.\n // We want to preserve that order on the returned array.\n // Exception being embeddables which should be on top of everything else in\n // terms of hit testing.\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeElement)(el)) {\n iframeLikes.push(el);\n return false;\n }\n\n return true;\n }).concat(iframeLikes);\n return elements;\n }\n\n getElementHitThreshold() {\n return _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value;\n }\n\n hitElement(x, y, element, considerBoundingBox = true) {\n // if the element is selected, then hit test is done against its bounding box\n if (considerBoundingBox && this.state.selectedElementIds[element.id] && (0,_excalidraw_element_transformHandles__WEBPACK_IMPORTED_MODULE_21__.shouldShowBoundingBox)([element], this.state)) {\n const selectionShape = (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_7__.getSelectionBoxShape)(element, this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(element) ? 0 : this.getElementHitThreshold()); // if hitting the bounding box, return early\n // but if not, we should check for other cases as well (e.g. frame name)\n\n if ((0,_excalidraw_utils_collision__WEBPACK_IMPORTED_MODULE_6__.isPointInShape)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), selectionShape)) {\n return true;\n }\n } // take bound text element into consideration for hit collision as well\n\n\n const hitBoundTextOfElement = (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementBoundText)(x, y, (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getBoundTextShape)(element, this.scene.getNonDeletedElementsMap()));\n\n if (hitBoundTextOfElement) {\n return true;\n }\n\n return (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x,\n y,\n element,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(element, this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold(),\n frameNameBound: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element) ? this.frameNameBoundsCache.get(element) : null\n });\n }\n\n getTextBindableContainerAtPosition(x, y) {\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextBindableContainer)(selectedElements[0], false) ? selectedElements[0] : null;\n }\n\n let hitElement = null; // We need to do hit testing from front (end of the array) to back (beginning of the array)\n\n for (let index = elements.length - 1; index >= 0; --index) {\n if (elements[index].isDeleted) {\n continue;\n }\n\n const [x1, y1, x2, y2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getElementAbsoluteCoords)(elements[index], this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isArrowElement)(elements[index]) && (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x,\n y,\n element: elements[index],\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(elements[index], this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold()\n })) {\n hitElement = elements[index];\n break;\n } else if (x1 < x && x < x2 && y1 < y && y < y2) {\n hitElement = elements[index];\n break;\n }\n }\n\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextBindableContainer)(hitElement, false) ? hitElement : null;\n }\n\n handleHoverSelectedLinearElement(linearElementEditor, scenePointerX, scenePointerY) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const element = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (!element) {\n return;\n }\n\n if (this.state.selectedLinearElement) {\n let hoverPointIndex = -1;\n let segmentMidPointHoveredCoords = null;\n\n if ((0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementItself)({\n x: scenePointerX,\n y: scenePointerY,\n element,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(element, this.scene.getNonDeletedElementsMap())\n })) {\n hoverPointIndex = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getPointIndexUnderCursor(element, elementsMap, this.state.zoom, scenePointerX, scenePointerY);\n segmentMidPointHoveredCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, {\n x: scenePointerX,\n y: scenePointerY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const isHoveringAPointHandle = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element) ? hoverPointIndex === 0 || hoverPointIndex === element.points.length - 1 : hoverPointIndex >= 0;\n\n if (isHoveringAPointHandle || segmentMidPointHoveredCoords) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.POINTER);\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE);\n }\n }\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.MOVE);\n }\n }\n\n if (this.state.selectedLinearElement.hoverPointIndex !== hoverPointIndex) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n hoverPointIndex\n })\n });\n }\n\n if (!_excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords, segmentMidPointHoveredCoords)) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords\n })\n });\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n }\n }\n\n updateGestureOnPointerDown(event) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n\n if (gesture.pointers.size === 2) {\n gesture.lastCenter = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getCenter)(gesture.pointers);\n gesture.initialScale = this.state.zoom.value;\n gesture.initialDistance = (0,_gesture__WEBPACK_IMPORTED_MODULE_59__.getDistance)(Array.from(gesture.pointers.values()));\n }\n }\n\n initialPointerDownState(event) {\n const origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n const selectedElements = this.scene.getSelectedElements(this.state);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements);\n const isElbowArrowOnly = selectedElements.findIndex(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow) === 0;\n return {\n origin,\n withCmdOrCtrl: event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD],\n originInGrid: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(origin.x, origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] || isElbowArrowOnly ? null : this.getEffectiveGridSize())),\n scrollbars: (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_80__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop),\n // we need to duplicate because we'll be updating this state\n lastCoords: Object.assign({}, origin),\n originalElements: this.scene.getNonDeletedElements().reduce((acc, element) => {\n acc.set(element.id, (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.deepCopyElement)(element));\n return acc;\n }, new Map()),\n resize: {\n handleType: false,\n isResizing: false,\n offset: {\n x: 0,\n y: 0\n },\n arrowDirection: \"origin\",\n center: {\n x: (maxX + minX) / 2,\n y: (maxY + minY) / 2\n }\n },\n hit: {\n element: null,\n allHitElements: [],\n wasAddedToSelection: false,\n hasBeenDuplicated: false,\n hasHitCommonBoundingBoxOfSelectedElements: this.isHittingCommonBoundingBoxOfSelectedElements(origin, selectedElements)\n },\n drag: {\n hasOccurred: false,\n offset: null,\n origin: Object.assign({}, origin)\n },\n eventListeners: {\n onMove: null,\n onUp: null,\n onKeyUp: null,\n onKeyDown: null\n },\n boxSelection: {\n hasOccurred: false\n }\n };\n } // Returns whether the event is a dragging a scrollbar\n\n\n handleDraggingScrollBar(event, pointerDownState) {\n if (!(pointerDownState.scrollbars.isOverEither && !this.state.multiElement)) {\n return false;\n }\n\n isDraggingScrollBar = true;\n pointerDownState.lastCoords.x = event.clientX;\n pointerDownState.lastCoords.y = event.clientY;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdatesThrottled)(event => {\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n this.handlePointerMoveOverScrollbars(event, pointerDownState);\n });\n const onPointerUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(() => {\n lastPointerUp = null;\n isDraggingScrollBar = false;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp);\n onPointerMove.flush();\n });\n lastPointerUp = onPointerUp;\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, onPointerUp);\n return true;\n }\n\n isASelectedElement(hitElement) {\n return hitElement != null && this.state.selectedElementIds[hitElement.id];\n }\n\n isHittingCommonBoundingBoxOfSelectedElements(point, selectedElements) {\n if (selectedElements.length < 2) {\n return false;\n } // How many pixels off the shape boundary we still consider a hit\n\n\n const threshold = this.getElementHitThreshold();\n const [x1, y1, x2, y2] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getCommonBounds)(selectedElements);\n return point.x > x1 - threshold && point.x < x2 + threshold && point.y > y1 - threshold && point.y < y2 + threshold;\n }\n\n getCurrentItemRoundness(elementType) {\n return this.state.currentItemRoundness === \"round\" ? {\n type: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isUsingAdaptiveRadius)(elementType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null;\n }\n\n maybeCacheReferenceSnapPoints(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.getReferenceSnapPoints())) {\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setReferenceSnapPoints((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.getReferenceSnapPoints)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n maybeCacheVisibleGaps(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.getVisibleGaps())) {\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setVisibleGaps((0,_snapping__WEBPACK_IMPORTED_MODULE_70__.getVisibleGaps)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n onKeyDownFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onKeyUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(event => {\n // Prevents focus from escaping excalidraw tab\n event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.ALT && event.preventDefault();\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onPointerMoveFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdatesThrottled)(event => {\n var _a, _b, _c, _d, _e, _f, _g; //To avoid pointerMove canceling the selection of locked elements on mobile //zsviczian\n\n\n if (Boolean(this.state.contextMenu) || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n return;\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.elbowed && this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n let index = this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;\n\n if (index < 0) {\n const nextCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: gridX,\n y: gridY\n }, this.state, this.scene.getNonDeletedElementsMap());\n index = nextCoords ? _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : -1;\n }\n\n const ret = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.moveFixedSegment(this.state.selectedLinearElement, index, gridX, gridY, this.scene);\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: ret.segmentMidPointHoveredCoords,\n pointerDownState: ret.pointerDownState\n })\n });\n }\n });\n return;\n }\n\n const lastPointerCoords = (_b = this.lastPointerMoveCoords) !== null && _b !== void 0 ? _b : pointerDownState.origin;\n this.lastPointerMoveCoords = pointerCoords; // We need to initialize dragOffsetXY only after we've updated\n // `state.selectedElementIds` on pointerDown. Doing it here in pointerMove\n // event handler should hopefully ensure we're already working with\n // the updated state.\n\n if (pointerDownState.drag.offset === null) {\n pointerDownState.drag.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.tupleToCoors)((0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.getDragOffsetXY)(this.scene.getSelectedElements(this.state), pointerDownState.origin.x, pointerDownState.origin.y));\n }\n\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n if (this.handlePointerMoveOverScrollbars(event, pointerDownState)) {\n return;\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state)) {\n this.handleEraser(event, pointerCoords);\n return;\n }\n\n if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.addPointToPath(pointerCoords.x, pointerCoords.y);\n }\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize()); // for arrows/lines, don't start dragging until a given threshold\n // to ensure we don't create a 2-point arrow by mistake when\n // user clicks mouse in a way that it moves a tiny bit (thus\n // triggering pointermove)\n\n if (!pointerDownState.drag.hasOccurred && (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\")) {\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.DRAGGING_THRESHOLD) {\n return;\n }\n }\n\n if (pointerDownState.resize.isResizing) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (this.maybeHandleCrop(pointerDownState, event)) {\n return true;\n }\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return true;\n }\n }\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.editingLinearElement || this.state.selectedLinearElement;\n\n if (_excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.shouldAddMidpoint(this.state.selectedLinearElement, pointerCoords, this.state, elementsMap)) {\n const ret = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.addMidpoint(this.state.selectedLinearElement, pointerCoords, this, !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD], this.scene);\n\n if (!ret) {\n return;\n } // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n\n if (this.state.editingLinearElement) {\n this.setState({\n editingLinearElement: Object.assign(Object.assign({}, this.state.editingLinearElement), {\n pointerDownState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n });\n return;\n } else if (linearElementEditor.pointerDownState.segmentMidpoint.value !== null && !linearElementEditor.pointerDownState.segmentMidpoint.added) {\n return;\n }\n\n const newLinearElementEditor = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointDragging(event, this, pointerCoords.x, pointerCoords.y, (element, pointsSceneCoords) => {\n this.maybeSuggestBindingsForLinearElementAtCoords(element, pointsSceneCoords);\n }, linearElementEditor, this.scene);\n\n if (newLinearElementEditor) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n pointerDownState.drag.hasOccurred = true;\n this.setState({\n editingLinearElement: this.state.editingLinearElement ? newLinearElementEditor : null,\n selectedLinearElement: newLinearElementEditor\n });\n return;\n }\n }\n\n const hasHitASelectedElement = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n const isSelectingPointsInLineEditor = this.state.editingLinearElement && event.shiftKey && this.state.editingLinearElement.elementId === ((_c = pointerDownState.hit.element) === null || _c === void 0 ? void 0 : _c.id);\n\n if ((hasHitASelectedElement || pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && !isSelectingPointsInLineEditor && this.state.activeTool.type !== \"lasso\") {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.every(element => element.locked)) {\n return;\n }\n\n const selectedElementsHasAFrame = selectedElements.find(e => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(e));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(pointerCoords);\n const frameToHighlight = topLayerFrame && !selectedElementsHasAFrame ? topLayerFrame : null; // Only update the state if there is a difference\n\n if (this.state.frameToHighlight !== frameToHighlight) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n frameToHighlight\n });\n });\n } // Marking that click was used for dragging to check\n // if elements should be deselected on pointerup\n\n\n pointerDownState.drag.hasOccurred = true; // prevent dragging even if we're no longer holding cmd/ctrl otherwise\n // it would have weird results (stuff jumping all over the screen)\n // Checking for editingTextElement to avoid jump while editing on mobile #6503\n\n if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl && !this.state.editingTextElement && ((_d = this.state.activeEmbeddable) === null || _d === void 0 ? void 0 : _d.state) !== \"active\") {\n const dragOffset = {\n x: pointerCoords.x - pointerDownState.drag.origin.x,\n y: pointerCoords.y - pointerDownState.drag.origin.y\n };\n const originalElements = [...pointerDownState.originalElements.values()]; // We only drag in one direction if shift is pressed\n\n const lockDirection = event.shiftKey;\n\n if (lockDirection) {\n const distanceX = Math.abs(dragOffset.x);\n const distanceY = Math.abs(dragOffset.y);\n const lockX = lockDirection && distanceX < distanceY;\n const lockY = lockDirection && distanceX > distanceY;\n\n if (lockX) {\n dragOffset.x = 0;\n }\n\n if (lockY) {\n dragOffset.y = 0;\n }\n } // #region move crop region\n\n\n if (this.state.croppingElementId) {\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (croppingElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(croppingElement) && croppingElement.crop !== null && pointerDownState.hit.element === croppingElement) {\n const crop = croppingElement.crop;\n const image = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isInitializedImageElement)(croppingElement) && ((_e = this.imageCache.get(croppingElement.fileId)) === null || _e === void 0 ? void 0 : _e.image);\n\n if (image && !(image instanceof Promise)) {\n const instantDragOffset = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)(pointerCoords.x - lastPointerCoords.x, pointerCoords.y - lastPointerCoords.y), Math.max(this.state.zoom.value, 2));\n const [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_9__.getElementAbsoluteCoords)(croppingElement, elementsMap);\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(topRight, topLeft));\n const leftEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(bottomLeft, topLeft)); // project instantDrafOffset onto leftEdge and topEdge to decompose\n\n const offsetVector = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, topEdge), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, leftEdge));\n const nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.x - offsetVector[0] * Math.sign(croppingElement.scale[0]), 0, image.naturalWidth - crop.width),\n y: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.y - offsetVector[1] * Math.sign(croppingElement.scale[1]), 0, image.naturalHeight - crop.height)\n });\n this.scene.mutateElement(croppingElement, {\n crop: nextCrop\n });\n return;\n }\n }\n } // Snap cache *must* be synchronously popuplated before initial drag,\n // otherwise the first drag even will not snap, causing a jump before\n // it snaps to its position if previously snapped already.\n\n\n this.maybeCacheVisibleGaps(event, selectedElements);\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_70__.snapDraggedElements)(originalElements, dragOffset, this, event, this.scene.getNonDeletedElementsMap());\n this.setState({\n snapLines\n }); // when we're editing the name of a frame, we want the user to be\n // able to select and interact with the text input\n\n if (!this.state.editingFrame) {\n (0,_excalidraw_element_dragElements__WEBPACK_IMPORTED_MODULE_36__.dragSelectedElements)(pointerDownState, selectedElements, dragOffset, this.scene, snapOffset, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n }\n\n this.setState({\n selectedElementsAreBeingDragged: true,\n // element is being dragged and selectionElement that was created on pointer down\n // should be removed\n selectionElement: null\n });\n\n if (selectedElements.length !== 1 || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(selectedElements[0])) {\n this.setState({\n suggestedBindings: (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n } // We duplicate the selected element if alt is pressed on pointer move\n\n\n if (event.altKey && !pointerDownState.hit.hasBeenDuplicated) {\n // Move the currently selected elements to the top of the z index stack, and\n // put the duplicates where the selected elements used to be.\n // (the origin point where the dragging started)\n pointerDownState.hit.hasBeenDuplicated = true;\n const elements = this.scene.getElementsIncludingDeleted();\n const hitElement = pointerDownState.hit.element;\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n\n if (hitElement && // hit element may not end up being selected\n // if we're alt-dragging a common bounding box\n // over the hit element\n pointerDownState.hit.wasAddedToSelection && !selectedElements.find(el => el.id === hitElement.id)) {\n selectedElements.push(hitElement);\n }\n\n const idsOfElementsToDuplicate = new Map(selectedElements.map(el => [el.id, el]));\n const {\n duplicatedElements,\n duplicateElementsMap,\n elementsWithDuplicates,\n origIdToDuplicateId\n } = (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElements)({\n type: \"in-place\",\n elements,\n appState: this.state,\n randomizeSeed: true,\n idsOfElementsToDuplicate,\n overrides: ({\n duplicateElement,\n origElement\n }) => {\n var _a;\n\n return {\n // reset to the original element's frameId (unless we've\n // duplicated alongside a frame in which case we need to\n // keep the duplicate frame's id) so that the element\n // frame membership is refreshed on pointerup\n // NOTE this is a hacky solution and should be done\n // differently\n frameId: (_a = duplicateElement.frameId) !== null && _a !== void 0 ? _a : origElement.frameId,\n seed: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.randomInteger)()\n };\n }\n });\n duplicatedElements.forEach(element => {\n pointerDownState.originalElements.set(element.id, (0,_excalidraw_element_duplicate__WEBPACK_IMPORTED_MODULE_14__.deepCopyElement)(element));\n });\n const mappedClonedElements = elementsWithDuplicates.map(el => {\n if (idsOfElementsToDuplicate.has(el.id)) {\n const origEl = pointerDownState.originalElements.get(el.id);\n\n if (origEl) {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_12__.newElementWith)(el, {\n x: origEl.x,\n y: origEl.y\n });\n }\n }\n\n return el;\n });\n const mappedNewSceneElements = (_g = (_f = this.props).onDuplicate) === null || _g === void 0 ? void 0 : _g.call(_f, mappedClonedElements, elements);\n const elementsWithIndices = (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_32__.syncMovedIndices)(mappedNewSceneElements || mappedClonedElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.arrayToMap)(duplicatedElements)); // we need to update synchronously so as to keep pointerDownState,\n // appState, and scene elements in sync\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n // swap hit element with the duplicated one\n if (pointerDownState.hit.element) {\n const cloneId = origIdToDuplicateId.get(pointerDownState.hit.element.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n pointerDownState.hit.element = clonedElement || null;\n } // swap hit elements with the duplicated ones\n\n\n pointerDownState.hit.allHitElements = pointerDownState.hit.allHitElements.reduce((acc, origHitElement) => {\n const cloneId = origIdToDuplicateId.get(origHitElement.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n\n if (clonedElement) {\n acc.push(clonedElement);\n }\n\n return acc;\n }, []); // update drag origin to the position at which we started\n // the duplication so that the drag offset is correct\n\n pointerDownState.drag.origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(event, this.state); // switch selected elements to the duplicated ones\n\n this.setState(prevState => Object.assign({}, (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.getSelectionStateForElements)(duplicatedElements, this.scene.getNonDeletedElements(), prevState)));\n this.scene.replaceAllElements(elementsWithIndices);\n this.maybeCacheVisibleGaps(event, selectedElements, true);\n this.maybeCacheReferenceSnapPoints(event, selectedElements, true);\n });\n }\n\n return;\n }\n }\n\n if (this.state.selectionElement) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (event.altKey) {\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n }, event.shiftKey);\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setAppState({\n selectionElement: null\n });\n } else {\n this.maybeDragNewGenericElement(pointerDownState, event);\n }\n } else if (this.state.activeTool.type === \"lasso\") {\n if (!event.altKey && this.state.activeTool.fromSelection) {\n this.setActiveTool({\n type: \"selection\"\n });\n this.createGenericElementOnPointerDown(\"selection\", pointerDownState);\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event);\n this.lassoTrail.endPath();\n } else {\n this.lassoTrail.addPointToPath(pointerCoords.x, pointerCoords.y, event.shiftKey);\n }\n } else {\n // It is very important to read this.state within each move event,\n // otherwise we would read a stale one!\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n if (newElement.type === \"freedraw\") {\n const points = newElement.points;\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n const lastPoint = points.length > 0 && points[points.length - 1];\n const discardPoint = lastPoint && lastPoint[0] === dx && lastPoint[1] === dy;\n\n if (!discardPoint) {\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const pressures = newElement.simulatePressure ? newElement.pressures : [//zsviczian\n ...newElement.pressures, (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n newElement\n });\n }\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(newElement)) {\n pointerDownState.drag.hasOccurred = true;\n const points = newElement.points;\n let dx = gridX - newElement.x;\n let dy = gridY - newElement.y;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.shouldRotateWithDiscreteAngle)(event) && points.length === 2) {\n ({\n width: dx,\n height: dy\n } = (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.getLockedLinearCursorAlignSize)(newElement.x, newElement.y, pointerCoords.x, pointerCoords.y));\n }\n\n if (points.length === 1) {\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else if (points.length === 2 || points.length > 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(newElement)) {\n this.scene.mutateElement(newElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n isDragging: true,\n informMutation: false\n });\n }\n\n this.setState({\n newElement\n });\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(newElement, false)) {\n // When creating a linear element by dragging\n this.maybeSuggestBindingsForLinearElementAtCoords(newElement, [pointerCoords], this.state.startBoundElement);\n }\n } else {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event, false);\n }\n }\n\n if (this.state.activeTool.type === \"selection\") {\n pointerDownState.boxSelection.hasOccurred = true;\n const elements = this.scene.getNonDeletedElements(); // box-select line editor points\n\n if (this.state.editingLinearElement) {\n _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handleBoxSelection(event, this.state, this.setState.bind(this), this.scene.getNonDeletedElementsMap()); // regular box-select\n } else {\n let shouldReuseSelection = true;\n\n if (!event.shiftKey && (0,_scene__WEBPACK_IMPORTED_MODULE_62__.isSomeElementSelected)(elements, this.state)) {\n if (pointerDownState.withCmdOrCtrl && pointerDownState.hit.element) {\n this.setState(prevState => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)(Object.assign(Object.assign({}, prevState), {\n selectedElementIds: {\n [pointerDownState.hit.element.id]: true\n }\n }), this.scene.getNonDeletedElements(), prevState, this));\n } else {\n shouldReuseSelection = false;\n }\n }\n\n const elementsWithinSelection = this.state.selectionElement ? (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getElementsWithinSelection)(elements, this.state.selectionElement, this.scene.getNonDeletedElementsMap(), false) : [];\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, shouldReuseSelection && prevState.selectedElementIds), elementsWithinSelection.reduce((acc, element) => {\n acc[element.id] = true;\n return acc;\n }, {}));\n\n if (pointerDownState.hit.element) {\n // if using ctrl/cmd, select the hitElement only if we\n // haven't box-selected anything else\n if (!elementsWithinSelection.length) {\n nextSelectedElementIds[pointerDownState.hit.element.id] = true;\n } else {\n delete nextSelectedElementIds[pointerDownState.hit.element.id];\n }\n }\n\n prevState = !shouldReuseSelection ? Object.assign(Object.assign({}, prevState), {\n selectedGroupIds: {},\n editingGroupId: null\n }) : prevState;\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // select linear element only when we haven't box-selected anything else\n selectedLinearElement: elementsWithinSelection.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(elementsWithinSelection[0]) ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(elementsWithinSelection[0], this.scene.getNonDeletedElementsMap()) : null,\n showHyperlinkPopup: elementsWithinSelection.length === 1 && (elementsWithinSelection[0].link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(elementsWithinSelection[0])) ? \"info\" : false\n });\n });\n }\n }\n });\n } // Returns whether the pointer move happened over either scrollbar\n\n\n handlePointerMoveOverScrollbars(event, pointerDownState) {\n var _a, _b;\n\n if (pointerDownState.scrollbars.isOverHorizontal) {\n const x = event.clientX;\n const dx = x - pointerDownState.lastCoords.x;\n this.translateCanvas({\n scrollX: this.state.scrollX - dx * (((_a = currentScrollBars.horizontal) === null || _a === void 0 ? void 0 : _a.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.x = x;\n return true;\n }\n\n if (pointerDownState.scrollbars.isOverVertical) {\n const y = event.clientY;\n const dy = y - pointerDownState.lastCoords.y;\n this.translateCanvas({\n scrollY: this.state.scrollY - dy * (((_b = currentScrollBars.vertical) === null || _b === void 0 ? void 0 : _b.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.y = y;\n return true;\n }\n\n return false;\n }\n\n onPointerUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_78__.withBatchedUpdates)(childEvent => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;\n\n this.removePointer(childEvent);\n\n if (pointerDownState.eventListeners.onMove) {\n pointerDownState.eventListeners.onMove.flush();\n }\n\n const {\n newElement,\n resizingElement,\n croppingElementId,\n multiElement,\n activeTool,\n isResizing,\n isRotating,\n isCropping\n } = this.state;\n this.setState(prevState => ({\n isResizing: false,\n isRotating: false,\n isCropping: false,\n resizingElement: null,\n selectionElement: null,\n frameToHighlight: null,\n elementsToHighlight: null,\n cursorButton: \"up\",\n snapLines: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateStable)(prevState.snapLines, []),\n originSnapOffset: null\n })); // just in case, tool changes mid drag, always clean up\n\n this.lassoTrail.endPath();\n this.lastPointerMoveCoords = null;\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setReferenceSnapPoints(null);\n _snapping__WEBPACK_IMPORTED_MODULE_70__.SnapCache.setVisibleGaps(null);\n this.savePointer(childEvent.clientX, childEvent.clientY, \"up\");\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (pointerDownState.drag.hasOccurred && ((_b = (_a = pointerDownState.hit) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.id)) {\n const element = elementsMap.get(pointerDownState.hit.element.id);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindableElement)(element)) {\n // Renormalize elbow arrows when they are changed via indirect move\n (_c = element.boundElements) === null || _c === void 0 ? void 0 : _c.filter(e => e.type === \"arrow\").map(e => elementsMap.get(e.id)).filter(e => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(e)).forEach(e => {\n !!e && this.scene.mutateElement(e, {});\n });\n }\n } // Handle end of dragging a point of a linear element, might close a loop\n // and sets binding element\n\n\n if (this.state.editingLinearElement) {\n if (!pointerDownState.boxSelection.hasOccurred && ((_e = (_d = pointerDownState.hit) === null || _d === void 0 ? void 0 : _d.element) === null || _e === void 0 ? void 0 : _e.id) !== this.state.editingLinearElement.elementId) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n } else {\n const editingLinearElement = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerUp(childEvent, this.state.editingLinearElement, this.state, this.scene);\n\n if (editingLinearElement !== this.state.editingLinearElement) {\n this.setState({\n editingLinearElement,\n suggestedBindings: []\n });\n }\n }\n } else if (this.state.selectedLinearElement) {\n // Normalize elbow arrow points, remove close parallel segments\n if (this.state.selectedLinearElement.elbowed) {\n const element = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if (element) {\n this.scene.mutateElement(element, {});\n }\n }\n\n if (((_g = (_f = pointerDownState.hit) === null || _f === void 0 ? void 0 : _f.element) === null || _g === void 0 ? void 0 : _g.id) !== this.state.selectedLinearElement.elementId) {\n const selectedELements = this.scene.getSelectedElements(this.state); // set selectedLinearElement to null if there is more than one element selected since we don't want to show linear element handles\n\n if (selectedELements.length > 1) {\n this.setState({\n selectedLinearElement: null\n });\n }\n } else {\n const linearElementEditor = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor.handlePointerUp(childEvent, this.state.selectedLinearElement, this.state, this.scene);\n const {\n startBindingElement,\n endBindingElement\n } = linearElementEditor;\n const element = this.scene.getElement(linearElementEditor.elementId);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(element)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.bindOrUnbindLinearElement)(element, startBindingElement, endBindingElement, this.scene);\n }\n\n if (linearElementEditor !== this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n selectedPointsIndices: null\n }),\n suggestedBindings: []\n });\n }\n }\n }\n\n this.missingPointerEventCleanupEmitter.clear();\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_MOVE, pointerDownState.eventListeners.onMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.POINTER_UP, pointerDownState.eventListeners.onUp);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYDOWN, pointerDownState.eventListeners.onKeyDown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.EVENT.KEYUP, pointerDownState.eventListeners.onKeyUp);\n\n if (this.state.pendingImageElementId) {\n this.setState({\n pendingImageElementId: null\n });\n }\n\n (_j = (_h = this.props) === null || _h === void 0 ? void 0 : _h.onPointerUp) === null || _j === void 0 ? void 0 : _j.call(_h, activeTool, pointerDownState);\n this.onPointerUpEmitter.trigger(this.state.activeTool, pointerDownState, childEvent);\n\n if ((newElement === null || newElement === void 0 ? void 0 : newElement.type) === \"freedraw\") {\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const points = newElement.points;\n let dx = pointerCoords.x - newElement.x;\n let dy = pointerCoords.y - newElement.y; // Allows dots to avoid being flagged as infinitely small\n\n if (dx === points[0][0] && dy === points[0][1]) {\n dy += 0.0001;\n dx += 0.0001;\n }\n\n const pressures = newElement.simulatePressure ? [] : [...newElement.pressures, childEvent.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures,\n lastCommittedPoint: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isImageElement)(newElement)) {\n const imageElement = newElement;\n\n try {\n this.initializeImageDimensions(imageElement);\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({\n [imageElement.id]: true\n }, this.state)\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n });\n } catch (error) {\n console.error(error);\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(el => el.id !== imageElement.id));\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_39__.actionFinalize);\n }\n\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(newElement)) {\n if (newElement.points.length > 1) {\n this.store.shouldCaptureIncrement();\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(childEvent, this.state);\n\n if (!pointerDownState.drag.hasOccurred && newElement && !multiElement) {\n this.scene.mutateElement(newElement, {\n points: [...newElement.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x - newElement.x, pointerCoords.y - newElement.y)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n multiElement: newElement,\n newElement\n });\n } else if (pointerDownState.drag.hasOccurred && !multiElement) {\n if ((0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBindingElement)(newElement, false)) {\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.maybeBindLinearElement)(newElement, this.state, pointerCoords, this.scene);\n }\n\n this.setState({\n suggestedBindings: [],\n startBoundElement: null\n });\n\n if (!activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n }),\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap())\n }));\n } else {\n this.setState(prevState => ({\n newElement: null\n }));\n } // so that the scene gets rendered again to display the newly drawn linear as well\n\n\n this.scene.triggerUpdate();\n }\n\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isTextElement)(newElement)) {\n const minWidth = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_28__.getMinTextElementWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.getFontString)({\n fontSize: newElement.fontSize,\n fontFamily: newElement.fontFamily\n }), newElement.lineHeight);\n\n if (newElement.width < minWidth) {\n this.scene.mutateElement(newElement, {\n autoResize: true\n });\n }\n\n this.resetCursor();\n this.handleTextWysiwyg(newElement, {\n isExistingElement: true\n });\n }\n\n if (activeTool.type !== \"selection\" && newElement && (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isInvisiblySmallElement)(newElement)) {\n // remove invisible element which was added in onPointerDown\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== newElement.id),\n appState: {\n newElement: null\n },\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n });\n return;\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(newElement)) {\n const elementsInsideFrame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInNewFrame)(this.scene.getElementsIncludingDeleted(), newElement, this.scene.getNonDeletedElementsMap());\n this.scene.replaceAllElements((0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.addElementsToFrame)(this.scene.getElementsMapIncludingDeleted(), elementsInsideFrame, newElement, this.state));\n }\n\n if (newElement) {\n this.scene.mutateElement(newElement, (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.getNormalizedDimensions)(newElement), {\n informMutation: false,\n isDragging: false\n }); // the above does not guarantee the scene to be rendered again, hence the trigger below\n\n this.scene.triggerUpdate();\n }\n\n if (pointerDownState.drag.hasOccurred) {\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)(childEvent, this.state); // when editing the points of a linear element, we check if the\n // linear element still is in the frame afterwards\n // if not, the linear element will be removed from its frame (if any)\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.isDragging) {\n const linearElement = this.scene.getElement(this.state.selectedLinearElement.elementId);\n\n if (linearElement === null || linearElement === void 0 ? void 0 : linearElement.frameId) {\n const frame = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getContainingFrame)(linearElement, elementsMap);\n\n if (frame && linearElement) {\n if (!(0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.elementOverlapsWithFrame)(linearElement, frame, this.scene.getNonDeletedElementsMap())) {\n // remove the linear element from all groups\n // before removing it from the frame as well\n this.scene.mutateElement(linearElement, {\n groupIds: []\n });\n (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.removeElementsFromFrame)([linearElement], this.scene.getNonDeletedElementsMap());\n this.scene.triggerUpdate();\n }\n }\n }\n } else {\n // update the relationships between selected elements and frames\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(sceneCoords);\n const selectedElements = this.scene.getSelectedElements(this.state);\n let nextElements = this.scene.getElementsMapIncludingDeleted();\n\n const updateGroupIdsAfterEditingGroup = elements => {\n if (elements.length > 0) {\n for (const element of elements) {\n const index = element.groupIds.indexOf(this.state.editingGroupId);\n this.scene.mutateElement(element, {\n groupIds: element.groupIds.slice(0, index)\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n nextElements.forEach(element => {\n if (element.groupIds.length && (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(nextElements, element.groupIds[element.groupIds.length - 1]).length < 2) {\n this.scene.mutateElement(element, {\n groupIds: []\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n });\n this.setState({\n editingGroupId: null\n });\n }\n };\n\n if (topLayerFrame && !this.state.selectedElementIds[topLayerFrame.id]) {\n const elementsToAdd = selectedElements.filter(element => element.frameId !== topLayerFrame.id && (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isElementInFrame)(element, nextElements, this.state));\n\n if (this.state.editingGroupId) {\n updateGroupIdsAfterEditingGroup(elementsToAdd);\n }\n\n nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.addElementsToFrame)(nextElements, elementsToAdd, topLayerFrame, this.state);\n } else if (!topLayerFrame) {\n if (this.state.editingGroupId) {\n const elementsToRemove = selectedElements.filter(element => element.frameId && !(0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.isElementInFrame)(element, nextElements, this.state));\n updateGroupIdsAfterEditingGroup(elementsToRemove);\n }\n }\n\n nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.updateFrameMembershipOfSelectedElements)(nextElements, this.state, this);\n this.scene.replaceAllElements(nextElements);\n }\n }\n\n if (resizingElement) {\n this.store.shouldCaptureIncrement();\n }\n\n if (resizingElement && (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_16__.isInvisiblySmallElement)(resizingElement)) {\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== resizingElement.id),\n captureUpdate: _store__WEBPACK_IMPORTED_MODULE_76__.CaptureUpdateAction.NEVER\n });\n } // handle frame membership for resizing frames and/or selected elements\n\n\n if (pointerDownState.resize.isResizing) {\n let nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.updateFrameMembershipOfSelectedElements)(this.scene.getElementsIncludingDeleted(), this.state, this);\n const selectedFrames = this.scene.getSelectedElements(this.state).filter(element => (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(element));\n\n for (const frame of selectedFrames) {\n nextElements = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.replaceAllElementsInFrame)(nextElements, (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_22__.getElementsInResizingFrame)(this.scene.getElementsIncludingDeleted(), frame, this.state, elementsMap), frame, this);\n }\n\n this.scene.replaceAllElements(nextElements);\n } // Code below handles selection when element(s) weren't\n // drag or added to selection on pointer down phase.\n\n\n const hitElement = pointerDownState.hit.element;\n\n if (((_k = this.state.selectedLinearElement) === null || _k === void 0 ? void 0 : _k.elementId) !== (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(hitElement)) {\n const selectedElements = this.scene.getSelectedElements(this.state); // set selectedLinearElement when no other element selected except\n // the one we've hit\n\n if (selectedElements.length === 1) {\n this.setState({\n selectedLinearElement: new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap())\n });\n }\n } // click outside the cropping region to exit\n\n\n if ( // not in the cropping mode at all\n !croppingElementId || // in the cropping mode\n croppingElementId && ( // not cropping and no hit element\n !hitElement && !isCropping || // hitting something else\n hitElement && hitElement.id !== croppingElementId)) {\n this.finishImageCropping();\n }\n\n const pointerStart = this.lastPointerDownEvent;\n const pointerEnd = this.lastPointerUpEvent || this.lastPointerMoveEvent;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_54__.isEraserActive)(this.state) && pointerStart && pointerEnd) {\n this.eraserTrail.endPath();\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerStart.clientX, pointerStart.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerEnd.clientX, pointerEnd.clientY));\n\n if (draggedDistance === 0) {\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.viewportCoordsToSceneCoords)({\n clientX: pointerEnd.clientX,\n clientY: pointerEnd.clientY\n }, this.state);\n const hitElements = this.getElementsAtPosition(scenePointer.x, scenePointer.y);\n hitElements.forEach(hitElement => this.elementsPendingErasure.add(hitElement.id));\n }\n\n this.eraseElements();\n return;\n } else if (this.elementsPendingErasure.size) {\n this.restoreReadyToEraseElements();\n }\n\n if (hitElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && ( // if we're editing a line, pointerup shouldn't switch selection if\n // box selected\n !this.state.editingLinearElement || !pointerDownState.boxSelection.hasOccurred)) {\n // when inside line editor, shift selects points instead\n if (childEvent.shiftKey && !this.state.editingLinearElement) {\n if (this.state.selectedElementIds[hitElement.id]) {\n if ((0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.isSelectedViaGroup)(this.state, hitElement)) {\n this.setState(_prevState => {\n const nextSelectedElementIds = Object.assign({}, _prevState.selectedElementIds); // We want to unselect all groups hitElement is part of\n // as well as all elements that are part of the groups\n // hitElement is part of\n\n for (const groupedElement of hitElement.groupIds.flatMap(groupId => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), groupId))) {\n delete nextSelectedElementIds[groupedElement.id];\n }\n\n return {\n selectedGroupIds: Object.assign(Object.assign({}, _prevState.selectedElementIds), hitElement.groupIds.map(gId => ({\n [gId]: false\n })).reduce((prev, acc) => Object.assign(Object.assign({}, prev), acc), {})),\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(nextSelectedElementIds, _prevState)\n };\n }); // if not dragging a linear element point (outside editor)\n } else if (!((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.isDragging)) {\n // remove element from selection while\n // keeping prev elements selected\n this.setState(prevState => {\n const newSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete newSelectedElementIds[hitElement.id];\n const newSelectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_62__.getSelectedElements)(this.scene.getNonDeletedElements(), {\n selectedElementIds: newSelectedElementIds\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: newSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // set selectedLinearElement only if thats the only element selected\n selectedLinearElement: newSelectedElements.length === 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(newSelectedElements[0]) ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(newSelectedElements[0], this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n } else if (hitElement.frameId && this.state.selectedElementIds[hitElement.frameId]) {\n // when hitElement is part of a selected frame, deselect the frame\n // to avoid frame and containing elements selected simultaneously\n this.setState(prevState => {\n var _a, _b;\n\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n }); // deselect the frame\n\n delete nextSelectedElementIds[hitElement.frameId]; // deselect groups containing the frame\n\n ((_b = (_a = this.scene.getElement(hitElement.frameId)) === null || _a === void 0 ? void 0 : _a.groupIds) !== null && _b !== void 0 ? _b : []).flatMap(gid => (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n } else {\n // add element to selection while keeping prev elements selected\n this.setState(_prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, _prevState.selectedElementIds), {\n [hitElement.id]: true\n }), _prevState)\n }));\n }\n } else {\n this.setState(prevState => {\n var _a;\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n selectedLinearElement: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement)(hitElement) && // Don't set `selectedLinearElement` if its same as the hitElement, this is mainly to prevent resetting the `hoverPointIndex` to -1.\n // Future we should update the API to take care of setting the correct `hoverPointIndex` when initialized\n ((_a = prevState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId) !== hitElement.id ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_11__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n }\n\n if ( // do not clear selection if lasso is active\n this.state.activeTool.type !== \"lasso\" && // not elbow midpoint dragged\n !(hitElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isElbowArrow)(hitElement)) && // not dragged\n !pointerDownState.drag.hasOccurred && // not resized\n !this.state.isResizing && ( // only hitting the bounding box of the previous hit element\n hitElement && (0,_excalidraw_element_collision__WEBPACK_IMPORTED_MODULE_23__.hitElementBoundingBoxOnly)({\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y,\n element: hitElement,\n shape: (0,_excalidraw_element_shapes__WEBPACK_IMPORTED_MODULE_17__.getElementShape)(hitElement, this.scene.getNonDeletedElementsMap()),\n threshold: this.getElementHitThreshold(),\n frameNameBound: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isFrameLikeElement)(hitElement) ? this.frameNameBoundsCache.get(hitElement) : null\n }, elementsMap) || !hitElement && pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements)) {\n if (this.state.editingLinearElement) {\n this.setState({\n editingLinearElement: null\n });\n } else {\n // Deselect selected elements\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // reset cursor\n\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.CURSOR_TYPE.AUTO);\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && newElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n showHyperlinkPopup: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isEmbeddableElement)(newElement) && !newElement.link ? \"editor\" : prevState.showHyperlinkPopup\n }));\n }\n\n if (activeTool.type !== \"selection\" || (0,_scene__WEBPACK_IMPORTED_MODULE_62__.isSomeElementSelected)(this.scene.getNonDeletedElements(), this.state) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.isShallowEqual)(this.state.previousSelectedElementIds, this.state.selectedElementIds)) {\n this.store.shouldCaptureIncrement();\n }\n\n if (pointerDownState.drag.hasOccurred || isResizing || isRotating || isCropping) {\n // We only allow binding via linear elements, specifically via dragging\n // the endpoints (\"start\" or \"end\").\n const linearElements = this.scene.getSelectedElements(this.state).filter(_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isLinearElement);\n (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.bindOrUnbindLinearElements)(linearElements, (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_10__.isBindingEnabled)(this.state), (_o = (_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.selectedPointsIndices) !== null && _o !== void 0 ? _o : [], this.scene, this.state.zoom);\n }\n\n if (activeTool.type === \"laser\") {\n this.laserTrails.endPath();\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && (activeTool.type !== \"lasso\" || // if lasso is turned on but from selection => reset to selection\n activeTool.type === \"lasso\" && activeTool.fromSelection)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_73__.resetCursor)(this.interactiveCanvas);\n this.setState({\n newElement: null,\n suggestedBindings: [],\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n } else {\n this.setState({\n newElement: null,\n suggestedBindings: []\n });\n }\n\n if (hitElement && this.lastPointerUpEvent && this.lastPointerDownEvent && this.lastPointerUpEvent.timeStamp - this.lastPointerDownEvent.timeStamp < 300 && gesture.pointers.size <= 1 && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, this.lastPointerUpEvent, pointerDownState.origin.x, pointerDownState.origin.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n }\n });\n } //zsviczian - published on API\n\n\n setSelection(elements) {\n const selectedElementIds = {};\n const selectedGroupIds = {};\n elements.forEach(ele => {\n if (ele.groupIds.length) {\n selectedElementIds[ele.id] = true;\n ele.groupIds.forEach(id => {\n selectedGroupIds[id] = true;\n });\n } // exclude bound text elements as we don't mark them as selected when\n // container is selected unless in group\n else if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_15__.isBoundToContainer)(ele)) {\n selectedElementIds[ele.id] = true;\n }\n });\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds,\n selectedElementIds,\n selectedGroupIds\n });\n }\n\n clearSelection(hitElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, prevState),\n activeEmbeddable: null,\n selectedGroupIds: {},\n // Continue editing the same group if the user selected a different\n // element from it\n editingGroupId: prevState.editingGroupId && hitElement != null && (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_31__.isElementInGroup)(hitElement, prevState.editingGroupId) ? prevState.editingGroupId : null\n }));\n this.setState({\n selectedElementIds: (0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_33__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null,\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n\n getTextWysiwygSnappedToCenterPosition(x, y, appState, container) {\n if (container) {\n let elementCenterX = container.x + container.width / 2;\n let elementCenterY = container.y + container.height / 2;\n const elementCenter = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_20__.getContainerCenter)(container, appState, this.scene.getNonDeletedElementsMap());\n\n if (elementCenter) {\n elementCenterX = elementCenter.x;\n elementCenterY = elementCenter.y;\n }\n\n const distanceToCenter = Math.hypot(x - elementCenterX, y - elementCenterY);\n const isSnappedToCenter = distanceToCenter < _excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.TEXT_TO_CENTER_SNAP_THRESHOLD;\n\n if (isSnappedToCenter) {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_8__.sceneCoordsToViewportCoords)({\n sceneX: elementCenterX,\n sceneY: elementCenterY\n }, appState);\n return {\n viewportX,\n viewportY,\n elementCenterX,\n elementCenterY\n };\n }\n }\n }\n\n getCanvasOffsets() {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n left,\n top\n } = excalidrawContainer.getBoundingClientRect();\n return {\n offsetLeft: left,\n offsetTop: top\n };\n }\n\n return {\n offsetLeft: 0,\n offsetTop: 0\n };\n }\n\n async updateLanguage() {\n const currentLang = _i18n__WEBPACK_IMPORTED_MODULE_61__.languages.find(lang => lang.code === this.props.langCode) || _i18n__WEBPACK_IMPORTED_MODULE_61__.defaultLang;\n await (0,_i18n__WEBPACK_IMPORTED_MODULE_61__.setLanguage)(currentLang);\n this.setAppState({});\n }\n\n} // -----------------------------------------------------------------------------\n// TEST HOOKS\n// -----------------------------------------------------------------------------\n\n/* //zsviczian - I get a type error on h, but anyway I don't need this test hook\r\ndeclare global {\r\n interface Window {\r\n h: {\r\n scene: Scene;\r\n elements: readonly ExcalidrawElement[];\r\n state: AppState;\r\n setState: React.Component<any, AppState>[\"setState\"];\r\n app: InstanceType<typeof App>;\r\n history: History;\r\n store: Store;\r\n };\r\n }\r\n}\r\n\r\nexport const createTestHook = () => {\r\n if (isTestEnv() || isDevEnv()) {\r\n window.h = window.h || ({} as Window[\"h\"]);\r\n\r\n Object.defineProperties(window.h, {\r\n elements: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene.getElementsIncludingDeleted();\r\n },\r\n set(elements: ExcalidrawElement[]) {\r\n return this.app?.scene.replaceAllElements(\r\n syncInvalidIndices(elements),\r\n );\r\n },\r\n },\r\n scene: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene;\r\n },\r\n },\r\n });\r\n }\r\n};\r\n\r\ncreateTestHook();\r\n*/\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/App.tsx?");
|
|
14261
14272
|
|
|
14262
14273
|
/***/ }),
|
|
14263
14274
|
|
|
@@ -14554,7 +14565,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
|
|
|
14554
14565
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14555
14566
|
|
|
14556
14567
|
"use strict";
|
|
14557
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CommandPalette: () => (/* binding */ CommandPalette),\n/* harmony export */ DEFAULT_CATEGORIES: () => (/* binding */ DEFAULT_CATEGORIES)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var fuzzy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fuzzy */ \"../../node_modules/fuzzy/lib/fuzzy.js\");\n/* harmony import */ var fuzzy__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fuzzy__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../analytics */ \"./analytics.ts\");\n/* harmony import */ var _context_ui_appState__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../context/ui-appState */ \"./context/ui-appState.ts\");\n/* harmony import */ var _deburr__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../deburr */ \"./deburr.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../i18n */ \"./i18n.ts\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../App */ \"./components/App.tsx\");\n/* harmony import */ var _Dialog__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Dialog */ \"./components/Dialog.tsx\");\n/* harmony import */ var _InlineIcon__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../InlineIcon */ \"./components/InlineIcon.tsx\");\n/* harmony import */ var _TextField__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../TextField */ \"./components/TextField.tsx\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../scene */ \"./scene/index.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _Actions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Actions */ \"./components/Actions.tsx\");\n/* harmony import */ var _hooks_useStableCallback__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../hooks/useStableCallback */ \"./hooks/useStableCallback.ts\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _hooks_useStable__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../hooks/useStable */ \"./hooks/useStable.ts\");\n/* harmony import */ var _defaultCommandPaletteItems__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./defaultCommandPaletteItems */ \"./components/CommandPalette/defaultCommandPaletteItems.ts\");\n/* harmony import */ var _CommandPalette_scss__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./CommandPalette.scss */ \"./components/CommandPalette/CommandPalette.scss\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst lastUsedPaletteItem = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_10__.atom)(null);\nconst DEFAULT_CATEGORIES = {\n app: \"App\",\n export: \"Export\",\n tools: \"Tools\",\n editor: \"Editor\",\n elements: \"Elements\",\n links: \"Links\"\n};\n\nconst getCategoryOrder = category => {\n switch (category) {\n case DEFAULT_CATEGORIES.app:\n return 1;\n\n case DEFAULT_CATEGORIES.export:\n return 2;\n\n case DEFAULT_CATEGORIES.editor:\n return 3;\n\n case DEFAULT_CATEGORIES.tools:\n return 4;\n\n case DEFAULT_CATEGORIES.elements:\n return 5;\n\n case DEFAULT_CATEGORIES.links:\n return 6;\n\n default:\n return 10;\n }\n};\n\nconst CommandShortcutHint = ({\n shortcut,\n className,\n children\n}) => {\n const shortcuts = shortcut.replace(\"++\", \"+$\").split(\"+\");\n return React.createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"shortcut\", className)\n }, shortcuts.map((item, idx) => {\n return React.createElement(\"div\", {\n className: \"shortcut-wrapper\",\n key: item\n }, React.createElement(\"div\", {\n className: \"shortcut-key\"\n }, item === \"$\" ? \"+\" : item));\n }), React.createElement(\"div\", {\n className: \"shortcut-desc\"\n }, children));\n};\n\nconst isCommandPaletteToggleShortcut = event => {\n return !event.altKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.CTRL_OR_CMD] && (event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.P || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.SLASH);\n};\n\nconst CommandPalette = Object.assign(props => {\n var _a;\n\n const uiAppState = (0,_context_ui_appState__WEBPACK_IMPORTED_MODULE_8__.useUIAppState)();\n const setAppState = (0,_App__WEBPACK_IMPORTED_MODULE_12__.useExcalidrawSetAppState)();\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n const commandPaletteShortcut = event => {\n if (isCommandPaletteToggleShortcut(event)) {\n event.preventDefault();\n event.stopPropagation();\n setAppState(appState => {\n var _a;\n\n const nextState = ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"commandPalette\" ? null : {\n name: \"commandPalette\"\n };\n\n if (nextState) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_7__.trackEvent)(\"command_palette\", \"open\", \"shortcut\");\n }\n\n return {\n openDialog: nextState\n };\n });\n }\n };\n\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, commandPaletteShortcut, {\n capture: true\n });\n return () => window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, commandPaletteShortcut, {\n capture: true\n });\n }, [setAppState]);\n\n if (((_a = uiAppState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"commandPalette\") {\n return null;\n }\n\n return React.createElement(CommandPaletteInner, Object.assign({}, props));\n}, {\n defaultItems: _defaultCommandPaletteItems__WEBPACK_IMPORTED_MODULE_23__\n});\n\nfunction CommandPaletteInner({\n customCommandPaletteItems\n}) {\n const app = (0,_App__WEBPACK_IMPORTED_MODULE_12__.useApp)();\n const uiAppState = (0,_context_ui_appState__WEBPACK_IMPORTED_MODULE_8__.useUIAppState)();\n const setAppState = (0,_App__WEBPACK_IMPORTED_MODULE_12__.useExcalidrawSetAppState)();\n const appProps = (0,_App__WEBPACK_IMPORTED_MODULE_12__.useAppProps)();\n const actionManager = (0,_App__WEBPACK_IMPORTED_MODULE_12__.useExcalidrawActionManager)();\n const [lastUsed, setLastUsed] = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_10__.useAtom)(lastUsedPaletteItem);\n const [allCommands, setAllCommands] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(null);\n const inputRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);\n const stableDeps = (0,_hooks_useStable__WEBPACK_IMPORTED_MODULE_22__.useStable)({\n uiAppState,\n customCommandPaletteItems,\n appProps\n });\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n var _a; // these props change often and we don't want them to re-run the effect\n // which would renew `allCommands`, cascading down and resetting state.\n //\n // This means that the commands won't update on appState/appProps changes\n // while the command palette is open\n\n\n const {\n uiAppState,\n customCommandPaletteItems,\n appProps\n } = stableDeps;\n\n const getActionLabel = action => {\n let label = \"\";\n\n if (action.label) {\n if (typeof action.label === \"function\") {\n label = (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(action.label(app.scene.getNonDeletedElements(), uiAppState, app));\n } else {\n label = (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(action.label);\n }\n }\n\n return label;\n };\n\n const getActionIcon = action => {\n if (typeof action.icon === \"function\") {\n return action.icon(uiAppState, app.scene.getNonDeletedElements());\n }\n\n return action.icon;\n };\n\n let commandsFromActions = [];\n\n const actionToCommand = (action, category, transformer) => {\n const command = {\n label: getActionLabel(action),\n icon: getActionIcon(action),\n category,\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_6__.getShortcutFromShortcutName)(action.name),\n keywords: action.keywords,\n predicate: action.predicate,\n viewMode: action.viewMode,\n perform: () => {\n actionManager.executeAction(action, \"commandPalette\");\n }\n };\n return transformer ? transformer(command, action) : command;\n };\n\n if (uiAppState && app.scene && actionManager) {\n const elementsCommands = [actionManager.actions.group, actionManager.actions.ungroup, actionManager.actions.cut, actionManager.actions.copy, actionManager.actions.deleteSelectedElements, actionManager.actions.wrapSelectionInFrame, actionManager.actions.copyStyles, actionManager.actions.pasteStyles, actionManager.actions.bringToFront, actionManager.actions.bringForward, actionManager.actions.sendBackward, actionManager.actions.sendToBack, actionManager.actions.alignTop, actionManager.actions.alignBottom, actionManager.actions.alignLeft, actionManager.actions.alignRight, actionManager.actions.alignVerticallyCentered, actionManager.actions.alignHorizontallyCentered, actionManager.actions.duplicateSelection, actionManager.actions.flipHorizontal, actionManager.actions.flipVertical, actionManager.actions.zoomToFitSelection, actionManager.actions.zoomToFitSelectionInViewport, actionManager.actions.increaseFontSize, actionManager.actions.decreaseFontSize, actionManager.actions.toggleLinearEditor, actionManager.actions.cropEditor, _actions__WEBPACK_IMPORTED_MODULE_4__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_5__.actionCopyElementLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_5__.actionLinkToElement].map(action => actionToCommand(action, DEFAULT_CATEGORIES.elements, (command, action) => Object.assign(Object.assign({}, command), {\n predicate: action.predicate ? action.predicate : (elements, appState, appProps, app) => {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_16__.getSelectedElements)(elements, appState);\n return selectedElements.length > 0;\n }\n })));\n const toolCommands = [actionManager.actions.toggleHandTool, actionManager.actions.setFrameAsActiveTool, actionManager.actions.toggleLassoTool].map(action => actionToCommand(action, DEFAULT_CATEGORIES.tools));\n const editorCommands = [actionManager.actions.undo, actionManager.actions.redo, actionManager.actions.zoomIn, actionManager.actions.zoomOut, actionManager.actions.resetZoom, actionManager.actions.zoomToFit, actionManager.actions.zenMode, actionManager.actions.viewMode, actionManager.actions.gridMode, actionManager.actions.objectsSnapMode, actionManager.actions.toggleShortcuts, actionManager.actions.selectAll, actionManager.actions.toggleElementLock, actionManager.actions.unlockAllElements, actionManager.actions.stats].map(action => actionToCommand(action, DEFAULT_CATEGORIES.editor));\n const exportCommands = [actionManager.actions.saveToActiveFile, actionManager.actions.saveFileToDisk, actionManager.actions.copyAsPng, actionManager.actions.copyAsSvg].map(action => actionToCommand(action, DEFAULT_CATEGORIES.export));\n commandsFromActions = [...elementsCommands, ...editorCommands, {\n label: getActionLabel(_actions__WEBPACK_IMPORTED_MODULE_4__.actionClearCanvas),\n icon: getActionIcon(_actions__WEBPACK_IMPORTED_MODULE_4__.actionClearCanvas),\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_6__.getShortcutFromShortcutName)(_actions__WEBPACK_IMPORTED_MODULE_4__.actionClearCanvas.name),\n category: DEFAULT_CATEGORIES.editor,\n keywords: [\"delete\", \"destroy\"],\n viewMode: false,\n perform: () => {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_10__.editorJotaiStore.set(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_21__.activeConfirmDialogAtom, \"clearCanvas\");\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"buttons.exportImage\"),\n category: DEFAULT_CATEGORIES.export,\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.ExportImageIcon,\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_6__.getShortcutFromShortcutName)(\"imageExport\"),\n keywords: [\"export\", \"image\", \"png\", \"jpeg\", \"svg\", \"clipboard\", \"picture\"],\n perform: () => {\n setAppState({\n openDialog: {\n name: \"imageExport\"\n }\n });\n }\n }, ...exportCommands];\n const additionalCommands = [{\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"toolBar.library\"),\n category: DEFAULT_CATEGORIES.app,\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.LibraryIcon,\n viewMode: false,\n perform: () => {\n if (uiAppState.openSidebar) {\n setAppState({\n openSidebar: null\n });\n } else {\n setAppState({\n openSidebar: {\n name: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.DEFAULT_SIDEBAR.name,\n tab: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.DEFAULT_SIDEBAR.defaultTab\n }\n });\n }\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"search.title\"),\n category: DEFAULT_CATEGORIES.app,\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.searchIcon,\n viewMode: true,\n perform: () => {\n actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_4__.actionToggleSearchMenu);\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"labels.changeStroke\"),\n keywords: [\"color\", \"outline\"],\n category: DEFAULT_CATEGORIES.elements,\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.bucketFillIcon,\n viewMode: false,\n predicate: (elements, appState) => {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_16__.getSelectedElements)(elements, appState);\n return selectedElements.length > 0 && (0,_Actions__WEBPACK_IMPORTED_MODULE_19__.canChangeStrokeColor)(appState, selectedElements);\n },\n perform: () => {\n setAppState(prevState => ({\n openMenu: prevState.openMenu === \"shape\" ? null : \"shape\",\n openPopup: \"elementStroke\"\n }));\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"labels.changeBackground\"),\n keywords: [\"color\", \"fill\"],\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.bucketFillIcon,\n category: DEFAULT_CATEGORIES.elements,\n viewMode: false,\n predicate: (elements, appState) => {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_16__.getSelectedElements)(elements, appState);\n return selectedElements.length > 0 && (0,_Actions__WEBPACK_IMPORTED_MODULE_19__.canChangeBackgroundColor)(appState, selectedElements);\n },\n perform: () => {\n setAppState(prevState => ({\n openMenu: prevState.openMenu === \"shape\" ? null : \"shape\",\n openPopup: \"elementBackground\"\n }));\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"labels.canvasBackground\"),\n keywords: [\"color\"],\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.bucketFillIcon,\n category: DEFAULT_CATEGORIES.editor,\n viewMode: false,\n perform: () => {\n setAppState(prevState => ({\n openMenu: prevState.openMenu === \"canvas\" ? null : \"canvas\",\n openPopup: \"canvasBackground\"\n }));\n }\n }, ..._shapes__WEBPACK_IMPORTED_MODULE_18__.SHAPES.reduce((acc, shape) => {\n var _a;\n\n const {\n value,\n icon,\n key,\n numericKey\n } = shape;\n\n if (((_a = appProps.UIOptions.tools) === null || _a === void 0 ? void 0 : _a[value]) === false) {\n return acc;\n }\n\n const letter = key && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.capitalizeString)(typeof key === \"string\" ? key : key[0]);\n const shortcut = letter || numericKey;\n const command = {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(`toolBar.${value}`),\n category: DEFAULT_CATEGORIES.tools,\n shortcut,\n icon,\n keywords: [\"toolbar\"],\n viewMode: false,\n perform: ({\n event\n }) => {\n if (value === \"image\") {\n app.setActiveTool({\n type: value,\n insertOnCanvasDirectly: event.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN\n });\n } else {\n app.setActiveTool({\n type: value\n });\n }\n }\n };\n acc.push(command);\n return acc;\n }, []), ...toolCommands, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"toolBar.lock\"),\n category: DEFAULT_CATEGORIES.tools,\n icon: uiAppState.activeTool.locked ? _icons__WEBPACK_IMPORTED_MODULE_17__.LockedIcon : _icons__WEBPACK_IMPORTED_MODULE_17__.UnlockedIcon,\n shortcut: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.Q.toLocaleUpperCase(),\n viewMode: false,\n perform: () => {\n app.toggleLock();\n }\n }, {\n label: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"labels.textToDiagram\")}...`,\n category: DEFAULT_CATEGORIES.tools,\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.brainIconThin,\n viewMode: false,\n predicate: appProps.aiEnabled,\n perform: () => {\n setAppState(state => Object.assign(Object.assign({}, state), {\n openDialog: {\n name: \"ttd\",\n tab: \"text-to-diagram\"\n }\n }));\n }\n }, {\n label: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"toolBar.mermaidToExcalidraw\")}...`,\n category: DEFAULT_CATEGORIES.tools,\n icon: _icons__WEBPACK_IMPORTED_MODULE_17__.mermaidLogoIcon,\n viewMode: false,\n predicate: appProps.aiEnabled,\n perform: () => {\n setAppState(state => Object.assign(Object.assign({}, state), {\n openDialog: {\n name: \"ttd\",\n tab: \"mermaid\"\n }\n }));\n }\n } // {\n // label: `${t(\"toolBar.magicframe\")}...`,\n // category: DEFAULT_CATEGORIES.tools,\n // icon: MagicIconThin,\n // viewMode: false,\n // predicate: appProps.aiEnabled,\n // perform: () => {\n // app.onMagicframeToolSelect();\n // },\n // },\n ];\n const allCommands = [...commandsFromActions, ...additionalCommands, ...(customCommandPaletteItems || [])].map(command => {\n var _a, _b;\n\n return Object.assign(Object.assign({}, command), {\n icon: command.icon || _icons__WEBPACK_IMPORTED_MODULE_17__.boltIcon,\n order: (_a = command.order) !== null && _a !== void 0 ? _a : getCategoryOrder(command.category),\n haystack: `${(0,_deburr__WEBPACK_IMPORTED_MODULE_9__.deburr)(command.label.toLocaleLowerCase())} ${((_b = command.keywords) === null || _b === void 0 ? void 0 : _b.join(\" \")) || \"\"}`\n });\n });\n setAllCommands(allCommands);\n setLastUsed((_a = allCommands.find(command => command.label === (lastUsed === null || lastUsed === void 0 ? void 0 : lastUsed.label))) !== null && _a !== void 0 ? _a : null);\n }\n }, [stableDeps, app, actionManager, setAllCommands, lastUsed === null || lastUsed === void 0 ? void 0 : lastUsed.label, setLastUsed, setAppState]);\n const [commandSearch, setCommandSearch] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(\"\");\n const [currentCommand, setCurrentCommand] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(null);\n const [commandsByCategory, setCommandsByCategory] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)({});\n\n const closeCommandPalette = cb => {\n setAppState({\n openDialog: null\n }, cb);\n setCommandSearch(\"\");\n };\n\n const executeCommand = (command, event) => {\n var _a;\n\n if (((_a = uiAppState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"commandPalette\") {\n event.stopPropagation();\n event.preventDefault();\n document.body.classList.add(\"excalidraw-animations-disabled\");\n closeCommandPalette(() => {\n command.perform({\n actionManager,\n event\n });\n setLastUsed(command);\n requestAnimationFrame(() => {\n document.body.classList.remove(\"excalidraw-animations-disabled\");\n });\n });\n }\n };\n\n const isCommandAvailable = (0,_hooks_useStableCallback__WEBPACK_IMPORTED_MODULE_20__.useStableCallback)(command => {\n if (command.viewMode === false && uiAppState.viewModeEnabled) {\n return false;\n }\n\n return typeof command.predicate === \"function\" ? command.predicate(app.scene.getNonDeletedElements(), uiAppState, appProps, app) : command.predicate === undefined || command.predicate;\n });\n const handleKeyDown = (0,_hooks_useStableCallback__WEBPACK_IMPORTED_MODULE_20__.useStableCallback)(event => {\n var _a;\n\n const ignoreAlphanumerics = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.isWritableElement)(event.target) || isCommandPaletteToggleShortcut(event) || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ESCAPE;\n\n if (ignoreAlphanumerics && event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_UP && event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_DOWN && event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ENTER) {\n return;\n }\n\n const matchingCommands = Object.values(commandsByCategory).flat();\n const shouldConsiderLastUsed = lastUsed && !commandSearch && isCommandAvailable(lastUsed);\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_UP) {\n event.preventDefault();\n const index = matchingCommands.findIndex(item => item.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label));\n\n if (shouldConsiderLastUsed) {\n if (index === 0) {\n setCurrentCommand(lastUsed);\n return;\n }\n\n if (currentCommand === lastUsed) {\n const nextItem = matchingCommands[matchingCommands.length - 1];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n }\n\n let nextIndex;\n\n if (index === -1) {\n nextIndex = matchingCommands.length - 1;\n } else {\n nextIndex = index === 0 ? matchingCommands.length - 1 : (index - 1) % matchingCommands.length;\n }\n\n const nextItem = matchingCommands[nextIndex];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_DOWN) {\n event.preventDefault();\n const index = matchingCommands.findIndex(item => item.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label));\n\n if (shouldConsiderLastUsed) {\n if (!currentCommand || index === matchingCommands.length - 1) {\n setCurrentCommand(lastUsed);\n return;\n }\n\n if (currentCommand === lastUsed) {\n const nextItem = matchingCommands[0];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n }\n\n const nextIndex = (index + 1) % matchingCommands.length;\n const nextItem = matchingCommands[nextIndex];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ENTER) {\n if (currentCommand) {\n setTimeout(() => {\n executeCommand(currentCommand, event);\n });\n }\n }\n\n if (ignoreAlphanumerics) {\n return;\n } // prevent regular editor shortcuts\n\n\n event.stopPropagation(); // if alphanumeric keypress and we're not inside the input, focus it\n\n if (/^[a-zA-Z0-9]$/.test(event.key)) {\n (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n return;\n }\n\n event.preventDefault();\n });\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, handleKeyDown, {\n capture: true\n });\n return () => window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, handleKeyDown, {\n capture: true\n });\n }, [handleKeyDown]);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n var _a;\n\n if (!allCommands) {\n return;\n }\n\n const getNextCommandsByCategory = commands => {\n const nextCommandsByCategory = {};\n\n for (const command of commands) {\n if (nextCommandsByCategory[command.category]) {\n nextCommandsByCategory[command.category].push(command);\n } else {\n nextCommandsByCategory[command.category] = [command];\n }\n }\n\n return nextCommandsByCategory;\n };\n\n let matchingCommands = allCommands.filter(isCommandAvailable).sort((a, b) => a.order - b.order);\n const showLastUsed = !commandSearch && lastUsed && isCommandAvailable(lastUsed);\n\n if (!commandSearch) {\n setCommandsByCategory(getNextCommandsByCategory(showLastUsed ? matchingCommands.filter(command => command.label !== (lastUsed === null || lastUsed === void 0 ? void 0 : lastUsed.label)) : matchingCommands));\n setCurrentCommand(showLastUsed ? lastUsed : matchingCommands[0] || null);\n return;\n }\n\n const _query = (0,_deburr__WEBPACK_IMPORTED_MODULE_9__.deburr)(commandSearch.toLocaleLowerCase().replace(/[<>_| -]/g, \"\"));\n\n matchingCommands = fuzzy__WEBPACK_IMPORTED_MODULE_1___default().filter(_query, matchingCommands, {\n extract: command => command.haystack\n }).sort((a, b) => b.score - a.score).map(item => item.original);\n setCommandsByCategory(getNextCommandsByCategory(matchingCommands));\n setCurrentCommand((_a = matchingCommands[0]) !== null && _a !== void 0 ? _a : null);\n }, [commandSearch, allCommands, isCommandAvailable, lastUsed]);\n return React.createElement(_Dialog__WEBPACK_IMPORTED_MODULE_13__.Dialog, {\n onCloseRequest: () => closeCommandPalette(),\n closeOnClickOutside: true,\n title: false,\n size: 720,\n autofocus: true,\n className: \"command-palette-dialog\"\n }, React.createElement(_TextField__WEBPACK_IMPORTED_MODULE_15__.TextField, {\n value: commandSearch,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.search.placeholder\"),\n onChange: value => {\n setCommandSearch(value);\n },\n selectOnRender: true,\n ref: inputRef\n }), !app.device.viewport.isMobile && React.createElement(\"div\", {\n className: \"shortcuts-wrapper\"\n }, React.createElement(CommandShortcutHint, {\n shortcut: \"\\u2191\\u2193\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.shortcuts.select\")), React.createElement(CommandShortcutHint, {\n shortcut: \"\\u21B5\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.shortcuts.confirm\")), React.createElement(CommandShortcutHint, {\n shortcut: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.getShortcutKey)(\"Esc\")\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.shortcuts.close\"))), React.createElement(\"div\", {\n className: \"commands\"\n }, lastUsed && !commandSearch && React.createElement(\"div\", {\n className: \"command-category\"\n }, React.createElement(\"div\", {\n className: \"command-category-title\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.recents\"), React.createElement(\"div\", {\n className: \"icon\",\n style: {\n marginLeft: \"6px\"\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_17__.clockIcon)), React.createElement(CommandItem, {\n command: lastUsed,\n isSelected: lastUsed.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label),\n onClick: event => executeCommand(lastUsed, event),\n disabled: !isCommandAvailable(lastUsed),\n onMouseMove: () => setCurrentCommand(lastUsed),\n showShortcut: !app.device.viewport.isMobile,\n appState: uiAppState\n })), Object.keys(commandsByCategory).length > 0 ? Object.keys(commandsByCategory).map((category, idx) => {\n return React.createElement(\"div\", {\n className: \"command-category\",\n key: category\n }, React.createElement(\"div\", {\n className: \"command-category-title\"\n }, category), commandsByCategory[category].map(command => React.createElement(CommandItem, {\n key: command.label,\n command: command,\n isSelected: command.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label),\n onClick: event => executeCommand(command, event),\n onMouseMove: () => setCurrentCommand(command),\n showShortcut: !app.device.viewport.isMobile,\n appState: uiAppState\n })));\n }) : allCommands ? React.createElement(\"div\", {\n className: \"no-match\"\n }, React.createElement(\"div\", {\n className: \"icon\"\n }, _icons__WEBPACK_IMPORTED_MODULE_17__.searchIcon), \" \", (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.search.noMatch\")) : null));\n}\n\nconst CommandItem = ({\n command,\n isSelected,\n disabled,\n onMouseMove,\n onClick,\n showShortcut,\n appState\n}) => {\n const noop = () => {};\n\n return React.createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"command-item\", {\n \"item-selected\": isSelected,\n \"item-disabled\": disabled\n }),\n ref: ref => {\n var _a;\n\n if (isSelected && !disabled) {\n (_a = ref === null || ref === void 0 ? void 0 : ref.scrollIntoView) === null || _a === void 0 ? void 0 : _a.call(ref, {\n block: \"nearest\"\n });\n }\n },\n onClick: disabled ? noop : onClick,\n onMouseMove: disabled ? noop : onMouseMove,\n title: disabled ? (0,_i18n__WEBPACK_IMPORTED_MODULE_11__.t)(\"commandPalette.itemNotAvailable\") : \"\"\n }, React.createElement(\"div\", {\n className: \"name\"\n }, command.icon && React.createElement(_InlineIcon__WEBPACK_IMPORTED_MODULE_14__.InlineIcon, {\n icon: typeof command.icon === \"function\" ? command.icon(appState) : command.icon\n }), command.label), showShortcut && command.shortcut && React.createElement(CommandShortcutHint, {\n shortcut: command.shortcut\n }));\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/CommandPalette/CommandPalette.tsx?");
|
|
14568
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CommandPalette: () => (/* binding */ CommandPalette),\n/* harmony export */ DEFAULT_CATEGORIES: () => (/* binding */ DEFAULT_CATEGORIES)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var fuzzy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fuzzy */ \"../../node_modules/fuzzy/lib/fuzzy.js\");\n/* harmony import */ var fuzzy__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fuzzy__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_excalidraw_actions_actionToggleShapeSwitch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/excalidraw/actions/actionToggleShapeSwitch */ \"./actions/actionToggleShapeSwitch.tsx\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../analytics */ \"./analytics.ts\");\n/* harmony import */ var _context_ui_appState__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../context/ui-appState */ \"./context/ui-appState.ts\");\n/* harmony import */ var _deburr__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../deburr */ \"./deburr.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../i18n */ \"./i18n.ts\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../App */ \"./components/App.tsx\");\n/* harmony import */ var _Dialog__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Dialog */ \"./components/Dialog.tsx\");\n/* harmony import */ var _InlineIcon__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../InlineIcon */ \"./components/InlineIcon.tsx\");\n/* harmony import */ var _TextField__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../TextField */ \"./components/TextField.tsx\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../scene */ \"./scene/index.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _Actions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Actions */ \"./components/Actions.tsx\");\n/* harmony import */ var _hooks_useStableCallback__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../hooks/useStableCallback */ \"./hooks/useStableCallback.ts\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _hooks_useStable__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../hooks/useStable */ \"./hooks/useStable.ts\");\n/* harmony import */ var _defaultCommandPaletteItems__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./defaultCommandPaletteItems */ \"./components/CommandPalette/defaultCommandPaletteItems.ts\");\n/* harmony import */ var _CommandPalette_scss__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./CommandPalette.scss */ \"./components/CommandPalette/CommandPalette.scss\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst lastUsedPaletteItem = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_11__.atom)(null);\nconst DEFAULT_CATEGORIES = {\n app: \"App\",\n export: \"Export\",\n tools: \"Tools\",\n editor: \"Editor\",\n elements: \"Elements\",\n links: \"Links\"\n};\n\nconst getCategoryOrder = category => {\n switch (category) {\n case DEFAULT_CATEGORIES.app:\n return 1;\n\n case DEFAULT_CATEGORIES.export:\n return 2;\n\n case DEFAULT_CATEGORIES.editor:\n return 3;\n\n case DEFAULT_CATEGORIES.tools:\n return 4;\n\n case DEFAULT_CATEGORIES.elements:\n return 5;\n\n case DEFAULT_CATEGORIES.links:\n return 6;\n\n default:\n return 10;\n }\n};\n\nconst CommandShortcutHint = ({\n shortcut,\n className,\n children\n}) => {\n const shortcuts = shortcut.replace(\"++\", \"+$\").split(\"+\");\n return React.createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"shortcut\", className)\n }, shortcuts.map((item, idx) => {\n return React.createElement(\"div\", {\n className: \"shortcut-wrapper\",\n key: item\n }, React.createElement(\"div\", {\n className: \"shortcut-key\"\n }, item === \"$\" ? \"+\" : item));\n }), React.createElement(\"div\", {\n className: \"shortcut-desc\"\n }, children));\n};\n\nconst isCommandPaletteToggleShortcut = event => {\n return !event.altKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.CTRL_OR_CMD] && (event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.P || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.SLASH);\n};\n\nconst CommandPalette = Object.assign(props => {\n var _a;\n\n const uiAppState = (0,_context_ui_appState__WEBPACK_IMPORTED_MODULE_9__.useUIAppState)();\n const setAppState = (0,_App__WEBPACK_IMPORTED_MODULE_13__.useExcalidrawSetAppState)();\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n const commandPaletteShortcut = event => {\n if (isCommandPaletteToggleShortcut(event)) {\n event.preventDefault();\n event.stopPropagation();\n setAppState(appState => {\n var _a;\n\n const nextState = ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"commandPalette\" ? null : {\n name: \"commandPalette\"\n };\n\n if (nextState) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_8__.trackEvent)(\"command_palette\", \"open\", \"shortcut\");\n }\n\n return {\n openDialog: nextState\n };\n });\n }\n };\n\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, commandPaletteShortcut, {\n capture: true\n });\n return () => window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, commandPaletteShortcut, {\n capture: true\n });\n }, [setAppState]);\n\n if (((_a = uiAppState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"commandPalette\") {\n return null;\n }\n\n return React.createElement(CommandPaletteInner, Object.assign({}, props));\n}, {\n defaultItems: _defaultCommandPaletteItems__WEBPACK_IMPORTED_MODULE_24__\n});\n\nfunction CommandPaletteInner({\n customCommandPaletteItems\n}) {\n const app = (0,_App__WEBPACK_IMPORTED_MODULE_13__.useApp)();\n const uiAppState = (0,_context_ui_appState__WEBPACK_IMPORTED_MODULE_9__.useUIAppState)();\n const setAppState = (0,_App__WEBPACK_IMPORTED_MODULE_13__.useExcalidrawSetAppState)();\n const appProps = (0,_App__WEBPACK_IMPORTED_MODULE_13__.useAppProps)();\n const actionManager = (0,_App__WEBPACK_IMPORTED_MODULE_13__.useExcalidrawActionManager)();\n const [lastUsed, setLastUsed] = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_11__.useAtom)(lastUsedPaletteItem);\n const [allCommands, setAllCommands] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(null);\n const inputRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);\n const stableDeps = (0,_hooks_useStable__WEBPACK_IMPORTED_MODULE_23__.useStable)({\n uiAppState,\n customCommandPaletteItems,\n appProps\n });\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n var _a; // these props change often and we don't want them to re-run the effect\n // which would renew `allCommands`, cascading down and resetting state.\n //\n // This means that the commands won't update on appState/appProps changes\n // while the command palette is open\n\n\n const {\n uiAppState,\n customCommandPaletteItems,\n appProps\n } = stableDeps;\n\n const getActionLabel = action => {\n let label = \"\";\n\n if (action.label) {\n if (typeof action.label === \"function\") {\n label = (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(action.label(app.scene.getNonDeletedElements(), uiAppState, app));\n } else {\n label = (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(action.label);\n }\n }\n\n return label;\n };\n\n const getActionIcon = action => {\n if (typeof action.icon === \"function\") {\n return action.icon(uiAppState, app.scene.getNonDeletedElements());\n }\n\n return action.icon;\n };\n\n let commandsFromActions = [];\n\n const actionToCommand = (action, category, transformer) => {\n const command = {\n label: getActionLabel(action),\n icon: getActionIcon(action),\n category,\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_7__.getShortcutFromShortcutName)(action.name),\n keywords: action.keywords,\n predicate: action.predicate,\n viewMode: action.viewMode,\n perform: () => {\n actionManager.executeAction(action, \"commandPalette\");\n }\n };\n return transformer ? transformer(command, action) : command;\n };\n\n if (uiAppState && app.scene && actionManager) {\n const elementsCommands = [actionManager.actions.group, actionManager.actions.ungroup, actionManager.actions.cut, actionManager.actions.copy, actionManager.actions.deleteSelectedElements, actionManager.actions.wrapSelectionInFrame, actionManager.actions.copyStyles, actionManager.actions.pasteStyles, actionManager.actions.bringToFront, actionManager.actions.bringForward, actionManager.actions.sendBackward, actionManager.actions.sendToBack, actionManager.actions.alignTop, actionManager.actions.alignBottom, actionManager.actions.alignLeft, actionManager.actions.alignRight, actionManager.actions.alignVerticallyCentered, actionManager.actions.alignHorizontallyCentered, actionManager.actions.duplicateSelection, actionManager.actions.flipHorizontal, actionManager.actions.flipVertical, actionManager.actions.zoomToFitSelection, actionManager.actions.zoomToFitSelectionInViewport, actionManager.actions.increaseFontSize, actionManager.actions.decreaseFontSize, actionManager.actions.toggleLinearEditor, actionManager.actions.cropEditor, _actions__WEBPACK_IMPORTED_MODULE_5__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_6__.actionCopyElementLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_6__.actionLinkToElement].map(action => actionToCommand(action, DEFAULT_CATEGORIES.elements, (command, action) => Object.assign(Object.assign({}, command), {\n predicate: action.predicate ? action.predicate : (elements, appState, appProps, app) => {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_17__.getSelectedElements)(elements, appState);\n return selectedElements.length > 0;\n }\n })));\n const toolCommands = [actionManager.actions.toggleHandTool, actionManager.actions.setFrameAsActiveTool, actionManager.actions.toggleLassoTool].map(action => actionToCommand(action, DEFAULT_CATEGORIES.tools));\n const editorCommands = [actionManager.actions.undo, actionManager.actions.redo, actionManager.actions.zoomIn, actionManager.actions.zoomOut, actionManager.actions.resetZoom, actionManager.actions.zoomToFit, actionManager.actions.zenMode, actionManager.actions.viewMode, actionManager.actions.gridMode, actionManager.actions.objectsSnapMode, actionManager.actions.toggleShortcuts, actionManager.actions.selectAll, actionManager.actions.toggleElementLock, actionManager.actions.unlockAllElements, actionManager.actions.stats].map(action => actionToCommand(action, DEFAULT_CATEGORIES.editor));\n const exportCommands = [actionManager.actions.saveToActiveFile, actionManager.actions.saveFileToDisk, actionManager.actions.copyAsPng, actionManager.actions.copyAsSvg].map(action => actionToCommand(action, DEFAULT_CATEGORIES.export));\n commandsFromActions = [...elementsCommands, ...editorCommands, {\n label: getActionLabel(_actions__WEBPACK_IMPORTED_MODULE_5__.actionClearCanvas),\n icon: getActionIcon(_actions__WEBPACK_IMPORTED_MODULE_5__.actionClearCanvas),\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_7__.getShortcutFromShortcutName)(_actions__WEBPACK_IMPORTED_MODULE_5__.actionClearCanvas.name),\n category: DEFAULT_CATEGORIES.editor,\n keywords: [\"delete\", \"destroy\"],\n viewMode: false,\n perform: () => {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_11__.editorJotaiStore.set(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_22__.activeConfirmDialogAtom, \"clearCanvas\");\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"buttons.exportImage\"),\n category: DEFAULT_CATEGORIES.export,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.ExportImageIcon,\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_7__.getShortcutFromShortcutName)(\"imageExport\"),\n keywords: [\"export\", \"image\", \"png\", \"jpeg\", \"svg\", \"clipboard\", \"picture\"],\n perform: () => {\n setAppState({\n openDialog: {\n name: \"imageExport\"\n }\n });\n }\n }, ...exportCommands];\n const additionalCommands = [{\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"toolBar.library\"),\n category: DEFAULT_CATEGORIES.app,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.LibraryIcon,\n viewMode: false,\n perform: () => {\n if (uiAppState.openSidebar) {\n setAppState({\n openSidebar: null\n });\n } else {\n setAppState({\n openSidebar: {\n name: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.DEFAULT_SIDEBAR.name,\n tab: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.DEFAULT_SIDEBAR.defaultTab\n }\n });\n }\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"search.title\"),\n category: DEFAULT_CATEGORIES.app,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.searchIcon,\n viewMode: true,\n perform: () => {\n actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_5__.actionToggleSearchMenu);\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"labels.shapeSwitch\"),\n category: DEFAULT_CATEGORIES.elements,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.boltIcon,\n perform: () => {\n actionManager.executeAction(_excalidraw_excalidraw_actions_actionToggleShapeSwitch__WEBPACK_IMPORTED_MODULE_4__.actionToggleShapeSwitch);\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"labels.changeStroke\"),\n keywords: [\"color\", \"outline\"],\n category: DEFAULT_CATEGORIES.elements,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.bucketFillIcon,\n viewMode: false,\n predicate: (elements, appState) => {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_17__.getSelectedElements)(elements, appState);\n return selectedElements.length > 0 && (0,_Actions__WEBPACK_IMPORTED_MODULE_20__.canChangeStrokeColor)(appState, selectedElements);\n },\n perform: () => {\n setAppState(prevState => ({\n openMenu: prevState.openMenu === \"shape\" ? null : \"shape\",\n openPopup: \"elementStroke\"\n }));\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"labels.changeBackground\"),\n keywords: [\"color\", \"fill\"],\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.bucketFillIcon,\n category: DEFAULT_CATEGORIES.elements,\n viewMode: false,\n predicate: (elements, appState) => {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_17__.getSelectedElements)(elements, appState);\n return selectedElements.length > 0 && (0,_Actions__WEBPACK_IMPORTED_MODULE_20__.canChangeBackgroundColor)(appState, selectedElements);\n },\n perform: () => {\n setAppState(prevState => ({\n openMenu: prevState.openMenu === \"shape\" ? null : \"shape\",\n openPopup: \"elementBackground\"\n }));\n }\n }, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"labels.canvasBackground\"),\n keywords: [\"color\"],\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.bucketFillIcon,\n category: DEFAULT_CATEGORIES.editor,\n viewMode: false,\n perform: () => {\n setAppState(prevState => ({\n openMenu: prevState.openMenu === \"canvas\" ? null : \"canvas\",\n openPopup: \"canvasBackground\"\n }));\n }\n }, ..._shapes__WEBPACK_IMPORTED_MODULE_19__.SHAPES.reduce((acc, shape) => {\n var _a;\n\n const {\n value,\n icon,\n key,\n numericKey\n } = shape;\n\n if (((_a = appProps.UIOptions.tools) === null || _a === void 0 ? void 0 : _a[value]) === false) {\n return acc;\n }\n\n const letter = key && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.capitalizeString)(typeof key === \"string\" ? key : key[0]);\n const shortcut = letter || numericKey;\n const command = {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(`toolBar.${value}`),\n category: DEFAULT_CATEGORIES.tools,\n shortcut,\n icon,\n keywords: [\"toolbar\"],\n viewMode: false,\n perform: ({\n event\n }) => {\n if (value === \"image\") {\n app.setActiveTool({\n type: value,\n insertOnCanvasDirectly: event.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN\n });\n } else {\n app.setActiveTool({\n type: value\n });\n }\n }\n };\n acc.push(command);\n return acc;\n }, []), ...toolCommands, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"toolBar.lock\"),\n category: DEFAULT_CATEGORIES.tools,\n icon: uiAppState.activeTool.locked ? _icons__WEBPACK_IMPORTED_MODULE_18__.LockedIcon : _icons__WEBPACK_IMPORTED_MODULE_18__.UnlockedIcon,\n shortcut: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.Q.toLocaleUpperCase(),\n viewMode: false,\n perform: () => {\n app.toggleLock();\n }\n }, {\n label: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"labels.textToDiagram\")}...`,\n category: DEFAULT_CATEGORIES.tools,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.brainIconThin,\n viewMode: false,\n predicate: appProps.aiEnabled,\n perform: () => {\n setAppState(state => Object.assign(Object.assign({}, state), {\n openDialog: {\n name: \"ttd\",\n tab: \"text-to-diagram\"\n }\n }));\n }\n }, {\n label: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"toolBar.mermaidToExcalidraw\")}...`,\n category: DEFAULT_CATEGORIES.tools,\n icon: _icons__WEBPACK_IMPORTED_MODULE_18__.mermaidLogoIcon,\n viewMode: false,\n predicate: appProps.aiEnabled,\n perform: () => {\n setAppState(state => Object.assign(Object.assign({}, state), {\n openDialog: {\n name: \"ttd\",\n tab: \"mermaid\"\n }\n }));\n }\n } // {\n // label: `${t(\"toolBar.magicframe\")}...`,\n // category: DEFAULT_CATEGORIES.tools,\n // icon: MagicIconThin,\n // viewMode: false,\n // predicate: appProps.aiEnabled,\n // perform: () => {\n // app.onMagicframeToolSelect();\n // },\n // },\n ];\n const allCommands = [...commandsFromActions, ...additionalCommands, ...(customCommandPaletteItems || [])].map(command => {\n var _a, _b;\n\n return Object.assign(Object.assign({}, command), {\n icon: command.icon || _icons__WEBPACK_IMPORTED_MODULE_18__.boltIcon,\n order: (_a = command.order) !== null && _a !== void 0 ? _a : getCategoryOrder(command.category),\n haystack: `${(0,_deburr__WEBPACK_IMPORTED_MODULE_10__.deburr)(command.label.toLocaleLowerCase())} ${((_b = command.keywords) === null || _b === void 0 ? void 0 : _b.join(\" \")) || \"\"}`\n });\n });\n setAllCommands(allCommands);\n setLastUsed((_a = allCommands.find(command => command.label === (lastUsed === null || lastUsed === void 0 ? void 0 : lastUsed.label))) !== null && _a !== void 0 ? _a : null);\n }\n }, [stableDeps, app, actionManager, setAllCommands, lastUsed === null || lastUsed === void 0 ? void 0 : lastUsed.label, setLastUsed, setAppState]);\n const [commandSearch, setCommandSearch] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(\"\");\n const [currentCommand, setCurrentCommand] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(null);\n const [commandsByCategory, setCommandsByCategory] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)({});\n\n const closeCommandPalette = cb => {\n setAppState({\n openDialog: null\n }, cb);\n setCommandSearch(\"\");\n };\n\n const executeCommand = (command, event) => {\n var _a;\n\n if (((_a = uiAppState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"commandPalette\") {\n event.stopPropagation();\n event.preventDefault();\n document.body.classList.add(\"excalidraw-animations-disabled\");\n closeCommandPalette(() => {\n command.perform({\n actionManager,\n event\n });\n setLastUsed(command);\n requestAnimationFrame(() => {\n document.body.classList.remove(\"excalidraw-animations-disabled\");\n });\n });\n }\n };\n\n const isCommandAvailable = (0,_hooks_useStableCallback__WEBPACK_IMPORTED_MODULE_21__.useStableCallback)(command => {\n if (command.viewMode === false && uiAppState.viewModeEnabled) {\n return false;\n }\n\n return typeof command.predicate === \"function\" ? command.predicate(app.scene.getNonDeletedElements(), uiAppState, appProps, app) : command.predicate === undefined || command.predicate;\n });\n const handleKeyDown = (0,_hooks_useStableCallback__WEBPACK_IMPORTED_MODULE_21__.useStableCallback)(event => {\n var _a;\n\n const ignoreAlphanumerics = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.isWritableElement)(event.target) || isCommandPaletteToggleShortcut(event) || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ESCAPE;\n\n if (ignoreAlphanumerics && event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_UP && event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_DOWN && event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ENTER) {\n return;\n }\n\n const matchingCommands = Object.values(commandsByCategory).flat();\n const shouldConsiderLastUsed = lastUsed && !commandSearch && isCommandAvailable(lastUsed);\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_UP) {\n event.preventDefault();\n const index = matchingCommands.findIndex(item => item.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label));\n\n if (shouldConsiderLastUsed) {\n if (index === 0) {\n setCurrentCommand(lastUsed);\n return;\n }\n\n if (currentCommand === lastUsed) {\n const nextItem = matchingCommands[matchingCommands.length - 1];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n }\n\n let nextIndex;\n\n if (index === -1) {\n nextIndex = matchingCommands.length - 1;\n } else {\n nextIndex = index === 0 ? matchingCommands.length - 1 : (index - 1) % matchingCommands.length;\n }\n\n const nextItem = matchingCommands[nextIndex];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ARROW_DOWN) {\n event.preventDefault();\n const index = matchingCommands.findIndex(item => item.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label));\n\n if (shouldConsiderLastUsed) {\n if (!currentCommand || index === matchingCommands.length - 1) {\n setCurrentCommand(lastUsed);\n return;\n }\n\n if (currentCommand === lastUsed) {\n const nextItem = matchingCommands[0];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n }\n\n const nextIndex = (index + 1) % matchingCommands.length;\n const nextItem = matchingCommands[nextIndex];\n\n if (nextItem) {\n setCurrentCommand(nextItem);\n }\n\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.KEYS.ENTER) {\n if (currentCommand) {\n setTimeout(() => {\n executeCommand(currentCommand, event);\n });\n }\n }\n\n if (ignoreAlphanumerics) {\n return;\n } // prevent regular editor shortcuts\n\n\n event.stopPropagation(); // if alphanumeric keypress and we're not inside the input, focus it\n\n if (/^[a-zA-Z0-9]$/.test(event.key)) {\n (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n return;\n }\n\n event.preventDefault();\n });\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, handleKeyDown, {\n capture: true\n });\n return () => window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EVENT.KEYDOWN, handleKeyDown, {\n capture: true\n });\n }, [handleKeyDown]);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n var _a;\n\n if (!allCommands) {\n return;\n }\n\n const getNextCommandsByCategory = commands => {\n const nextCommandsByCategory = {};\n\n for (const command of commands) {\n if (nextCommandsByCategory[command.category]) {\n nextCommandsByCategory[command.category].push(command);\n } else {\n nextCommandsByCategory[command.category] = [command];\n }\n }\n\n return nextCommandsByCategory;\n };\n\n let matchingCommands = allCommands.filter(isCommandAvailable).sort((a, b) => a.order - b.order);\n const showLastUsed = !commandSearch && lastUsed && isCommandAvailable(lastUsed);\n\n if (!commandSearch) {\n setCommandsByCategory(getNextCommandsByCategory(showLastUsed ? matchingCommands.filter(command => command.label !== (lastUsed === null || lastUsed === void 0 ? void 0 : lastUsed.label)) : matchingCommands));\n setCurrentCommand(showLastUsed ? lastUsed : matchingCommands[0] || null);\n return;\n }\n\n const _query = (0,_deburr__WEBPACK_IMPORTED_MODULE_10__.deburr)(commandSearch.toLocaleLowerCase().replace(/[<>_| -]/g, \"\"));\n\n matchingCommands = fuzzy__WEBPACK_IMPORTED_MODULE_1___default().filter(_query, matchingCommands, {\n extract: command => command.haystack\n }).sort((a, b) => b.score - a.score).map(item => item.original);\n setCommandsByCategory(getNextCommandsByCategory(matchingCommands));\n setCurrentCommand((_a = matchingCommands[0]) !== null && _a !== void 0 ? _a : null);\n }, [commandSearch, allCommands, isCommandAvailable, lastUsed]);\n return React.createElement(_Dialog__WEBPACK_IMPORTED_MODULE_14__.Dialog, {\n onCloseRequest: () => closeCommandPalette(),\n closeOnClickOutside: true,\n title: false,\n size: 720,\n autofocus: true,\n className: \"command-palette-dialog\"\n }, React.createElement(_TextField__WEBPACK_IMPORTED_MODULE_16__.TextField, {\n value: commandSearch,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.search.placeholder\"),\n onChange: value => {\n setCommandSearch(value);\n },\n selectOnRender: true,\n ref: inputRef\n }), !app.device.viewport.isMobile && React.createElement(\"div\", {\n className: \"shortcuts-wrapper\"\n }, React.createElement(CommandShortcutHint, {\n shortcut: \"\\u2191\\u2193\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.shortcuts.select\")), React.createElement(CommandShortcutHint, {\n shortcut: \"\\u21B5\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.shortcuts.confirm\")), React.createElement(CommandShortcutHint, {\n shortcut: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.getShortcutKey)(\"Esc\")\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.shortcuts.close\"))), React.createElement(\"div\", {\n className: \"commands\"\n }, lastUsed && !commandSearch && React.createElement(\"div\", {\n className: \"command-category\"\n }, React.createElement(\"div\", {\n className: \"command-category-title\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.recents\"), React.createElement(\"div\", {\n className: \"icon\",\n style: {\n marginLeft: \"6px\"\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_18__.clockIcon)), React.createElement(CommandItem, {\n command: lastUsed,\n isSelected: lastUsed.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label),\n onClick: event => executeCommand(lastUsed, event),\n disabled: !isCommandAvailable(lastUsed),\n onMouseMove: () => setCurrentCommand(lastUsed),\n showShortcut: !app.device.viewport.isMobile,\n appState: uiAppState\n })), Object.keys(commandsByCategory).length > 0 ? Object.keys(commandsByCategory).map((category, idx) => {\n return React.createElement(\"div\", {\n className: \"command-category\",\n key: category\n }, React.createElement(\"div\", {\n className: \"command-category-title\"\n }, category), commandsByCategory[category].map(command => React.createElement(CommandItem, {\n key: command.label,\n command: command,\n isSelected: command.label === (currentCommand === null || currentCommand === void 0 ? void 0 : currentCommand.label),\n onClick: event => executeCommand(command, event),\n onMouseMove: () => setCurrentCommand(command),\n showShortcut: !app.device.viewport.isMobile,\n appState: uiAppState\n })));\n }) : allCommands ? React.createElement(\"div\", {\n className: \"no-match\"\n }, React.createElement(\"div\", {\n className: \"icon\"\n }, _icons__WEBPACK_IMPORTED_MODULE_18__.searchIcon), \" \", (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.search.noMatch\")) : null));\n}\n\nconst CommandItem = ({\n command,\n isSelected,\n disabled,\n onMouseMove,\n onClick,\n showShortcut,\n appState\n}) => {\n const noop = () => {};\n\n return React.createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"command-item\", {\n \"item-selected\": isSelected,\n \"item-disabled\": disabled\n }),\n ref: ref => {\n var _a;\n\n if (isSelected && !disabled) {\n (_a = ref === null || ref === void 0 ? void 0 : ref.scrollIntoView) === null || _a === void 0 ? void 0 : _a.call(ref, {\n block: \"nearest\"\n });\n }\n },\n onClick: disabled ? noop : onClick,\n onMouseMove: disabled ? noop : onMouseMove,\n title: disabled ? (0,_i18n__WEBPACK_IMPORTED_MODULE_12__.t)(\"commandPalette.itemNotAvailable\") : \"\"\n }, React.createElement(\"div\", {\n className: \"name\"\n }, command.icon && React.createElement(_InlineIcon__WEBPACK_IMPORTED_MODULE_15__.InlineIcon, {\n icon: typeof command.icon === \"function\" ? command.icon(appState) : command.icon\n }), command.label), showShortcut && command.shortcut && React.createElement(CommandShortcutHint, {\n shortcut: command.shortcut\n }));\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/CommandPalette/CommandPalette.tsx?");
|
|
14558
14569
|
|
|
14559
14570
|
/***/ }),
|
|
14560
14571
|
|
|
@@ -14613,6 +14624,28 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
14613
14624
|
|
|
14614
14625
|
/***/ }),
|
|
14615
14626
|
|
|
14627
|
+
/***/ "./components/ConvertElementTypePopup.scss":
|
|
14628
|
+
/*!*************************************************!*\
|
|
14629
|
+
!*** ./components/ConvertElementTypePopup.scss ***!
|
|
14630
|
+
\*************************************************/
|
|
14631
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14632
|
+
|
|
14633
|
+
"use strict";
|
|
14634
|
+
eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://ExcalidrawLib/./components/ConvertElementTypePopup.scss?");
|
|
14635
|
+
|
|
14636
|
+
/***/ }),
|
|
14637
|
+
|
|
14638
|
+
/***/ "./components/ConvertElementTypePopup.tsx":
|
|
14639
|
+
/*!************************************************!*\
|
|
14640
|
+
!*** ./components/ConvertElementTypePopup.tsx ***!
|
|
14641
|
+
\************************************************/
|
|
14642
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14643
|
+
|
|
14644
|
+
"use strict";
|
|
14645
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ adjustBoundTextSize: () => (/* binding */ adjustBoundTextSize),\n/* harmony export */ convertElementTypePopupAtom: () => (/* binding */ convertElementTypePopupAtom),\n/* harmony export */ convertElementTypes: () => (/* binding */ convertElementTypes),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ fontSize_conversionCacheAtom: () => (/* binding */ fontSize_conversionCacheAtom),\n/* harmony export */ getConversionTypeFromElements: () => (/* binding */ getConversionTypeFromElements),\n/* harmony export */ linearElement_conversionCacheAtom: () => (/* binding */ linearElement_conversionCacheAtom)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/elbowArrow */ \"../element/src/elbowArrow.ts\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @excalidraw/element/ShapeCache */ \"../element/src/ShapeCache.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _element_src_binding__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../element/src/binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _ConvertElementTypePopup_scss__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ConvertElementTypePopup.scss */ \"./components/ConvertElementTypePopup.scss\");\n/* harmony import */ var _ToolButton__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst GAP_HORIZONTAL = 8;\nconst GAP_VERTICAL = 10; // indicates order of switching\n\nconst GENERIC_TYPES = [\"rectangle\", \"diamond\", \"ellipse\"]; // indicates order of switching\n\nconst LINEAR_TYPES = [\"line\", \"sharpArrow\", \"curvedArrow\", \"elbowArrow\"];\nconst CONVERTIBLE_GENERIC_TYPES = new Set(GENERIC_TYPES);\nconst CONVERTIBLE_LINEAR_TYPES = new Set(LINEAR_TYPES);\n\nconst isConvertibleGenericType = elementType => CONVERTIBLE_GENERIC_TYPES.has(elementType);\n\nconst isConvertibleLinearType = elementType => elementType === \"arrow\" || CONVERTIBLE_LINEAR_TYPES.has(elementType);\n\nconst convertElementTypePopupAtom = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.atom)(null); // NOTE doesn't need to be an atom. Review once we integrate with properties panel.\n\nconst fontSize_conversionCacheAtom = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.atom)(null); // NOTE doesn't need to be an atom. Review once we integrate with properties panel.\n\nconst linearElement_conversionCacheAtom = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.atom)(null);\n\nconst ConvertElementTypePopup = ({\n app\n}) => {\n const setFontSizeCache = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.useSetAtom)(fontSize_conversionCacheAtom);\n const setLinearElementCache = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.useSetAtom)(linearElement_conversionCacheAtom);\n const selectedElements = app.scene.getSelectedElements(app.state);\n const elementsCategoryRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); // close shape switch panel if selecting different \"types\" of elements\n\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n if (selectedElements.length === 0) {\n app.updateEditorAtom(convertElementTypePopupAtom, null);\n return;\n }\n\n const conversionType = getConversionTypeFromElements(selectedElements);\n\n if (conversionType && !elementsCategoryRef.current) {\n elementsCategoryRef.current = conversionType;\n } else if (elementsCategoryRef.current && !conversionType || elementsCategoryRef.current && conversionType !== elementsCategoryRef.current) {\n app.updateEditorAtom(convertElementTypePopupAtom, null);\n elementsCategoryRef.current = null;\n }\n }, [selectedElements, app]);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n return () => {\n setFontSizeCache(null);\n setLinearElementCache(null);\n };\n }, [setFontSizeCache, setLinearElementCache]);\n return React.createElement(Panel, {\n app: app,\n elements: selectedElements\n });\n};\n\nconst Panel = ({\n app,\n elements\n}) => {\n const conversionType = getConversionTypeFromElements(elements);\n const genericElements = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => {\n return conversionType === \"generic\" ? filterGenericConvetibleElements(elements) : [];\n }, [conversionType, elements]);\n const linearElements = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => {\n return conversionType === \"linear\" ? filterLinearConvertibleElements(elements) : [];\n }, [conversionType, elements]);\n const sameType = conversionType === \"generic\" ? genericElements.every(element => element.type === genericElements[0].type) : conversionType === \"linear\" ? linearElements.every(element => getArrowType(element) === getArrowType(linearElements[0])) : false;\n const [panelPosition, setPanelPosition] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({\n x: 0,\n y: 0\n });\n const positionRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(\"\");\n const panelRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n const elements = [...genericElements, ...linearElements].sort((a, b) => a.id.localeCompare(b.id));\n const newPositionRef = `\n ${app.state.scrollX}${app.state.scrollY}${app.state.offsetTop}${app.state.offsetLeft}${app.state.zoom.value}${elements.map(el => el.id).join(\",\")}`;\n\n if (newPositionRef === positionRef.current) {\n return;\n }\n\n positionRef.current = newPositionRef;\n let bottomLeft;\n\n if (elements.length === 1) {\n const [x1,,, y2, cx, cy] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_4__.getElementAbsoluteCoords)(elements[0], app.scene.getNonDeletedElementsMap());\n bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_2__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_2__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_2__.pointFrom)(cx, cy), elements[0].angle);\n } else {\n const {\n minX,\n maxY\n } = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_4__.getCommonBoundingBox)(elements);\n bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_2__.pointFrom)(minX, maxY);\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.sceneCoordsToViewportCoords)({\n sceneX: bottomLeft[0],\n sceneY: bottomLeft[1]\n }, app.state);\n setPanelPosition({\n x,\n y\n });\n }, [genericElements, linearElements, app.scene, app.state]);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(linearElement_conversionCacheAtom)) {\n return;\n }\n\n for (const linearElement of linearElements) {\n const initialType = getArrowType(linearElement);\n const cachedProperties = initialType === \"line\" ? getLineProperties(linearElement) : initialType === \"sharpArrow\" ? getSharpArrowProperties(linearElement) : initialType === \"curvedArrow\" ? getCurvedArrowProperties(linearElement) : initialType === \"elbowArrow\" ? getElbowArrowProperties(linearElement) : {};\n _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.set(linearElement_conversionCacheAtom, Object.assign(Object.assign({}, _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(linearElement_conversionCacheAtom)), {\n [linearElement.id]: {\n properties: cachedProperties,\n initialType\n }\n }));\n }\n }, [linearElements]);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(fontSize_conversionCacheAtom)) {\n return;\n }\n\n for (const element of genericElements) {\n const boundText = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_5__.getBoundTextElement)(element, app.scene.getNonDeletedElementsMap());\n\n if (boundText) {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.set(fontSize_conversionCacheAtom, Object.assign(Object.assign({}, _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(fontSize_conversionCacheAtom)), {\n [element.id]: {\n fontSize: boundText.fontSize,\n elementType: element.type\n }\n }));\n }\n }\n }, [genericElements, app.scene]);\n const SHAPES = conversionType === \"linear\" ? [[\"line\", _icons__WEBPACK_IMPORTED_MODULE_17__.LineIcon], [\"sharpArrow\", _icons__WEBPACK_IMPORTED_MODULE_17__.sharpArrowIcon], [\"curvedArrow\", _icons__WEBPACK_IMPORTED_MODULE_17__.roundArrowIcon], [\"elbowArrow\", _icons__WEBPACK_IMPORTED_MODULE_17__.elbowArrowIcon]] : conversionType === \"generic\" ? [[\"rectangle\", _icons__WEBPACK_IMPORTED_MODULE_17__.RectangleIcon], [\"diamond\", _icons__WEBPACK_IMPORTED_MODULE_17__.DiamondIcon], [\"ellipse\", _icons__WEBPACK_IMPORTED_MODULE_17__.EllipseIcon]] : [];\n return React.createElement(\"div\", {\n ref: panelRef,\n tabIndex: -1,\n style: {\n position: \"absolute\",\n top: `${panelPosition.y + (GAP_VERTICAL + 8) * app.state.zoom.value - app.state.offsetTop}px`,\n left: `${panelPosition.x - app.state.offsetLeft - GAP_HORIZONTAL}px`,\n zIndex: 2\n },\n className: _excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.CLASSES.CONVERT_ELEMENT_TYPE_POPUP\n }, SHAPES.map(([type, icon]) => {\n const isSelected = sameType && (conversionType === \"generic\" && genericElements[0].type === type || conversionType === \"linear\" && getArrowType(linearElements[0]) === type);\n return React.createElement(_ToolButton__WEBPACK_IMPORTED_MODULE_16__.ToolButton, {\n className: \"Shape\",\n key: `${elements[0].id}${elements[0].version}_${type}`,\n type: \"radio\",\n icon: icon,\n checked: isSelected,\n name: \"convertElementType-option\",\n title: type,\n keyBindingLabel: \"\",\n \"aria-label\": type,\n \"data-testid\": `toolbar-${type}`,\n onChange: () => {\n var _a;\n\n if (app.state.activeTool.type !== type) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_12__.trackEvent)(\"convertElementType\", type, \"ui\");\n }\n\n convertElementTypes(app, {\n conversionType,\n nextType: type\n });\n (_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n }\n });\n }));\n};\n\nconst adjustBoundTextSize = (container, boundText, scene) => {\n const maxWidth = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_5__.getBoundTextMaxWidth)(container, boundText);\n const maxHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_5__.getBoundTextMaxHeight)(container, boundText);\n const wrappedText = (0,_excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_6__.wrapText)(boundText.text, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.getFontString)(boundText), maxWidth);\n let metrics = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__.measureText)(wrappedText, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.getFontString)(boundText), boundText.lineHeight);\n let nextFontSize = boundText.fontSize;\n\n while ((metrics.width > maxWidth || metrics.height > maxHeight) && nextFontSize > 0) {\n nextFontSize -= 1;\n\n const _updatedTextElement = Object.assign(Object.assign({}, boundText), {\n fontSize: nextFontSize\n });\n\n metrics = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__.measureText)(boundText.text, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.getFontString)(_updatedTextElement), boundText.lineHeight);\n }\n\n (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.mutateElement)(boundText, scene.getNonDeletedElementsMap(), {\n fontSize: nextFontSize,\n width: metrics.width,\n height: metrics.height\n });\n (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_5__.redrawTextBoundingBox)(boundText, container, scene);\n};\nconst convertElementTypes = (app, {\n conversionType,\n nextType,\n direction = \"right\"\n}) => {\n var _a, _b, _c, _d, _e, _f, _g;\n\n if (!conversionType) {\n return false;\n }\n\n const selectedElements = app.scene.getSelectedElements(app.state);\n const selectedElementIds = selectedElements.reduce((acc, element) => Object.assign(Object.assign({}, acc), {\n [element.id]: true\n }), {});\n const advancement = direction === \"right\" ? 1 : -1;\n\n if (conversionType === \"generic\") {\n const convertibleGenericElements = filterGenericConvetibleElements(selectedElements);\n const sameType = convertibleGenericElements.every(element => element.type === convertibleGenericElements[0].type);\n const index = sameType ? GENERIC_TYPES.indexOf(convertibleGenericElements[0].type) : -1;\n nextType = nextType !== null && nextType !== void 0 ? nextType : GENERIC_TYPES[(index + GENERIC_TYPES.length + advancement) % GENERIC_TYPES.length];\n\n if (nextType && isConvertibleGenericType(nextType)) {\n const convertedElements = {};\n\n for (const element of convertibleGenericElements) {\n const convertedElement = convertElementType(element, nextType, app);\n convertedElements[convertedElement.id] = convertedElement;\n }\n\n const nextElements = [];\n\n for (const element of app.scene.getElementsIncludingDeleted()) {\n if (convertedElements[element.id]) {\n nextElements.push(convertedElements[element.id]);\n } else {\n nextElements.push(element);\n }\n }\n\n app.scene.replaceAllElements(nextElements);\n\n for (const element of Object.values(convertedElements)) {\n const boundText = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_5__.getBoundTextElement)(element, app.scene.getNonDeletedElementsMap());\n\n if (boundText) {\n if (((_b = (_a = _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(fontSize_conversionCacheAtom)) === null || _a === void 0 ? void 0 : _a[element.id]) === null || _b === void 0 ? void 0 : _b.elementType) === nextType) {\n (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.mutateElement)(boundText, app.scene.getNonDeletedElementsMap(), {\n fontSize: (_e = (_d = (_c = _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(fontSize_conversionCacheAtom)) === null || _c === void 0 ? void 0 : _c[element.id]) === null || _d === void 0 ? void 0 : _d.fontSize) !== null && _e !== void 0 ? _e : boundText.fontSize\n });\n }\n\n adjustBoundTextSize(element, boundText, app.scene);\n }\n }\n\n app.setState(prevState => {\n return {\n selectedElementIds,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.updateActiveTool)(prevState, {\n type: \"selection\"\n })\n };\n });\n }\n }\n\n if (conversionType === \"linear\") {\n const convertibleLinearElements = filterLinearConvertibleElements(selectedElements);\n const arrowType = getArrowType(convertibleLinearElements[0]);\n const sameType = convertibleLinearElements.every(element => getArrowType(element) === arrowType);\n const index = sameType ? LINEAR_TYPES.indexOf(arrowType) : -1;\n nextType = nextType !== null && nextType !== void 0 ? nextType : LINEAR_TYPES[(index + LINEAR_TYPES.length + advancement) % LINEAR_TYPES.length];\n\n if (nextType && isConvertibleLinearType(nextType)) {\n const convertedElements = {};\n\n for (const element of convertibleLinearElements) {\n const {\n properties,\n initialType\n } = ((_f = _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(linearElement_conversionCacheAtom)) === null || _f === void 0 ? void 0 : _f[element.id]) || {}; // If the initial type is not elbow, and when we switch to elbow,\n // the linear line might be \"bent\" and the points would likely be different.\n // When we then switch to other non elbow types from this converted elbow,\n // we still want to use the original points instead.\n\n if (initialType && properties && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(element) && initialType !== \"elbowArrow\" && nextType !== \"elbowArrow\") {\n // first convert back to the original type\n const originalType = convertElementType(element, initialType, app); // then convert to the target type\n\n const converted = convertElementType(initialType === \"line\" ? (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newLinearElement)(Object.assign(Object.assign(Object.assign({}, originalType), properties), {\n type: \"line\"\n })) : (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newArrowElement)(Object.assign(Object.assign(Object.assign({}, originalType), properties), {\n type: \"arrow\"\n })), nextType, app);\n convertedElements[converted.id] = converted;\n } else {\n const converted = convertElementType(element, nextType, app);\n convertedElements[converted.id] = converted;\n }\n }\n\n const nextElements = [];\n\n for (const element of app.scene.getElementsIncludingDeleted()) {\n if (convertedElements[element.id]) {\n nextElements.push(convertedElements[element.id]);\n } else {\n nextElements.push(element);\n }\n }\n\n app.scene.replaceAllElements(nextElements);\n\n for (const element of Object.values(convertedElements)) {\n const cachedLinear = (_g = _editor_jotai__WEBPACK_IMPORTED_MODULE_13__.editorJotaiStore.get(linearElement_conversionCacheAtom)) === null || _g === void 0 ? void 0 : _g[element.id];\n\n if (cachedLinear) {\n const {\n properties,\n initialType\n } = cachedLinear;\n\n if (initialType === nextType) {\n (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.mutateElement)(element, app.scene.getNonDeletedElementsMap(), properties);\n continue;\n }\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(element)) {\n const nextPoints = convertLineToElbow(element);\n\n if (nextPoints.length < 2) {\n // skip if not enough points to form valid segments\n continue;\n }\n\n const fixedSegments = [];\n\n for (let i = 0; i < nextPoints.length - 1; i++) {\n fixedSegments.push({\n start: nextPoints[i],\n end: nextPoints[i + 1],\n index: i + 1\n });\n }\n\n const updates = (0,_excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_1__.updateElbowArrowPoints)(element, app.scene.getNonDeletedElementsMap(), {\n points: nextPoints,\n fixedSegments\n });\n (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.mutateElement)(element, app.scene.getNonDeletedElementsMap(), Object.assign({}, updates));\n }\n }\n }\n\n const convertedSelectedLinearElements = filterLinearConvertibleElements(app.scene.getSelectedElements(app.state));\n app.setState(prevState => ({\n selectedElementIds,\n selectedLinearElement: convertedSelectedLinearElements.length === 1 ? new _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_9__.LinearElementEditor(convertedSelectedLinearElements[0], app.scene.getNonDeletedElementsMap()) : null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.updateActiveTool)(prevState, {\n type: \"selection\"\n })\n }));\n }\n\n return true;\n};\nconst getConversionTypeFromElements = elements => {\n if (elements.length === 0) {\n return null;\n }\n\n let canBeLinear = false;\n\n for (const element of elements) {\n if (isConvertibleGenericType(element.type)) {\n // generic type conversion have preference\n return \"generic\";\n }\n\n if (isEligibleLinearElement(element)) {\n canBeLinear = true;\n }\n }\n\n if (canBeLinear) {\n return \"linear\";\n }\n\n return null;\n};\n\nconst isEligibleLinearElement = element => {\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isLinearElement)(element) && (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isArrowElement)(element) || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isArrowBoundToElement)(element) && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(element));\n};\n\nconst getArrowType = element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isSharpArrow)(element)) {\n return \"sharpArrow\";\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isCurvedArrow)(element)) {\n return \"curvedArrow\";\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(element)) {\n return \"elbowArrow\";\n }\n\n return \"line\";\n};\n\nconst getLineProperties = element => {\n if (element.type === \"line\") {\n return {\n points: element.points,\n roundness: element.roundness\n };\n }\n\n return {};\n};\n\nconst getSharpArrowProperties = element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isSharpArrow)(element)) {\n return {\n points: element.points,\n startArrowhead: element.startArrowhead,\n endArrowhead: element.endArrowhead,\n startBinding: element.startBinding,\n endBinding: element.endBinding,\n roundness: null\n };\n }\n\n return {};\n};\n\nconst getCurvedArrowProperties = element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isCurvedArrow)(element)) {\n return {\n points: element.points,\n startArrowhead: element.startArrowhead,\n endArrowhead: element.endArrowhead,\n startBinding: element.startBinding,\n endBinding: element.endBinding,\n roundness: element.roundness\n };\n }\n\n return {};\n};\n\nconst getElbowArrowProperties = element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(element)) {\n return {\n points: element.points,\n startArrowhead: element.startArrowhead,\n endArrowhead: element.endArrowhead,\n startBinding: element.startBinding,\n endBinding: element.endBinding,\n roundness: null,\n fixedSegments: element.fixedSegments,\n startIsSpecial: element.startIsSpecial,\n endIsSpecial: element.endIsSpecial\n };\n }\n\n return {};\n};\n\nconst filterGenericConvetibleElements = elements => elements.filter(element => isConvertibleGenericType(element.type));\n\nconst filterLinearConvertibleElements = elements => elements.filter(element => isEligibleLinearElement(element));\n\nconst THRESHOLD = 20;\n\nconst isVert = (a, b) => a[0] === b[0];\n\nconst isHorz = (a, b) => a[1] === b[1];\n\nconst dist = (a, b) => isVert(a, b) ? Math.abs(a[1] - b[1]) : Math.abs(a[0] - b[0]);\n\nconst convertLineToElbow = line => {\n // 1. build an *orthogonal* route, snapping offsets < SNAP\n const ortho = [line.points[0]];\n const src = sanitizePoints(line.points);\n\n for (let i = 1; i < src.length; ++i) {\n const start = ortho[ortho.length - 1];\n const end = [...src[i]]; // clone\n // snap tiny offsets onto the current axis\n\n if (Math.abs(end[0] - start[0]) < THRESHOLD) {\n end[0] = start[0];\n } else if (Math.abs(end[1] - start[1]) < THRESHOLD) {\n end[1] = start[1];\n } // straight or needs a 90 ° bend?\n\n\n if (isVert(start, end) || isHorz(start, end)) {\n ortho.push(end);\n } else {\n ortho.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_2__.pointFrom)(start[0], end[1]));\n ortho.push(end);\n }\n } // 2. drop obviously colinear middle points\n\n\n const trimmed = [ortho[0]];\n\n for (let i = 1; i < ortho.length - 1; ++i) {\n if (!(isVert(ortho[i - 1], ortho[i]) && isVert(ortho[i], ortho[i + 1]) || isHorz(ortho[i - 1], ortho[i]) && isHorz(ortho[i], ortho[i + 1]))) {\n trimmed.push(ortho[i]);\n }\n }\n\n trimmed.push(ortho[ortho.length - 1]); // 3. collapse micro “jogs” (V-H-V / H-V-H whose short leg < SNAP)\n\n const clean = [trimmed[0]];\n\n for (let i = 1; i < trimmed.length - 1; ++i) {\n const a = clean[clean.length - 1];\n const b = trimmed[i];\n const c = trimmed[i + 1];\n const v1 = isVert(a, b);\n const v2 = isVert(b, c);\n\n if (v1 !== v2) {\n const d1 = dist(a, b);\n const d2 = dist(b, c);\n\n if (d1 < THRESHOLD || d2 < THRESHOLD) {\n // pick the shorter leg to remove\n if (d2 < d1) {\n // … absorb leg 2 – pull *c* onto axis of *a-b*\n if (v1) {\n c[0] = a[0];\n } else {\n c[1] = a[1];\n }\n } else {\n // … absorb leg 1 – slide the whole first leg onto *b-c* axis\n // eslint-disable-next-line no-lonely-if\n if (v2) {\n for (let k = clean.length - 1; k >= 0 && clean[k][0] === a[0]; --k) {\n clean[k][0] = b[0];\n }\n } else {\n for (let k = clean.length - 1; k >= 0 && clean[k][1] === a[1]; --k) {\n clean[k][1] = b[1];\n }\n }\n } // *b* is gone, don’t add it\n\n\n continue;\n }\n }\n\n clean.push(b);\n }\n\n clean.push(trimmed[trimmed.length - 1]);\n return clean;\n};\n\nconst sanitizePoints = points => {\n if (points.length === 0) {\n return [];\n }\n\n const sanitized = [points[0]];\n\n for (let i = 1; i < points.length; i++) {\n const [x1, y1] = sanitized[sanitized.length - 1];\n const [x2, y2] = points[i];\n\n if (x1 !== x2 || y1 !== y2) {\n sanitized.push(points[i]);\n }\n }\n\n return sanitized;\n};\n/**\r\n * Converts an element to a new type, adding or removing properties as needed\r\n * so that the element object is always valid.\r\n *\r\n * Valid conversions at this point:\r\n * - switching between generic elements\r\n * e.g. rectangle -> diamond\r\n * - switching between linear elements\r\n * e.g. elbow arrow -> line\r\n */\n\n\nconst convertElementType = (element, targetType, app) => {\n if (!isValidConversion(element.type, targetType)) {\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.isProdEnv)()) {\n throw Error(`Invalid conversion from ${element.type} to ${targetType}.`);\n }\n\n return element;\n }\n\n if (element.type === targetType) {\n return element;\n }\n\n _excalidraw_element_ShapeCache__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.delete(element);\n\n if (isConvertibleGenericType(targetType)) {\n const nextElement = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.bumpVersion)((0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newElement)(Object.assign(Object.assign({}, element), {\n type: targetType,\n roundness: targetType === \"diamond\" && element.roundness ? {\n type: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_3__.isUsingAdaptiveRadius)(targetType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : element.roundness\n })));\n (0,_element_src_binding__WEBPACK_IMPORTED_MODULE_14__.updateBindings)(nextElement, app.scene);\n return nextElement;\n }\n\n if (isConvertibleLinearType(targetType)) {\n switch (targetType) {\n case \"line\":\n {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.bumpVersion)((0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newLinearElement)(Object.assign(Object.assign({}, element), {\n type: \"line\"\n })));\n }\n\n case \"sharpArrow\":\n {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.bumpVersion)((0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newArrowElement)(Object.assign(Object.assign({}, element), {\n type: \"arrow\",\n elbowed: false,\n roundness: null,\n startArrowhead: app.state.currentItemStartArrowhead,\n endArrowhead: app.state.currentItemEndArrowhead\n })));\n }\n\n case \"curvedArrow\":\n {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.bumpVersion)((0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newArrowElement)(Object.assign(Object.assign({}, element), {\n type: \"arrow\",\n elbowed: false,\n roundness: {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.ROUNDNESS.PROPORTIONAL_RADIUS\n },\n startArrowhead: app.state.currentItemStartArrowhead,\n endArrowhead: app.state.currentItemEndArrowhead\n })));\n }\n\n case \"elbowArrow\":\n {\n return (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_18__.bumpVersion)((0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_10__.newArrowElement)(Object.assign(Object.assign({}, element), {\n type: \"arrow\",\n elbowed: true,\n fixedSegments: null,\n roundness: null\n })));\n }\n }\n }\n\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_7__.assertNever)(targetType, `unhandled conversion type: ${targetType}`);\n return element;\n};\n\nconst isValidConversion = (startType, targetType) => {\n if (isConvertibleGenericType(startType) && isConvertibleGenericType(targetType)) {\n return true;\n }\n\n if (isConvertibleLinearType(startType) && isConvertibleLinearType(targetType)) {\n return true;\n } // NOTE: add more conversions when needed\n\n\n return false;\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ConvertElementTypePopup);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/ConvertElementTypePopup.tsx?");
|
|
14646
|
+
|
|
14647
|
+
/***/ }),
|
|
14648
|
+
|
|
14616
14649
|
/***/ "./components/DarkModeToggle.tsx":
|
|
14617
14650
|
/*!***************************************!*\
|
|
14618
14651
|
!*** ./components/DarkModeToggle.tsx ***!
|
|
@@ -14961,7 +14994,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
|
|
|
14961
14994
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14962
14995
|
|
|
14963
14996
|
"use strict";
|
|
14964
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HelpDialog: () => (/* binding */ HelpDialog)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _Dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Dialog */ \"./components/Dialog.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _HelpDialog_scss__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HelpDialog.scss */ \"./components/HelpDialog.scss\");\n\n\n\n\n\n\n\n\n\n\nconst Header = () => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__header\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\" //zsviczian\n ,\n href: \"https://github.com/zsviczian/obsidian-excalidraw-plugin/#readme\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.ExternalLinkIcon), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.documentation\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\",\n href: \"https://www.youtube.com/@VisualPKM\" //zsviczian\n ,\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n}, \"Visual PKM YouTube\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.ExternalLinkIcon), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.blog\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\" //zsviczian\n ,\n href: \"https://github.com/zsviczian/obsidian-excalidraw-plugin/issues\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.GithubIcon), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.github\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\",\n href: \"https://youtube.com/@excalidraw\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.youtubeIcon), \"YouTube\"));\n\nconst Section = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"h3\", null, props.title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__islands-container\"\n}, props.children));\n\nconst ShortcutIsland = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: `HelpDialog__island ${props.className}`\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"h4\", {\n className: \"HelpDialog__island-title\"\n}, props.caption), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__island-content\"\n}, props.children));\n\nfunction* intersperse(as, delim) {\n let first = true;\n\n for (const x of as) {\n if (!first) {\n yield delim;\n }\n\n first = false;\n yield x;\n }\n}\n\nconst upperCaseSingleChars = str => {\n return str.replace(/\\b[a-z]\\b/, c => c.toUpperCase());\n};\n\nconst Shortcut = ({\n label,\n shortcuts,\n isOr = true\n}) => {\n const splitShortcutKeys = shortcuts.map(shortcut => {\n const keys = shortcut.endsWith(\"++\") ? [...shortcut.slice(0, -2).split(\"+\"), \"+\"] : shortcut.split(\"+\");\n return keys.map(key => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutKey, {\n key: key\n }, upperCaseSingleChars(key)));\n });\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__shortcut\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", null, label), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__key-container\"\n }, [...intersperse(splitShortcutKeys, isOr ? (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.or\") : null)]));\n};\n\nconst ShortcutKey = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"kbd\", Object.assign({\n className: \"HelpDialog__key\"\n}, props));\n\nconst HelpDialog = ({\n onClose\n}) => {\n const handleClose = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(() => {\n if (onClose) {\n onClose();\n }\n }, [onClose]);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog, {\n onCloseRequest: handleClose,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.title\"),\n className: \"HelpDialog\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Header, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Section, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.shortcuts\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutIsland, {\n className: \"HelpDialog__island--tools\",\n caption: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.tools\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.hand\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.H]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.selection\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.V, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"1\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.rectangle\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.R, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"2\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.diamond\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.D, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"3\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.ellipse\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.O, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"4\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.arrow\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.A, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"5\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.line\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.L, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"6\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.freedraw\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.P, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"7\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.text\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.T, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"8\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.image\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"9\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.eraser\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.E, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"0\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.frame\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.F]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.laser\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.K]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.eyeDropper\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.I, \"Shift+S\", \"Shift+G\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.editLineArrowPoints\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.editText\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.textNewLine\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.textFinish\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Esc\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.curvedArrow\"),\n shortcuts: [\"A\", (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")],\n isOr: false\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.curvedLine\"),\n shortcuts: [\"L\", (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")],\n isOr: false\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.cropStart\"),\n shortcuts: [(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.doubleClick\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\")],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.cropFinish\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Escape\")],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.lock\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.Q]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.preventBinding\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.link\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+K\")]\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutIsland, {\n className: \"HelpDialog__island--view\",\n caption: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.view\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.zoomIn\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd++\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.zoomOut\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+-\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.resetZoom\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+0\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.zoomToFit\"),\n shortcuts: [\"Shift+1\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.zoomToSelection\"),\n shortcuts: [\"Shift+2\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.movePageUpDown\"),\n shortcuts: [\"PgUp/PgDn\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.movePageLeftRight\"),\n shortcuts: [\"Shift+PgUp/PgDn\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.zenMode\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+Z\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.objectsSnapMode\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+S\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.toggleGrid\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+'\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.viewMode\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+R\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.toggleTheme\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+Shift+D\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"stats.fullTitle\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+/\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"search.title\"),\n shortcuts: [(0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"searchMenu\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"commandPalette.title\"),\n shortcuts: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isFirefox ? [(0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"commandPalette\")] : [(0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"commandPalette\"), (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"commandPalette\", 1)]\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutIsland, {\n className: \"HelpDialog__island--editor\",\n caption: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.editor\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.createFlowchart\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`CtrlOrCmd+Arrow Key`)],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.navigateFlowchart\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Alt+Arrow Key`)],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.moveCanvas\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Space+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Wheel+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`)],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.clearReset\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Delete\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.delete\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Delete\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.cut\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+X\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.copy\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+C\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.paste\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.pasteAsPlaintext\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.selectAll\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+A\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.multiSelect\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Shift+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")}`)]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.deepSelect\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`CtrlOrCmd+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")}`)]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.deepBoxSelect\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`CtrlOrCmd+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`)]\n }), (_clipboard__WEBPACK_IMPORTED_MODULE_3__.probablySupportsClipboardBlob || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isFirefox) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.copyAsPng\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+Alt+C\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.copyStyles\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+C\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.pasteStyles\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.sendToBack\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isDarwin ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+[\") : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+[\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.bringToFront\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isDarwin ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+]\") : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+]\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.sendBackward\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+[\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.bringForward\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+]\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignTop\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Up\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignBottom\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Down\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignLeft\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Left\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignRight\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Right\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.duplicateSelection\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+D\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Alt+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`)]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.toggleElementLock\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+L\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.undo\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Z\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.redo\"),\n shortcuts: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isWindows ? [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Y\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Z\")] : [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Z\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.group\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+G\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.ungroup\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+G\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.flipHorizontal\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+H\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.flipVertical\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.showStroke\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"S\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.showBackground\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"G\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.showFonts\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+F\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.decreaseFontSize\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+<\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.increaseFontSize\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+>\")]\n })))));\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/HelpDialog.tsx?");
|
|
14997
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HelpDialog: () => (/* binding */ HelpDialog)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _Dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Dialog */ \"./components/Dialog.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _HelpDialog_scss__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HelpDialog.scss */ \"./components/HelpDialog.scss\");\n\n\n\n\n\n\n\n\n\n\nconst Header = () => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__header\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\" //zsviczian\n ,\n href: \"https://github.com/zsviczian/obsidian-excalidraw-plugin/#readme\",\n target: \"_blank\",\n rel: \"noopener\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.ExternalLinkIcon), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.documentation\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\",\n href: \"https://www.youtube.com/@VisualPKM\" //zsviczian\n ,\n target: \"_blank\",\n rel: \"noopener\"\n}, \"Visual PKM YouTube\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.ExternalLinkIcon), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.blog\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\" //zsviczian\n ,\n href: \"https://github.com/zsviczian/obsidian-excalidraw-plugin/issues\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.GithubIcon), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.github\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", {\n className: \"HelpDialog__btn\",\n href: \"https://youtube.com/@excalidraw\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__link-icon\"\n}, _icons__WEBPACK_IMPORTED_MODULE_6__.youtubeIcon), \"YouTube\"));\n\nconst Section = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"h3\", null, props.title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__islands-container\"\n}, props.children));\n\nconst ShortcutIsland = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: `HelpDialog__island ${props.className}`\n}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"h4\", {\n className: \"HelpDialog__island-title\"\n}, props.caption), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__island-content\"\n}, props.children));\n\nfunction* intersperse(as, delim) {\n let first = true;\n\n for (const x of as) {\n if (!first) {\n yield delim;\n }\n\n first = false;\n yield x;\n }\n}\n\nconst upperCaseSingleChars = str => {\n return str.replace(/\\b[a-z]\\b/, c => c.toUpperCase());\n};\n\nconst Shortcut = ({\n label,\n shortcuts,\n isOr = true\n}) => {\n const splitShortcutKeys = shortcuts.map(shortcut => {\n const keys = shortcut.endsWith(\"++\") ? [...shortcut.slice(0, -2).split(\"+\"), \"+\"] : shortcut.split(\"+\");\n return keys.map(key => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutKey, {\n key: key\n }, upperCaseSingleChars(key)));\n });\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__shortcut\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", null, label), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"HelpDialog__key-container\"\n }, [...intersperse(splitShortcutKeys, isOr ? (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.or\") : null)]));\n};\n\nconst ShortcutKey = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"kbd\", Object.assign({\n className: \"HelpDialog__key\"\n}, props));\n\nconst HelpDialog = ({\n onClose\n}) => {\n const handleClose = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(() => {\n if (onClose) {\n onClose();\n }\n }, [onClose]);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Dialog__WEBPACK_IMPORTED_MODULE_5__.Dialog, {\n onCloseRequest: handleClose,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.title\"),\n className: \"HelpDialog\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Header, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Section, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.shortcuts\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutIsland, {\n className: \"HelpDialog__island--tools\",\n caption: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.tools\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.hand\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.H]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.selection\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.V, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"1\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.rectangle\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.R, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"2\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.diamond\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.D, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"3\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.ellipse\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.O, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"4\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.arrow\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.A, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"5\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.line\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.L, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"6\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.freedraw\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.P, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"7\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.text\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.T, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"8\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.image\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"9\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.eraser\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.E, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS[\"0\"]]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.frame\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.F]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.laser\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.K]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.eyeDropper\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.I, \"Shift+S\", \"Shift+G\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.editLineArrowPoints\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.editText\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.textNewLine\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.textFinish\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Esc\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Enter\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.curvedArrow\"),\n shortcuts: [\"A\", (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")],\n isOr: false\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.curvedLine\"),\n shortcuts: [\"L\", (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\"), (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")],\n isOr: false\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.cropStart\"),\n shortcuts: [(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.doubleClick\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\")],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.cropFinish\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Enter\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Escape\")],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.lock\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.Q]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.preventBinding\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.link\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+K\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.convertElementType\"),\n shortcuts: [\"Tab\", \"Shift+Tab\"],\n isOr: true\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutIsland, {\n className: \"HelpDialog__island--view\",\n caption: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.view\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.zoomIn\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd++\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.zoomOut\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+-\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.resetZoom\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+0\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.zoomToFit\"),\n shortcuts: [\"Shift+1\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.zoomToSelection\"),\n shortcuts: [\"Shift+2\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.movePageUpDown\"),\n shortcuts: [\"PgUp/PgDn\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.movePageLeftRight\"),\n shortcuts: [\"Shift+PgUp/PgDn\"]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.zenMode\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+Z\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.objectsSnapMode\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+S\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.toggleGrid\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+'\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.viewMode\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+R\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.toggleTheme\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+Shift+D\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"stats.fullTitle\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Alt+/\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"search.title\"),\n shortcuts: [(0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"searchMenu\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"commandPalette.title\"),\n shortcuts: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isFirefox ? [(0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"commandPalette\")] : [(0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"commandPalette\"), (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_2__.getShortcutFromShortcutName)(\"commandPalette\", 1)]\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ShortcutIsland, {\n className: \"HelpDialog__island--editor\",\n caption: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.editor\")\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.createFlowchart\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`CtrlOrCmd+Arrow Key`)],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.navigateFlowchart\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Alt+Arrow Key`)],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.moveCanvas\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Space+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Wheel+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`)],\n isOr: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.clearReset\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Delete\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.delete\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Delete\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.cut\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+X\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.copy\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+C\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.paste\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.pasteAsPlaintext\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.selectAll\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+A\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.multiSelect\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Shift+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")}`)]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.deepSelect\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`CtrlOrCmd+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.click\")}`)]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.deepBoxSelect\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`CtrlOrCmd+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`)]\n }), (_clipboard__WEBPACK_IMPORTED_MODULE_3__.probablySupportsClipboardBlob || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isFirefox) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.copyAsPng\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+Alt+C\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.copyStyles\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+C\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.pasteStyles\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.sendToBack\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isDarwin ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+[\") : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+[\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.bringToFront\"),\n shortcuts: [_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isDarwin ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Alt+]\") : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+]\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.sendBackward\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+[\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.bringForward\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+]\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignTop\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Up\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignBottom\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Down\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignLeft\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Left\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.alignRight\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Right\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.duplicateSelection\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+D\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(`Alt+${(0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.drag\")}`)]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.toggleElementLock\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+L\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.undo\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Z\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.redo\"),\n shortcuts: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isWindows ? [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Y\"), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Z\")] : [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+Z\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.group\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+G\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.ungroup\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+G\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.flipHorizontal\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+H\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.flipVertical\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+V\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.showStroke\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"S\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.showBackground\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"G\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.showFonts\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"Shift+F\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.decreaseFontSize\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+<\")]\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Shortcut, {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"labels.increaseFontSize\"),\n shortcuts: [(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+Shift+>\")]\n })))));\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/HelpDialog.tsx?");
|
|
14965
14998
|
|
|
14966
14999
|
/***/ }),
|
|
14967
15000
|
|
|
@@ -15445,7 +15478,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
|
|
|
15445
15478
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
15446
15479
|
|
|
15447
15480
|
"use strict";
|
|
15448
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/utils/export */ \"../utils/src/export.ts\");\n/* harmony import */ var open_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! open-color */ \"../../node_modules/open-color/open-color.json\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../data/EditorLocalStorage */ \"./data/EditorLocalStorage.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _Dialog__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Dialog */ \"./components/Dialog.tsx\");\n/* harmony import */ var _DialogActionButton__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./DialogActionButton */ \"./components/DialogActionButton.tsx\");\n/* harmony import */ var _ToolButton__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _Trans__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Trans */ \"./components/Trans.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _PublishLibrary_scss__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./PublishLibrary.scss */ \"./components/PublishLibrary.scss\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst generatePreviewImage = async libraryItems => {\n const MAX_ITEMS_PER_ROW = 6;\n const BOX_SIZE = 128;\n const BOX_PADDING = Math.round(BOX_SIZE / 16);\n const BORDER_WIDTH = Math.max(Math.round(BOX_SIZE / 64), 2);\n const rows = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.chunk)(libraryItems, MAX_ITEMS_PER_ROW);\n const canvas = document.createElement(\"canvas\");\n canvas.width = rows[0].length * BOX_SIZE + (rows[0].length + 1) * (BOX_PADDING * 2) - BOX_PADDING * 2;\n canvas.height = rows.length * BOX_SIZE + (rows.length + 1) * (BOX_PADDING * 2) - BOX_PADDING * 2;\n const ctx = canvas.getContext(\"2d\");\n ctx.fillStyle = open_color__WEBPACK_IMPORTED_MODULE_1__.white;\n ctx.fillRect(0, 0, canvas.width, canvas.height); // draw items\n // ---------------------------------------------------------------------------\n\n for (const [index, item] of libraryItems.entries()) {\n const itemCanvas = await (0,_excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_0__.exportToCanvas)({\n elements: item.elements,\n files: null,\n maxWidthOrHeight: BOX_SIZE\n });\n const {\n width,\n height\n } = itemCanvas; // draw item\n // -------------------------------------------------------------------------\n\n const rowOffset = Math.floor(index / MAX_ITEMS_PER_ROW) * (BOX_SIZE + BOX_PADDING * 2);\n const colOffset = index % MAX_ITEMS_PER_ROW * (BOX_SIZE + BOX_PADDING * 2);\n ctx.drawImage(itemCanvas, colOffset + (BOX_SIZE - width) / 2 + BOX_PADDING, rowOffset + (BOX_SIZE - height) / 2 + BOX_PADDING); // draw item border\n // -------------------------------------------------------------------------\n\n ctx.lineWidth = BORDER_WIDTH;\n ctx.strokeStyle = open_color__WEBPACK_IMPORTED_MODULE_1__.gray[4];\n ctx.strokeRect(colOffset + BOX_PADDING / 2, rowOffset + BOX_PADDING / 2, BOX_SIZE + BOX_PADDING, BOX_SIZE + BOX_PADDING);\n }\n\n return await (0,_data_blob__WEBPACK_IMPORTED_MODULE_5__.resizeImageFile)(new File([await (0,_data_blob__WEBPACK_IMPORTED_MODULE_5__.canvasToBlob)(canvas)], \"preview\", {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.MIME_TYPES.png\n }), {\n outputType: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.MIME_TYPES.jpg,\n maxWidthOrHeight: 5000\n });\n};\n\nconst SingleLibraryItem = ({\n libItem,\n appState,\n index,\n onChange,\n onRemove\n}) => {\n const svgRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);\n const inputRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n const node = svgRef.current;\n\n if (!node) {\n return;\n }\n\n (async () => {\n const svg = await (0,_excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_0__.exportToSvg)({\n elements: libItem.elements,\n appState: Object.assign(Object.assign({}, appState), {\n viewBackgroundColor: open_color__WEBPACK_IMPORTED_MODULE_1__.white,\n exportBackground: true\n }),\n files: null,\n skipInliningFonts: true\n });\n node.innerHTML = svg.outerHTML;\n })();\n }, [libItem.elements, appState]);\n return React.createElement(\"div\", {\n className: \"single-library-item\"\n }, libItem.status === \"published\" && React.createElement(\"span\", {\n className: \"single-library-item-status\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"labels.statusPublished\")), React.createElement(\"div\", {\n ref: svgRef,\n className: \"single-library-item__svg\"\n }), React.createElement(_ToolButton__WEBPACK_IMPORTED_MODULE_9__.ToolButton, {\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.remove\"),\n type: \"button\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_11__.CloseIcon,\n className: \"single-library-item--remove\",\n onClick: onRemove.bind(null, libItem.id),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.remove\")\n }), React.createElement(\"div\", {\n style: {\n display: \"flex\",\n margin: \"0.8rem 0\",\n width: \"100%\",\n fontSize: \"14px\",\n fontWeight: 500,\n flexDirection: \"column\"\n }\n }, React.createElement(\"label\", {\n style: {\n display: \"flex\",\n justifyContent: \"space-between\",\n flexDirection: \"column\"\n }\n }, React.createElement(\"div\", {\n style: {\n padding: \"0.5em 0\"\n }\n }, React.createElement(\"span\", {\n style: {\n fontWeight: 500,\n color: open_color__WEBPACK_IMPORTED_MODULE_1__.gray[6]\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.itemName\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"input\", {\n type: \"text\",\n ref: inputRef,\n style: {\n width: \"80%\",\n padding: \"0.2rem\"\n },\n defaultValue: libItem.name,\n placeholder: \"Item name\",\n onChange: event => {\n onChange(event.target.value, index);\n }\n })), React.createElement(\"span\", {\n className: \"error\"\n }, libItem.error)));\n};\n\nconst PublishLibrary = ({\n onClose,\n libraryItems,\n appState,\n onSuccess,\n onError,\n updateItemsInStorage,\n onRemove\n}) => {\n const [libraryData, setLibraryData] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)({\n authorName: \"\",\n githubHandle: \"\",\n name: \"\",\n description: \"\",\n twitterHandle: \"\",\n website: \"\"\n });\n const [isSubmitting, setIsSubmitting] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(false);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n const data = _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__.EditorLocalStorage.get(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EDITOR_LS_KEYS.PUBLISH_LIBRARY);\n\n if (data) {\n setLibraryData(data);\n }\n }, []);\n const [clonedLibItems, setClonedLibItems] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(libraryItems.slice());\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n setClonedLibItems(libraryItems.slice());\n }, [libraryItems]);\n\n const onInputChange = event => {\n setLibraryData(Object.assign(Object.assign({}, libraryData), {\n [event.target.name]: event.target.value\n }));\n };\n\n const onSubmit = async event => {\n event.preventDefault();\n setIsSubmitting(true);\n const erroredLibItems = [];\n let isError = false;\n clonedLibItems.forEach(libItem => {\n let error = \"\";\n\n if (!libItem.name) {\n error = (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.errors.required\");\n isError = true;\n }\n\n erroredLibItems.push(Object.assign(Object.assign({}, libItem), {\n error\n }));\n });\n\n if (isError) {\n setClonedLibItems(erroredLibItems);\n setIsSubmitting(false);\n return;\n }\n\n const previewImage = await generatePreviewImage(clonedLibItems);\n const libContent = {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EXPORT_DATA_TYPES.excalidrawLibrary,\n version: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.VERSIONS.excalidrawLibrary,\n source: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EXPORT_SOURCE,\n libraryItems: clonedLibItems\n };\n const content = JSON.stringify(libContent, null, 2);\n const lib = new Blob([content], {\n type: \"application/json\"\n });\n const formData = new FormData();\n formData.append(\"excalidrawLib\", lib);\n formData.append(\"previewImage\", previewImage);\n formData.append(\"previewImageType\", previewImage.type);\n formData.append(\"title\", libraryData.name);\n formData.append(\"authorName\", libraryData.authorName);\n formData.append(\"githubHandle\", libraryData.githubHandle);\n formData.append(\"name\", libraryData.name);\n formData.append(\"description\", libraryData.description);\n formData.append(\"twitterHandle\", libraryData.twitterHandle);\n formData.append(\"website\", libraryData.website);\n fetch(`${\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\"}/submit`, {\n method: \"post\",\n body: formData\n }).then(response => {\n if (response.ok) {\n return response.json().then(({\n url\n }) => {\n // flush data from local storage\n _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__.EditorLocalStorage.delete(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EDITOR_LS_KEYS.PUBLISH_LIBRARY);\n onSuccess({\n url,\n authorName: libraryData.authorName,\n items: clonedLibItems\n });\n });\n }\n\n return response.json().catch(() => {\n throw new Error(response.statusText || \"something went wrong\");\n }).then(error => {\n throw new Error(error.message || response.statusText || \"something went wrong\");\n });\n }, err => {\n console.error(err);\n onError(err);\n setIsSubmitting(false);\n }).catch(err => {\n console.error(err);\n onError(err);\n setIsSubmitting(false);\n });\n };\n\n const renderLibraryItems = () => {\n const items = [];\n clonedLibItems.forEach((libItem, index) => {\n items.push(React.createElement(\"div\", {\n className: \"single-library-item-wrapper\",\n key: index\n }, React.createElement(SingleLibraryItem, {\n libItem: libItem,\n appState: appState,\n index: index,\n onChange: (val, index) => {\n const items = clonedLibItems.slice();\n items[index].name = val;\n setClonedLibItems(items);\n },\n onRemove: onRemove\n })));\n });\n return React.createElement(\"div\", {\n className: \"selected-library-items\"\n }, items);\n };\n\n const onDialogClose = (0,react__WEBPACK_IMPORTED_MODULE_2__.useCallback)(() => {\n updateItemsInStorage(clonedLibItems);\n _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__.EditorLocalStorage.set(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EDITOR_LS_KEYS.PUBLISH_LIBRARY, libraryData);\n onClose();\n }, [clonedLibItems, onClose, updateItemsInStorage, libraryData]);\n const shouldRenderForm = !!libraryItems.length;\n const containsPublishedItems = libraryItems.some(item => item.status === \"published\");\n return React.createElement(_Dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog, {\n onCloseRequest: onDialogClose,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.title\"),\n className: \"publish-library\"\n }, shouldRenderForm ? React.createElement(\"form\", {\n onSubmit: onSubmit\n }, React.createElement(\"div\", {\n className: \"publish-library-note\"\n }, React.createElement(_Trans__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n i18nKey: \"publishDialog.noteDescription\",\n link: el => React.createElement(\"a\", {\n href: \"https://libraries.excalidraw.com\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n }, el)\n })), React.createElement(\"span\", {\n className: \"publish-library-note\"\n }, React.createElement(_Trans__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n i18nKey: \"publishDialog.noteGuidelines\",\n link: el => React.createElement(\"a\", {\n href: \"https://github.com/excalidraw/excalidraw-libraries#guidelines\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n }, el)\n })), React.createElement(\"div\", {\n className: \"publish-library-note\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.noteItems\")), containsPublishedItems && React.createElement(\"span\", {\n className: \"publish-library-note publish-library-warning\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.republishWarning\")), renderLibraryItems(), React.createElement(\"div\", {\n className: \"publish-library__fields\"\n }, React.createElement(\"label\", null, React.createElement(\"div\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.libraryName\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"name\",\n required: true,\n value: libraryData.name,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.libraryName\")\n })), React.createElement(\"label\", {\n style: {\n alignItems: \"flex-start\"\n }\n }, React.createElement(\"div\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.libraryDesc\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"textarea\", {\n name: \"description\",\n rows: 4,\n required: true,\n value: libraryData.description,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.libraryDesc\")\n })), React.createElement(\"label\", null, React.createElement(\"div\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.authorName\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"authorName\",\n required: true,\n value: libraryData.authorName,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.authorName\")\n })), React.createElement(\"label\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.githubUsername\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"githubHandle\",\n value: libraryData.githubHandle,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.githubHandle\")\n })), React.createElement(\"label\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.twitterUsername\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"twitterHandle\",\n value: libraryData.twitterHandle,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.twitterHandle\")\n })), React.createElement(\"label\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.website\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"website\",\n pattern: \"https?://.+\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.errors.website\"),\n value: libraryData.website,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.website\")\n })), React.createElement(\"span\", {\n className: \"publish-library-note\"\n }, React.createElement(_Trans__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n i18nKey: \"publishDialog.noteLicense\",\n link: el => React.createElement(\"a\", {\n href: \"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n }, el)\n }))), React.createElement(\"div\", {\n className: \"publish-library__buttons\"\n }, React.createElement(_DialogActionButton__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.cancel\"),\n onClick: onDialogClose,\n \"data-testid\": \"cancel-clear-canvas-button\"\n }), React.createElement(_DialogActionButton__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n type: \"submit\",\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.submit\"),\n actionType: \"primary\",\n isLoading: isSubmitting\n }))) : React.createElement(\"p\", {\n style: {\n padding: \"1em\",\n textAlign: \"center\",\n fontWeight: 500\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.atleastOneLibItem\")));\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PublishLibrary);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/PublishLibrary.tsx?");
|
|
15481
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/utils/export */ \"../utils/src/export.ts\");\n/* harmony import */ var open_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! open-color */ \"../../node_modules/open-color/open-color.json\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../data/EditorLocalStorage */ \"./data/EditorLocalStorage.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _Dialog__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Dialog */ \"./components/Dialog.tsx\");\n/* harmony import */ var _DialogActionButton__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./DialogActionButton */ \"./components/DialogActionButton.tsx\");\n/* harmony import */ var _ToolButton__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _Trans__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Trans */ \"./components/Trans.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _PublishLibrary_scss__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./PublishLibrary.scss */ \"./components/PublishLibrary.scss\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst generatePreviewImage = async libraryItems => {\n const MAX_ITEMS_PER_ROW = 6;\n const BOX_SIZE = 128;\n const BOX_PADDING = Math.round(BOX_SIZE / 16);\n const BORDER_WIDTH = Math.max(Math.round(BOX_SIZE / 64), 2);\n const rows = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.chunk)(libraryItems, MAX_ITEMS_PER_ROW);\n const canvas = document.createElement(\"canvas\");\n canvas.width = rows[0].length * BOX_SIZE + (rows[0].length + 1) * (BOX_PADDING * 2) - BOX_PADDING * 2;\n canvas.height = rows.length * BOX_SIZE + (rows.length + 1) * (BOX_PADDING * 2) - BOX_PADDING * 2;\n const ctx = canvas.getContext(\"2d\");\n ctx.fillStyle = open_color__WEBPACK_IMPORTED_MODULE_1__.white;\n ctx.fillRect(0, 0, canvas.width, canvas.height); // draw items\n // ---------------------------------------------------------------------------\n\n for (const [index, item] of libraryItems.entries()) {\n const itemCanvas = await (0,_excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_0__.exportToCanvas)({\n elements: item.elements,\n files: null,\n maxWidthOrHeight: BOX_SIZE\n });\n const {\n width,\n height\n } = itemCanvas; // draw item\n // -------------------------------------------------------------------------\n\n const rowOffset = Math.floor(index / MAX_ITEMS_PER_ROW) * (BOX_SIZE + BOX_PADDING * 2);\n const colOffset = index % MAX_ITEMS_PER_ROW * (BOX_SIZE + BOX_PADDING * 2);\n ctx.drawImage(itemCanvas, colOffset + (BOX_SIZE - width) / 2 + BOX_PADDING, rowOffset + (BOX_SIZE - height) / 2 + BOX_PADDING); // draw item border\n // -------------------------------------------------------------------------\n\n ctx.lineWidth = BORDER_WIDTH;\n ctx.strokeStyle = open_color__WEBPACK_IMPORTED_MODULE_1__.gray[4];\n ctx.strokeRect(colOffset + BOX_PADDING / 2, rowOffset + BOX_PADDING / 2, BOX_SIZE + BOX_PADDING, BOX_SIZE + BOX_PADDING);\n }\n\n return await (0,_data_blob__WEBPACK_IMPORTED_MODULE_5__.resizeImageFile)(new File([await (0,_data_blob__WEBPACK_IMPORTED_MODULE_5__.canvasToBlob)(canvas)], \"preview\", {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.MIME_TYPES.png\n }), {\n outputType: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.MIME_TYPES.jpg,\n maxWidthOrHeight: 5000\n });\n};\n\nconst SingleLibraryItem = ({\n libItem,\n appState,\n index,\n onChange,\n onRemove\n}) => {\n const svgRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);\n const inputRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n const node = svgRef.current;\n\n if (!node) {\n return;\n }\n\n (async () => {\n const svg = await (0,_excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_0__.exportToSvg)({\n elements: libItem.elements,\n appState: Object.assign(Object.assign({}, appState), {\n viewBackgroundColor: open_color__WEBPACK_IMPORTED_MODULE_1__.white,\n exportBackground: true\n }),\n files: null,\n skipInliningFonts: true\n });\n node.innerHTML = svg.outerHTML;\n })();\n }, [libItem.elements, appState]);\n return React.createElement(\"div\", {\n className: \"single-library-item\"\n }, libItem.status === \"published\" && React.createElement(\"span\", {\n className: \"single-library-item-status\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"labels.statusPublished\")), React.createElement(\"div\", {\n ref: svgRef,\n className: \"single-library-item__svg\"\n }), React.createElement(_ToolButton__WEBPACK_IMPORTED_MODULE_9__.ToolButton, {\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.remove\"),\n type: \"button\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_11__.CloseIcon,\n className: \"single-library-item--remove\",\n onClick: onRemove.bind(null, libItem.id),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.remove\")\n }), React.createElement(\"div\", {\n style: {\n display: \"flex\",\n margin: \"0.8rem 0\",\n width: \"100%\",\n fontSize: \"14px\",\n fontWeight: 500,\n flexDirection: \"column\"\n }\n }, React.createElement(\"label\", {\n style: {\n display: \"flex\",\n justifyContent: \"space-between\",\n flexDirection: \"column\"\n }\n }, React.createElement(\"div\", {\n style: {\n padding: \"0.5em 0\"\n }\n }, React.createElement(\"span\", {\n style: {\n fontWeight: 500,\n color: open_color__WEBPACK_IMPORTED_MODULE_1__.gray[6]\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.itemName\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"input\", {\n type: \"text\",\n ref: inputRef,\n style: {\n width: \"80%\",\n padding: \"0.2rem\"\n },\n defaultValue: libItem.name,\n placeholder: \"Item name\",\n onChange: event => {\n onChange(event.target.value, index);\n }\n })), React.createElement(\"span\", {\n className: \"error\"\n }, libItem.error)));\n};\n\nconst PublishLibrary = ({\n onClose,\n libraryItems,\n appState,\n onSuccess,\n onError,\n updateItemsInStorage,\n onRemove\n}) => {\n const [libraryData, setLibraryData] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)({\n authorName: \"\",\n githubHandle: \"\",\n name: \"\",\n description: \"\",\n twitterHandle: \"\",\n website: \"\"\n });\n const [isSubmitting, setIsSubmitting] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(false);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n const data = _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__.EditorLocalStorage.get(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EDITOR_LS_KEYS.PUBLISH_LIBRARY);\n\n if (data) {\n setLibraryData(data);\n }\n }, []);\n const [clonedLibItems, setClonedLibItems] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(libraryItems.slice());\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n setClonedLibItems(libraryItems.slice());\n }, [libraryItems]);\n\n const onInputChange = event => {\n setLibraryData(Object.assign(Object.assign({}, libraryData), {\n [event.target.name]: event.target.value\n }));\n };\n\n const onSubmit = async event => {\n event.preventDefault();\n setIsSubmitting(true);\n const erroredLibItems = [];\n let isError = false;\n clonedLibItems.forEach(libItem => {\n let error = \"\";\n\n if (!libItem.name) {\n error = (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.errors.required\");\n isError = true;\n }\n\n erroredLibItems.push(Object.assign(Object.assign({}, libItem), {\n error\n }));\n });\n\n if (isError) {\n setClonedLibItems(erroredLibItems);\n setIsSubmitting(false);\n return;\n }\n\n const previewImage = await generatePreviewImage(clonedLibItems);\n const libContent = {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EXPORT_DATA_TYPES.excalidrawLibrary,\n version: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.VERSIONS.excalidrawLibrary,\n source: _excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EXPORT_SOURCE,\n libraryItems: clonedLibItems\n };\n const content = JSON.stringify(libContent, null, 2);\n const lib = new Blob([content], {\n type: \"application/json\"\n });\n const formData = new FormData();\n formData.append(\"excalidrawLib\", lib);\n formData.append(\"previewImage\", previewImage);\n formData.append(\"previewImageType\", previewImage.type);\n formData.append(\"title\", libraryData.name);\n formData.append(\"authorName\", libraryData.authorName);\n formData.append(\"githubHandle\", libraryData.githubHandle);\n formData.append(\"name\", libraryData.name);\n formData.append(\"description\", libraryData.description);\n formData.append(\"twitterHandle\", libraryData.twitterHandle);\n formData.append(\"website\", libraryData.website);\n fetch(`${\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\"}/submit`, {\n method: \"post\",\n body: formData\n }).then(response => {\n if (response.ok) {\n return response.json().then(({\n url\n }) => {\n // flush data from local storage\n _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__.EditorLocalStorage.delete(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EDITOR_LS_KEYS.PUBLISH_LIBRARY);\n onSuccess({\n url,\n authorName: libraryData.authorName,\n items: clonedLibItems\n });\n });\n }\n\n return response.json().catch(() => {\n throw new Error(response.statusText || \"something went wrong\");\n }).then(error => {\n throw new Error(error.message || response.statusText || \"something went wrong\");\n });\n }, err => {\n console.error(err);\n onError(err);\n setIsSubmitting(false);\n }).catch(err => {\n console.error(err);\n onError(err);\n setIsSubmitting(false);\n });\n };\n\n const renderLibraryItems = () => {\n const items = [];\n clonedLibItems.forEach((libItem, index) => {\n items.push(React.createElement(\"div\", {\n className: \"single-library-item-wrapper\",\n key: index\n }, React.createElement(SingleLibraryItem, {\n libItem: libItem,\n appState: appState,\n index: index,\n onChange: (val, index) => {\n const items = clonedLibItems.slice();\n items[index].name = val;\n setClonedLibItems(items);\n },\n onRemove: onRemove\n })));\n });\n return React.createElement(\"div\", {\n className: \"selected-library-items\"\n }, items);\n };\n\n const onDialogClose = (0,react__WEBPACK_IMPORTED_MODULE_2__.useCallback)(() => {\n updateItemsInStorage(clonedLibItems);\n _data_EditorLocalStorage__WEBPACK_IMPORTED_MODULE_4__.EditorLocalStorage.set(_excalidraw_common__WEBPACK_IMPORTED_MODULE_3__.EDITOR_LS_KEYS.PUBLISH_LIBRARY, libraryData);\n onClose();\n }, [clonedLibItems, onClose, updateItemsInStorage, libraryData]);\n const shouldRenderForm = !!libraryItems.length;\n const containsPublishedItems = libraryItems.some(item => item.status === \"published\");\n return React.createElement(_Dialog__WEBPACK_IMPORTED_MODULE_7__.Dialog, {\n onCloseRequest: onDialogClose,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.title\"),\n className: \"publish-library\"\n }, shouldRenderForm ? React.createElement(\"form\", {\n onSubmit: onSubmit\n }, React.createElement(\"div\", {\n className: \"publish-library-note\"\n }, React.createElement(_Trans__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n i18nKey: \"publishDialog.noteDescription\",\n link: el => React.createElement(\"a\", {\n href: \"https://libraries.excalidraw.com\",\n target: \"_blank\",\n rel: \"noopener\"\n }, el)\n })), React.createElement(\"span\", {\n className: \"publish-library-note\"\n }, React.createElement(_Trans__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n i18nKey: \"publishDialog.noteGuidelines\",\n link: el => React.createElement(\"a\", {\n href: \"https://github.com/excalidraw/excalidraw-libraries#guidelines\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n }, el)\n })), React.createElement(\"div\", {\n className: \"publish-library-note\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.noteItems\")), containsPublishedItems && React.createElement(\"span\", {\n className: \"publish-library-note publish-library-warning\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.republishWarning\")), renderLibraryItems(), React.createElement(\"div\", {\n className: \"publish-library__fields\"\n }, React.createElement(\"label\", null, React.createElement(\"div\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.libraryName\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"name\",\n required: true,\n value: libraryData.name,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.libraryName\")\n })), React.createElement(\"label\", {\n style: {\n alignItems: \"flex-start\"\n }\n }, React.createElement(\"div\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.libraryDesc\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"textarea\", {\n name: \"description\",\n rows: 4,\n required: true,\n value: libraryData.description,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.libraryDesc\")\n })), React.createElement(\"label\", null, React.createElement(\"div\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.authorName\")), React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"required\"\n }, \"*\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"authorName\",\n required: true,\n value: libraryData.authorName,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.authorName\")\n })), React.createElement(\"label\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.githubUsername\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"githubHandle\",\n value: libraryData.githubHandle,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.githubHandle\")\n })), React.createElement(\"label\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.twitterUsername\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"twitterHandle\",\n value: libraryData.twitterHandle,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.twitterHandle\")\n })), React.createElement(\"label\", null, React.createElement(\"span\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.website\")), React.createElement(\"input\", {\n type: \"text\",\n name: \"website\",\n pattern: \"https?://.+\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.errors.website\"),\n value: libraryData.website,\n onChange: onInputChange,\n placeholder: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.placeholder.website\")\n })), React.createElement(\"span\", {\n className: \"publish-library-note\"\n }, React.createElement(_Trans__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n i18nKey: \"publishDialog.noteLicense\",\n link: el => React.createElement(\"a\", {\n href: \"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE\",\n target: \"_blank\",\n rel: \"noopener noreferrer\"\n }, el)\n }))), React.createElement(\"div\", {\n className: \"publish-library__buttons\"\n }, React.createElement(_DialogActionButton__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.cancel\"),\n onClick: onDialogClose,\n \"data-testid\": \"cancel-clear-canvas-button\"\n }), React.createElement(_DialogActionButton__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n type: \"submit\",\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"buttons.submit\"),\n actionType: \"primary\",\n isLoading: isSubmitting\n }))) : React.createElement(\"p\", {\n style: {\n padding: \"1em\",\n textAlign: \"center\",\n fontWeight: 500\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"publishDialog.atleastOneLibItem\")));\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PublishLibrary);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/PublishLibrary.tsx?");
|
|
15449
15482
|
|
|
15450
15483
|
/***/ }),
|
|
15451
15484
|
|
|
@@ -15753,7 +15786,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
15753
15786
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
15754
15787
|
|
|
15755
15788
|
"use strict";
|
|
15756
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\n/* harmony import */ var
|
|
15789
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\n/* harmony import */ var _element_src_binding__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../element/src/binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _DragInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DragInput */ \"./components/Stats/DragInput.tsx\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils */ \"./components/Stats/utils.ts\");\n\n\n\n\n\n\n\nconst STEP_SIZE = 15;\n\nconst handleDegreeChange = ({\n accumulatedChange,\n originalElements,\n shouldChangeByStepSize,\n nextValue,\n scene\n}) => {\n const elementsMap = scene.getNonDeletedElementsMap();\n const origElement = originalElements[0];\n\n if (origElement && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isElbowArrow)(origElement)) {\n const latestElement = elementsMap.get(origElement.id);\n\n if (!latestElement) {\n return;\n }\n\n if (nextValue !== undefined) {\n const nextAngle = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.degreesToRadians)(nextValue);\n scene.mutateElement(latestElement, {\n angle: nextAngle\n });\n (0,_element_src_binding__WEBPACK_IMPORTED_MODULE_4__.updateBindings)(latestElement, scene);\n const boundTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(latestElement, elementsMap);\n\n if (boundTextElement && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(latestElement)) {\n scene.mutateElement(boundTextElement, {\n angle: nextAngle\n });\n }\n\n return;\n }\n\n const originalAngleInDegrees = Math.round((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.radiansToDegrees)(origElement.angle) * 100) / 100;\n const changeInDegrees = Math.round(accumulatedChange);\n let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;\n\n if (shouldChangeByStepSize) {\n nextAngleInDegrees = (0,_utils__WEBPACK_IMPORTED_MODULE_6__.getStepSizedValue)(nextAngleInDegrees, STEP_SIZE);\n }\n\n nextAngleInDegrees = nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;\n const nextAngle = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.degreesToRadians)(nextAngleInDegrees);\n scene.mutateElement(latestElement, {\n angle: nextAngle\n });\n (0,_element_src_binding__WEBPACK_IMPORTED_MODULE_4__.updateBindings)(latestElement, scene);\n const boundTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(latestElement, elementsMap);\n\n if (boundTextElement && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(latestElement)) {\n scene.mutateElement(boundTextElement, {\n angle: nextAngle\n });\n }\n }\n};\n\nconst Angle = ({\n element,\n scene,\n appState,\n property\n}) => {\n return React.createElement(_DragInput__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n label: \"A\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_3__.angleIcon,\n value: Math.round((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.radiansToDegrees)(element.angle) % 360 * 100) / 100,\n elements: [element],\n dragInputCallback: handleDegreeChange,\n editable: (0,_utils__WEBPACK_IMPORTED_MODULE_6__.isPropertyEditable)(element, \"angle\"),\n scene: scene,\n appState: appState,\n property: property\n });\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Angle);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/Stats/Angle.tsx?");
|
|
15757
15790
|
|
|
15758
15791
|
/***/ }),
|
|
15759
15792
|
|
|
@@ -15874,7 +15907,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
15874
15907
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
15875
15908
|
|
|
15876
15909
|
"use strict";
|
|
15877
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _DragInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./DragInput */ \"./components/Stats/DragInput.tsx\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ \"./components/Stats/utils.ts\");\n\n\n\n\n\n\n\
|
|
15910
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _DragInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./DragInput */ \"./components/Stats/DragInput.tsx\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ \"./components/Stats/utils.ts\");\n\n\n\n\n\n\n\n\nconst moveElements = (property, changeInTopX, changeInTopY, originalElements, originalElementsMap, scene) => {\n for (let i = 0; i < originalElements.length; i++) {\n const origElement = originalElements[i];\n const [cx, cy] = [origElement.x + origElement.width / 2, origElement.y + origElement.height / 2];\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(origElement.x, origElement.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), origElement.angle);\n const newTopLeftX = property === \"x\" ? Math.round(topLeftX + changeInTopX) : topLeftX;\n const newTopLeftY = property === \"y\" ? Math.round(topLeftY + changeInTopY) : topLeftY;\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.moveElement)(newTopLeftX, newTopLeftY, origElement, scene, originalElementsMap, false);\n }\n};\n\nconst moveGroupTo = (nextX, nextY, originalElements, originalElementsMap, scene) => {\n const elementsMap = scene.getNonDeletedElementsMap();\n const [x1, y1,,] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_3__.getCommonBounds)(originalElements);\n const offsetX = nextX - x1;\n const offsetY = nextY - y1;\n\n for (let i = 0; i < originalElements.length; i++) {\n const origElement = originalElements[i];\n const latestElement = elementsMap.get(origElement.id);\n\n if (!latestElement) {\n continue;\n } // bound texts are moved with their containers\n\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(latestElement) || !latestElement.containerId) {\n const [cx, cy] = [latestElement.x + latestElement.width / 2, latestElement.y + latestElement.height / 2];\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(latestElement.x, latestElement.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), latestElement.angle);\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.moveElement)(topLeftX + offsetX, topLeftY + offsetY, origElement, scene, originalElementsMap, false);\n }\n }\n};\n\nconst handlePositionChange = ({\n accumulatedChange,\n originalElements,\n originalElementsMap,\n shouldChangeByStepSize,\n nextValue,\n property,\n scene,\n originalAppState\n}) => {\n var _a, _b;\n\n const elementsMap = scene.getNonDeletedElementsMap();\n\n if (nextValue !== undefined) {\n for (const atomicUnit of (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getAtomicUnits)(originalElements, originalAppState)) {\n const elementsInUnit = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getElementsInAtomicUnit)(atomicUnit, elementsMap, originalElementsMap);\n\n if (elementsInUnit.length > 1) {\n const [x1, y1,,] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_3__.getCommonBounds)(elementsInUnit.map(el => el.latest));\n const newTopLeftX = property === \"x\" ? nextValue : x1;\n const newTopLeftY = property === \"y\" ? nextValue : y1;\n moveGroupTo(newTopLeftX, newTopLeftY, elementsInUnit.map(el => el.original), originalElementsMap, scene);\n } else {\n const origElement = (_a = elementsInUnit[0]) === null || _a === void 0 ? void 0 : _a.original;\n const latestElement = (_b = elementsInUnit[0]) === null || _b === void 0 ? void 0 : _b.latest;\n\n if (origElement && latestElement && (0,_utils__WEBPACK_IMPORTED_MODULE_5__.isPropertyEditable)(latestElement, property)) {\n const [cx, cy] = [origElement.x + origElement.width / 2, origElement.y + origElement.height / 2];\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(origElement.x, origElement.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), origElement.angle);\n const newTopLeftX = property === \"x\" ? nextValue : topLeftX;\n const newTopLeftY = property === \"y\" ? nextValue : topLeftY;\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.moveElement)(newTopLeftX, newTopLeftY, origElement, scene, originalElementsMap, false);\n }\n }\n }\n\n scene.triggerUpdate();\n return;\n }\n\n const change = shouldChangeByStepSize ? (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getStepSizedValue)(accumulatedChange, _utils__WEBPACK_IMPORTED_MODULE_5__.STEP_SIZE) : accumulatedChange;\n const changeInTopX = property === \"x\" ? change : 0;\n const changeInTopY = property === \"y\" ? change : 0;\n moveElements(property, changeInTopX, changeInTopY, originalElements, originalElementsMap, scene);\n scene.triggerUpdate();\n};\n\nconst MultiPosition = ({\n property,\n elements,\n elementsMap,\n atomicUnits,\n scene,\n appState\n}) => {\n const positions = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(() => atomicUnits.map(atomicUnit => {\n const elementsInUnit = Object.keys(atomicUnit).map(id => elementsMap.get(id)).filter(el => el !== undefined); // we're dealing with a group\n\n if (elementsInUnit.length > 1) {\n const [x1, y1] = (0,_excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_3__.getCommonBounds)(elementsInUnit);\n return Math.round((property === \"x\" ? x1 : y1) * 100) / 100;\n }\n\n const [el] = elementsInUnit;\n const [cx, cy] = [el.x + el.width / 2, el.y + el.height / 2];\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(el.x, el.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), el.angle);\n return Math.round((property === \"x\" ? topLeftX : topLeftY) * 100) / 100;\n }), [atomicUnits, elementsMap, property]);\n const value = new Set(positions).size === 1 ? positions[0] : \"Mixed\";\n return React.createElement(_DragInput__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n label: property === \"x\" ? \"X\" : \"Y\",\n elements: elements,\n dragInputCallback: handlePositionChange,\n value: value,\n property: property,\n scene: scene,\n appState: appState\n });\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MultiPosition);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/Stats/MultiPosition.tsx?");
|
|
15878
15911
|
|
|
15879
15912
|
/***/ }),
|
|
15880
15913
|
|
|
@@ -15885,7 +15918,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
15885
15918
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
15886
15919
|
|
|
15887
15920
|
"use strict";
|
|
15888
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _DragInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DragInput */ \"./components/Stats/DragInput.tsx\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./components/Stats/utils.ts\");\n\n\n\n\n\
|
|
15921
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _DragInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DragInput */ \"./components/Stats/DragInput.tsx\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./components/Stats/utils.ts\");\n\n\n\n\n\n\nconst handlePositionChange = ({\n accumulatedChange,\n instantChange,\n originalElements,\n originalElementsMap,\n shouldChangeByStepSize,\n nextValue,\n property,\n scene,\n originalAppState\n}) => {\n const elementsMap = scene.getNonDeletedElementsMap();\n const origElement = originalElements[0];\n const [cx, cy] = [origElement.x + origElement.width / 2, origElement.y + origElement.height / 2];\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(origElement.x, origElement.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), origElement.angle);\n\n if (originalAppState.croppingElementId === origElement.id) {\n const element = elementsMap.get(origElement.id);\n\n if (!element || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isImageElement)(element) || !element.crop) {\n return;\n }\n\n const crop = element.crop;\n let nextCrop = crop;\n const isFlippedByX = element.scale[0] === -1;\n const isFlippedByY = element.scale[1] === -1;\n const {\n width: uncroppedWidth,\n height: uncroppedHeight\n } = (0,_excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_1__.getUncroppedWidthAndHeight)(element);\n\n if (nextValue !== undefined) {\n if (property === \"x\") {\n const nextValueInNatural = nextValue * (crop.naturalWidth / uncroppedWidth);\n\n if (isFlippedByX) {\n nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(crop.naturalWidth - nextValueInNatural - crop.width, 0, crop.naturalWidth - crop.width)\n });\n } else {\n nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(nextValue * (crop.naturalWidth / uncroppedWidth), 0, crop.naturalWidth - crop.width)\n });\n }\n }\n\n if (property === \"y\") {\n nextCrop = Object.assign(Object.assign({}, crop), {\n y: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(nextValue * (crop.naturalHeight / uncroppedHeight), 0, crop.naturalHeight - crop.height)\n });\n }\n\n scene.mutateElement(element, {\n crop: nextCrop\n });\n return;\n }\n\n const changeInX = (property === \"x\" ? instantChange : 0) * (isFlippedByX ? -1 : 1);\n const changeInY = (property === \"y\" ? instantChange : 0) * (isFlippedByY ? -1 : 1);\n nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(crop.x + changeInX, 0, crop.naturalWidth - crop.width),\n y: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(crop.y + changeInY, 0, crop.naturalHeight - crop.height)\n });\n scene.mutateElement(element, {\n crop: nextCrop\n });\n return;\n }\n\n if (nextValue !== undefined) {\n const newTopLeftX = property === \"x\" ? nextValue : topLeftX;\n const newTopLeftY = property === \"y\" ? nextValue : topLeftY;\n (0,_utils__WEBPACK_IMPORTED_MODULE_4__.moveElement)(newTopLeftX, newTopLeftY, origElement, scene, originalElementsMap);\n return;\n }\n\n const changeInTopX = property === \"x\" ? accumulatedChange : 0;\n const changeInTopY = property === \"y\" ? accumulatedChange : 0;\n const newTopLeftX = property === \"x\" ? Math.round(shouldChangeByStepSize ? (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getStepSizedValue)(origElement.x + changeInTopX, _utils__WEBPACK_IMPORTED_MODULE_4__.STEP_SIZE) : topLeftX + changeInTopX) : topLeftX;\n const newTopLeftY = property === \"y\" ? Math.round(shouldChangeByStepSize ? (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getStepSizedValue)(origElement.y + changeInTopY, _utils__WEBPACK_IMPORTED_MODULE_4__.STEP_SIZE) : topLeftY + changeInTopY) : topLeftY;\n (0,_utils__WEBPACK_IMPORTED_MODULE_4__.moveElement)(newTopLeftX, newTopLeftY, origElement, scene, originalElementsMap);\n};\n\nconst Position = ({\n property,\n element,\n elementsMap,\n scene,\n appState\n}) => {\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(element.x, element.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(element.x + element.width / 2, element.y + element.height / 2), element.angle);\n let value = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.round)(property === \"x\" ? topLeftX : topLeftY, 2);\n\n if (appState.croppingElementId === element.id && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isImageElement)(element) && element.crop) {\n const flipAdjustedPosition = (0,_excalidraw_element_cropElement__WEBPACK_IMPORTED_MODULE_1__.getFlipAdjustedCropPosition)(element);\n\n if (flipAdjustedPosition) {\n value = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.round)(property === \"x\" ? flipAdjustedPosition.x : flipAdjustedPosition.y, 2);\n }\n }\n\n return React.createElement(_DragInput__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n label: property === \"x\" ? \"X\" : \"Y\",\n elements: [element],\n dragInputCallback: handlePositionChange,\n scene: scene,\n value: value,\n property: property,\n appState: appState\n });\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Position);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/Stats/Position.tsx?");
|
|
15889
15922
|
|
|
15890
15923
|
/***/ }),
|
|
15891
15924
|
|
|
@@ -15918,7 +15951,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
15918
15951
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
15919
15952
|
|
|
15920
15953
|
"use strict";
|
|
15921
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SMALLEST_DELTA: () => (/* binding */ SMALLEST_DELTA),\n/* harmony export */
|
|
15954
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SMALLEST_DELTA: () => (/* binding */ SMALLEST_DELTA),\n/* harmony export */ STEP_SIZE: () => (/* binding */ STEP_SIZE),\n/* harmony export */ getAtomicUnits: () => (/* binding */ getAtomicUnits),\n/* harmony export */ getElementsInAtomicUnit: () => (/* binding */ getElementsInAtomicUnit),\n/* harmony export */ getStepSizedValue: () => (/* binding */ getStepSizedValue),\n/* harmony export */ isPropertyEditable: () => (/* binding */ isPropertyEditable),\n/* harmony export */ moveElement: () => (/* binding */ moveElement),\n/* harmony export */ newOrigin: () => (/* binding */ newOrigin)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/element/frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _element_src_binding__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../element/src/binding */ \"../element/src/binding.ts\");\n\n\n\n\n\n\nconst SMALLEST_DELTA = 0.01;\nconst STEP_SIZE = 10;\nconst isPropertyEditable = (element, property) => {\n if (property === \"height\" && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(element)) {\n return false;\n }\n\n if (property === \"width\" && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(element)) {\n return false;\n }\n\n if (property === \"angle\" && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(element)) {\n return false;\n }\n\n return true;\n};\nconst getStepSizedValue = (value, stepSize) => {\n const v = value + stepSize / 2;\n return v - v % stepSize;\n};\nconst getElementsInAtomicUnit = (atomicUnit, elementsMap, originalElementsMap) => {\n return Object.keys(atomicUnit).map(id => ({\n original: (originalElementsMap !== null && originalElementsMap !== void 0 ? originalElementsMap : elementsMap).get(id),\n latest: elementsMap.get(id)\n })).filter(el => el.original !== undefined && el.latest !== undefined);\n};\nconst newOrigin = (x1, y1, w1, h1, w2, h2, angle) => {\n /**\r\n * The formula below is the result of solving\r\n * rotate(x1, y1, cx1, cy1, angle) = rotate(x2, y2, cx2, cy2, angle)\r\n * where rotate is the function defined in math.ts\r\n *\r\n * This is so that the new origin (x2, y2),\r\n * when rotated against the new center (cx2, cy2),\r\n * coincides with (x1, y1) rotated against (cx1, cy1)\r\n *\r\n * The reason for doing this computation is so the element's top left corner\r\n * on the canvas remains fixed after any changes in its dimension.\r\n */\n return {\n x: x1 + (w1 - w2) / 2 + (w2 - w1) / 2 * Math.cos(angle) + (h1 - h2) / 2 * Math.sin(angle),\n y: y1 + (h1 - h2) / 2 + (w2 - w1) / 2 * Math.sin(angle) + (h2 - h1) / 2 * Math.cos(angle)\n };\n};\nconst moveElement = (newTopLeftX, newTopLeftY, originalElement, scene, originalElementsMap, shouldInformMutation = true) => {\n const elementsMap = scene.getNonDeletedElementsMap();\n const latestElement = elementsMap.get(originalElement.id);\n\n if (!latestElement) {\n return;\n }\n\n const [cx, cy] = [originalElement.x + originalElement.width / 2, originalElement.y + originalElement.height / 2];\n const [topLeftX, topLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(originalElement.x, originalElement.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), originalElement.angle);\n const changeInX = newTopLeftX - topLeftX;\n const changeInY = newTopLeftY - topLeftY;\n const [x, y] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(newTopLeftX, newTopLeftY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx + changeInX, cy + changeInY), -originalElement.angle);\n scene.mutateElement(latestElement, {\n x,\n y\n }, {\n informMutation: shouldInformMutation,\n isDragging: false\n });\n (0,_element_src_binding__WEBPACK_IMPORTED_MODULE_5__.updateBindings)(latestElement, scene);\n const boundTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(originalElement, originalElementsMap);\n\n if (boundTextElement) {\n const latestBoundTextElement = elementsMap.get(boundTextElement.id);\n latestBoundTextElement && scene.mutateElement(latestBoundTextElement, {\n x: boundTextElement.x + changeInX,\n y: boundTextElement.y + changeInY\n }, {\n informMutation: shouldInformMutation,\n isDragging: false\n });\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(originalElement)) {\n const originalChildren = (0,_excalidraw_element_frame__WEBPACK_IMPORTED_MODULE_4__.getFrameChildren)(originalElementsMap, originalElement.id);\n originalChildren.forEach(child => {\n const latestChildElement = elementsMap.get(child.id);\n\n if (!latestChildElement) {\n return;\n }\n\n const [childCX, childCY] = [child.x + child.width / 2, child.y + child.height / 2];\n const [childTopLeftX, childTopLeftY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(child.x, child.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(childCX, childCY), child.angle);\n const childNewTopLeftX = Math.round(childTopLeftX + changeInX);\n const childNewTopLeftY = Math.round(childTopLeftY + changeInY);\n const [childX, childY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(childNewTopLeftX, childNewTopLeftY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(childCX + changeInX, childCY + changeInY), -child.angle);\n scene.mutateElement(latestChildElement, {\n x: childX,\n y: childY\n }, {\n informMutation: shouldInformMutation,\n isDragging: false\n });\n (0,_element_src_binding__WEBPACK_IMPORTED_MODULE_5__.updateBindings)(latestChildElement, scene, {\n simultaneouslyUpdated: originalChildren\n });\n const boundTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(latestChildElement, originalElementsMap);\n\n if (boundTextElement) {\n const latestBoundTextElement = elementsMap.get(boundTextElement.id);\n latestBoundTextElement && scene.mutateElement(latestBoundTextElement, {\n x: boundTextElement.x + changeInX,\n y: boundTextElement.y + changeInY\n }, {\n informMutation: shouldInformMutation,\n isDragging: false\n });\n }\n });\n }\n};\nconst getAtomicUnits = (targetElements, appState) => {\n const selectedGroupIds = (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_3__.getSelectedGroupIds)(appState);\n\n const _atomicUnits = selectedGroupIds.map(gid => {\n return (0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_3__.getElementsInGroup)(targetElements, gid).reduce((acc, el) => {\n acc[el.id] = true;\n return acc;\n }, {});\n });\n\n targetElements.filter(el => !(0,_excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_3__.isInGroup)(el)).forEach(el => {\n _atomicUnits.push({\n [el.id]: true\n });\n });\n return _atomicUnits;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/Stats/utils.ts?");
|
|
15922
15955
|
|
|
15923
15956
|
/***/ }),
|
|
15924
15957
|
|
|
@@ -16402,7 +16435,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
16402
16435
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
16403
16436
|
|
|
16404
16437
|
"use strict";
|
|
16405
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _DropdownMenuItemContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DropdownMenuItemContent */ \"./components/dropdownMenu/DropdownMenuItemContent.tsx\");\n/* harmony import */ var _common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./common */ \"./components/dropdownMenu/common.ts\");\nvar __rest = undefined && undefined.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\n\n\n\n\nconst DropdownMenuItemLink = _a => {\n var _b;\n\n var {\n icon,\n shortcut,\n href,\n children,\n onSelect,\n className = \"\",\n selected,\n rel = \"
|
|
16438
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _DropdownMenuItemContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DropdownMenuItemContent */ \"./components/dropdownMenu/DropdownMenuItemContent.tsx\");\n/* harmony import */ var _common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./common */ \"./components/dropdownMenu/common.ts\");\nvar __rest = undefined && undefined.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\n\n\n\n\nconst DropdownMenuItemLink = _a => {\n var _b;\n\n var {\n icon,\n shortcut,\n href,\n children,\n onSelect,\n className = \"\",\n selected,\n rel = \"noopener\"\n } = _a,\n rest = __rest(_a, [\"icon\", \"shortcut\", \"href\", \"children\", \"onSelect\", \"className\", \"selected\", \"rel\"]);\n\n const handleClick = (0,_common__WEBPACK_IMPORTED_MODULE_2__.useHandleDropdownMenuItemClick)(rest.onClick, onSelect);\n return (\n /*#__PURE__*/\n // eslint-disable-next-line react/jsx-no-target-blank\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"a\", Object.assign({}, rest, {\n href: href,\n target: \"_blank\",\n rel: rel || \"noopener\",\n className: (0,_common__WEBPACK_IMPORTED_MODULE_2__.getDropdownMenuItemClassName)(className, selected),\n title: (_b = rest.title) !== null && _b !== void 0 ? _b : rest[\"aria-label\"],\n onClick: handleClick\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_DropdownMenuItemContent__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: icon,\n shortcut: shortcut\n }, children))\n );\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DropdownMenuItemLink);\nDropdownMenuItemLink.displayName = \"DropdownMenuItemLink\";\n\n//# sourceURL=webpack://ExcalidrawLib/./components/dropdownMenu/DropdownMenuItemLink.tsx?");
|
|
16406
16439
|
|
|
16407
16440
|
/***/ }),
|
|
16408
16441
|
|
|
@@ -16611,7 +16644,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
16611
16644
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
16612
16645
|
|
|
16613
16646
|
"use strict";
|
|
16614
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Center: () => (/* binding */ Center)\n/* harmony export */ });\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _context_ui_appState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../context/ui-appState */ \"./context/ui-appState.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../i18n */ \"./i18n.ts\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../App */ \"./components/App.tsx\");\n/* harmony import */ var _ExcalidrawLogo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../ExcalidrawLogo */ \"./components/ExcalidrawLogo.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\nvar __rest = undefined && undefined.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\n\n\n\n\n\n\n\n\n\nconst WelcomeScreenMenuItemContent = ({\n icon,\n shortcut,\n children\n}) => {\n const device = (0,_App__WEBPACK_IMPORTED_MODULE_5__.useDevice)();\n return React.createElement(React.Fragment, null, React.createElement(\"div\", {\n className: \"welcome-screen-menu-item__icon\"\n }, icon), React.createElement(\"div\", {\n className: \"welcome-screen-menu-item__text\"\n }, children), shortcut && !device.editor.isMobile && React.createElement(\"div\", {\n className: \"welcome-screen-menu-item__shortcut\"\n }, shortcut));\n};\n\nWelcomeScreenMenuItemContent.displayName = \"WelcomeScreenMenuItemContent\";\n\nconst WelcomeScreenMenuItem = _a => {\n var {\n onSelect,\n children,\n icon,\n shortcut,\n className = \"\"\n } = _a,\n props = __rest(_a, [\"onSelect\", \"children\", \"icon\", \"shortcut\", \"className\"]);\n\n return React.createElement(\"button\", Object.assign({}, props, {\n type: \"button\",\n className: `welcome-screen-menu-item ${className}`,\n onClick: onSelect\n }), React.createElement(WelcomeScreenMenuItemContent, {\n icon: icon,\n shortcut: shortcut\n }, children));\n};\n\nWelcomeScreenMenuItem.displayName = \"WelcomeScreenMenuItem\";\n\nconst WelcomeScreenMenuItemLink = _a => {\n var {\n children,\n href,\n icon,\n shortcut,\n className = \"\"\n } = _a,\n props = __rest(_a, [\"children\", \"href\", \"icon\", \"shortcut\", \"className\"]);\n\n return React.createElement(\"a\", Object.assign({}, props, {\n className: `welcome-screen-menu-item ${className}`,\n href: href,\n target: \"_blank\",\n rel: \"
|
|
16647
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Center: () => (/* binding */ Center)\n/* harmony export */ });\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _context_ui_appState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../context/ui-appState */ \"./context/ui-appState.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../i18n */ \"./i18n.ts\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../App */ \"./components/App.tsx\");\n/* harmony import */ var _ExcalidrawLogo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../ExcalidrawLogo */ \"./components/ExcalidrawLogo.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\nvar __rest = undefined && undefined.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\n\n\n\n\n\n\n\n\n\nconst WelcomeScreenMenuItemContent = ({\n icon,\n shortcut,\n children\n}) => {\n const device = (0,_App__WEBPACK_IMPORTED_MODULE_5__.useDevice)();\n return React.createElement(React.Fragment, null, React.createElement(\"div\", {\n className: \"welcome-screen-menu-item__icon\"\n }, icon), React.createElement(\"div\", {\n className: \"welcome-screen-menu-item__text\"\n }, children), shortcut && !device.editor.isMobile && React.createElement(\"div\", {\n className: \"welcome-screen-menu-item__shortcut\"\n }, shortcut));\n};\n\nWelcomeScreenMenuItemContent.displayName = \"WelcomeScreenMenuItemContent\";\n\nconst WelcomeScreenMenuItem = _a => {\n var {\n onSelect,\n children,\n icon,\n shortcut,\n className = \"\"\n } = _a,\n props = __rest(_a, [\"onSelect\", \"children\", \"icon\", \"shortcut\", \"className\"]);\n\n return React.createElement(\"button\", Object.assign({}, props, {\n type: \"button\",\n className: `welcome-screen-menu-item ${className}`,\n onClick: onSelect\n }), React.createElement(WelcomeScreenMenuItemContent, {\n icon: icon,\n shortcut: shortcut\n }, children));\n};\n\nWelcomeScreenMenuItem.displayName = \"WelcomeScreenMenuItem\";\n\nconst WelcomeScreenMenuItemLink = _a => {\n var {\n children,\n href,\n icon,\n shortcut,\n className = \"\"\n } = _a,\n props = __rest(_a, [\"children\", \"href\", \"icon\", \"shortcut\", \"className\"]);\n\n return React.createElement(\"a\", Object.assign({}, props, {\n className: `welcome-screen-menu-item ${className}`,\n href: href,\n target: \"_blank\",\n rel: \"noopener\"\n }), React.createElement(WelcomeScreenMenuItemContent, {\n icon: icon,\n shortcut: shortcut\n }, children));\n};\n\nWelcomeScreenMenuItemLink.displayName = \"WelcomeScreenMenuItemLink\";\n\nconst Center = ({\n children\n}) => {\n const {\n WelcomeScreenCenterTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_2__.useTunnels)();\n return React.createElement(WelcomeScreenCenterTunnel.In, null, React.createElement(\"div\", {\n className: \"welcome-screen-center\"\n }, children || React.createElement(React.Fragment, null, React.createElement(Logo, null), React.createElement(Heading, null, (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"welcomeScreen.defaults.center_heading\")), React.createElement(Menu, null, React.createElement(MenuItemLoadScene, null), React.createElement(MenuItemHelp, null)))));\n};\n\nCenter.displayName = \"Center\";\n\nconst Logo = ({\n children\n}) => {\n return React.createElement(\"div\", {\n className: \"welcome-screen-center__logo excalifont welcome-screen-decor\"\n }, children || React.createElement(_ExcalidrawLogo__WEBPACK_IMPORTED_MODULE_6__.ExcalidrawLogo, {\n withText: true\n }));\n};\n\nLogo.displayName = \"Logo\"; //zsviczian added color\n\nconst Heading = ({\n children,\n color,\n message\n}) => {\n if (color && message) {\n return React.createElement(\"div\", {\n className: \"welcome-screen-center__heading welcome-screen-decor excalifont\",\n style: {\n color,\n marginTop: \"-1.5rem\"\n }\n }, children, React.createElement(\"div\", {\n style: {\n fontSize: \"0.7rem\"\n }\n }, message));\n }\n\n return React.createElement(\"div\", {\n className: \"welcome-screen-center__heading welcome-screen-decor excalifont\"\n }, children);\n};\n\nHeading.displayName = \"Heading\";\n\nconst Menu = ({\n children\n}) => {\n return React.createElement(\"div\", {\n className: \"welcome-screen-menu\"\n }, children);\n};\n\nMenu.displayName = \"Menu\";\n\nconst MenuItemHelp = () => {\n const actionManager = (0,_App__WEBPACK_IMPORTED_MODULE_5__.useExcalidrawActionManager)();\n return React.createElement(WelcomeScreenMenuItem, {\n onSelect: () => actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_0__.actionShortcuts),\n shortcut: \"?\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_7__.HelpIcon\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"helpDialog.title\"));\n};\n\nMenuItemHelp.displayName = \"MenuItemHelp\";\n\nconst MenuItemLoadScene = () => {\n const appState = (0,_context_ui_appState__WEBPACK_IMPORTED_MODULE_3__.useUIAppState)();\n const actionManager = (0,_App__WEBPACK_IMPORTED_MODULE_5__.useExcalidrawActionManager)();\n\n if (appState.viewModeEnabled) {\n return null;\n }\n\n return React.createElement(WelcomeScreenMenuItem, {\n onSelect: () => actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_0__.actionLoadScene),\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_1__.getShortcutFromShortcutName)(\"loadScene\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_7__.LoadIcon\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.load\"));\n};\n\nMenuItemLoadScene.displayName = \"MenuItemLoadScene\";\n\nconst MenuItemLiveCollaborationTrigger = ({\n onSelect\n}) => {\n const {\n t\n } = (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.useI18n)();\n return React.createElement(WelcomeScreenMenuItem, {\n shortcut: null,\n onSelect: onSelect,\n icon: _icons__WEBPACK_IMPORTED_MODULE_7__.usersIcon\n }, t(\"labels.liveCollaboration\"));\n};\n\nMenuItemLiveCollaborationTrigger.displayName = \"MenuItemLiveCollaborationTrigger\"; // -----------------------------------------------------------------------------\n\nCenter.Logo = Logo;\nCenter.Heading = Heading;\nCenter.Menu = Menu;\nCenter.MenuItem = WelcomeScreenMenuItem;\nCenter.MenuItemLink = WelcomeScreenMenuItemLink;\nCenter.MenuItemHelp = MenuItemHelp;\nCenter.MenuItemLoadScene = MenuItemLoadScene;\nCenter.MenuItemLiveCollaborationTrigger = MenuItemLiveCollaborationTrigger;\n\n\n//# sourceURL=webpack://ExcalidrawLib/./components/welcome-screen/WelcomeScreen.Center.tsx?");
|
|
16615
16648
|
|
|
16616
16649
|
/***/ }),
|
|
16617
16650
|
|
|
@@ -16831,7 +16864,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
16831
16864
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
16832
16865
|
|
|
16833
16866
|
"use strict";
|
|
16834
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AllowedExcalidrawActiveTools: () => (/* binding */ AllowedExcalidrawActiveTools),\n/* harmony export */ restore: () => (/* binding */ restore),\n/* harmony export */ restoreAppState: () => (/* binding */ restoreAppState),\n/* harmony export */ restoreElements: () => (/* binding */ restoreElements),\n/* harmony export */ restoreLibraryItems: () => (/* binding */ restoreLibraryItems)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/element/elbowArrow */ \"../element/src/elbowArrow.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @excalidraw/element/fractionalIndex */ \"../element/src/fractionalIndex.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @excalidraw/element/sizeHelpers */ \"../element/src/sizeHelpers.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst AllowedExcalidrawActiveTools = {\n selection: true,\n lasso: true,\n text: true,\n rectangle: true,\n diamond: true,\n ellipse: true,\n line: true,\n image: true,\n arrow: true,\n freedraw: true,\n eraser: false,\n custom: true,\n frame: true,\n embeddable: true,\n hand: true,\n mermaid: true,\n laser: false,\n magicframe: false\n};\n\nconst getFontFamilyByName = fontFamilyName => {\n if (Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY).includes(fontFamilyName)) {\n return _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY[fontFamilyName];\n }\n\n return _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_FONT_FAMILY;\n};\n\nconst repairBinding = (element, binding) => {\n var _a;\n\n if (!binding) {\n return null;\n }\n\n const focus = binding.focus || 0;\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element)) {\n const fixedPointBinding = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isFixedPointBinding)(binding) ? Object.assign(Object.assign({}, binding), {\n focus,\n fixedPoint: (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_3__.normalizeFixedPoint)((_a = binding.fixedPoint) !== null && _a !== void 0 ? _a : [0, 0])\n }) : null;\n return fixedPointBinding;\n }\n\n return Object.assign(Object.assign({}, binding), {\n focus\n });\n};\n\nconst restoreElementWithProperties = (element, extra) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const base = {\n type: extra.type || element.type,\n // all elements must have version > 0 so getSceneVersion() will pick up\n // newly added elements\n version: element.version || 1,\n versionNonce: (_a = element.versionNonce) !== null && _a !== void 0 ? _a : 0,\n index: (_b = element.index) !== null && _b !== void 0 ? _b : null,\n isDeleted: (_c = element.isDeleted) !== null && _c !== void 0 ? _c : false,\n id: element.id || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)(),\n fillStyle: element.fillStyle || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.fillStyle,\n strokeWidth: element.strokeWidth || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.strokeWidth,\n strokeStyle: (_d = element.strokeStyle) !== null && _d !== void 0 ? _d : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.strokeStyle,\n roughness: (_e = element.roughness) !== null && _e !== void 0 ? _e : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.roughness,\n opacity: element.opacity == null ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.opacity : element.opacity,\n angle: element.angle || 0,\n x: (_g = (_f = extra.x) !== null && _f !== void 0 ? _f : element.x) !== null && _g !== void 0 ? _g : 0,\n y: (_j = (_h = extra.y) !== null && _h !== void 0 ? _h : element.y) !== null && _j !== void 0 ? _j : 0,\n strokeColor: element.strokeColor || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.strokeColor,\n backgroundColor: element.backgroundColor || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.backgroundColor,\n width: element.width || 0,\n height: element.height || 0,\n seed: (_k = element.seed) !== null && _k !== void 0 ? _k : 1,\n groupIds: (_l = element.groupIds) !== null && _l !== void 0 ? _l : [],\n frameId: (_m = element.frameId) !== null && _m !== void 0 ? _m : null,\n roundness: element.roundness ? element.roundness : element.strokeSharpness === \"round\" && element.type !== \"image\" ? {\n // for old elements that would now use adaptive radius algo,\n // use legacy algo instead\n type: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isUsingAdaptiveRadius)(element.type) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.ROUNDNESS.LEGACY : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n boundElements: element.boundElementIds ? element.boundElementIds.map(id => ({\n type: \"arrow\",\n id\n })) : (_o = element.boundElements) !== null && _o !== void 0 ? _o : [],\n updated: (_p = element.updated) !== null && _p !== void 0 ? _p : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getUpdatedTimestamp)(),\n link: element.link ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.normalizeLink)(element.link) : null,\n locked: (_q = element.locked) !== null && _q !== void 0 ? _q : false\n };\n\n if (\"customData\" in element || \"customData\" in extra) {\n base.customData = \"customData\" in extra ? extra.customData : element.customData;\n }\n\n const ret = Object.assign(Object.assign(Object.assign(Object.assign({}, element), base), (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_12__.getNormalizedDimensions)(base)), extra); // strip legacy props (migrated in previous steps)\n\n delete ret.strokeSharpness;\n delete ret.boundElementIds;\n return ret;\n};\n\nconst restoreElement = element => {\n var _a, _b, _c, _d, _e, _f;\n\n element = Object.assign({}, element);\n\n switch (element.type) {\n case \"text\":\n // temp fix: cleanup legacy obsidian-excalidraw attribute else it'll\n // conflict when porting between the apps\n //delete (element as any).rawText; //zsviczian\n let fontSize = element.fontSize;\n let fontFamily = element.fontFamily;\n\n if (\"font\" in element) {\n const [fontPx, _fontFamily] = element.font.split(\" \");\n fontSize = parseFloat(fontPx);\n fontFamily = getFontFamilyByName(_fontFamily);\n }\n\n const text = typeof element.text === \"string\" && element.text || \"\"; // line-height might not be specified either when creating elements\n // programmatically, or when importing old diagrams.\n // For the latter we want to detect the original line height which\n // will likely differ from our per-font fixed line height we now use,\n // to maintain backward compatibility.\n\n const lineHeight = element.lineHeight || (element.height ? // detect line-height from current element height and font-size\n (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__.detectLineHeight)(element) : // no element height likely means programmatic use, so default\n // to a fixed line height\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getLineHeight)(element.fontFamily));\n element = restoreElementWithProperties(element, {\n fontSize,\n fontFamily,\n text,\n rawText: (_a = element.rawText) !== null && _a !== void 0 ? _a : \"\",\n textAlign: element.textAlign || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_TEXT_ALIGN,\n verticalAlign: element.verticalAlign || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_VERTICAL_ALIGN,\n containerId: (_b = element.containerId) !== null && _b !== void 0 ? _b : null,\n originalText: element.originalText || text,\n autoResize: (_c = element.autoResize) !== null && _c !== void 0 ? _c : true,\n lineHeight\n }); // if empty text, mark as deleted. We keep in array\n // for data integrity purposes (collab etc.)\n\n if (!text && !element.isDeleted) {\n element = Object.assign(Object.assign({}, element), {\n originalText: text,\n isDeleted: true\n });\n element = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_6__.bumpVersion)(element);\n }\n\n return element;\n\n case \"freedraw\":\n {\n return restoreElementWithProperties(element, {\n points: element.points,\n lastCommittedPoint: null,\n simulatePressure: element.simulatePressure,\n pressures: element.pressures\n });\n }\n\n case \"image\":\n return restoreElementWithProperties(element, {\n status: element.status || \"pending\",\n fileId: element.fileId,\n scale: element.scale || [1, 1],\n crop: (_d = element.crop) !== null && _d !== void 0 ? _d : null\n });\n\n case \"line\": // @ts-ignore LEGACY type\n // eslint-disable-next-line no-fallthrough\n\n case \"draw\":\n const {\n startArrowhead = null,\n endArrowhead = null\n } = element;\n let x = element.x;\n let y = element.y;\n let points = // migrate old arrow model to new one\n !Array.isArray(element.points) || element.points.length < 2 ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(element.width, element.height)] : element.points;\n\n if (points[0][0] !== 0 || points[0][1] !== 0) {\n ({\n points,\n x,\n y\n } = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_5__.LinearElementEditor.getNormalizedPoints(element));\n }\n\n return restoreElementWithProperties(element, Object.assign({\n type: element.type === \"draw\" ? \"line\" : element.type,\n startBinding: repairBinding(element, element.startBinding),\n endBinding: repairBinding(element, element.endBinding),\n lastCommittedPoint: null,\n startArrowhead,\n endArrowhead,\n points,\n x,\n y\n }, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getSizeFromPoints)(points)));\n\n case \"arrow\":\n {\n const {\n startArrowhead = null,\n endArrowhead = \"arrow\"\n } = element;\n let x = element.x;\n let y = element.y;\n let points = // migrate old arrow model to new one\n !Array.isArray(element.points) || element.points.length < 2 ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(element.width, element.height)] : element.points;\n\n if (points[0][0] !== 0 || points[0][1] !== 0) {\n ({\n points,\n x,\n y\n } = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_5__.LinearElementEditor.getNormalizedPoints(element));\n }\n\n const base = Object.assign({\n type: element.type,\n startBinding: repairBinding(element, element.startBinding),\n endBinding: repairBinding(element, element.endBinding),\n lastCommittedPoint: null,\n startArrowhead,\n endArrowhead,\n points,\n x,\n y,\n elbowed: element.elbowed\n }, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getSizeFromPoints)(points)); // TODO: Separate arrow from linear element\n\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element) ? restoreElementWithProperties(element, Object.assign(Object.assign({}, base), {\n elbowed: true,\n startBinding: repairBinding(element, element.startBinding),\n endBinding: repairBinding(element, element.endBinding),\n fixedSegments: element.fixedSegments,\n startIsSpecial: element.startIsSpecial,\n endIsSpecial: element.endIsSpecial\n })) : restoreElementWithProperties(element, base);\n }\n // generic elements\n\n case \"ellipse\":\n case \"rectangle\":\n case \"diamond\":\n return restoreElementWithProperties(element, {});\n\n case \"iframe\": //zsviczian\n\n case \"embeddable\":\n return restoreElementWithProperties(element, {\n scale: (_e = element.scale) !== null && _e !== void 0 ? _e : [1, 1] //zsviczian\n\n });\n\n case \"magicframe\":\n case \"frame\":\n return restoreElementWithProperties(element, {\n name: (_f = element.name) !== null && _f !== void 0 ? _f : null\n });\n // Don't use default case so as to catch a missing an element type case.\n // We also don't want to throw, but instead return void so we filter\n // out these unsupported elements from the restored array.\n }\n\n return null;\n};\n/**\r\n * Repairs container element's boundElements array by removing duplicates and\r\n * fixing containerId of bound elements if not present. Also removes any\r\n * bound elements that do not exist in the elements array.\r\n *\r\n * NOTE mutates elements.\r\n */\n\n\nconst repairContainerElement = (container, elementsMap) => {\n if (container.boundElements) {\n // copy because we're not cloning on restore, and we don't want to mutate upstream\n const boundElements = container.boundElements.slice(); // dedupe bindings & fix boundElement.containerId if not set already\n\n const boundIds = new Set();\n container.boundElements = boundElements.reduce((acc, binding) => {\n const boundElement = elementsMap.get(binding.id);\n\n if (boundElement && !boundIds.has(binding.id)) {\n boundIds.add(binding.id);\n\n if (boundElement.isDeleted) {\n return acc;\n }\n\n acc.push(binding);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isTextElement)(boundElement) && // being slightly conservative here, preserving existing containerId\n // if defined, lest boundElements is stale\n !boundElement.containerId) {\n boundElement.containerId = container.id;\n }\n }\n\n return acc;\n }, []);\n }\n};\n/**\r\n * Repairs target bound element's container's boundElements array,\r\n * or removes contaienrId if container does not exist.\r\n *\r\n * NOTE mutates elements.\r\n */\n\n\nconst repairBoundElement = (boundElement, elementsMap) => {\n var _a;\n\n const container = boundElement.containerId ? elementsMap.get(boundElement.containerId) : null;\n boundElement.angle = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowElement)(container) ? 0 : (_a = container === null || container === void 0 ? void 0 : container.angle) !== null && _a !== void 0 ? _a : 0;\n\n if (!container) {\n boundElement.containerId = null;\n return;\n }\n\n if (boundElement.isDeleted) {\n return;\n }\n\n if (container.boundElements && !container.boundElements.find(binding => binding.id === boundElement.id)) {\n // copy because we're not cloning on restore, and we don't want to mutate upstream\n const boundElements = (container.boundElements || (container.boundElements = [])).slice();\n boundElements.push({\n type: \"text\",\n id: boundElement.id\n });\n container.boundElements = boundElements;\n }\n};\n/**\r\n * Remove an element's frameId if its containing frame is non-existent\r\n *\r\n * NOTE mutates elements.\r\n */\n\n\nconst repairFrameMembership = (element, elementsMap) => {\n if (element.frameId) {\n const containingFrame = elementsMap.get(element.frameId);\n\n if (!containingFrame) {\n element.frameId = null;\n }\n }\n};\n\nconst restoreElements = (elements,\n/** NOTE doesn't serve for reconciliation */\nlocalElements, opts) => {\n // used to detect duplicate top-level element ids\n const existingIds = new Set();\n const localElementsMap = localElements ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(localElements) : null;\n const restoredElements = (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_10__.syncInvalidIndices)((elements || []).reduce((elements, element) => {\n // filtering out selection, which is legacy, no longer kept in elements,\n // and causing issues if retained\n if (element.type !== \"selection\" && !(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_12__.isInvisiblySmallElement)(element)) {\n let migratedElement = restoreElement(element);\n\n if (migratedElement) {\n const localElement = localElementsMap === null || localElementsMap === void 0 ? void 0 : localElementsMap.get(element.id);\n\n if (localElement && localElement.version > migratedElement.version) {\n migratedElement = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_6__.bumpVersion)(migratedElement, localElement.version);\n }\n\n if (existingIds.has(migratedElement.id)) {\n migratedElement = Object.assign(Object.assign({}, migratedElement), {\n id: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)()\n });\n }\n\n existingIds.add(migratedElement.id);\n elements.push(migratedElement);\n }\n }\n\n return elements;\n }, []));\n\n if (!(opts === null || opts === void 0 ? void 0 : opts.repairBindings)) {\n return restoredElements;\n } // repair binding. Mutates elements.\n\n\n const restoredElementsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(restoredElements);\n\n for (const element of restoredElements) {\n if (element.frameId) {\n repairFrameMembership(element, restoredElementsMap);\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isTextElement)(element) && element.containerId) {\n repairBoundElement(element, restoredElementsMap);\n } else if (element.boundElements) {\n repairContainerElement(element, restoredElementsMap);\n }\n\n if (opts.refreshDimensions && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isTextElement)(element)) {\n Object.assign(element, (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_11__.refreshTextDimensions)(element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(element, restoredElementsMap), restoredElementsMap));\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isLinearElement)(element)) {\n if (element.startBinding && (!restoredElementsMap.has(element.startBinding.elementId) || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowElement)(element))) {\n element.startBinding = null;\n }\n\n if (element.endBinding && (!restoredElementsMap.has(element.endBinding.elementId) || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowElement)(element))) {\n element.endBinding = null;\n }\n }\n } // NOTE (mtolmacs): Temporary fix for extremely large arrows\n // Need to iterate again so we have attached text nodes in elementsMap\n\n\n return restoredElements.map(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element) && element.startBinding == null && element.endBinding == null && !(0,_excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_4__.validateElbowPoints)(element.points)) {\n return Object.assign(Object.assign(Object.assign({}, element), (0,_excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_4__.updateElbowArrowPoints)(element, restoredElementsMap, {\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), element.points[element.points.length - 1]]\n })), {\n index: element.index\n });\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element) && element.startBinding && element.endBinding && element.startBinding.elementId === element.endBinding.elementId && element.points.length > 1 && element.points.some(([rx, ry]) => Math.abs(rx) > 1e6 || Math.abs(ry) > 1e6)) {\n console.error(\"Fixing self-bound elbow arrow\", element.id);\n const boundElement = restoredElementsMap.get(element.startBinding.elementId);\n\n if (!boundElement) {\n console.error(\"Bound element not found\", element.startBinding.elementId);\n return element;\n }\n\n return Object.assign(Object.assign({}, element), {\n x: boundElement.x + boundElement.width / 2,\n y: boundElement.y - 5,\n width: boundElement.width,\n height: boundElement.height,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, -10), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(boundElement.width / 2 + 5, -10), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(boundElement.width / 2 + 5, boundElement.height / 2 + 5)]\n });\n }\n\n return element;\n });\n};\n\nconst coalesceAppStateValue = (key, appState, defaultAppState) => {\n const value = appState[key]; // NOTE the value! assertion is needed in TS 4.5.5 (fixed in newer versions)\n\n return value !== undefined ? value : defaultAppState[key];\n};\n\nconst LegacyAppStateMigrations = {\n isSidebarDocked: (appState, defaultAppState) => {\n var _a;\n\n return [\"defaultSidebarDockedPreference\", (_a = appState.isSidebarDocked) !== null && _a !== void 0 ? _a : coalesceAppStateValue(\"defaultSidebarDockedPreference\", appState, defaultAppState)];\n }\n};\nconst restoreAppState = (appState, localAppState) => {\n var _a, _b, _c, _d, _e;\n\n appState = appState || {};\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_13__.getDefaultAppState)();\n const nextAppState = {}; // first, migrate all legacy AppState properties to new ones. We do it\n // in one go before migrate the rest of the properties in case the new ones\n // depend on checking any other key (i.e. they are coupled)\n\n for (const legacyKey of Object.keys(LegacyAppStateMigrations)) {\n if (legacyKey in appState) {\n const [nextKey, nextValue] = LegacyAppStateMigrations[legacyKey](appState, defaultAppState);\n nextAppState[nextKey] = nextValue;\n }\n }\n\n for (const [key, defaultValue] of Object.entries(defaultAppState)) {\n // if AppState contains a legacy key, prefer that one and migrate its\n // value to the new one\n const suppliedValue = appState[key];\n const localValue = localAppState ? localAppState[key] : undefined;\n nextAppState[key] = suppliedValue !== undefined ? suppliedValue : localValue !== undefined ? localValue : defaultValue;\n }\n\n return Object.assign(Object.assign({}, nextAppState), {\n cursorButton: (localAppState === null || localAppState === void 0 ? void 0 : localAppState.cursorButton) || \"up\",\n // reset on fresh restore so as to hide the UI button if penMode not active\n penDetected: (_a = localAppState === null || localAppState === void 0 ? void 0 : localAppState.penDetected) !== null && _a !== void 0 ? _a : appState.penMode ? (_b = appState.penDetected) !== null && _b !== void 0 ? _b : false : false,\n activeTool: Object.assign(Object.assign({}, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(defaultAppState, nextAppState.activeTool.type && AllowedExcalidrawActiveTools[nextAppState.activeTool.type] ? nextAppState.activeTool : {\n type: \"selection\"\n })), {\n lastActiveTool: null,\n locked: (_c = nextAppState.activeTool.locked) !== null && _c !== void 0 ? _c : false\n }),\n // Migrates from previous version where appState.zoom was a number\n zoom: {\n value: (0,_scene__WEBPACK_IMPORTED_MODULE_14__.getNormalizedZoom)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.isFiniteNumber)(appState.zoom) ? appState.zoom : (_e = (_d = appState.zoom) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : defaultAppState.zoom.value)\n },\n openSidebar: // string (legacy)\n typeof appState.openSidebar === \"string\" ? {\n name: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SIDEBAR.name\n } : nextAppState.openSidebar,\n gridSize: (0,_scene__WEBPACK_IMPORTED_MODULE_14__.getNormalizedGridSize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.isFiniteNumber)(appState.gridSize) ? appState.gridSize : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_GRID_SIZE),\n gridStep: (0,_scene__WEBPACK_IMPORTED_MODULE_14__.getNormalizedGridStep)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.isFiniteNumber)(appState.gridStep) ? appState.gridStep : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_GRID_STEP),\n editingFrame: null\n });\n};\nconst restore = (data,\n/**\r\n * Local AppState (`this.state` or initial state from localStorage) so that we\r\n * don't overwrite local state with default values (when values not\r\n * explicitly specified).\r\n * Supply `null` if you can't get access to it.\r\n */\nlocalAppState, localElements, elementsConfig) => {\n return {\n elements: restoreElements(data === null || data === void 0 ? void 0 : data.elements, localElements, elementsConfig),\n appState: restoreAppState(data === null || data === void 0 ? void 0 : data.appState, localAppState || null),\n files: (data === null || data === void 0 ? void 0 : data.files) || {}\n };\n};\n\nconst restoreLibraryItem = libraryItem => {\n const elements = restoreElements((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getNonDeletedElements)(libraryItem.elements), null);\n return elements.length ? Object.assign(Object.assign({}, libraryItem), {\n elements\n }) : null;\n};\n\nconst restoreLibraryItems = (libraryItems = [], defaultStatus) => {\n const restoredItems = [];\n\n for (const item of libraryItems) {\n // migrate older libraries\n if (Array.isArray(item)) {\n const restoredItem = restoreLibraryItem({\n status: defaultStatus,\n elements: item,\n id: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)(),\n created: Date.now()\n });\n\n if (restoredItem) {\n restoredItems.push(restoredItem);\n }\n } else {\n const _item = item;\n const restoredItem = restoreLibraryItem(Object.assign(Object.assign({}, _item), {\n id: _item.id || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)(),\n status: _item.status || defaultStatus,\n created: _item.created || Date.now()\n }));\n\n if (restoredItem) {\n restoredItems.push(restoredItem);\n }\n }\n }\n\n return restoredItems;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./data/restore.ts?");
|
|
16867
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AllowedExcalidrawActiveTools: () => (/* binding */ AllowedExcalidrawActiveTools),\n/* harmony export */ restore: () => (/* binding */ restore),\n/* harmony export */ restoreAppState: () => (/* binding */ restoreAppState),\n/* harmony export */ restoreElements: () => (/* binding */ restoreElements),\n/* harmony export */ restoreLibraryItems: () => (/* binding */ restoreLibraryItems)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/element/elbowArrow */ \"../element/src/elbowArrow.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @excalidraw/element/fractionalIndex */ \"../element/src/fractionalIndex.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @excalidraw/element/sizeHelpers */ \"../element/src/sizeHelpers.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst AllowedExcalidrawActiveTools = {\n selection: true,\n lasso: true,\n text: true,\n rectangle: true,\n diamond: true,\n ellipse: true,\n line: true,\n image: true,\n arrow: true,\n freedraw: true,\n eraser: false,\n custom: true,\n frame: true,\n embeddable: true,\n hand: true,\n mermaid: true,\n laser: false,\n magicframe: false\n};\n\nconst getFontFamilyByName = fontFamilyName => {\n if (Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY).includes(fontFamilyName)) {\n return _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY[fontFamilyName];\n }\n\n return _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_FONT_FAMILY;\n};\n\nconst repairBinding = (element, binding) => {\n var _a;\n\n if (!binding) {\n return null;\n }\n\n const focus = binding.focus || 0;\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element)) {\n const fixedPointBinding = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isFixedPointBinding)(binding) ? Object.assign(Object.assign({}, binding), {\n focus,\n fixedPoint: (0,_excalidraw_element_binding__WEBPACK_IMPORTED_MODULE_3__.normalizeFixedPoint)((_a = binding.fixedPoint) !== null && _a !== void 0 ? _a : [0, 0])\n }) : null;\n return fixedPointBinding;\n }\n\n return Object.assign(Object.assign({}, binding), {\n focus\n });\n};\n\nconst restoreElementWithProperties = (element, extra) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const base = {\n type: extra.type || element.type,\n // all elements must have version > 0 so getSceneVersion() will pick up\n // newly added elements\n version: element.version || 1,\n versionNonce: (_a = element.versionNonce) !== null && _a !== void 0 ? _a : 0,\n index: (_b = element.index) !== null && _b !== void 0 ? _b : null,\n isDeleted: (_c = element.isDeleted) !== null && _c !== void 0 ? _c : false,\n id: element.id || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)(),\n fillStyle: element.fillStyle || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.fillStyle,\n strokeWidth: element.strokeWidth || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.strokeWidth,\n strokeStyle: (_d = element.strokeStyle) !== null && _d !== void 0 ? _d : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.strokeStyle,\n roughness: (_e = element.roughness) !== null && _e !== void 0 ? _e : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.roughness,\n opacity: element.opacity == null ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.opacity : element.opacity,\n angle: element.angle || 0,\n x: (_g = (_f = extra.x) !== null && _f !== void 0 ? _f : element.x) !== null && _g !== void 0 ? _g : 0,\n y: (_j = (_h = extra.y) !== null && _h !== void 0 ? _h : element.y) !== null && _j !== void 0 ? _j : 0,\n strokeColor: element.strokeColor || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.strokeColor,\n backgroundColor: element.backgroundColor || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_PROPS.backgroundColor,\n width: element.width || 0,\n height: element.height || 0,\n seed: (_k = element.seed) !== null && _k !== void 0 ? _k : 1,\n groupIds: (_l = element.groupIds) !== null && _l !== void 0 ? _l : [],\n frameId: (_m = element.frameId) !== null && _m !== void 0 ? _m : null,\n roundness: element.roundness ? element.roundness : element.strokeSharpness === \"round\" && element.type !== \"image\" ? {\n // for old elements that would now use adaptive radius algo,\n // use legacy algo instead\n type: (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isUsingAdaptiveRadius)(element.type) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.ROUNDNESS.LEGACY : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n boundElements: element.boundElementIds ? element.boundElementIds.map(id => ({\n type: \"arrow\",\n id\n })) : (_o = element.boundElements) !== null && _o !== void 0 ? _o : [],\n updated: (_p = element.updated) !== null && _p !== void 0 ? _p : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getUpdatedTimestamp)(),\n link: element.link ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.normalizeLink)(element.link) : null,\n locked: (_q = element.locked) !== null && _q !== void 0 ? _q : false\n };\n\n if (\"customData\" in element || \"customData\" in extra) {\n base.customData = \"customData\" in extra ? extra.customData : element.customData;\n }\n\n const ret = Object.assign(Object.assign(Object.assign(Object.assign({}, element), base), (0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_12__.getNormalizedDimensions)(base)), extra); // strip legacy props (migrated in previous steps)\n\n delete ret.strokeSharpness;\n delete ret.boundElementIds;\n return ret;\n};\n\nconst restoreElement = element => {\n var _a, _b, _c, _d, _e, _f;\n\n element = Object.assign({}, element);\n\n switch (element.type) {\n case \"text\":\n // temp fix: cleanup legacy obsidian-excalidraw attribute else it'll\n // conflict when porting between the apps\n //delete (element as any).rawText; //zsviczian\n let fontSize = element.fontSize;\n let fontFamily = element.fontFamily;\n\n if (\"font\" in element) {\n const [fontPx, _fontFamily] = element.font.split(\" \");\n fontSize = parseFloat(fontPx);\n fontFamily = getFontFamilyByName(_fontFamily);\n }\n\n const text = typeof element.text === \"string\" && element.text || \"\"; // line-height might not be specified either when creating elements\n // programmatically, or when importing old diagrams.\n // For the latter we want to detect the original line height which\n // will likely differ from our per-font fixed line height we now use,\n // to maintain backward compatibility.\n\n const lineHeight = element.lineHeight || (element.height ? // detect line-height from current element height and font-size\n (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_8__.detectLineHeight)(element) : // no element height likely means programmatic use, so default\n // to a fixed line height\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getLineHeight)(element.fontFamily));\n element = restoreElementWithProperties(element, {\n fontSize,\n fontFamily,\n text,\n rawText: (_a = element.rawText) !== null && _a !== void 0 ? _a : \"\",\n textAlign: element.textAlign || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_TEXT_ALIGN,\n verticalAlign: element.verticalAlign || _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_VERTICAL_ALIGN,\n containerId: (_b = element.containerId) !== null && _b !== void 0 ? _b : null,\n originalText: element.originalText || text,\n autoResize: (_c = element.autoResize) !== null && _c !== void 0 ? _c : true,\n lineHeight\n }); // if empty text, mark as deleted. We keep in array\n // for data integrity purposes (collab etc.)\n\n if (!text && !element.isDeleted) {\n element = Object.assign(Object.assign({}, element), {\n originalText: text,\n isDeleted: true\n });\n element = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_6__.bumpVersion)(element);\n }\n\n return element;\n\n case \"freedraw\":\n {\n return restoreElementWithProperties(element, {\n points: element.points,\n lastCommittedPoint: null,\n simulatePressure: element.simulatePressure,\n pressures: element.pressures\n });\n }\n\n case \"image\":\n return restoreElementWithProperties(element, {\n status: element.status || \"pending\",\n fileId: element.fileId,\n scale: element.scale || [1, 1],\n crop: (_d = element.crop) !== null && _d !== void 0 ? _d : null\n });\n\n case \"line\": // @ts-ignore LEGACY type\n // eslint-disable-next-line no-fallthrough\n\n case \"draw\":\n const {\n startArrowhead = null,\n endArrowhead = null\n } = element;\n let x = element.x;\n let y = element.y;\n let points = // migrate old arrow model to new one\n !Array.isArray(element.points) || element.points.length < 2 ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(element.width, element.height)] : element.points;\n\n if (points[0][0] !== 0 || points[0][1] !== 0) {\n ({\n points,\n x,\n y\n } = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_5__.LinearElementEditor.getNormalizedPoints(element));\n }\n\n return restoreElementWithProperties(element, Object.assign({\n type: element.type === \"draw\" ? \"line\" : element.type,\n startBinding: repairBinding(element, element.startBinding),\n endBinding: repairBinding(element, element.endBinding),\n lastCommittedPoint: null,\n startArrowhead,\n endArrowhead,\n points,\n x,\n y\n }, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getSizeFromPoints)(points)));\n\n case \"arrow\":\n {\n const {\n startArrowhead = null,\n endArrowhead = \"arrow\"\n } = element;\n let x = element.x;\n let y = element.y;\n let points = // migrate old arrow model to new one\n !Array.isArray(element.points) || element.points.length < 2 ? [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(element.width, element.height)] : element.points;\n\n if (points[0][0] !== 0 || points[0][1] !== 0) {\n ({\n points,\n x,\n y\n } = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_5__.LinearElementEditor.getNormalizedPoints(element));\n }\n\n const base = Object.assign({\n type: element.type,\n startBinding: repairBinding(element, element.startBinding),\n endBinding: repairBinding(element, element.endBinding),\n lastCommittedPoint: null,\n startArrowhead,\n endArrowhead,\n points,\n x,\n y,\n elbowed: element.elbowed\n }, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getSizeFromPoints)(points)); // TODO: Separate arrow from linear element\n\n return (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element) ? restoreElementWithProperties(element, Object.assign(Object.assign({}, base), {\n elbowed: true,\n startBinding: repairBinding(element, element.startBinding),\n endBinding: repairBinding(element, element.endBinding),\n fixedSegments: element.fixedSegments,\n startIsSpecial: element.startIsSpecial,\n endIsSpecial: element.endIsSpecial\n })) : restoreElementWithProperties(element, base);\n }\n // generic elements\n\n case \"ellipse\":\n case \"rectangle\":\n case \"diamond\":\n return restoreElementWithProperties(element, {});\n\n case \"iframe\": //zsviczian\n\n case \"embeddable\":\n return restoreElementWithProperties(element, {\n scale: (_e = element.scale) !== null && _e !== void 0 ? _e : [1, 1] //zsviczian\n\n });\n\n case \"magicframe\":\n case \"frame\":\n return restoreElementWithProperties(element, {\n name: (_f = element.name) !== null && _f !== void 0 ? _f : null\n });\n // Don't use default case so as to catch a missing an element type case.\n // We also don't want to throw, but instead return void so we filter\n // out these unsupported elements from the restored array.\n }\n\n return null;\n};\n/**\r\n * Repairs container element's boundElements array by removing duplicates and\r\n * fixing containerId of bound elements if not present. Also removes any\r\n * bound elements that do not exist in the elements array.\r\n *\r\n * NOTE mutates elements.\r\n */\n\n\nconst repairContainerElement = (container, elementsMap) => {\n if (container.boundElements) {\n // copy because we're not cloning on restore, and we don't want to mutate upstream\n const boundElements = container.boundElements.slice(); // dedupe bindings & fix boundElement.containerId if not set already\n\n const boundIds = new Set();\n container.boundElements = boundElements.reduce((acc, binding) => {\n const boundElement = elementsMap.get(binding.id);\n\n if (boundElement && !boundIds.has(binding.id)) {\n boundIds.add(binding.id);\n\n if (boundElement.isDeleted) {\n return acc;\n }\n\n acc.push(binding);\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isTextElement)(boundElement) && // being slightly conservative here, preserving existing containerId\n // if defined, lest boundElements is stale\n !boundElement.containerId) {\n boundElement.containerId = container.id;\n }\n }\n\n return acc;\n }, []);\n }\n};\n/**\r\n * Repairs target bound element's container's boundElements array,\r\n * or removes contaienrId if container does not exist.\r\n *\r\n * NOTE mutates elements.\r\n */\n\n\nconst repairBoundElement = (boundElement, elementsMap) => {\n var _a;\n\n const container = boundElement.containerId ? elementsMap.get(boundElement.containerId) : null;\n boundElement.angle = (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowElement)(container) ? 0 : (_a = container === null || container === void 0 ? void 0 : container.angle) !== null && _a !== void 0 ? _a : 0;\n\n if (!container) {\n boundElement.containerId = null;\n return;\n }\n\n if (boundElement.isDeleted) {\n return;\n }\n\n if (container.boundElements && !container.boundElements.find(binding => binding.id === boundElement.id)) {\n // copy because we're not cloning on restore, and we don't want to mutate upstream\n const boundElements = (container.boundElements || (container.boundElements = [])).slice();\n boundElements.push({\n type: \"text\",\n id: boundElement.id\n });\n container.boundElements = boundElements;\n }\n};\n/**\r\n * Remove an element's frameId if its containing frame is non-existent\r\n *\r\n * NOTE mutates elements.\r\n */\n\n\nconst repairFrameMembership = (element, elementsMap) => {\n if (element.frameId) {\n const containingFrame = elementsMap.get(element.frameId);\n\n if (!containingFrame) {\n element.frameId = null;\n }\n }\n};\n\nconst restoreElements = (elements,\n/** NOTE doesn't serve for reconciliation */\nlocalElements, opts) => {\n // used to detect duplicate top-level element ids\n const existingIds = new Set();\n const localElementsMap = localElements ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(localElements) : null;\n const restoredElements = (0,_excalidraw_element_fractionalIndex__WEBPACK_IMPORTED_MODULE_10__.syncInvalidIndices)((elements || []).reduce((elements, element) => {\n // filtering out selection, which is legacy, no longer kept in elements,\n // and causing issues if retained\n if (element.type !== \"selection\" && !(0,_excalidraw_element_sizeHelpers__WEBPACK_IMPORTED_MODULE_12__.isInvisiblySmallElement)(element)) {\n let migratedElement = restoreElement(element);\n\n if (migratedElement) {\n const localElement = localElementsMap === null || localElementsMap === void 0 ? void 0 : localElementsMap.get(element.id);\n\n if (localElement && localElement.version > migratedElement.version) {\n migratedElement = (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_6__.bumpVersion)(migratedElement, localElement.version);\n }\n\n if (existingIds.has(migratedElement.id)) {\n migratedElement = Object.assign(Object.assign({}, migratedElement), {\n id: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)()\n });\n }\n\n existingIds.add(migratedElement.id);\n elements.push(migratedElement);\n }\n }\n\n return elements;\n }, []));\n\n if (!(opts === null || opts === void 0 ? void 0 : opts.repairBindings)) {\n return restoredElements;\n } // repair binding. Mutates elements.\n\n\n const restoredElementsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(restoredElements);\n\n for (const element of restoredElements) {\n if (element.frameId) {\n repairFrameMembership(element, restoredElementsMap);\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isTextElement)(element) && element.containerId) {\n repairBoundElement(element, restoredElementsMap);\n } else if (element.boundElements) {\n repairContainerElement(element, restoredElementsMap);\n }\n\n if (opts.refreshDimensions && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isTextElement)(element)) {\n Object.assign(element, (0,_excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_11__.refreshTextDimensions)(element, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(element, restoredElementsMap), restoredElementsMap));\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isLinearElement)(element)) {\n if (element.startBinding && (!restoredElementsMap.has(element.startBinding.elementId) || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowElement)(element))) {\n element.startBinding = null;\n }\n\n if (element.endBinding && (!restoredElementsMap.has(element.endBinding.elementId) || !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowElement)(element))) {\n element.endBinding = null;\n }\n }\n } // NOTE (mtolmacs): Temporary fix for extremely large arrows\n // Need to iterate again so we have attached text nodes in elementsMap\n\n\n return restoredElements.map(element => {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element) && !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isArrowBoundToElement)(element) && !(0,_excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_4__.validateElbowPoints)(element.points)) {\n return Object.assign(Object.assign(Object.assign({}, element), (0,_excalidraw_element_elbowArrow__WEBPACK_IMPORTED_MODULE_4__.updateElbowArrowPoints)(element, restoredElementsMap, {\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), element.points[element.points.length - 1]]\n })), {\n index: element.index\n });\n }\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_9__.isElbowArrow)(element) && element.startBinding && element.endBinding && element.startBinding.elementId === element.endBinding.elementId && element.points.length > 1 && element.points.some(([rx, ry]) => Math.abs(rx) > 1e6 || Math.abs(ry) > 1e6)) {\n console.error(\"Fixing self-bound elbow arrow\", element.id);\n const boundElement = restoredElementsMap.get(element.startBinding.elementId);\n\n if (!boundElement) {\n console.error(\"Bound element not found\", element.startBinding.elementId);\n return element;\n }\n\n return Object.assign(Object.assign({}, element), {\n x: boundElement.x + boundElement.width / 2,\n y: boundElement.y - 5,\n width: boundElement.width,\n height: boundElement.height,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(0, -10), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(boundElement.width / 2 + 5, -10), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(boundElement.width / 2 + 5, boundElement.height / 2 + 5)]\n });\n }\n\n return element;\n });\n};\n\nconst coalesceAppStateValue = (key, appState, defaultAppState) => {\n const value = appState[key]; // NOTE the value! assertion is needed in TS 4.5.5 (fixed in newer versions)\n\n return value !== undefined ? value : defaultAppState[key];\n};\n\nconst LegacyAppStateMigrations = {\n isSidebarDocked: (appState, defaultAppState) => {\n var _a;\n\n return [\"defaultSidebarDockedPreference\", (_a = appState.isSidebarDocked) !== null && _a !== void 0 ? _a : coalesceAppStateValue(\"defaultSidebarDockedPreference\", appState, defaultAppState)];\n }\n};\nconst restoreAppState = (appState, localAppState) => {\n var _a, _b, _c, _d, _e;\n\n appState = appState || {};\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_13__.getDefaultAppState)();\n const nextAppState = {}; // first, migrate all legacy AppState properties to new ones. We do it\n // in one go before migrate the rest of the properties in case the new ones\n // depend on checking any other key (i.e. they are coupled)\n\n for (const legacyKey of Object.keys(LegacyAppStateMigrations)) {\n if (legacyKey in appState) {\n const [nextKey, nextValue] = LegacyAppStateMigrations[legacyKey](appState, defaultAppState);\n nextAppState[nextKey] = nextValue;\n }\n }\n\n for (const [key, defaultValue] of Object.entries(defaultAppState)) {\n // if AppState contains a legacy key, prefer that one and migrate its\n // value to the new one\n const suppliedValue = appState[key];\n const localValue = localAppState ? localAppState[key] : undefined;\n nextAppState[key] = suppliedValue !== undefined ? suppliedValue : localValue !== undefined ? localValue : defaultValue;\n }\n\n return Object.assign(Object.assign({}, nextAppState), {\n cursorButton: (localAppState === null || localAppState === void 0 ? void 0 : localAppState.cursorButton) || \"up\",\n // reset on fresh restore so as to hide the UI button if penMode not active\n penDetected: (_a = localAppState === null || localAppState === void 0 ? void 0 : localAppState.penDetected) !== null && _a !== void 0 ? _a : appState.penMode ? (_b = appState.penDetected) !== null && _b !== void 0 ? _b : false : false,\n activeTool: Object.assign(Object.assign({}, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(defaultAppState, nextAppState.activeTool.type && AllowedExcalidrawActiveTools[nextAppState.activeTool.type] ? nextAppState.activeTool : {\n type: \"selection\"\n })), {\n lastActiveTool: null,\n locked: (_c = nextAppState.activeTool.locked) !== null && _c !== void 0 ? _c : false\n }),\n // Migrates from previous version where appState.zoom was a number\n zoom: {\n value: (0,_scene__WEBPACK_IMPORTED_MODULE_14__.getNormalizedZoom)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.isFiniteNumber)(appState.zoom) ? appState.zoom : (_e = (_d = appState.zoom) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : defaultAppState.zoom.value)\n },\n openSidebar: // string (legacy)\n typeof appState.openSidebar === \"string\" ? {\n name: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SIDEBAR.name\n } : nextAppState.openSidebar,\n gridSize: (0,_scene__WEBPACK_IMPORTED_MODULE_14__.getNormalizedGridSize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.isFiniteNumber)(appState.gridSize) ? appState.gridSize : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_GRID_SIZE),\n gridStep: (0,_scene__WEBPACK_IMPORTED_MODULE_14__.getNormalizedGridStep)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.isFiniteNumber)(appState.gridStep) ? appState.gridStep : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_GRID_STEP),\n editingFrame: null\n });\n};\nconst restore = (data,\n/**\r\n * Local AppState (`this.state` or initial state from localStorage) so that we\r\n * don't overwrite local state with default values (when values not\r\n * explicitly specified).\r\n * Supply `null` if you can't get access to it.\r\n */\nlocalAppState, localElements, elementsConfig) => {\n return {\n elements: restoreElements(data === null || data === void 0 ? void 0 : data.elements, localElements, elementsConfig),\n appState: restoreAppState(data === null || data === void 0 ? void 0 : data.appState, localAppState || null),\n files: (data === null || data === void 0 ? void 0 : data.files) || {}\n };\n};\n\nconst restoreLibraryItem = libraryItem => {\n const elements = restoreElements((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getNonDeletedElements)(libraryItem.elements), null);\n return elements.length ? Object.assign(Object.assign({}, libraryItem), {\n elements\n }) : null;\n};\n\nconst restoreLibraryItems = (libraryItems = [], defaultStatus) => {\n const restoredItems = [];\n\n for (const item of libraryItems) {\n // migrate older libraries\n if (Array.isArray(item)) {\n const restoredItem = restoreLibraryItem({\n status: defaultStatus,\n elements: item,\n id: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)(),\n created: Date.now()\n });\n\n if (restoredItem) {\n restoredItems.push(restoredItem);\n }\n } else {\n const _item = item;\n const restoredItem = restoreLibraryItem(Object.assign(Object.assign({}, _item), {\n id: _item.id || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.randomId)(),\n status: _item.status || defaultStatus,\n created: _item.created || Date.now()\n }));\n\n if (restoredItem) {\n restoredItems.push(restoredItem);\n }\n }\n }\n\n return restoredItems;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./data/restore.ts?");
|
|
16835
16868
|
|
|
16836
16869
|
/***/ }),
|
|
16837
16870
|
|
|
@@ -19899,7 +19932,7 @@ eval("module.exports = /*#__PURE__*/JSON.parse('{\"labels\":{\"paste\":\"Επι
|
|
|
19899
19932
|
/***/ ((module) => {
|
|
19900
19933
|
|
|
19901
19934
|
"use strict";
|
|
19902
|
-
eval("module.exports = /*#__PURE__*/JSON.parse('{\"labels\":{\"laser\":\"Toggle laser pointer\",\"paste\":\"Paste\",\"pasteAsPlaintext\":\"Paste as plaintext\",\"pasteCharts\":\"Paste charts\",\"selectAll\":\"Select all\",\"multiSelect\":\"Add element to selection\",\"moveCanvas\":\"Move canvas\",\"cut\":\"Cut\",\"copy\":\"Copy\",\"copyAsPng\":\"Copy to clipboard as PNG\",\"copyAsSvg\":\"Copy to clipboard as SVG\",\"copyText\":\"Copy to clipboard as text\",\"copySource\":\"Copy source to clipboard\",\"convertToCode\":\"Convert to code\",\"bringForward\":\"Bring forward\",\"sendToBack\":\"Send to back\",\"bringToFront\":\"Bring to front\",\"sendBackward\":\"Send backward\",\"delete\":\"Delete\",\"copyStyles\":\"Copy styles\",\"pasteStyles\":\"Paste styles\",\"stroke\":\"Stroke\",\"changeStroke\":\"Change stroke color\",\"background\":\"Background\",\"changeBackground\":\"Change background color\",\"fill\":\"Fill\",\"strokeWidth\":\"Stroke width\",\"strokeStyle\":\"Stroke style\",\"strokeStyle_solid\":\"Solid\",\"strokeStyle_dashed\":\"Dashed\",\"strokeStyle_dotted\":\"Dotted\",\"sloppiness\":\"Sloppiness\",\"opacity\":\"Opacity\",\"textAlign\":\"Text align\",\"edges\":\"Edges\",\"sharp\":\"Sharp\",\"round\":\"Round\",\"arrowheads\":\"Arrowheads\",\"arrowhead_none\":\"None\",\"arrowhead_arrow\":\"Arrow\",\"arrowhead_bar\":\"Bar\",\"arrowhead_dot\":\"Dot\",\"arrowhead_circle\":\"Circle\",\"arrowhead_circle_outline\":\"Circle (outline)\",\"arrowhead_triangle\":\"Triangle\",\"arrowhead_triangle_outline\":\"Triangle (outline)\",\"arrowhead_diamond\":\"Diamond\",\"arrowhead_diamond_outline\":\"Diamond (outline)\",\"arrowhead_crowfoot_many\":\"Crow\\'s foot (many)\",\"arrowhead_crowfoot_one\":\"Crow\\'s foot (one)\",\"arrowhead_crowfoot_one_or_many\":\"Crow\\'s foot (one or many)\",\"more_options\":\"More options\",\"arrowtypes\":\"Arrow type\",\"arrowtype_sharp\":\"Sharp arrow\",\"arrowtype_round\":\"Curved arrow\",\"arrowtype_elbowed\":\"Elbow arrow\",\"fontSize\":\"Font size\",\"fontFamily\":\"Font family\",\"addWatermark\":\"Add \\\\\"Made with Excalidraw\\\\\"\",\"handDrawn\":\"Hand-drawn\",\"normal\":\"Normal\",\"code\":\"Code\",\"localFont\":\"Local Font\",\"small\":\"Small\",\"medium\":\"Medium\",\"large\":\"Large\",\"veryLarge\":\"Very large\",\"solid\":\"Solid\",\"hachure\":\"Hachure\",\"zigzag\":\"Zigzag\",\"crossHatch\":\"Cross-hatch\",\"extraThin\":\"Extra thin\",\"thin\":\"Thin\",\"bold\":\"Bold\",\"left\":\"Left\",\"center\":\"Center\",\"right\":\"Right\",\"extraBold\":\"Extra bold\",\"architect\":\"Architect\",\"artist\":\"Artist\",\"cartoonist\":\"Cartoonist\",\"fileTitle\":\"File name\",\"colorPicker\":\"Color picker\",\"canvasColors\":\"Used on canvas\",\"canvasBackground\":\"Canvas background\",\"drawingCanvas\":\"Drawing canvas\",\"clearCanvas\":\"Clear canvas\",\"layers\":\"Layers\",\"actions\":\"Actions\",\"language\":\"Language\",\"liveCollaboration\":\"Live collaboration...\",\"duplicateSelection\":\"Duplicate\",\"untitled\":\"Untitled\",\"name\":\"Name\",\"yourName\":\"Your name\",\"madeWithExcalidraw\":\"Made with Excalidraw\",\"group\":\"Group selection\",\"ungroup\":\"Ungroup selection\",\"collaborators\":\"Collaborators\",\"toggleGrid\":\"Toggle grid\",\"addToLibrary\":\"Add to library\",\"removeFromLibrary\":\"Remove from library\",\"libraryLoadingMessage\":\"Loading library…\",\"libraries\":\"Browse libraries\",\"loadingScene\":\"Loading scene…\",\"loadScene\":\"Load scene from file\",\"align\":\"Align\",\"alignTop\":\"Align top\",\"alignBottom\":\"Align bottom\",\"alignLeft\":\"Align left\",\"alignRight\":\"Align right\",\"centerVertically\":\"Center vertically\",\"centerHorizontally\":\"Center horizontally\",\"distributeHorizontally\":\"Distribute horizontally\",\"distributeVertically\":\"Distribute vertically\",\"flipHorizontal\":\"Flip horizontal\",\"flipVertical\":\"Flip vertical\",\"viewMode\":\"View mode\",\"share\":\"Share\",\"showStroke\":\"Show stroke color picker\",\"showBackground\":\"Show background color picker\",\"showFonts\":\"Show font picker\",\"toggleTheme\":\"Toggle light/dark theme\",\"theme\":\"Theme\",\"personalLib\":\"Personal Library\",\"excalidrawLib\":\"Excalidraw Library\",\"decreaseFontSize\":\"Decrease font size\",\"increaseFontSize\":\"Increase font size\",\"unbindText\":\"Unbind text\",\"bindText\":\"Bind text to the container\",\"createContainerFromText\":\"Wrap text in a container\",\"link\":{\"edit\":\"Edit link\",\"editEmbed\":\"Edit embeddable link\",\"create\":\"Add link\",\"label\":\"Link\",\"labelEmbed\":\"Link & embed\",\"empty\":\"No link is set\",\"hint\":\"Type or paste your link here\",\"goToElement\":\"Go to target element\"},\"lineEditor\":{\"edit\":\"Edit line\",\"editArrow\":\"Edit arrow\"},\"elementLock\":{\"lock\":\"Lock\",\"unlock\":\"Unlock\",\"lockAll\":\"Lock all\",\"unlockAll\":\"Unlock all\"},\"statusPublished\":\"Published\",\"sidebarLock\":\"Keep sidebar open\",\"selectAllElementsInFrame\":\"Select all elements in frame\",\"removeAllElementsFromFrame\":\"Remove all elements from frame\",\"eyeDropper\":\"Pick color from canvas\",\"textToDiagram\":\"Text to diagram\",\"prompt\":\"Prompt\",\"followUs\":\"Follow us\",\"discordChat\":\"Discord chat\",\"zoomToFitViewport\":\"Zoom to fit in viewport\",\"zoomToFitSelection\":\"Zoom to fit selection\",\"zoomToFit\":\"Zoom to fit all elements\",\"installPWA\":\"Install Excalidraw locally (PWA)\",\"autoResize\":\"Enable text auto-resizing\",\"imageCropping\":\"Image cropping\",\"unCroppedDimension\":\"Uncropped dimension\",\"copyElementLink\":\"Copy link to object\",\"linkToElement\":\"Link to object\",\"wrapSelectionInFrame\":\"Wrap selection in frame\"},\"elementLink\":{\"title\":\"Link to object\",\"desc\":\"Click on a shape on canvas or paste a link.\",\"notFound\":\"Linked object wasn\\'t found on canvas.\"},\"library\":{\"noItems\":\"No items added yet...\",\"hint_emptyLibrary\":\"Select an item on canvas to add it here, or install a library from the public repository, below.\",\"hint_emptyPrivateLibrary\":\"Select an item on canvas to add it here.\"},\"search\":{\"title\":\"Find on canvas\",\"noMatch\":\"No matches found...\",\"singleResult\":\"result\",\"multipleResults\":\"results\",\"placeholder\":\"Find text on canvas...\"},\"buttons\":{\"clearReset\":\"Reset the canvas\",\"exportJSON\":\"Export to file\",\"exportImage\":\"Export image...\",\"export\":\"Save to...\",\"copyToClipboard\":\"Copy to clipboard\",\"copyLink\":\"Copy link\",\"save\":\"Save to current file\",\"saveAs\":\"Save as\",\"load\":\"Open\",\"getShareableLink\":\"Get shareable link\",\"close\":\"Close\",\"selectLanguage\":\"Select language\",\"scrollBackToContent\":\"Scroll back to content\",\"zoomIn\":\"Zoom in\",\"zoomOut\":\"Zoom out\",\"resetZoom\":\"Reset zoom\",\"menu\":\"Menu\",\"done\":\"Done\",\"edit\":\"Edit\",\"undo\":\"Undo\",\"redo\":\"Redo\",\"resetLibrary\":\"Reset library\",\"createNewRoom\":\"Create new room\",\"fullScreen\":\"Full screen\",\"darkMode\":\"Dark mode\",\"lightMode\":\"Light mode\",\"systemMode\":\"System mode\",\"zenMode\":\"Zen mode\",\"objectsSnapMode\":\"Snap to objects\",\"exitZenMode\":\"Exit zen mode\",\"cancel\":\"Cancel\",\"clear\":\"Clear\",\"remove\":\"Remove\",\"embed\":\"Toggle embedding\",\"publishLibrary\":\"Publish\",\"submit\":\"Submit\",\"confirm\":\"Confirm\",\"embeddableInteractionButton\":\"Click to interact\"},\"alerts\":{\"clearReset\":\"This will clear the whole canvas. Are you sure?\",\"couldNotCreateShareableLink\":\"Couldn\\'t create shareable link.\",\"couldNotCreateShareableLinkTooBig\":\"Couldn\\'t create shareable link: the scene is too big\",\"couldNotLoadInvalidFile\":\"Couldn\\'t load invalid file\",\"importBackendFailed\":\"Importing from backend failed.\",\"cannotExportEmptyCanvas\":\"Cannot export empty canvas.\",\"couldNotCopyToClipboard\":\"Couldn\\'t copy to clipboard.\",\"decryptFailed\":\"Couldn\\'t decrypt data.\",\"uploadedSecurly\":\"The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can\\'t read the content.\",\"loadSceneOverridePrompt\":\"Loading external drawing will replace your existing content. Do you wish to continue?\",\"collabStopOverridePrompt\":\"Stopping the session will overwrite your previous, locally stored drawing. Are you sure?\\\\n\\\\n(If you want to keep your local drawing, simply close the browser tab instead.)\",\"errorAddingToLibrary\":\"Couldn\\'t add item to the library\",\"errorRemovingFromLibrary\":\"Couldn\\'t remove item from the library\",\"confirmAddLibrary\":\"This will add {{numShapes}} shape(s) to your library. Are you sure?\",\"imageDoesNotContainScene\":\"This image does not seem to contain any scene data. Have you enabled scene embedding during export?\",\"cannotRestoreFromImage\":\"Scene couldn\\'t be restored from this image file\",\"invalidSceneUrl\":\"Couldn\\'t import scene from the supplied URL. It\\'s either malformed, or doesn\\'t contain valid Excalidraw JSON data.\",\"resetLibrary\":\"This will clear your library. Are you sure?\",\"removeItemsFromsLibrary\":\"Delete {{count}} item(s) from library?\",\"invalidEncryptionKey\":\"Encryption key must be of 22 characters. Live collaboration is disabled.\",\"collabOfflineWarning\":\"No internet connection available.\\\\nYour changes will not be saved!\"},\"errors\":{\"unsupportedFileType\":\"Unsupported file type.\",\"imageInsertError\":\"Couldn\\'t insert image. Try again later...\",\"fileTooBig\":\"File is too big. Maximum allowed size is {{maxSize}}.\",\"svgImageInsertError\":\"Couldn\\'t insert SVG image. The SVG markup looks invalid.\",\"failedToFetchImage\":\"Failed to fetch image.\",\"cannotResolveCollabServer\":\"Couldn\\'t connect to the collab server. Please reload the page and try again.\",\"importLibraryError\":\"Couldn\\'t load library\",\"saveLibraryError\":\"Couldn\\'t save library to storage. Please save your library to a file locally to make sure you don\\'t lose changes.\",\"collabSaveFailed\":\"Couldn\\'t save to the backend database. If problems persist, you should save your file locally to ensure you don\\'t lose your work.\",\"collabSaveFailed_sizeExceeded\":\"Couldn\\'t save to the backend database, the canvas seems to be too big. You should save the file locally to ensure you don\\'t lose your work.\",\"imageToolNotSupported\":\"Images are disabled.\",\"brave_measure_text_error\":{\"line1\":\"Looks like you are using Brave browser with the <bold>Aggressively Block Fingerprinting</bold> setting enabled.\",\"line2\":\"This could result in breaking the <bold>Text Elements</bold> in your drawings.\",\"line3\":\"We strongly recommend disabling this setting. You can follow <link>these steps</link> on how to do so.\",\"line4\":\"If disabling this setting doesn\\'t fix the display of text elements, please open an <issueLink>issue</issueLink> on our GitHub, or write us on <discordLink>Discord</discordLink>\"},\"libraryElementTypeError\":{\"embeddable\":\"Embeddable elements cannot be added to the library.\",\"iframe\":\"IFrame elements cannot be added to the library.\",\"image\":\"Support for adding images to the library coming soon!\"},\"asyncPasteFailedOnRead\":\"Couldn\\'t paste (couldn\\'t read from system clipboard).\",\"asyncPasteFailedOnParse\":\"Couldn\\'t paste.\",\"copyToSystemClipboardFailed\":\"Couldn\\'t copy to clipboard.\"},\"toolBar\":{\"selection\":\"Selection\",\"lasso\":\"Lasso selection\",\"image\":\"Insert image\",\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Draw\",\"text\":\"Text\",\"library\":\"Library\",\"lock\":\"Keep selected tool active after drawing\",\"penMode\":\"Pen mode - prevent touch\",\"link\":\"Add / Update link for a selected shape\",\"eraser\":\"Eraser\",\"frame\":\"Frame tool\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"laser\":\"Laser pointer\",\"hand\":\"Hand (panning tool)\",\"extraTools\":\"More tools\",\"mermaidToExcalidraw\":\"Mermaid to Excalidraw\"},\"element\":{\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Freedraw\",\"text\":\"Text\",\"image\":\"Image\",\"group\":\"Group\",\"frame\":\"Frame\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"selection\":\"Selection\",\"iframe\":\"IFrame\"},\"headings\":{\"canvasActions\":\"Canvas actions\",\"selectedShapeActions\":\"Selected shape actions\",\"shapes\":\"Shapes\"},\"hints\":{\"dismissSearch\":\"Escape to dismiss search\",\"canvasPanning\":\"To move canvas, hold mouse wheel or spacebar while dragging, or use the hand tool\",\"linearElement\":\"Click to start multiple points, drag for single line\",\"arrowTool\":\"Click to start multiple points, drag for single line. Press {{arrowShortcut}} again to change arrow type.\",\"freeDraw\":\"Click and drag, release when you\\'re finished\",\"text\":\"Tip: you can also add text by double-clicking anywhere with the selection tool\",\"embeddable\":\"Click-drag to create a website embed\",\"text_selected\":\"Double-click or press ENTER to edit text\",\"text_editing\":\"Press Escape or CtrlOrCmd+ENTER to finish editing\",\"linearElementMulti\":\"Click on last point or press Escape or Enter to finish\",\"lockAngle\":\"You can constrain angle by holding SHIFT\",\"resize\":\"You can constrain proportions by holding SHIFT while resizing,\\\\nhold ALT to resize from the center\",\"resizeImage\":\"You can resize freely by holding SHIFT,\\\\nhold ALT to resize from the center\",\"rotate\":\"You can constrain angles by holding SHIFT while rotating\",\"lineEditor_info\":\"Hold CtrlOrCmd and Double-click or press CtrlOrCmd + Enter to edit points\",\"lineEditor_pointSelected\":\"Press Delete to remove point(s),\\\\nCtrlOrCmd+D to duplicate, or drag to move\",\"lineEditor_nothingSelected\":\"Select a point to edit (hold SHIFT to select multiple),\\\\nor hold Alt and click to add new points\",\"placeImage\":\"Click to place the image, or click and drag to set its size manually\",\"publishLibrary\":\"Publish your own library\",\"bindTextToElement\":\"Press enter to add text\",\"createFlowchart\":\"Hold CtrlOrCmd and Arrow key to create a flowchart\",\"deepBoxSelect\":\"Hold CtrlOrCmd to deep select, and to prevent dragging\",\"eraserRevert\":\"Hold Alt to revert the elements marked for deletion\",\"firefox_clipboard_write\":\"This feature can likely be enabled by setting the \\\\\"dom.events.asyncClipboard.clipboardItem\\\\\" flag to \\\\\"true\\\\\". To change the browser flags in Firefox, visit the \\\\\"about:config\\\\\" page.\",\"disableSnapping\":\"Hold CtrlOrCmd to disable snapping\",\"enterCropEditor\":\"Double click the image or press ENTER to crop the image\",\"leaveCropEditor\":\"Click outside the image or press ENTER or ESCAPE to finish cropping\"},\"canvasError\":{\"cannotShowPreview\":\"Cannot show preview\",\"canvasTooBig\":\"The canvas may be too big.\",\"canvasTooBigTip\":\"Tip: try moving the farthest elements a bit closer together.\"},\"errorSplash\":{\"headingMain\":\"Encountered an error. Try <button>reloading the page</button>.\",\"clearCanvasMessage\":\"If reloading doesn\\'t work, try <button>clearing the canvas</button>.\",\"clearCanvasCaveat\":\" This will result in loss of work \",\"trackedToSentry\":\"The error with identifier {{eventId}} was tracked on our system.\",\"openIssueMessage\":\"We were very cautious not to include your scene information on the error. If your scene is not private, please consider following up on our <button>bug tracker</button>. Please include information below by copying and pasting into the GitHub issue.\",\"sceneContent\":\"Scene content:\"},\"shareDialog\":{\"or\":\"Or\"},\"roomDialog\":{\"desc_intro\":\"Invite people to collaborate on your drawing.\",\"desc_privacy\":\"Don\\'t worry, the session is end-to-end encrypted, and fully private. Not even our server can see what you draw.\",\"button_startSession\":\"Start session\",\"button_stopSession\":\"Stop session\",\"desc_inProgressIntro\":\"Live-collaboration session is now in progress.\",\"desc_shareLink\":\"Share this link with anyone you want to collaborate with:\",\"desc_exitSession\":\"Stopping the session will disconnect you from the room, but you\\'ll be able to continue working with the scene, locally. Note that this won\\'t affect other people, and they\\'ll still be able to collaborate on their version.\",\"shareTitle\":\"Join a live collaboration session on Excalidraw\"},\"errorDialog\":{\"title\":\"Error\"},\"exportDialog\":{\"disk_title\":\"Save to disk\",\"disk_details\":\"Export the scene data to a file from which you can import later.\",\"disk_button\":\"Save to file\",\"link_title\":\"Shareable link\",\"link_details\":\"Export as a read-only link.\",\"link_button\":\"Export to Link\",\"excalidrawplus_description\":\"Save the scene to your Excalidraw+ workspace.\",\"excalidrawplus_button\":\"Export\",\"excalidrawplus_exportError\":\"Couldn\\'t export to Excalidraw+ at this moment...\"},\"helpDialog\":{\"blog\":\"Read our blog\",\"click\":\"click\",\"deepSelect\":\"Deep select\",\"deepBoxSelect\":\"Deep select within box, and prevent dragging\",\"createFlowchart\":\"Create a flowchart from a generic element\",\"navigateFlowchart\":\"Navigate a flowchart\",\"curvedArrow\":\"Curved arrow\",\"curvedLine\":\"Curved line\",\"documentation\":\"Documentation\",\"doubleClick\":\"double-click\",\"drag\":\"drag\",\"editor\":\"Editor\",\"editLineArrowPoints\":\"Edit line/arrow points\",\"editText\":\"Edit text / add label\",\"github\":\"Found an issue? Submit\",\"howto\":\"Follow our guides\",\"or\":\"or\",\"preventBinding\":\"Prevent arrow binding\",\"tools\":\"Tools\",\"shortcuts\":\"Keyboard shortcuts\",\"textFinish\":\"Finish editing (text editor)\",\"textNewLine\":\"Add new line (text editor)\",\"title\":\"Help\",\"view\":\"View\",\"zoomToFit\":\"Zoom to fit all elements\",\"zoomToSelection\":\"Zoom to selection\",\"toggleElementLock\":\"Lock/unlock selection\",\"movePageUpDown\":\"Move page up/down\",\"movePageLeftRight\":\"Move page left/right\",\"cropStart\":\"Crop image\",\"cropFinish\":\"Finish image cropping\"},\"clearCanvasDialog\":{\"title\":\"Clear canvas\"},\"publishDialog\":{\"title\":\"Publish library\",\"itemName\":\"Item name\",\"authorName\":\"Author name\",\"githubUsername\":\"GitHub username\",\"twitterUsername\":\"Twitter username\",\"libraryName\":\"Library name\",\"libraryDesc\":\"Library description\",\"website\":\"Website\",\"placeholder\":{\"authorName\":\"Your name or username\",\"libraryName\":\"Name of your library\",\"libraryDesc\":\"Description of your library to help people understand its usage\",\"githubHandle\":\"GitHub handle (optional), so you can edit the library once submitted for review\",\"twitterHandle\":\"Twitter username (optional), so we know who to credit when promoting over Twitter\",\"website\":\"Link to your personal website or elsewhere (optional)\"},\"errors\":{\"required\":\"Required\",\"website\":\"Enter a valid URL\"},\"noteDescription\":\"Submit your library to be included in the <link>public library repository</link> for other people to use in their drawings.\",\"noteGuidelines\":\"The library needs to be manually approved first. Please read the <link>guidelines</link> before submitting. You will need a GitHub account to communicate and make changes if requested, but it is not strictly required.\",\"noteLicense\":\"By submitting, you agree the library will be published under the <link>MIT License</link>, which in short means anyone can use them without restrictions.\",\"noteItems\":\"Each library item must have its own name so it\\'s filterable. The following library items will be included:\",\"atleastOneLibItem\":\"Please select at least one library item to get started\",\"republishWarning\":\"Note: some of the selected items are marked as already published/submitted. You should only resubmit items when updating an existing library or submission.\"},\"publishSuccessDialog\":{\"title\":\"Library submitted\",\"content\":\"Thank you {{authorName}}. Your library has been submitted for review. You can track the status <link>here</link>\"},\"confirmDialog\":{\"resetLibrary\":\"Reset library\",\"removeItemsFromLib\":\"Remove selected items from library\"},\"imageExportDialog\":{\"header\":\"Export image\",\"label\":{\"withBackground\":\"Background\",\"onlySelected\":\"Only selected\",\"darkMode\":\"Dark mode\",\"embedScene\":\"Embed scene\",\"scale\":\"Scale\",\"padding\":\"Padding\"},\"tooltip\":{\"embedScene\":\"Scene data will be saved into the exported PNG/SVG file so that the scene can be restored from it.\\\\nWill increase exported file size.\"},\"title\":{\"exportToPng\":\"Export to PNG\",\"exportToSvg\":\"Export to SVG\",\"copyPngToClipboard\":\"Copy PNG to clipboard\"},\"button\":{\"exportToPng\":\"PNG\",\"exportToSvg\":\"SVG\",\"copyPngToClipboard\":\"Copy to clipboard\"}},\"encrypted\":{\"tooltip\":\"Your drawings are end-to-end encrypted so Excalidraw\\'s servers will never see them.\",\"link\":\"Blog post on end-to-end encryption in Excalidraw\"},\"stats\":{\"angle\":\"Angle\",\"shapes\":\"Shapes\",\"height\":\"Height\",\"scene\":\"Scene\",\"selected\":\"Selected\",\"storage\":\"Storage\",\"fullTitle\":\"Canvas & Shape properties\",\"title\":\"Properties\",\"generalStats\":\"General\",\"elementProperties\":\"Shape properties\",\"total\":\"Total\",\"version\":\"Version\",\"versionCopy\":\"Click to copy\",\"versionNotAvailable\":\"Version not available\",\"width\":\"Width\"},\"toast\":{\"addedToLibrary\":\"Added to library\",\"copyStyles\":\"Copied styles.\",\"copyToClipboard\":\"Copied to clipboard.\",\"copyToClipboardAsPng\":\"Copied {{exportSelection}} to clipboard as PNG\\\\n({{exportColorScheme}})\",\"copyToClipboardAsSvg\":\"Copied {{exportSelection}} to clipboard as SVG\\\\n({{exportColorScheme}})\",\"fileSaved\":\"File saved.\",\"fileSavedToFilename\":\"Saved to {filename}\",\"canvas\":\"canvas\",\"selection\":\"selection\",\"pasteAsSingleElement\":\"Use {{shortcut}} to paste as a single element,\\\\nor paste into an existing text editor\",\"unableToEmbed\":\"Embedding this url is currently not allowed. Raise an issue on GitHub to request the url whitelisted\",\"unrecognizedLinkFormat\":\"The link you embedded does not match the expected format. Please try to paste the \\'embed\\' string provided by the source site\",\"elementLinkCopied\":\"Link copied to clipboard\"},\"colors\":{\"transparent\":\"Transparent\",\"black\":\"Black\",\"white\":\"White\",\"red\":\"Red\",\"pink\":\"Pink\",\"grape\":\"Grape\",\"violet\":\"Violet\",\"gray\":\"Gray\",\"blue\":\"Blue\",\"cyan\":\"Cyan\",\"teal\":\"Teal\",\"green\":\"Green\",\"yellow\":\"Yellow\",\"orange\":\"Orange\",\"bronze\":\"Bronze\"},\"welcomeScreen\":{\"app\":{\"center_heading\":\"All your data is saved locally in your browser.\",\"center_heading_plus\":\"Did you want to go to the Excalidraw+ instead?\",\"menuHint\":\"Export, preferences, languages, ...\"},\"defaults\":{\"menuHint\":\"Export, preferences, and more...\",\"center_heading\":\"Diagrams. Made. Simple.\",\"toolbarHint\":\"Pick a tool & Start drawing!\",\"helpHint\":\"Shortcuts & help\"}},\"colorPicker\":{\"mostUsedCustomColors\":\"Most used custom colors\",\"colors\":\"Colors\",\"shades\":\"Shades\",\"hexCode\":\"Hex code\",\"noShades\":\"No shades available for this color\"},\"overwriteConfirm\":{\"action\":{\"exportToImage\":{\"title\":\"Export as image\",\"button\":\"Export as image\",\"description\":\"Export the scene data as an image from which you can import later.\"},\"saveToDisk\":{\"title\":\"Save to disk\",\"button\":\"Save to disk\",\"description\":\"Export the scene data to a file from which you can import later.\"},\"excalidrawPlus\":{\"title\":\"Excalidraw+\",\"button\":\"Export to Excalidraw+\",\"description\":\"Save the scene to your Excalidraw+ workspace.\"}},\"modal\":{\"loadFromFile\":{\"title\":\"Load from file\",\"button\":\"Load from file\",\"description\":\"Loading from a file will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first using one of the options below.\"},\"shareableLink\":{\"title\":\"Load from link\",\"button\":\"Replace my content\",\"description\":\"Loading external drawing will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first by using one of the options below.\"}}},\"mermaid\":{\"title\":\"Mermaid to Excalidraw\",\"button\":\"Insert\",\"description\":\"Currently only <flowchartLink>Flowchart</flowchartLink>,<sequenceLink> Sequence, </sequenceLink> and <classLink>Class </classLink>Diagrams are supported. The other types will be rendered as image in Excalidraw.\",\"syntax\":\"Mermaid Syntax\",\"preview\":\"Preview\"},\"quickSearch\":{\"placeholder\":\"Quick search\"},\"fontList\":{\"badge\":{\"old\":\"old\"},\"sceneFonts\":\"In this scene\",\"availableFonts\":\"Available fonts\",\"empty\":\"No fonts found\"},\"userList\":{\"empty\":\"No users found\",\"hint\":{\"text\":\"Click on user to follow\",\"followStatus\":\"You\\'re currently following this user\",\"inCall\":\"User is in a voice call\",\"micMuted\":\"User\\'s microphone is muted\",\"isSpeaking\":\"User is speaking\"}},\"commandPalette\":{\"title\":\"Command palette\",\"shortcuts\":{\"select\":\"Select\",\"confirm\":\"Confirm\",\"close\":\"Close\"},\"recents\":\"Recently used\",\"search\":{\"placeholder\":\"Search menus, commands, and discover hidden gems\",\"noMatch\":\"No matching commands...\"},\"itemNotAvailable\":\"Command is not available...\",\"shortcutHint\":\"For Command palette, use {{shortcut}}\"}}');\n\n//# sourceURL=webpack://ExcalidrawLib/./locales/en.json?");
|
|
19935
|
+
eval("module.exports = /*#__PURE__*/JSON.parse('{\"labels\":{\"laser\":\"Toggle laser pointer\",\"paste\":\"Paste\",\"pasteAsPlaintext\":\"Paste as plaintext\",\"pasteCharts\":\"Paste charts\",\"selectAll\":\"Select all\",\"multiSelect\":\"Add element to selection\",\"moveCanvas\":\"Move canvas\",\"cut\":\"Cut\",\"copy\":\"Copy\",\"copyAsPng\":\"Copy to clipboard as PNG\",\"copyAsSvg\":\"Copy to clipboard as SVG\",\"copyText\":\"Copy to clipboard as text\",\"copySource\":\"Copy source to clipboard\",\"convertToCode\":\"Convert to code\",\"bringForward\":\"Bring forward\",\"sendToBack\":\"Send to back\",\"bringToFront\":\"Bring to front\",\"sendBackward\":\"Send backward\",\"delete\":\"Delete\",\"copyStyles\":\"Copy styles\",\"pasteStyles\":\"Paste styles\",\"stroke\":\"Stroke\",\"changeStroke\":\"Change stroke color\",\"background\":\"Background\",\"changeBackground\":\"Change background color\",\"fill\":\"Fill\",\"strokeWidth\":\"Stroke width\",\"strokeStyle\":\"Stroke style\",\"strokeStyle_solid\":\"Solid\",\"strokeStyle_dashed\":\"Dashed\",\"strokeStyle_dotted\":\"Dotted\",\"sloppiness\":\"Sloppiness\",\"opacity\":\"Opacity\",\"textAlign\":\"Text align\",\"edges\":\"Edges\",\"sharp\":\"Sharp\",\"round\":\"Round\",\"arrowheads\":\"Arrowheads\",\"arrowhead_none\":\"None\",\"arrowhead_arrow\":\"Arrow\",\"arrowhead_bar\":\"Bar\",\"arrowhead_dot\":\"Dot\",\"arrowhead_circle\":\"Circle\",\"arrowhead_circle_outline\":\"Circle (outline)\",\"arrowhead_triangle\":\"Triangle\",\"arrowhead_triangle_outline\":\"Triangle (outline)\",\"arrowhead_diamond\":\"Diamond\",\"arrowhead_diamond_outline\":\"Diamond (outline)\",\"arrowhead_crowfoot_many\":\"Crow\\'s foot (many)\",\"arrowhead_crowfoot_one\":\"Crow\\'s foot (one)\",\"arrowhead_crowfoot_one_or_many\":\"Crow\\'s foot (one or many)\",\"more_options\":\"More options\",\"arrowtypes\":\"Arrow type\",\"arrowtype_sharp\":\"Sharp arrow\",\"arrowtype_round\":\"Curved arrow\",\"arrowtype_elbowed\":\"Elbow arrow\",\"fontSize\":\"Font size\",\"fontFamily\":\"Font family\",\"addWatermark\":\"Add \\\\\"Made with Excalidraw\\\\\"\",\"handDrawn\":\"Hand-drawn\",\"normal\":\"Normal\",\"code\":\"Code\",\"localFont\":\"Local Font\",\"small\":\"Small\",\"medium\":\"Medium\",\"large\":\"Large\",\"veryLarge\":\"Very large\",\"solid\":\"Solid\",\"hachure\":\"Hachure\",\"zigzag\":\"Zigzag\",\"crossHatch\":\"Cross-hatch\",\"extraThin\":\"Extra thin\",\"thin\":\"Thin\",\"bold\":\"Bold\",\"left\":\"Left\",\"center\":\"Center\",\"right\":\"Right\",\"extraBold\":\"Extra bold\",\"architect\":\"Architect\",\"artist\":\"Artist\",\"cartoonist\":\"Cartoonist\",\"fileTitle\":\"File name\",\"colorPicker\":\"Color picker\",\"canvasColors\":\"Used on canvas\",\"canvasBackground\":\"Canvas background\",\"drawingCanvas\":\"Drawing canvas\",\"clearCanvas\":\"Clear canvas\",\"layers\":\"Layers\",\"actions\":\"Actions\",\"language\":\"Language\",\"liveCollaboration\":\"Live collaboration...\",\"duplicateSelection\":\"Duplicate\",\"untitled\":\"Untitled\",\"name\":\"Name\",\"yourName\":\"Your name\",\"madeWithExcalidraw\":\"Made with Excalidraw\",\"group\":\"Group selection\",\"ungroup\":\"Ungroup selection\",\"collaborators\":\"Collaborators\",\"toggleGrid\":\"Toggle grid\",\"addToLibrary\":\"Add to library\",\"removeFromLibrary\":\"Remove from library\",\"libraryLoadingMessage\":\"Loading library…\",\"libraries\":\"Browse libraries\",\"loadingScene\":\"Loading scene…\",\"loadScene\":\"Load scene from file\",\"align\":\"Align\",\"alignTop\":\"Align top\",\"alignBottom\":\"Align bottom\",\"alignLeft\":\"Align left\",\"alignRight\":\"Align right\",\"centerVertically\":\"Center vertically\",\"centerHorizontally\":\"Center horizontally\",\"distributeHorizontally\":\"Distribute horizontally\",\"distributeVertically\":\"Distribute vertically\",\"flipHorizontal\":\"Flip horizontal\",\"flipVertical\":\"Flip vertical\",\"viewMode\":\"View mode\",\"share\":\"Share\",\"showStroke\":\"Show stroke color picker\",\"showBackground\":\"Show background color picker\",\"showFonts\":\"Show font picker\",\"toggleTheme\":\"Toggle light/dark theme\",\"theme\":\"Theme\",\"personalLib\":\"Personal Library\",\"excalidrawLib\":\"Excalidraw Library\",\"decreaseFontSize\":\"Decrease font size\",\"increaseFontSize\":\"Increase font size\",\"unbindText\":\"Unbind text\",\"bindText\":\"Bind text to the container\",\"createContainerFromText\":\"Wrap text in a container\",\"link\":{\"edit\":\"Edit link\",\"editEmbed\":\"Edit embeddable link\",\"create\":\"Add link\",\"label\":\"Link\",\"labelEmbed\":\"Link & embed\",\"empty\":\"No link is set\",\"hint\":\"Type or paste your link here\",\"goToElement\":\"Go to target element\"},\"lineEditor\":{\"edit\":\"Edit line\",\"editArrow\":\"Edit arrow\"},\"elementLock\":{\"lock\":\"Lock\",\"unlock\":\"Unlock\",\"lockAll\":\"Lock all\",\"unlockAll\":\"Unlock all\"},\"statusPublished\":\"Published\",\"sidebarLock\":\"Keep sidebar open\",\"selectAllElementsInFrame\":\"Select all elements in frame\",\"removeAllElementsFromFrame\":\"Remove all elements from frame\",\"eyeDropper\":\"Pick color from canvas\",\"textToDiagram\":\"Text to diagram\",\"prompt\":\"Prompt\",\"followUs\":\"Follow us\",\"discordChat\":\"Discord chat\",\"zoomToFitViewport\":\"Zoom to fit in viewport\",\"zoomToFitSelection\":\"Zoom to fit selection\",\"zoomToFit\":\"Zoom to fit all elements\",\"installPWA\":\"Install Excalidraw locally (PWA)\",\"autoResize\":\"Enable text auto-resizing\",\"imageCropping\":\"Image cropping\",\"unCroppedDimension\":\"Uncropped dimension\",\"copyElementLink\":\"Copy link to object\",\"linkToElement\":\"Link to object\",\"wrapSelectionInFrame\":\"Wrap selection in frame\",\"tab\":\"Tab\",\"shapeSwitch\":\"Switch shape\"},\"elementLink\":{\"title\":\"Link to object\",\"desc\":\"Click on a shape on canvas or paste a link.\",\"notFound\":\"Linked object wasn\\'t found on canvas.\"},\"library\":{\"noItems\":\"No items added yet...\",\"hint_emptyLibrary\":\"Select an item on canvas to add it here, or install a library from the public repository, below.\",\"hint_emptyPrivateLibrary\":\"Select an item on canvas to add it here.\"},\"search\":{\"title\":\"Find on canvas\",\"noMatch\":\"No matches found...\",\"singleResult\":\"result\",\"multipleResults\":\"results\",\"placeholder\":\"Find text on canvas...\"},\"buttons\":{\"clearReset\":\"Reset the canvas\",\"exportJSON\":\"Export to file\",\"exportImage\":\"Export image...\",\"export\":\"Save to...\",\"copyToClipboard\":\"Copy to clipboard\",\"copyLink\":\"Copy link\",\"save\":\"Save to current file\",\"saveAs\":\"Save as\",\"load\":\"Open\",\"getShareableLink\":\"Get shareable link\",\"close\":\"Close\",\"selectLanguage\":\"Select language\",\"scrollBackToContent\":\"Scroll back to content\",\"zoomIn\":\"Zoom in\",\"zoomOut\":\"Zoom out\",\"resetZoom\":\"Reset zoom\",\"menu\":\"Menu\",\"done\":\"Done\",\"edit\":\"Edit\",\"undo\":\"Undo\",\"redo\":\"Redo\",\"resetLibrary\":\"Reset library\",\"createNewRoom\":\"Create new room\",\"fullScreen\":\"Full screen\",\"darkMode\":\"Dark mode\",\"lightMode\":\"Light mode\",\"systemMode\":\"System mode\",\"zenMode\":\"Zen mode\",\"objectsSnapMode\":\"Snap to objects\",\"exitZenMode\":\"Exit zen mode\",\"cancel\":\"Cancel\",\"clear\":\"Clear\",\"remove\":\"Remove\",\"embed\":\"Toggle embedding\",\"publishLibrary\":\"Publish\",\"submit\":\"Submit\",\"confirm\":\"Confirm\",\"embeddableInteractionButton\":\"Click to interact\"},\"alerts\":{\"clearReset\":\"This will clear the whole canvas. Are you sure?\",\"couldNotCreateShareableLink\":\"Couldn\\'t create shareable link.\",\"couldNotCreateShareableLinkTooBig\":\"Couldn\\'t create shareable link: the scene is too big\",\"couldNotLoadInvalidFile\":\"Couldn\\'t load invalid file\",\"importBackendFailed\":\"Importing from backend failed.\",\"cannotExportEmptyCanvas\":\"Cannot export empty canvas.\",\"couldNotCopyToClipboard\":\"Couldn\\'t copy to clipboard.\",\"decryptFailed\":\"Couldn\\'t decrypt data.\",\"uploadedSecurly\":\"The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can\\'t read the content.\",\"loadSceneOverridePrompt\":\"Loading external drawing will replace your existing content. Do you wish to continue?\",\"collabStopOverridePrompt\":\"Stopping the session will overwrite your previous, locally stored drawing. Are you sure?\\\\n\\\\n(If you want to keep your local drawing, simply close the browser tab instead.)\",\"errorAddingToLibrary\":\"Couldn\\'t add item to the library\",\"errorRemovingFromLibrary\":\"Couldn\\'t remove item from the library\",\"confirmAddLibrary\":\"This will add {{numShapes}} shape(s) to your library. Are you sure?\",\"imageDoesNotContainScene\":\"This image does not seem to contain any scene data. Have you enabled scene embedding during export?\",\"cannotRestoreFromImage\":\"Scene couldn\\'t be restored from this image file\",\"invalidSceneUrl\":\"Couldn\\'t import scene from the supplied URL. It\\'s either malformed, or doesn\\'t contain valid Excalidraw JSON data.\",\"resetLibrary\":\"This will clear your library. Are you sure?\",\"removeItemsFromsLibrary\":\"Delete {{count}} item(s) from library?\",\"invalidEncryptionKey\":\"Encryption key must be of 22 characters. Live collaboration is disabled.\",\"collabOfflineWarning\":\"No internet connection available.\\\\nYour changes will not be saved!\"},\"errors\":{\"unsupportedFileType\":\"Unsupported file type.\",\"imageInsertError\":\"Couldn\\'t insert image. Try again later...\",\"fileTooBig\":\"File is too big. Maximum allowed size is {{maxSize}}.\",\"svgImageInsertError\":\"Couldn\\'t insert SVG image. The SVG markup looks invalid.\",\"failedToFetchImage\":\"Failed to fetch image.\",\"cannotResolveCollabServer\":\"Couldn\\'t connect to the collab server. Please reload the page and try again.\",\"importLibraryError\":\"Couldn\\'t load library\",\"saveLibraryError\":\"Couldn\\'t save library to storage. Please save your library to a file locally to make sure you don\\'t lose changes.\",\"collabSaveFailed\":\"Couldn\\'t save to the backend database. If problems persist, you should save your file locally to ensure you don\\'t lose your work.\",\"collabSaveFailed_sizeExceeded\":\"Couldn\\'t save to the backend database, the canvas seems to be too big. You should save the file locally to ensure you don\\'t lose your work.\",\"imageToolNotSupported\":\"Images are disabled.\",\"brave_measure_text_error\":{\"line1\":\"Looks like you are using Brave browser with the <bold>Aggressively Block Fingerprinting</bold> setting enabled.\",\"line2\":\"This could result in breaking the <bold>Text Elements</bold> in your drawings.\",\"line3\":\"We strongly recommend disabling this setting. You can follow <link>these steps</link> on how to do so.\",\"line4\":\"If disabling this setting doesn\\'t fix the display of text elements, please open an <issueLink>issue</issueLink> on our GitHub, or write us on <discordLink>Discord</discordLink>\"},\"libraryElementTypeError\":{\"embeddable\":\"Embeddable elements cannot be added to the library.\",\"iframe\":\"IFrame elements cannot be added to the library.\",\"image\":\"Support for adding images to the library coming soon!\"},\"asyncPasteFailedOnRead\":\"Couldn\\'t paste (couldn\\'t read from system clipboard).\",\"asyncPasteFailedOnParse\":\"Couldn\\'t paste.\",\"copyToSystemClipboardFailed\":\"Couldn\\'t copy to clipboard.\"},\"toolBar\":{\"selection\":\"Selection\",\"lasso\":\"Lasso selection\",\"image\":\"Insert image\",\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Draw\",\"text\":\"Text\",\"library\":\"Library\",\"lock\":\"Keep selected tool active after drawing\",\"penMode\":\"Pen mode - prevent touch\",\"link\":\"Add / Update link for a selected shape\",\"eraser\":\"Eraser\",\"frame\":\"Frame tool\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"laser\":\"Laser pointer\",\"hand\":\"Hand (panning tool)\",\"extraTools\":\"More tools\",\"mermaidToExcalidraw\":\"Mermaid to Excalidraw\",\"convertElementType\":\"Toggle shape type\"},\"element\":{\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Freedraw\",\"text\":\"Text\",\"image\":\"Image\",\"group\":\"Group\",\"frame\":\"Frame\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"selection\":\"Selection\",\"iframe\":\"IFrame\"},\"headings\":{\"canvasActions\":\"Canvas actions\",\"selectedShapeActions\":\"Selected shape actions\",\"shapes\":\"Shapes\"},\"hints\":{\"dismissSearch\":\"Escape to dismiss search\",\"canvasPanning\":\"To move canvas, hold mouse wheel or spacebar while dragging, or use the hand tool\",\"linearElement\":\"Click to start multiple points, drag for single line\",\"arrowTool\":\"Click to start multiple points, drag for single line. Press {{arrowShortcut}} again to change arrow type.\",\"freeDraw\":\"Click and drag, release when you\\'re finished\",\"text\":\"Tip: you can also add text by double-clicking anywhere with the selection tool\",\"embeddable\":\"Click-drag to create a website embed\",\"text_selected\":\"Double-click or press ENTER to edit text\",\"text_editing\":\"Press Escape or CtrlOrCmd+ENTER to finish editing\",\"linearElementMulti\":\"Click on last point or press Escape or Enter to finish\",\"lockAngle\":\"You can constrain angle by holding SHIFT\",\"resize\":\"You can constrain proportions by holding SHIFT while resizing,\\\\nhold ALT to resize from the center\",\"resizeImage\":\"You can resize freely by holding SHIFT,\\\\nhold ALT to resize from the center\",\"rotate\":\"You can constrain angles by holding SHIFT while rotating\",\"lineEditor_info\":\"Hold CtrlOrCmd and Double-click or press CtrlOrCmd + Enter to edit points\",\"lineEditor_pointSelected\":\"Press Delete to remove point(s),\\\\nCtrlOrCmd+D to duplicate, or drag to move\",\"lineEditor_nothingSelected\":\"Select a point to edit (hold SHIFT to select multiple),\\\\nor hold Alt and click to add new points\",\"placeImage\":\"Click to place the image, or click and drag to set its size manually\",\"publishLibrary\":\"Publish your own library\",\"bindTextToElement\":\"Press enter to add text\",\"createFlowchart\":\"Hold CtrlOrCmd and Arrow key to create a flowchart\",\"deepBoxSelect\":\"Hold CtrlOrCmd to deep select, and to prevent dragging\",\"eraserRevert\":\"Hold Alt to revert the elements marked for deletion\",\"firefox_clipboard_write\":\"This feature can likely be enabled by setting the \\\\\"dom.events.asyncClipboard.clipboardItem\\\\\" flag to \\\\\"true\\\\\". To change the browser flags in Firefox, visit the \\\\\"about:config\\\\\" page.\",\"disableSnapping\":\"Hold CtrlOrCmd to disable snapping\",\"enterCropEditor\":\"Double click the image or press ENTER to crop the image\",\"leaveCropEditor\":\"Click outside the image or press ENTER or ESCAPE to finish cropping\"},\"canvasError\":{\"cannotShowPreview\":\"Cannot show preview\",\"canvasTooBig\":\"The canvas may be too big.\",\"canvasTooBigTip\":\"Tip: try moving the farthest elements a bit closer together.\"},\"errorSplash\":{\"headingMain\":\"Encountered an error. Try <button>reloading the page</button>.\",\"clearCanvasMessage\":\"If reloading doesn\\'t work, try <button>clearing the canvas</button>.\",\"clearCanvasCaveat\":\" This will result in loss of work \",\"trackedToSentry\":\"The error with identifier {{eventId}} was tracked on our system.\",\"openIssueMessage\":\"We were very cautious not to include your scene information on the error. If your scene is not private, please consider following up on our <button>bug tracker</button>. Please include information below by copying and pasting into the GitHub issue.\",\"sceneContent\":\"Scene content:\"},\"shareDialog\":{\"or\":\"Or\"},\"roomDialog\":{\"desc_intro\":\"Invite people to collaborate on your drawing.\",\"desc_privacy\":\"Don\\'t worry, the session is end-to-end encrypted, and fully private. Not even our server can see what you draw.\",\"button_startSession\":\"Start session\",\"button_stopSession\":\"Stop session\",\"desc_inProgressIntro\":\"Live-collaboration session is now in progress.\",\"desc_shareLink\":\"Share this link with anyone you want to collaborate with:\",\"desc_exitSession\":\"Stopping the session will disconnect you from the room, but you\\'ll be able to continue working with the scene, locally. Note that this won\\'t affect other people, and they\\'ll still be able to collaborate on their version.\",\"shareTitle\":\"Join a live collaboration session on Excalidraw\"},\"errorDialog\":{\"title\":\"Error\"},\"exportDialog\":{\"disk_title\":\"Save to disk\",\"disk_details\":\"Export the scene data to a file from which you can import later.\",\"disk_button\":\"Save to file\",\"link_title\":\"Shareable link\",\"link_details\":\"Export as a read-only link.\",\"link_button\":\"Export to Link\",\"excalidrawplus_description\":\"Save the scene to your Excalidraw+ workspace.\",\"excalidrawplus_button\":\"Export\",\"excalidrawplus_exportError\":\"Couldn\\'t export to Excalidraw+ at this moment...\"},\"helpDialog\":{\"blog\":\"Read our blog\",\"click\":\"click\",\"deepSelect\":\"Deep select\",\"deepBoxSelect\":\"Deep select within box, and prevent dragging\",\"createFlowchart\":\"Create a flowchart from a generic element\",\"navigateFlowchart\":\"Navigate a flowchart\",\"curvedArrow\":\"Curved arrow\",\"curvedLine\":\"Curved line\",\"documentation\":\"Documentation\",\"doubleClick\":\"double-click\",\"drag\":\"drag\",\"editor\":\"Editor\",\"editLineArrowPoints\":\"Edit line/arrow points\",\"editText\":\"Edit text / add label\",\"github\":\"Found an issue? Submit\",\"howto\":\"Follow our guides\",\"or\":\"or\",\"preventBinding\":\"Prevent arrow binding\",\"tools\":\"Tools\",\"shortcuts\":\"Keyboard shortcuts\",\"textFinish\":\"Finish editing (text editor)\",\"textNewLine\":\"Add new line (text editor)\",\"title\":\"Help\",\"view\":\"View\",\"zoomToFit\":\"Zoom to fit all elements\",\"zoomToSelection\":\"Zoom to selection\",\"toggleElementLock\":\"Lock/unlock selection\",\"movePageUpDown\":\"Move page up/down\",\"movePageLeftRight\":\"Move page left/right\",\"cropStart\":\"Crop image\",\"cropFinish\":\"Finish image cropping\"},\"clearCanvasDialog\":{\"title\":\"Clear canvas\"},\"publishDialog\":{\"title\":\"Publish library\",\"itemName\":\"Item name\",\"authorName\":\"Author name\",\"githubUsername\":\"GitHub username\",\"twitterUsername\":\"Twitter username\",\"libraryName\":\"Library name\",\"libraryDesc\":\"Library description\",\"website\":\"Website\",\"placeholder\":{\"authorName\":\"Your name or username\",\"libraryName\":\"Name of your library\",\"libraryDesc\":\"Description of your library to help people understand its usage\",\"githubHandle\":\"GitHub handle (optional), so you can edit the library once submitted for review\",\"twitterHandle\":\"Twitter username (optional), so we know who to credit when promoting over Twitter\",\"website\":\"Link to your personal website or elsewhere (optional)\"},\"errors\":{\"required\":\"Required\",\"website\":\"Enter a valid URL\"},\"noteDescription\":\"Submit your library to be included in the <link>public library repository</link> for other people to use in their drawings.\",\"noteGuidelines\":\"The library needs to be manually approved first. Please read the <link>guidelines</link> before submitting. You will need a GitHub account to communicate and make changes if requested, but it is not strictly required.\",\"noteLicense\":\"By submitting, you agree the library will be published under the <link>MIT License</link>, which in short means anyone can use them without restrictions.\",\"noteItems\":\"Each library item must have its own name so it\\'s filterable. The following library items will be included:\",\"atleastOneLibItem\":\"Please select at least one library item to get started\",\"republishWarning\":\"Note: some of the selected items are marked as already published/submitted. You should only resubmit items when updating an existing library or submission.\"},\"publishSuccessDialog\":{\"title\":\"Library submitted\",\"content\":\"Thank you {{authorName}}. Your library has been submitted for review. You can track the status <link>here</link>\"},\"confirmDialog\":{\"resetLibrary\":\"Reset library\",\"removeItemsFromLib\":\"Remove selected items from library\"},\"imageExportDialog\":{\"header\":\"Export image\",\"label\":{\"withBackground\":\"Background\",\"onlySelected\":\"Only selected\",\"darkMode\":\"Dark mode\",\"embedScene\":\"Embed scene\",\"scale\":\"Scale\",\"padding\":\"Padding\"},\"tooltip\":{\"embedScene\":\"Scene data will be saved into the exported PNG/SVG file so that the scene can be restored from it.\\\\nWill increase exported file size.\"},\"title\":{\"exportToPng\":\"Export to PNG\",\"exportToSvg\":\"Export to SVG\",\"copyPngToClipboard\":\"Copy PNG to clipboard\"},\"button\":{\"exportToPng\":\"PNG\",\"exportToSvg\":\"SVG\",\"copyPngToClipboard\":\"Copy to clipboard\"}},\"encrypted\":{\"tooltip\":\"Your drawings are end-to-end encrypted so Excalidraw\\'s servers will never see them.\",\"link\":\"Blog post on end-to-end encryption in Excalidraw\"},\"stats\":{\"angle\":\"Angle\",\"shapes\":\"Shapes\",\"height\":\"Height\",\"scene\":\"Scene\",\"selected\":\"Selected\",\"storage\":\"Storage\",\"fullTitle\":\"Canvas & Shape properties\",\"title\":\"Properties\",\"generalStats\":\"General\",\"elementProperties\":\"Shape properties\",\"total\":\"Total\",\"version\":\"Version\",\"versionCopy\":\"Click to copy\",\"versionNotAvailable\":\"Version not available\",\"width\":\"Width\"},\"toast\":{\"addedToLibrary\":\"Added to library\",\"copyStyles\":\"Copied styles.\",\"copyToClipboard\":\"Copied to clipboard.\",\"copyToClipboardAsPng\":\"Copied {{exportSelection}} to clipboard as PNG\\\\n({{exportColorScheme}})\",\"copyToClipboardAsSvg\":\"Copied {{exportSelection}} to clipboard as SVG\\\\n({{exportColorScheme}})\",\"fileSaved\":\"File saved.\",\"fileSavedToFilename\":\"Saved to {filename}\",\"canvas\":\"canvas\",\"selection\":\"selection\",\"pasteAsSingleElement\":\"Use {{shortcut}} to paste as a single element,\\\\nor paste into an existing text editor\",\"unableToEmbed\":\"Embedding this url is currently not allowed. Raise an issue on GitHub to request the url whitelisted\",\"unrecognizedLinkFormat\":\"The link you embedded does not match the expected format. Please try to paste the \\'embed\\' string provided by the source site\",\"elementLinkCopied\":\"Link copied to clipboard\"},\"colors\":{\"transparent\":\"Transparent\",\"black\":\"Black\",\"white\":\"White\",\"red\":\"Red\",\"pink\":\"Pink\",\"grape\":\"Grape\",\"violet\":\"Violet\",\"gray\":\"Gray\",\"blue\":\"Blue\",\"cyan\":\"Cyan\",\"teal\":\"Teal\",\"green\":\"Green\",\"yellow\":\"Yellow\",\"orange\":\"Orange\",\"bronze\":\"Bronze\"},\"welcomeScreen\":{\"app\":{\"center_heading\":\"All your data is saved locally in your browser.\",\"center_heading_plus\":\"Did you want to go to the Excalidraw+ instead?\",\"menuHint\":\"Export, preferences, languages, ...\"},\"defaults\":{\"menuHint\":\"Export, preferences, and more...\",\"center_heading\":\"Diagrams. Made. Simple.\",\"toolbarHint\":\"Pick a tool & Start drawing!\",\"helpHint\":\"Shortcuts & help\"}},\"colorPicker\":{\"mostUsedCustomColors\":\"Most used custom colors\",\"colors\":\"Colors\",\"shades\":\"Shades\",\"hexCode\":\"Hex code\",\"noShades\":\"No shades available for this color\"},\"overwriteConfirm\":{\"action\":{\"exportToImage\":{\"title\":\"Export as image\",\"button\":\"Export as image\",\"description\":\"Export the scene data as an image from which you can import later.\"},\"saveToDisk\":{\"title\":\"Save to disk\",\"button\":\"Save to disk\",\"description\":\"Export the scene data to a file from which you can import later.\"},\"excalidrawPlus\":{\"title\":\"Excalidraw+\",\"button\":\"Export to Excalidraw+\",\"description\":\"Save the scene to your Excalidraw+ workspace.\"}},\"modal\":{\"loadFromFile\":{\"title\":\"Load from file\",\"button\":\"Load from file\",\"description\":\"Loading from a file will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first using one of the options below.\"},\"shareableLink\":{\"title\":\"Load from link\",\"button\":\"Replace my content\",\"description\":\"Loading external drawing will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first by using one of the options below.\"}}},\"mermaid\":{\"title\":\"Mermaid to Excalidraw\",\"button\":\"Insert\",\"description\":\"Currently only <flowchartLink>Flowchart</flowchartLink>,<sequenceLink> Sequence, </sequenceLink> and <classLink>Class </classLink>Diagrams are supported. The other types will be rendered as image in Excalidraw.\",\"syntax\":\"Mermaid Syntax\",\"preview\":\"Preview\"},\"quickSearch\":{\"placeholder\":\"Quick search\"},\"fontList\":{\"badge\":{\"old\":\"old\"},\"sceneFonts\":\"In this scene\",\"availableFonts\":\"Available fonts\",\"empty\":\"No fonts found\"},\"userList\":{\"empty\":\"No users found\",\"hint\":{\"text\":\"Click on user to follow\",\"followStatus\":\"You\\'re currently following this user\",\"inCall\":\"User is in a voice call\",\"micMuted\":\"User\\'s microphone is muted\",\"isSpeaking\":\"User is speaking\"}},\"commandPalette\":{\"title\":\"Command palette\",\"shortcuts\":{\"select\":\"Select\",\"confirm\":\"Confirm\",\"close\":\"Close\"},\"recents\":\"Recently used\",\"search\":{\"placeholder\":\"Search menus, commands, and discover hidden gems\",\"noMatch\":\"No matching commands...\"},\"itemNotAvailable\":\"Command is not available...\",\"shortcutHint\":\"For Command palette, use {{shortcut}}\"}}');\n\n//# sourceURL=webpack://ExcalidrawLib/./locales/en.json?");
|
|
19903
19936
|
|
|
19904
19937
|
/***/ }),
|
|
19905
19938
|
|
|
@@ -20789,7 +20822,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
20789
20822
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
20790
20823
|
|
|
20791
20824
|
"use strict";
|
|
20792
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ textWysiwyg: () => (/* binding */ textWysiwyg)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/containerCache */ \"../element/src/containerCache.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst getTransform = (width, height, angle, appState, maxWidth, maxHeight) => {\n const {\n zoom\n } = appState;\n const degree = 180 * angle / Math.PI;\n let translateX = width * (zoom.value - 1) / 2;\n let translateY = height * (zoom.value - 1) / 2;\n\n if (width > maxWidth && zoom.value !== 1) {\n translateX = maxWidth * (zoom.value - 1) / 2;\n }\n\n if (height > maxHeight && zoom.value !== 1) {\n translateY = maxHeight * (zoom.value - 1) / 2;\n }\n\n return `translate(${translateX}px, ${translateY}px) scale(${zoom.value}) rotate(${degree}deg)`;\n};\n\nconst textWysiwyg = ({\n id,\n onChange,\n onSubmit,\n getViewportCoords,\n element,\n canvas,\n excalidrawContainer,\n app,\n autoSelect = true\n}) => {\n const textPropertiesUpdated = (updatedTextElement, editable) => {\n if (!editable.style.fontFamily || !editable.style.fontSize) {\n return false;\n }\n\n const currentFont = editable.style.fontFamily.replace(/\"/g, \"\");\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontFamilyString)({\n fontFamily: updatedTextElement.fontFamily\n }) !== currentFont) {\n return true;\n }\n\n if (`${updatedTextElement.fontSize}px` !== editable.style.fontSize) {\n return true;\n }\n\n return false;\n };\n\n const updateWysiwygStyle = () => {\n const appState = app.state;\n const updatedTextElement = app.scene.getElement(id);\n\n if (!updatedTextElement) {\n return;\n }\n\n const {\n textAlign,\n verticalAlign\n } = updatedTextElement;\n const elementsMap = app.scene.getNonDeletedElementsMap();\n\n if (updatedTextElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(updatedTextElement)) {\n let coordX = updatedTextElement.x;\n let coordY = updatedTextElement.y;\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getContainerElement)(updatedTextElement, app.scene.getNonDeletedElementsMap());\n let width = updatedTextElement.width; // set to element height by default since that's\n // what is going to be used for unbounded text\n\n let height = updatedTextElement.height;\n let maxWidth = updatedTextElement.width;\n let maxHeight = updatedTextElement.height;\n\n if (container && updatedTextElement.containerId) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n const boundTextCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_2__.LinearElementEditor.getBoundTextElementPosition(container, updatedTextElement, elementsMap);\n coordX = boundTextCoords.x;\n coordY = boundTextCoords.y;\n }\n\n const propertiesUpdated = textPropertiesUpdated(updatedTextElement, editable);\n let originalContainerData;\n\n if (propertiesUpdated) {\n originalContainerData = (0,_excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__.updateOriginalContainerCache)(container.id, container.height);\n } else {\n originalContainerData = _excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__.originalContainerCache[container.id];\n\n if (!originalContainerData) {\n originalContainerData = (0,_excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__.updateOriginalContainerCache)(container.id, container.height);\n }\n }\n\n maxWidth = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxWidth)(container, updatedTextElement);\n maxHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxHeight)(container, updatedTextElement); // autogrow container height if text exceeds\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) && height > maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n return;\n } else if ( // autoshrink container height until original container height\n // is reached when text is removed\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) && container.height > originalContainerData.height && height < maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n } else {\n const {\n y\n } = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.computeBoundTextPosition)(container, updatedTextElement, elementsMap);\n coordY = y;\n }\n }\n\n const [viewportX, viewportY] = getViewportCoords(coordX, coordY);\n const initialSelectionStart = editable.selectionStart;\n const initialSelectionEnd = editable.selectionEnd;\n const initialLength = editable.value.length; // restore cursor position after value updated so it doesn't\n // go to the end of text when container auto expanded\n\n if (initialSelectionStart === initialSelectionEnd && initialSelectionEnd !== initialLength) {\n // get diff between length and selection end and shift\n // the cursor by \"diff\" times to position correctly\n const diff = initialLength - initialSelectionEnd;\n editable.selectionStart = editable.value.length - diff;\n editable.selectionEnd = editable.value.length - diff;\n }\n\n if (!container) {\n maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value;\n width = Math.min(width, maxWidth);\n } else {\n width += 0.5;\n } // add 5% buffer otherwise it causes wysiwyg to jump\n\n\n height *= 1.05;\n const font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontString)(updatedTextElement); // Make sure text editor height doesn't go beyond viewport\n\n const editorMaxHeight = (appState.height - viewportY) / appState.zoom.value;\n Object.assign(editable.style, {\n font,\n // must be defined *after* font ¯\\_(ツ)_/¯\n lineHeight: updatedTextElement.lineHeight,\n width: `${Math.ceil(width)}px`,\n height: `${height}px`,\n left: `${viewportX}px`,\n top: `${viewportY}px`,\n transform: getTransform(width, height, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getTextElementAngle)(updatedTextElement, container), appState, maxWidth, editorMaxHeight),\n textAlign,\n verticalAlign,\n color: updatedTextElement.strokeColor,\n opacity: updatedTextElement.opacity / 100,\n filter: \"var(--theme-filter)\",\n maxHeight: `${editorMaxHeight}px`,\n caretColor: updatedTextElement.strokeColor === \"transparent\" //zsviczian\n ? \"var(excalidraw-caret-color)\" : updatedTextElement.strokeColor //zsviczian Set caret color\n\n });\n editable.scrollTop = 0; // For some reason updating font attribute doesn't set font family\n // hence updating font family explicitly for test environment\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n editable.style.fontFamily = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontFamilyString)(updatedTextElement);\n }\n\n app.scene.mutateElement(updatedTextElement, {\n x: coordX,\n y: coordY\n });\n }\n };\n\n const editable = document.createElement(\"textarea\");\n editable.dir = \"auto\";\n editable.tabIndex = 0;\n editable.dataset.type = \"wysiwyg\"; // prevent line wrapping on Safari\n\n editable.wrap = \"off\";\n editable.classList.add(\"excalidraw-wysiwyg\");\n let whiteSpace = \"pre\";\n let wordBreak = \"normal\";\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(element) || !element.autoResize) {\n whiteSpace = \"pre-wrap\";\n wordBreak = \"break-word\";\n }\n\n Object.assign(editable.style, {\n position: \"absolute\",\n display: \"inline-block\",\n minHeight: \"1em\",\n backfaceVisibility: \"hidden\",\n margin: 0,\n padding: 0,\n border: 0,\n outline: 0,\n resize: \"none\",\n background: \"transparent\",\n overflow: \"hidden\",\n // must be specified because in dark mode canvas creates a stacking context\n zIndex: \"var(--zIndex-wysiwyg)\",\n wordBreak,\n // prevent line wrapping (`whitespace: nowrap` doesn't work on FF)\n whiteSpace,\n overflowWrap: \"break-word\",\n boxSizing: \"content-box\"\n });\n editable.value = element.originalText;\n updateWysiwygStyle();\n\n if (onChange) {\n editable.onpaste = async event => {\n const clipboardData = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_9__.parseClipboard)(event, true);\n\n if (!clipboardData.text) {\n return;\n }\n\n const data = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__.normalizeText)(clipboardData.text);\n\n if (!data) {\n return;\n }\n\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getContainerElement)(element, app.scene.getNonDeletedElementsMap());\n const font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontString)({\n fontSize: app.state.currentItemFontSize,\n fontFamily: app.state.currentItemFontFamily\n });\n\n if (container) {\n const boundTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextElement)(container, app.scene.getNonDeletedElementsMap());\n const wrappedText = (0,_excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_6__.wrapText)(`${editable.value}${data}`, font, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxWidth)(container, boundTextElement));\n const width = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__.getTextWidth)(wrappedText, font);\n editable.style.width = `${Math.ceil(width)}px`; //zsviczian Obsidian app zoom !== 100% issue\n }\n };\n\n editable.oninput = () => {\n const normalized = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__.normalizeText)(editable.value);\n\n if (editable.value !== normalized) {\n const selectionStart = editable.selectionStart;\n editable.value = normalized; // put the cursor at some position close to where it was before\n // normalization (otherwise it'll end up at the end of the text)\n\n editable.selectionStart = selectionStart;\n editable.selectionEnd = selectionStart;\n }\n\n onChange(editable.value);\n };\n }\n\n editable.onkeydown = event => {\n if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomIn.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomIn);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomOut.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomOut);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionResetZoom.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionResetZoom);\n updateWysiwygStyle();\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionDecreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionDecreaseFontSize);\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionIncreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionIncreaseFontSize);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.ESCAPE) {\n event.preventDefault();\n submittedViaKeyboard = true;\n handleSubmit();\n } else if (_actions__WEBPACK_IMPORTED_MODULE_8__.actionSaveToActiveFile.keyTest(event)) {\n event.preventDefault();\n handleSubmit();\n app.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionSaveToActiveFile);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.ENTER && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n\n if (event.isComposing || event.keyCode === 229) {\n return;\n }\n\n submittedViaKeyboard = true;\n handleSubmit();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.TAB || event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.CTRL_OR_CMD] && (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CODES.BRACKET_LEFT || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CODES.BRACKET_RIGHT)) {\n event.preventDefault();\n\n if (event.isComposing) {\n return;\n } else if (event.shiftKey || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CODES.BRACKET_LEFT) {\n outdent();\n } else {\n indent();\n } // We must send an input event to resize the element\n\n\n editable.dispatchEvent(new Event(\"input\"));\n }\n };\n\n const TAB_SIZE = 4;\n const TAB = \" \".repeat(TAB_SIZE);\n const RE_LEADING_TAB = new RegExp(`^ {1,${TAB_SIZE}}`);\n\n const indent = () => {\n const {\n selectionStart,\n selectionEnd\n } = editable;\n const linesStartIndices = getSelectedLinesStartIndices();\n let value = editable.value;\n linesStartIndices.forEach(startIndex => {\n const startValue = value.slice(0, startIndex);\n const endValue = value.slice(startIndex);\n value = `${startValue}${TAB}${endValue}`;\n });\n editable.value = value;\n editable.selectionStart = selectionStart + TAB_SIZE;\n editable.selectionEnd = selectionEnd + TAB_SIZE * linesStartIndices.length;\n };\n\n const outdent = () => {\n const {\n selectionStart,\n selectionEnd\n } = editable;\n const linesStartIndices = getSelectedLinesStartIndices();\n const removedTabs = [];\n let value = editable.value;\n linesStartIndices.forEach(startIndex => {\n const tabMatch = value.slice(startIndex, startIndex + TAB_SIZE).match(RE_LEADING_TAB);\n\n if (tabMatch) {\n const startValue = value.slice(0, startIndex);\n const endValue = value.slice(startIndex + tabMatch[0].length); // Delete a tab from the line\n\n value = `${startValue}${endValue}`;\n removedTabs.push(startIndex);\n }\n });\n editable.value = value;\n\n if (removedTabs.length) {\n if (selectionStart > removedTabs[removedTabs.length - 1]) {\n editable.selectionStart = Math.max(selectionStart - TAB_SIZE, removedTabs[removedTabs.length - 1]);\n } else {\n // If the cursor is before the first tab removed, ex:\n // Line| #1\n // Line #2\n // Lin|e #3\n // we should reset the selectionStart to his initial value.\n editable.selectionStart = selectionStart;\n }\n\n editable.selectionEnd = Math.max(editable.selectionStart, selectionEnd - TAB_SIZE * removedTabs.length);\n }\n };\n /**\r\n * @returns indices of start positions of selected lines, in reverse order\r\n */\n\n\n const getSelectedLinesStartIndices = () => {\n let {\n selectionStart,\n selectionEnd,\n value\n } = editable; // chars before selectionStart on the same line\n\n const startOffset = value.slice(0, selectionStart).match(/[^\\n]*$/)[0].length; // put caret at the start of the line\n\n selectionStart = selectionStart - startOffset;\n const selected = value.slice(selectionStart, selectionEnd);\n return selected.split(\"\\n\").reduce((startIndices, line, idx, lines) => startIndices.concat(idx ? // curr line index is prev line's start + prev line's length + \\n\n startIndices[idx - 1] + lines[idx - 1].length + 1 : // first selected line\n selectionStart), []).reverse();\n };\n\n const stopEvent = event => {\n if (event.target instanceof HTMLCanvasElement) {\n event.preventDefault();\n event.stopPropagation();\n }\n }; // using a state variable instead of passing it to the handleSubmit callback\n // so that we don't need to create separate a callback for event handlers\n\n\n let submittedViaKeyboard = false;\n\n const handleSubmit = () => {\n var _a; // prevent double submit\n\n\n if (isDestroyed) {\n return;\n }\n\n isDestroyed = true; // cleanup must be run before onSubmit otherwise when app blurs the wysiwyg\n // it'd get stuck in an infinite loop of blur→onSubmit after we re-focus the\n // wysiwyg on update\n\n cleanup();\n const updateElement = app.scene.getElement(element.id);\n\n if (!updateElement) {\n return;\n }\n\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getContainerElement)(updateElement, app.scene.getNonDeletedElementsMap());\n\n if (container) {\n if (editable.value.trim()) {\n const boundTextElementId = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextElementId)(container);\n\n if (!boundTextElementId || boundTextElementId !== element.id) {\n app.scene.mutateElement(container, {\n boundElements: (container.boundElements || []).concat({\n type: \"text\",\n id: element.id\n })\n });\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n // updating an arrow label may change bounds, prevent stale cache:\n (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_3__.bumpVersion)(container);\n }\n } else {\n app.scene.mutateElement(container, {\n boundElements: (_a = container.boundElements) === null || _a === void 0 ? void 0 : _a.filter(ele => !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(ele))\n });\n }\n\n (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.redrawTextBoundingBox)(updateElement, container, app.scene);\n }\n\n app.setState({\n openPopup: null\n }); //zsviczian (container text color issue)\n\n onSubmit({\n viaKeyboard: submittedViaKeyboard,\n nextOriginalText: editable.value\n });\n };\n\n const cleanup = () => {\n // remove events to ensure they don't late-fire\n editable.onblur = null;\n editable.oninput = null;\n editable.onkeydown = null;\n\n if (observer) {\n observer.disconnect();\n }\n\n window.removeEventListener(\"resize\", updateWysiwygStyle);\n window.removeEventListener(\"wheel\", stopEvent, true);\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"pointerup\", bindBlurEvent);\n window.removeEventListener(\"blur\", handleSubmit);\n window.removeEventListener(\"beforeunload\", handleSubmit);\n unbindUpdate();\n unbindOnScroll();\n editable.remove();\n };\n\n const bindBlurEvent = event => {\n window.removeEventListener(\"pointerup\", bindBlurEvent); // Deferred so that the pointerdown that initiates the wysiwyg doesn't\n // trigger the blur on ensuing pointerup.\n // Also to handle cases such as picking a color which would trigger a blur\n // in that same tick.\n\n const target = event === null || event === void 0 ? void 0 : event.target;\n const isPropertiesTrigger = target instanceof HTMLElement && target.classList.contains(\"properties-trigger\");\n setTimeout(() => {\n editable.onblur = handleSubmit; // case: clicking on the same property → no change → no update → no focus\n\n if (!isPropertiesTrigger) {\n editable.focus();\n }\n });\n };\n\n const temporarilyDisableSubmit = () => {\n editable.onblur = null;\n window.addEventListener(\"pointerup\", bindBlurEvent); // handle edge-case where pointerup doesn't fire e.g. due to user\n // alt-tabbing away\n\n window.addEventListener(\"blur\", handleSubmit);\n }; // prevent blur when changing properties from the menu\n\n\n const onPointerDown = event => {\n const target = event === null || event === void 0 ? void 0 : event.target;\n const isShapeActionsPanel = //zsviczian\n (event.target instanceof HTMLElement || event.target instanceof SVGElement) && (event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MENU}`) || event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MOBILE_MENU}`) || event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.MOBILE_TOOLBAR}`)); // panning canvas\n\n if (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.POINTER_BUTTON.WHEEL) {\n // trying to pan by clicking inside text area itself -> handle here\n if (target instanceof HTMLTextAreaElement) {\n event.preventDefault();\n app.handleCanvasPanUsingWheelOrSpaceDrag(event);\n }\n\n temporarilyDisableSubmit();\n return;\n }\n\n const isPropertiesTrigger = target instanceof HTMLElement && target.classList.contains(\"properties-trigger\");\n\n if ((event.target instanceof HTMLElement || event.target instanceof SVGElement) && (isShapeActionsPanel || //zsviczian\n event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MENU}, .${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.ZOOM_ACTIONS}`)) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isWritableElement)(event.target) || isPropertiesTrigger) {\n temporarilyDisableSubmit();\n } else if (event.target instanceof HTMLCanvasElement && // Vitest simply ignores stopPropagation, capture-mode, or rAF\n // so without introducing crazier hacks, nothing we can do\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n // On mobile, blur event doesn't seem to always fire correctly,\n // so we want to also submit on pointerdown outside the wysiwyg.\n // Done in the next frame to prevent pointerdown from creating a new text\n // immediately (if tools locked) so that users on mobile have chance\n // to submit first (to hide virtual keyboard).\n // Note: revisit if we want to differ this behavior on Desktop\n requestAnimationFrame(() => {\n handleSubmit();\n });\n }\n }; // handle updates of textElement properties of editing element\n\n\n const unbindUpdate = app.scene.onUpdate(() => {\n var _a;\n\n updateWysiwygStyle();\n const isPopupOpened = !!((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.closest(\".properties-content\"));\n\n if (!isPopupOpened) {\n editable.focus();\n }\n });\n const unbindOnScroll = app.onScrollChangeEmitter.on(() => {\n updateWysiwygStyle();\n }); // ---------------------------------------------------------------------------\n\n let isDestroyed = false;\n\n if (autoSelect) {\n // select on init (focusing is done separately inside the bindBlurEvent()\n // because we need it to happen *after* the blur event from `pointerdown`)\n editable.select();\n }\n\n bindBlurEvent(); // reposition wysiwyg in case of canvas is resized. Using ResizeObserver\n // is preferred so we catch changes from host, where window may not resize.\n\n let observer = null;\n\n if (canvas && \"ResizeObserver\" in window) {\n observer = new window.ResizeObserver(() => {\n updateWysiwygStyle();\n });\n observer.observe(canvas);\n } else {\n window.addEventListener(\"resize\", updateWysiwygStyle);\n }\n\n editable.onpointerdown = event => event.stopPropagation(); // rAF (+ capture to by doubly sure) so we don't catch te pointerdown that\n // triggered the wysiwyg\n\n\n requestAnimationFrame(() => {\n window.addEventListener(\"pointerdown\", onPointerDown, {\n capture: true\n });\n });\n window.addEventListener(\"beforeunload\", handleSubmit);\n excalidrawContainer === null || excalidrawContainer === void 0 ? void 0 : excalidrawContainer.querySelector(\".excalidraw-textEditorContainer\").appendChild(editable);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./wysiwyg/textWysiwyg.tsx?");
|
|
20825
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ textWysiwyg: () => (/* binding */ textWysiwyg)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element/containerCache */ \"../element/src/containerCache.ts\");\n/* harmony import */ var _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element/linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element/mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst getTransform = (width, height, angle, appState, maxWidth, maxHeight) => {\n const {\n zoom\n } = appState;\n const degree = 180 * angle / Math.PI;\n let translateX = width * (zoom.value - 1) / 2;\n let translateY = height * (zoom.value - 1) / 2;\n\n if (width > maxWidth && zoom.value !== 1) {\n translateX = maxWidth * (zoom.value - 1) / 2;\n }\n\n if (height > maxHeight && zoom.value !== 1) {\n translateY = maxHeight * (zoom.value - 1) / 2;\n }\n\n return `translate(${translateX}px, ${translateY}px) scale(${zoom.value}) rotate(${degree}deg)`;\n};\n\nconst textWysiwyg = ({\n id,\n onChange,\n onSubmit,\n getViewportCoords,\n element,\n canvas,\n excalidrawContainer,\n app,\n autoSelect = true\n}) => {\n const textPropertiesUpdated = (updatedTextElement, editable) => {\n if (!editable.style.fontFamily || !editable.style.fontSize) {\n return false;\n }\n\n const currentFont = editable.style.fontFamily.replace(/\"/g, \"\");\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontFamilyString)({\n fontFamily: updatedTextElement.fontFamily\n }) !== currentFont) {\n return true;\n }\n\n if (`${updatedTextElement.fontSize}px` !== editable.style.fontSize) {\n return true;\n }\n\n return false;\n };\n\n const updateWysiwygStyle = () => {\n const appState = app.state;\n const updatedTextElement = app.scene.getElement(id);\n\n if (!updatedTextElement) {\n return;\n }\n\n const {\n textAlign,\n verticalAlign\n } = updatedTextElement;\n const elementsMap = app.scene.getNonDeletedElementsMap();\n\n if (updatedTextElement && (0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(updatedTextElement)) {\n let coordX = updatedTextElement.x;\n let coordY = updatedTextElement.y;\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getContainerElement)(updatedTextElement, app.scene.getNonDeletedElementsMap());\n let width = updatedTextElement.width; // set to element height by default since that's\n // what is going to be used for unbounded text\n\n let height = updatedTextElement.height;\n let maxWidth = updatedTextElement.width;\n let maxHeight = updatedTextElement.height;\n\n if (container && updatedTextElement.containerId) {\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n const boundTextCoords = _excalidraw_element_linearElementEditor__WEBPACK_IMPORTED_MODULE_2__.LinearElementEditor.getBoundTextElementPosition(container, updatedTextElement, elementsMap);\n coordX = boundTextCoords.x;\n coordY = boundTextCoords.y;\n }\n\n const propertiesUpdated = textPropertiesUpdated(updatedTextElement, editable);\n let originalContainerData;\n\n if (propertiesUpdated) {\n originalContainerData = (0,_excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__.updateOriginalContainerCache)(container.id, container.height);\n } else {\n originalContainerData = _excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__.originalContainerCache[container.id];\n\n if (!originalContainerData) {\n originalContainerData = (0,_excalidraw_element_containerCache__WEBPACK_IMPORTED_MODULE_1__.updateOriginalContainerCache)(container.id, container.height);\n }\n }\n\n maxWidth = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxWidth)(container, updatedTextElement);\n maxHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxHeight)(container, updatedTextElement); // autogrow container height if text exceeds\n\n if (!(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) && height > maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n return;\n } else if ( // autoshrink container height until original container height\n // is reached when text is removed\n !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) && container.height > originalContainerData.height && height < maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n } else {\n const {\n y\n } = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.computeBoundTextPosition)(container, updatedTextElement, elementsMap);\n coordY = y;\n }\n }\n\n const [viewportX, viewportY] = getViewportCoords(coordX, coordY);\n const initialSelectionStart = editable.selectionStart;\n const initialSelectionEnd = editable.selectionEnd;\n const initialLength = editable.value.length; // restore cursor position after value updated so it doesn't\n // go to the end of text when container auto expanded\n\n if (initialSelectionStart === initialSelectionEnd && initialSelectionEnd !== initialLength) {\n // get diff between length and selection end and shift\n // the cursor by \"diff\" times to position correctly\n const diff = initialLength - initialSelectionEnd;\n editable.selectionStart = editable.value.length - diff;\n editable.selectionEnd = editable.value.length - diff;\n }\n\n if (!container) {\n maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value;\n width = Math.min(width, maxWidth);\n } else {\n width += 0.5;\n } // add 5% buffer otherwise it causes wysiwyg to jump\n\n\n height *= 1.05;\n const font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontString)(updatedTextElement); // Make sure text editor height doesn't go beyond viewport\n\n const editorMaxHeight = (appState.height - viewportY) / appState.zoom.value;\n Object.assign(editable.style, {\n font,\n // must be defined *after* font ¯\\_(ツ)_/¯\n lineHeight: updatedTextElement.lineHeight,\n width: `${Math.ceil(width)}px`,\n height: `${height}px`,\n left: `${viewportX}px`,\n top: `${viewportY}px`,\n transform: getTransform(width, height, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getTextElementAngle)(updatedTextElement, container), appState, maxWidth, editorMaxHeight),\n textAlign,\n verticalAlign,\n color: updatedTextElement.strokeColor,\n opacity: updatedTextElement.opacity / 100,\n filter: \"var(--theme-filter)\",\n maxHeight: `${editorMaxHeight}px`,\n caretColor: updatedTextElement.strokeColor === \"transparent\" //zsviczian\n ? \"var(excalidraw-caret-color)\" : updatedTextElement.strokeColor //zsviczian Set caret color\n\n });\n editable.scrollTop = 0; // For some reason updating font attribute doesn't set font family\n // hence updating font family explicitly for test environment\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n editable.style.fontFamily = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontFamilyString)(updatedTextElement);\n }\n\n app.scene.mutateElement(updatedTextElement, {\n x: coordX,\n y: coordY\n });\n }\n };\n\n const editable = document.createElement(\"textarea\");\n editable.dir = \"auto\";\n editable.tabIndex = 0;\n editable.dataset.type = \"wysiwyg\"; // prevent line wrapping on Safari\n\n editable.wrap = \"off\";\n editable.classList.add(\"excalidraw-wysiwyg\");\n let whiteSpace = \"pre\";\n let wordBreak = \"normal\";\n\n if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(element) || !element.autoResize) {\n whiteSpace = \"pre-wrap\";\n wordBreak = \"break-word\";\n }\n\n Object.assign(editable.style, {\n position: \"absolute\",\n display: \"inline-block\",\n minHeight: \"1em\",\n backfaceVisibility: \"hidden\",\n margin: 0,\n padding: 0,\n border: 0,\n outline: 0,\n resize: \"none\",\n background: \"transparent\",\n overflow: \"hidden\",\n // must be specified because in dark mode canvas creates a stacking context\n zIndex: \"var(--zIndex-wysiwyg)\",\n wordBreak,\n // prevent line wrapping (`whitespace: nowrap` doesn't work on FF)\n whiteSpace,\n overflowWrap: \"break-word\",\n boxSizing: \"content-box\"\n });\n editable.value = element.originalText;\n updateWysiwygStyle();\n\n if (onChange) {\n editable.onpaste = async event => {\n const clipboardData = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_9__.parseClipboard)(event, true);\n\n if (!clipboardData.text) {\n return;\n }\n\n const data = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__.normalizeText)(clipboardData.text);\n\n if (!data) {\n return;\n }\n\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getContainerElement)(element, app.scene.getNonDeletedElementsMap());\n const font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontString)({\n fontSize: app.state.currentItemFontSize,\n fontFamily: app.state.currentItemFontFamily\n });\n\n if (container) {\n const boundTextElement = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextElement)(container, app.scene.getNonDeletedElementsMap());\n const wrappedText = (0,_excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_6__.wrapText)(`${editable.value}${data}`, font, (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxWidth)(container, boundTextElement));\n const width = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__.getTextWidth)(wrappedText, font);\n editable.style.width = `${Math.ceil(width)}px`; //zsviczian Obsidian app zoom !== 100% issue\n }\n };\n\n editable.oninput = () => {\n const normalized = (0,_excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_5__.normalizeText)(editable.value);\n\n if (editable.value !== normalized) {\n const selectionStart = editable.selectionStart;\n editable.value = normalized; // put the cursor at some position close to where it was before\n // normalization (otherwise it'll end up at the end of the text)\n\n editable.selectionStart = selectionStart;\n editable.selectionEnd = selectionStart;\n }\n\n onChange(editable.value);\n };\n }\n\n editable.onkeydown = event => {\n if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomIn.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomIn);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomOut.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionZoomOut);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionResetZoom.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_11__.actionResetZoom);\n updateWysiwygStyle();\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionDecreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionDecreaseFontSize);\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionIncreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.actionIncreaseFontSize);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.ESCAPE) {\n event.preventDefault();\n submittedViaKeyboard = true;\n handleSubmit();\n } else if (_actions__WEBPACK_IMPORTED_MODULE_8__.actionSaveToActiveFile.keyTest(event)) {\n event.preventDefault();\n handleSubmit();\n app.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionSaveToActiveFile);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.ENTER && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n\n if (event.isComposing || event.keyCode === 229) {\n return;\n }\n\n submittedViaKeyboard = true;\n handleSubmit();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.TAB || event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.KEYS.CTRL_OR_CMD] && (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CODES.BRACKET_LEFT || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CODES.BRACKET_RIGHT)) {\n event.preventDefault();\n\n if (event.isComposing) {\n return;\n } else if (event.shiftKey || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CODES.BRACKET_LEFT) {\n outdent();\n } else {\n indent();\n } // We must send an input event to resize the element\n\n\n editable.dispatchEvent(new Event(\"input\"));\n }\n };\n\n const TAB_SIZE = 4;\n const TAB = \" \".repeat(TAB_SIZE);\n const RE_LEADING_TAB = new RegExp(`^ {1,${TAB_SIZE}}`);\n\n const indent = () => {\n const {\n selectionStart,\n selectionEnd\n } = editable;\n const linesStartIndices = getSelectedLinesStartIndices();\n let value = editable.value;\n linesStartIndices.forEach(startIndex => {\n const startValue = value.slice(0, startIndex);\n const endValue = value.slice(startIndex);\n value = `${startValue}${TAB}${endValue}`;\n });\n editable.value = value;\n editable.selectionStart = selectionStart + TAB_SIZE;\n editable.selectionEnd = selectionEnd + TAB_SIZE * linesStartIndices.length;\n };\n\n const outdent = () => {\n const {\n selectionStart,\n selectionEnd\n } = editable;\n const linesStartIndices = getSelectedLinesStartIndices();\n const removedTabs = [];\n let value = editable.value;\n linesStartIndices.forEach(startIndex => {\n const tabMatch = value.slice(startIndex, startIndex + TAB_SIZE).match(RE_LEADING_TAB);\n\n if (tabMatch) {\n const startValue = value.slice(0, startIndex);\n const endValue = value.slice(startIndex + tabMatch[0].length); // Delete a tab from the line\n\n value = `${startValue}${endValue}`;\n removedTabs.push(startIndex);\n }\n });\n editable.value = value;\n\n if (removedTabs.length) {\n if (selectionStart > removedTabs[removedTabs.length - 1]) {\n editable.selectionStart = Math.max(selectionStart - TAB_SIZE, removedTabs[removedTabs.length - 1]);\n } else {\n // If the cursor is before the first tab removed, ex:\n // Line| #1\n // Line #2\n // Lin|e #3\n // we should reset the selectionStart to his initial value.\n editable.selectionStart = selectionStart;\n }\n\n editable.selectionEnd = Math.max(editable.selectionStart, selectionEnd - TAB_SIZE * removedTabs.length);\n }\n };\n /**\r\n * @returns indices of start positions of selected lines, in reverse order\r\n */\n\n\n const getSelectedLinesStartIndices = () => {\n let {\n selectionStart,\n selectionEnd,\n value\n } = editable; // chars before selectionStart on the same line\n\n const startOffset = value.slice(0, selectionStart).match(/[^\\n]*$/)[0].length; // put caret at the start of the line\n\n selectionStart = selectionStart - startOffset;\n const selected = value.slice(selectionStart, selectionEnd);\n return selected.split(\"\\n\").reduce((startIndices, line, idx, lines) => startIndices.concat(idx ? // curr line index is prev line's start + prev line's length + \\n\n startIndices[idx - 1] + lines[idx - 1].length + 1 : // first selected line\n selectionStart), []).reverse();\n };\n\n const stopEvent = event => {\n if (event.target instanceof HTMLCanvasElement) {\n event.preventDefault();\n event.stopPropagation();\n }\n }; // using a state variable instead of passing it to the handleSubmit callback\n // so that we don't need to create separate a callback for event handlers\n\n\n let submittedViaKeyboard = false;\n\n const handleSubmit = () => {\n var _a; // prevent double submit\n\n\n if (isDestroyed) {\n return;\n }\n\n isDestroyed = true; // cleanup must be run before onSubmit otherwise when app blurs the wysiwyg\n // it'd get stuck in an infinite loop of blur→onSubmit after we re-focus the\n // wysiwyg on update\n\n cleanup();\n const updateElement = app.scene.getElement(element.id);\n\n if (!updateElement) {\n return;\n }\n\n const container = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getContainerElement)(updateElement, app.scene.getNonDeletedElementsMap());\n\n if (container) {\n if (editable.value.trim()) {\n const boundTextElementId = (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.getBoundTextElementId)(container);\n\n if (!boundTextElementId || boundTextElementId !== element.id) {\n app.scene.mutateElement(container, {\n boundElements: (container.boundElements || []).concat({\n type: \"text\",\n id: element.id\n })\n });\n } else if ((0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n // updating an arrow label may change bounds, prevent stale cache:\n (0,_excalidraw_element_mutateElement__WEBPACK_IMPORTED_MODULE_3__.bumpVersion)(container);\n }\n } else {\n app.scene.mutateElement(container, {\n boundElements: (_a = container.boundElements) === null || _a === void 0 ? void 0 : _a.filter(ele => !(0,_excalidraw_element_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(ele))\n });\n }\n\n (0,_excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_4__.redrawTextBoundingBox)(updateElement, container, app.scene);\n }\n\n app.setState({\n openPopup: null\n }); //zsviczian (container text color issue)\n\n onSubmit({\n viaKeyboard: submittedViaKeyboard,\n nextOriginalText: editable.value\n });\n };\n\n const cleanup = () => {\n // remove events to ensure they don't late-fire\n editable.onblur = null;\n editable.oninput = null;\n editable.onkeydown = null;\n\n if (observer) {\n observer.disconnect();\n }\n\n window.removeEventListener(\"resize\", updateWysiwygStyle);\n window.removeEventListener(\"wheel\", stopEvent, true);\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"pointerup\", bindBlurEvent);\n window.removeEventListener(\"blur\", handleSubmit);\n window.removeEventListener(\"beforeunload\", handleSubmit);\n unbindUpdate();\n unbindOnScroll();\n editable.remove();\n };\n\n const bindBlurEvent = event => {\n window.removeEventListener(\"pointerup\", bindBlurEvent); // Deferred so that the pointerdown that initiates the wysiwyg doesn't\n // trigger the blur on ensuing pointerup.\n // Also to handle cases such as picking a color which would trigger a blur\n // in that same tick.\n\n const target = event === null || event === void 0 ? void 0 : event.target;\n const isPropertiesTrigger = target instanceof HTMLElement && target.classList.contains(\"properties-trigger\");\n setTimeout(() => {\n editable.onblur = handleSubmit; // case: clicking on the same property → no change → no update → no focus\n\n if (!isPropertiesTrigger) {\n editable.focus();\n }\n });\n };\n\n const temporarilyDisableSubmit = () => {\n editable.onblur = null;\n window.addEventListener(\"pointerup\", bindBlurEvent); // handle edge-case where pointerup doesn't fire e.g. due to user\n // alt-tabbing away\n\n window.addEventListener(\"blur\", handleSubmit);\n }; // prevent blur when changing properties from the menu\n\n\n const onPointerDown = event => {\n const target = event === null || event === void 0 ? void 0 : event.target;\n const isShapeActionsPanel = //zsviczian\n (event.target instanceof HTMLElement || event.target instanceof SVGElement) && (event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MENU}`) || event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MOBILE_MENU}`) || event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.MOBILE_TOOLBAR}`)); // panning canvas\n\n if (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.POINTER_BUTTON.WHEEL) {\n // trying to pan by clicking inside text area itself -> handle here\n if (target instanceof HTMLTextAreaElement) {\n event.preventDefault();\n app.handleCanvasPanUsingWheelOrSpaceDrag(event);\n }\n\n temporarilyDisableSubmit();\n return;\n }\n\n const isPropertiesTrigger = target instanceof HTMLElement && target.classList.contains(\"properties-trigger\");\n\n if ((event.target instanceof HTMLElement || event.target instanceof SVGElement) && (isShapeActionsPanel || //zsviczian\n event.target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MENU}, .${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.ZOOM_ACTIONS}`)) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isWritableElement)(event.target) || isPropertiesTrigger) {\n temporarilyDisableSubmit();\n } else if (event.target instanceof HTMLCanvasElement && // Vitest simply ignores stopPropagation, capture-mode, or rAF\n // so without introducing crazier hacks, nothing we can do\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n // On mobile, blur event doesn't seem to always fire correctly,\n // so we want to also submit on pointerdown outside the wysiwyg.\n // Done in the next frame to prevent pointerdown from creating a new text\n // immediately (if tools locked) so that users on mobile have chance\n // to submit first (to hide virtual keyboard).\n // Note: revisit if we want to differ this behavior on Desktop\n requestAnimationFrame(() => {\n handleSubmit();\n });\n }\n }; // handle updates of textElement properties of editing element\n\n\n const unbindUpdate = app.scene.onUpdate(() => {\n var _a;\n\n updateWysiwygStyle();\n const isPopupOpened = !!((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.closest(\".properties-content\"));\n\n if (!isPopupOpened) {\n editable.focus();\n }\n });\n const unbindOnScroll = app.onScrollChangeEmitter.on(() => {\n updateWysiwygStyle();\n }); // ---------------------------------------------------------------------------\n\n let isDestroyed = false;\n\n if (autoSelect) {\n // select on init (focusing is done separately inside the bindBlurEvent()\n // because we need it to happen *after* the blur event from `pointerdown`)\n editable.select();\n }\n\n bindBlurEvent(); // reposition wysiwyg in case of canvas is resized. Using ResizeObserver\n // is preferred so we catch changes from host, where window may not resize.\n\n let observer = null;\n\n if (canvas && \"ResizeObserver\" in window) {\n observer = new window.ResizeObserver(() => {\n updateWysiwygStyle();\n });\n observer.observe(canvas);\n } else {\n window.addEventListener(\"resize\", updateWysiwygStyle);\n }\n\n editable.onpointerdown = event => event.stopPropagation(); // rAF (+ capture to by doubly sure) so we don't catch te pointerdown that\n // triggered the wysiwyg\n\n\n requestAnimationFrame(() => {\n window.addEventListener(\"pointerdown\", onPointerDown, {\n capture: true\n });\n });\n window.addEventListener(\"beforeunload\", handleSubmit);\n excalidrawContainer === null || excalidrawContainer === void 0 ? void 0 : excalidrawContainer.querySelector(\".excalidraw-textEditorContainer\").appendChild(editable);\n return handleSubmit;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./wysiwyg/textWysiwyg.tsx?");
|
|
20793
20826
|
|
|
20794
20827
|
/***/ }),
|
|
20795
20828
|
|