@zsviczian/excalidraw 0.18.0-94 → 0.18.96

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.
@@ -10483,7 +10483,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
10483
10483
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10484
10484
 
10485
10485
  "use strict";
10486
- 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 _arrayMap_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_arrayMap.js */ \"../../node_modules/lodash-es/_arrayMap.js\");\n/* harmony import */ var _baseGet_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_baseGet.js */ \"../../node_modules/lodash-es/_baseGet.js\");\n/* harmony import */ var _baseIteratee_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./_baseIteratee.js */ \"../../node_modules/lodash-es/_baseIteratee.js\");\n/* harmony import */ var _baseMap_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./_baseMap.js */ \"../../node_modules/lodash-es/_baseMap.js\");\n/* harmony import */ var _baseSortBy_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./_baseSortBy.js */ \"../../node_modules/lodash-es/_baseSortBy.js\");\n/* harmony import */ var _baseUnary_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./_baseUnary.js */ \"../../node_modules/lodash-es/_baseUnary.js\");\n/* harmony import */ var _compareMultiple_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./_compareMultiple.js */ \"../../node_modules/lodash-es/_compareMultiple.js\");\n/* harmony import */ var _identity_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./identity.js */ \"../../node_modules/lodash-es/identity.js\");\n/* harmony import */ var _isArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./isArray.js */ \"../../node_modules/lodash-es/isArray.js\");\n\n\n\n\n\n\n\n\n\n\n/**\n * The base implementation of `_.orderBy` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {string[]} orders The sort orders of `iteratees`.\n * @returns {Array} Returns the new sorted array.\n */\nfunction baseOrderBy(collection, iteratees, orders) {\n if (iteratees.length) {\n iteratees = (0,_arrayMap_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(iteratees, function(iteratee) {\n if ((0,_isArray_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(iteratee)) {\n return function(value) {\n return (0,_baseGet_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(value, iteratee.length === 1 ? iteratee[0] : iteratee);\n }\n }\n return iteratee;\n });\n } else {\n iteratees = [_identity_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]];\n }\n\n var index = -1;\n iteratees = (0,_arrayMap_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(iteratees, (0,_baseUnary_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(_baseIteratee_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]));\n\n var result = (0,_baseMap_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(collection, function(value, key, collection) {\n var criteria = (0,_arrayMap_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(iteratees, function(iteratee) {\n return iteratee(value);\n });\n return { 'criteria': criteria, 'index': ++index, 'value': value };\n });\n\n return (0,_baseSortBy_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(result, function(object, other) {\n return (0,_compareMultiple_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(object, other, orders);\n });\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (baseOrderBy);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/lodash-es/_baseOrderBy.js?");
10486
+ 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 _arrayMap_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_arrayMap.js */ \"../../node_modules/lodash-es/_arrayMap.js\");\n/* harmony import */ var _baseGet_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_baseGet.js */ \"../../node_modules/lodash-es/_baseGet.js\");\n/* harmony import */ var _baseIteratee_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./_baseIteratee.js */ \"../../node_modules/lodash-es/_baseIteratee.js\");\n/* harmony import */ var _baseMap_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./_baseMap.js */ \"../../node_modules/lodash-es/_baseMap.js\");\n/* harmony import */ var _baseSortBy_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./_baseSortBy.js */ \"../../node_modules/lodash-es/_baseSortBy.js\");\n/* harmony import */ var _baseUnary_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./_baseUnary.js */ \"../../node_modules/lodash-es/_baseUnary.js\");\n/* harmony import */ var _compareMultiple_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./_compareMultiple.js */ \"../../node_modules/lodash-es/_compareMultiple.js\");\n/* harmony import */ var _identity_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./identity.js */ \"../../node_modules/lodash-es/identity.js\");\n/* harmony import */ var _isArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./isArray.js */ \"../../node_modules/lodash-es/isArray.js\");\n\n\n\n\n\n\n\n\n\n\n/**\n * The base implementation of `_.orderBy` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {string[]} orders The sort orders of `iteratees`.\n * @returns {Array} Returns the new sorted array.\n */\nfunction baseOrderBy(collection, iteratees, orders) {\n if (iteratees.length) {\n iteratees = (0,_arrayMap_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(iteratees, function(iteratee) {\n if ((0,_isArray_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(iteratee)) {\n return function(value) {\n return (0,_baseGet_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(value, iteratee.length === 1 ? iteratee[0] : iteratee);\n };\n }\n return iteratee;\n });\n } else {\n iteratees = [_identity_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]];\n }\n\n var index = -1;\n iteratees = (0,_arrayMap_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(iteratees, (0,_baseUnary_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(_baseIteratee_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]));\n\n var result = (0,_baseMap_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(collection, function(value, key, collection) {\n var criteria = (0,_arrayMap_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(iteratees, function(iteratee) {\n return iteratee(value);\n });\n return { 'criteria': criteria, 'index': ++index, 'value': value };\n });\n\n return (0,_baseSortBy_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(result, function(object, other) {\n return (0,_compareMultiple_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(object, other, orders);\n });\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (baseOrderBy);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/lodash-es/_baseOrderBy.js?");
10487
10487
 
10488
10488
  /***/ }),
10489
10489
 
@@ -11616,7 +11616,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
11616
11616
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11617
11617
 
11618
11618
  "use strict";
11619
- 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/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (setCacheHas);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/lodash-es/_setCacheHas.js?");
11619
+ 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/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {boolean} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (setCacheHas);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/lodash-es/_setCacheHas.js?");
11620
11620
 
11621
11621
  /***/ }),
11622
11622
 
@@ -11847,7 +11847,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
11847
11847
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11848
11848
 
11849
11849
  "use strict";
11850
- 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/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (compact);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/lodash-es/compact.js?");
11850
+ 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/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `-0`, `0n`, `\"\"`, `undefined`, and `NaN` are falsy.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (compact);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/lodash-es/compact.js?");
11851
11851
 
11852
11852
  /***/ }),
11853
11853
 
@@ -14280,7 +14280,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
14280
14280
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14281
14281
 
14282
14282
  "use strict";
14283
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ COLORS_PER_ROW: () => (/* binding */ COLORS_PER_ROW),\n/* harmony export */ COLOR_OUTLINE_CONTRAST_THRESHOLD: () => (/* binding */ COLOR_OUTLINE_CONTRAST_THRESHOLD),\n/* harmony export */ COLOR_PALETTE: () => (/* binding */ COLOR_PALETTE),\n/* harmony export */ DEFAULT_CANVAS_BACKGROUND_PICKS: () => (/* binding */ DEFAULT_CANVAS_BACKGROUND_PICKS),\n/* harmony export */ DEFAULT_CHART_COLOR_INDEX: () => (/* binding */ DEFAULT_CHART_COLOR_INDEX),\n/* harmony export */ DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX: () => (/* binding */ DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX),\n/* harmony export */ DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE: () => (/* binding */ DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE),\n/* harmony export */ DEFAULT_ELEMENT_BACKGROUND_PICKS: () => (/* binding */ DEFAULT_ELEMENT_BACKGROUND_PICKS),\n/* harmony export */ DEFAULT_ELEMENT_STROKE_COLOR_INDEX: () => (/* binding */ DEFAULT_ELEMENT_STROKE_COLOR_INDEX),\n/* harmony export */ DEFAULT_ELEMENT_STROKE_COLOR_PALETTE: () => (/* binding */ DEFAULT_ELEMENT_STROKE_COLOR_PALETTE),\n/* harmony export */ DEFAULT_ELEMENT_STROKE_PICKS: () => (/* binding */ DEFAULT_ELEMENT_STROKE_PICKS),\n/* harmony export */ MAX_CUSTOM_COLORS_USED_IN_CANVAS: () => (/* binding */ MAX_CUSTOM_COLORS_USED_IN_CANVAS),\n/* harmony export */ applyDarkModeFilter: () => (/* binding */ applyDarkModeFilter),\n/* harmony export */ colorToHex: () => (/* binding */ colorToHex),\n/* harmony export */ getAllColorsSpecificShade: () => (/* binding */ getAllColorsSpecificShade),\n/* harmony export */ isColorDark: () => (/* binding */ isColorDark),\n/* harmony export */ isTransparent: () => (/* binding */ isTransparent),\n/* harmony export */ normalizeInputColor: () => (/* binding */ normalizeInputColor),\n/* harmony export */ rgbToHex: () => (/* binding */ rgbToHex)\n/* harmony export */ });\n/* harmony import */ var tinycolor2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tinycolor2 */ \"../../node_modules/tinycolor2/esm/tinycolor.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n\n\n // ---------------------------------------------------------------------------\n// Dark mode color transformation\n// ---------------------------------------------------------------------------\n// Browser-only cache to avoid memory leaks on server\n\nconst DARK_MODE_COLORS_CACHE = typeof window !== \"undefined\" ? new Map() : null;\n\nfunction cssHueRotate(red, green, blue, degrees) {\n // normalize\n const r = red / 255;\n const g = green / 255;\n const b = blue / 255; // Convert degrees to radians\n\n const a = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.degreesToRadians)(degrees);\n const c = Math.cos(a);\n const s = Math.sin(a); // rotation matrix\n\n const matrix = [0.213 + c * 0.787 - s * 0.213, 0.715 - c * 0.715 - s * 0.715, 0.072 - c * 0.072 + s * 0.928, 0.213 - c * 0.213 + s * 0.143, 0.715 + c * 0.285 + s * 0.14, 0.072 - c * 0.072 - s * 0.283, 0.213 - c * 0.213 - s * 0.787, 0.715 - c * 0.715 + s * 0.715, 0.072 + c * 0.928 + s * 0.072]; // transform\n\n const newR = r * matrix[0] + g * matrix[1] + b * matrix[2];\n const newG = r * matrix[3] + g * matrix[4] + b * matrix[5];\n const newB = r * matrix[6] + g * matrix[7] + b * matrix[8]; // clamp the values to [0, 1] range and convert back to [0, 255]\n\n return {\n r: Math.round(Math.max(0, Math.min(1, newR)) * 255),\n g: Math.round(Math.max(0, Math.min(1, newG)) * 255),\n b: Math.round(Math.max(0, Math.min(1, newB)) * 255)\n };\n}\n\nconst cssInvert = (r, g, b, percent) => {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(percent, 0, 100) / 100; // Function to invert a single color component\n\n const invertComponent = color => {\n // Apply the invert formula\n const inverted = color * (1 - p) + (255 - color) * p; // Round to the nearest integer and clamp to [0, 255]\n\n return Math.round((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(inverted, 0, 255));\n }; // Calculate the inverted RGB components\n\n\n const invertedR = invertComponent(r);\n const invertedG = invertComponent(g);\n const invertedB = invertComponent(b);\n return {\n r: invertedR,\n g: invertedG,\n b: invertedB\n };\n};\n\nconst applyDarkModeFilter = color => {\n const cached = DARK_MODE_COLORS_CACHE === null || DARK_MODE_COLORS_CACHE === void 0 ? void 0 : DARK_MODE_COLORS_CACHE.get(color);\n\n if (cached) {\n return cached;\n }\n\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n const alpha = tc.getAlpha(); // order of operations matters\n // (corresponds to \"filter: invert(invertPercent) hue-rotate(hueDegrees)\" in css)\n\n const rgb = tc.toRgb();\n const inverted = cssInvert(rgb.r, rgb.g, rgb.b, 93);\n const rotated = cssHueRotate(inverted.r, inverted.g, inverted.b, 180);\n const result = rgbToHex(rotated.r, rotated.g, rotated.b, alpha);\n\n if (DARK_MODE_COLORS_CACHE) {\n DARK_MODE_COLORS_CACHE.set(color, result);\n }\n\n return result;\n}; // ---------------------------------------------------------------------------\n// Color palette\n// ---------------------------------------------------------------------------\n// FIXME can't put to utils.ts rn because of circular dependency\n\nconst pick = (source, keys) => {\n return keys.reduce((acc, key) => {\n if (key in source) {\n acc[key] = source[key];\n }\n\n return acc;\n }, {});\n};\n\nconst MAX_CUSTOM_COLORS_USED_IN_CANVAS = 5;\nconst COLORS_PER_ROW = 5;\nconst DEFAULT_CHART_COLOR_INDEX = 4;\nconst DEFAULT_ELEMENT_STROKE_COLOR_INDEX = 4;\nconst DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX = 1;\nconst COLOR_PALETTE = {\n transparent: \"transparent\",\n black: \"#1e1e1e\",\n white: \"#ffffff\",\n // open-color from https://github.com/yeun/open-color/blob/master/open-color.js\n // corresponds to indexes [0,2,4,6,8] (weights: 50, 200, 400, 600, 800)\n gray: [\"#f8f9fa\", \"#e9ecef\", \"#ced4da\", \"#868e96\", \"#343a40\"],\n red: [\"#fff5f5\", \"#ffc9c9\", \"#ff8787\", \"#fa5252\", \"#e03131\"],\n pink: [\"#fff0f6\", \"#fcc2d7\", \"#f783ac\", \"#e64980\", \"#c2255c\"],\n grape: [\"#f8f0fc\", \"#eebefa\", \"#da77f2\", \"#be4bdb\", \"#9c36b5\"],\n violet: [\"#f3f0ff\", \"#d0bfff\", \"#9775fa\", \"#7950f2\", \"#6741d9\"],\n blue: [\"#e7f5ff\", \"#a5d8ff\", \"#4dabf7\", \"#228be6\", \"#1971c2\"],\n cyan: [\"#e3fafc\", \"#99e9f2\", \"#3bc9db\", \"#15aabf\", \"#0c8599\"],\n teal: [\"#e6fcf5\", \"#96f2d7\", \"#38d9a9\", \"#12b886\", \"#099268\"],\n green: [\"#ebfbee\", \"#b2f2bb\", \"#69db7c\", \"#40c057\", \"#2f9e44\"],\n yellow: [\"#fff9db\", \"#ffec99\", \"#ffd43b\", \"#fab005\", \"#f08c00\"],\n orange: [\"#fff4e6\", \"#ffd8a8\", \"#ffa94d\", \"#fd7e14\", \"#e8590c\"],\n // radix bronze shades [3,5,7,9,11]\n bronze: [\"#f8f1ee\", \"#eaddd7\", \"#d2bab0\", \"#a18072\", \"#846358\"]\n};\nconst COMMON_ELEMENT_SHADES = pick(COLOR_PALETTE, [\"cyan\", \"blue\", \"violet\", \"grape\", \"pink\", \"green\", \"teal\", \"yellow\", \"orange\", \"red\"]); // quick picks defaults\n// -----------------------------------------------------------------------------\n// ORDER matters for positioning in quick picker\n\nconst DEFAULT_ELEMENT_STROKE_PICKS = [COLOR_PALETTE.black, COLOR_PALETTE.red[DEFAULT_ELEMENT_STROKE_COLOR_INDEX], COLOR_PALETTE.green[DEFAULT_ELEMENT_STROKE_COLOR_INDEX], COLOR_PALETTE.blue[DEFAULT_ELEMENT_STROKE_COLOR_INDEX], COLOR_PALETTE.yellow[DEFAULT_ELEMENT_STROKE_COLOR_INDEX]]; // ORDER matters for positioning in quick picker\n\nconst DEFAULT_ELEMENT_BACKGROUND_PICKS = [COLOR_PALETTE.transparent, COLOR_PALETTE.red[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX], COLOR_PALETTE.green[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX], COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX], COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]]; // ORDER matters for positioning in quick picker\n\nconst DEFAULT_CANVAS_BACKGROUND_PICKS = [COLOR_PALETTE.white, // radix slate2\n\"#f8f9fa\", // radix blue2\n\"#f5faff\", // radix yellow2\n\"#fffce8\", // radix bronze2\n\"#fdf8f6\"]; // palette defaults\n// -----------------------------------------------------------------------------\n\nconst DEFAULT_ELEMENT_STROKE_COLOR_PALETTE = Object.assign({\n // 1st row\n transparent: COLOR_PALETTE.transparent,\n white: COLOR_PALETTE.white,\n gray: COLOR_PALETTE.gray,\n black: COLOR_PALETTE.black,\n bronze: COLOR_PALETTE.bronze\n}, COMMON_ELEMENT_SHADES); // ORDER matters for positioning in pallete (5x3 grid)s\n\nconst DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE = Object.assign({\n transparent: COLOR_PALETTE.transparent,\n white: COLOR_PALETTE.white,\n gray: COLOR_PALETTE.gray,\n black: COLOR_PALETTE.black,\n bronze: COLOR_PALETTE.bronze\n}, COMMON_ELEMENT_SHADES); // color palette helpers\n// -----------------------------------------------------------------------------\n// !!!MUST BE WITHOUT GRAY, TRANSPARENT AND BLACK!!!\n\nconst getAllColorsSpecificShade = index => [// 2nd row\nCOLOR_PALETTE.cyan[index], COLOR_PALETTE.blue[index], COLOR_PALETTE.violet[index], COLOR_PALETTE.grape[index], COLOR_PALETTE.pink[index], // 3rd row\nCOLOR_PALETTE.green[index], COLOR_PALETTE.teal[index], COLOR_PALETTE.yellow[index], COLOR_PALETTE.orange[index], COLOR_PALETTE.red[index]]; // -----------------------------------------------------------------------------\n// other helpers\n// -----------------------------------------------------------------------------\n\nconst rgbToHex = (r, g, b, a) => {\n // (1 << 24) adds 0x1000000 to ensure the hex string is always 7 chars,\n // then slice(1) removes the leading \"1\" to get exactly 6 hex digits\n // e.g. rgb(0,0,0) -> 0x1000000 -> \"1000000\" -> \"000000\"\n const hex6 = `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;\n\n if (a !== undefined && a < 1) {\n // convert alpha from 0-1 float to 0-255 int, then to 2-digit hex\n // e.g. 0.5 -> 128 -> \"80\"\n const alphaHex = Math.round(a * 255).toString(16).padStart(2, \"0\");\n return `${hex6}${alphaHex}`;\n }\n\n return hex6;\n};\n/**\n * @returns #RRGGBB or #RRGGBBAA based on color containing non-opaque alpha,\n * null if not valid color\n */\n\nconst colorToHex = color => {\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n\n if (!tc.isValid()) {\n return null;\n }\n\n const {\n r,\n g,\n b,\n a\n } = tc.toRgb();\n return rgbToHex(r, g, b, a);\n};\nconst isTransparent = color => {\n return (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color).getAlpha() === 0;\n}; // -----------------------------------------------------------------------------\n// color contract helpers\n// -----------------------------------------------------------------------------\n\nconst COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;\n\nconst calculateContrast = (r, g, b) => {\n const yiq = (r * 299 + g * 587 + b * 114) / 1000;\n return yiq;\n}; // YIQ algo, inspiration from https://stackoverflow.com/a/11868398\n\n\nconst isColorDark = (color, threshold = 160) => {\n // no color (\"\") -> assume it default to black\n if (!color) {\n return true;\n }\n\n if (isTransparent(color)) {\n return false;\n }\n\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n\n if (!tc.isValid()) {\n // invalid color -> assume it defaults to black\n return true;\n }\n\n const {\n r,\n g,\n b\n } = tc.toRgb();\n return calculateContrast(r, g, b) < threshold;\n}; // -----------------------------------------------------------------------------\n// normalization\n// -----------------------------------------------------------------------------\n\n/**\n * tries to keep the input color as-is if it's valid, making minimal adjustments\n * (trimming whitespace or adding `#` to hex colors)\n */\n\nconst normalizeInputColor = color => {\n color = color.trim();\n\n if (isTransparent(color)) {\n return color;\n }\n\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n\n if (tc.isValid()) {\n // testing for `#` first fixes a bug on Electron (more specfically, an\n // Obsidian popout window), where a hex color without `#` is considered valid\n if ([\"hex\", \"hex8\"].includes(tc.getFormat()) && !color.startsWith(\"#\")) {\n return `#${color}`;\n }\n\n return color;\n }\n\n return null;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/colors.ts?");
14283
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ COLORS_PER_ROW: () => (/* binding */ COLORS_PER_ROW),\n/* harmony export */ COLOR_OUTLINE_CONTRAST_THRESHOLD: () => (/* binding */ COLOR_OUTLINE_CONTRAST_THRESHOLD),\n/* harmony export */ COLOR_PALETTE: () => (/* binding */ COLOR_PALETTE),\n/* harmony export */ DEFAULT_CANVAS_BACKGROUND_PICKS: () => (/* binding */ DEFAULT_CANVAS_BACKGROUND_PICKS),\n/* harmony export */ DEFAULT_CHART_COLOR_INDEX: () => (/* binding */ DEFAULT_CHART_COLOR_INDEX),\n/* harmony export */ DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX: () => (/* binding */ DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX),\n/* harmony export */ DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE: () => (/* binding */ DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE),\n/* harmony export */ DEFAULT_ELEMENT_BACKGROUND_PICKS: () => (/* binding */ DEFAULT_ELEMENT_BACKGROUND_PICKS),\n/* harmony export */ DEFAULT_ELEMENT_STROKE_COLOR_INDEX: () => (/* binding */ DEFAULT_ELEMENT_STROKE_COLOR_INDEX),\n/* harmony export */ DEFAULT_ELEMENT_STROKE_COLOR_PALETTE: () => (/* binding */ DEFAULT_ELEMENT_STROKE_COLOR_PALETTE),\n/* harmony export */ DEFAULT_ELEMENT_STROKE_PICKS: () => (/* binding */ DEFAULT_ELEMENT_STROKE_PICKS),\n/* harmony export */ MAX_CUSTOM_COLORS_USED_IN_CANVAS: () => (/* binding */ MAX_CUSTOM_COLORS_USED_IN_CANVAS),\n/* harmony export */ applyDarkModeFilter: () => (/* binding */ applyDarkModeFilter),\n/* harmony export */ colorToHex: () => (/* binding */ colorToHex),\n/* harmony export */ getAllColorsSpecificShade: () => (/* binding */ getAllColorsSpecificShade),\n/* harmony export */ isColorDark: () => (/* binding */ isColorDark),\n/* harmony export */ isTransparent: () => (/* binding */ isTransparent),\n/* harmony export */ normalizeInputColor: () => (/* binding */ normalizeInputColor),\n/* harmony export */ rgbToHex: () => (/* binding */ rgbToHex)\n/* harmony export */ });\n/* harmony import */ var tinycolor2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tinycolor2 */ \"../../node_modules/tinycolor2/esm/tinycolor.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n\n\n // ---------------------------------------------------------------------------\n// Dark mode color transformation\n// ---------------------------------------------------------------------------\n// Browser-only cache to avoid memory leaks on server\n\nconst DARK_MODE_COLORS_CACHE = typeof window !== \"undefined\" ? new Map() : null;\n\nfunction cssHueRotate(red, green, blue, degrees) {\n // normalize\n const r = red / 255;\n const g = green / 255;\n const b = blue / 255; // Convert degrees to radians\n\n const a = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.degreesToRadians)(degrees);\n const c = Math.cos(a);\n const s = Math.sin(a); // rotation matrix\n\n const matrix = [0.213 + c * 0.787 - s * 0.213, 0.715 - c * 0.715 - s * 0.715, 0.072 - c * 0.072 + s * 0.928, 0.213 - c * 0.213 + s * 0.143, 0.715 + c * 0.285 + s * 0.14, 0.072 - c * 0.072 - s * 0.283, 0.213 - c * 0.213 - s * 0.787, 0.715 - c * 0.715 + s * 0.715, 0.072 + c * 0.928 + s * 0.072]; // transform\n\n const newR = r * matrix[0] + g * matrix[1] + b * matrix[2];\n const newG = r * matrix[3] + g * matrix[4] + b * matrix[5];\n const newB = r * matrix[6] + g * matrix[7] + b * matrix[8]; // clamp the values to [0, 1] range and convert back to [0, 255]\n\n return {\n r: Math.round(Math.max(0, Math.min(1, newR)) * 255),\n g: Math.round(Math.max(0, Math.min(1, newG)) * 255),\n b: Math.round(Math.max(0, Math.min(1, newB)) * 255)\n };\n}\n\nconst cssInvert = (r, g, b, percent) => {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(percent, 0, 100) / 100; // Function to invert a single color component\n\n const invertComponent = color => {\n // Apply the invert formula\n const inverted = color * (1 - p) + (255 - color) * p; // Round to the nearest integer and clamp to [0, 255]\n\n return Math.round((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.clamp)(inverted, 0, 255));\n }; // Calculate the inverted RGB components\n\n\n const invertedR = invertComponent(r);\n const invertedG = invertComponent(g);\n const invertedB = invertComponent(b);\n return {\n r: invertedR,\n g: invertedG,\n b: invertedB\n };\n};\n\nconst applyDarkModeFilter = (color, enable = true) => {\n if (!enable) {\n return color;\n }\n\n const cached = DARK_MODE_COLORS_CACHE === null || DARK_MODE_COLORS_CACHE === void 0 ? void 0 : DARK_MODE_COLORS_CACHE.get(color);\n\n if (cached) {\n return cached;\n }\n\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n const alpha = tc.getAlpha(); // order of operations matters\n // (corresponds to \"filter: invert(invertPercent) hue-rotate(hueDegrees)\" in css)\n\n const rgb = tc.toRgb();\n const inverted = cssInvert(rgb.r, rgb.g, rgb.b, 93);\n const rotated = cssHueRotate(inverted.r, inverted.g, inverted.b, 180);\n const result = rgbToHex(rotated.r, rotated.g, rotated.b, alpha);\n\n if (DARK_MODE_COLORS_CACHE) {\n DARK_MODE_COLORS_CACHE.set(color, result);\n }\n\n return result;\n}; // ---------------------------------------------------------------------------\n// Color palette\n// ---------------------------------------------------------------------------\n// FIXME can't put to utils.ts rn because of circular dependency\n\nconst pick = (source, keys) => {\n return keys.reduce((acc, key) => {\n if (key in source) {\n acc[key] = source[key];\n }\n\n return acc;\n }, {});\n};\n\nconst MAX_CUSTOM_COLORS_USED_IN_CANVAS = 5;\nconst COLORS_PER_ROW = 5;\nconst DEFAULT_CHART_COLOR_INDEX = 4;\nconst DEFAULT_ELEMENT_STROKE_COLOR_INDEX = 4;\nconst DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX = 1;\nconst COLOR_PALETTE = {\n transparent: \"transparent\",\n black: \"#1e1e1e\",\n white: \"#ffffff\",\n // open-color from https://github.com/yeun/open-color/blob/master/open-color.js\n // corresponds to indexes [0,2,4,6,8] (weights: 50, 200, 400, 600, 800)\n gray: [\"#f8f9fa\", \"#e9ecef\", \"#ced4da\", \"#868e96\", \"#343a40\"],\n red: [\"#fff5f5\", \"#ffc9c9\", \"#ff8787\", \"#fa5252\", \"#e03131\"],\n pink: [\"#fff0f6\", \"#fcc2d7\", \"#f783ac\", \"#e64980\", \"#c2255c\"],\n grape: [\"#f8f0fc\", \"#eebefa\", \"#da77f2\", \"#be4bdb\", \"#9c36b5\"],\n violet: [\"#f3f0ff\", \"#d0bfff\", \"#9775fa\", \"#7950f2\", \"#6741d9\"],\n blue: [\"#e7f5ff\", \"#a5d8ff\", \"#4dabf7\", \"#228be6\", \"#1971c2\"],\n cyan: [\"#e3fafc\", \"#99e9f2\", \"#3bc9db\", \"#15aabf\", \"#0c8599\"],\n teal: [\"#e6fcf5\", \"#96f2d7\", \"#38d9a9\", \"#12b886\", \"#099268\"],\n green: [\"#ebfbee\", \"#b2f2bb\", \"#69db7c\", \"#40c057\", \"#2f9e44\"],\n yellow: [\"#fff9db\", \"#ffec99\", \"#ffd43b\", \"#fab005\", \"#f08c00\"],\n orange: [\"#fff4e6\", \"#ffd8a8\", \"#ffa94d\", \"#fd7e14\", \"#e8590c\"],\n // radix bronze shades [3,5,7,9,11]\n bronze: [\"#f8f1ee\", \"#eaddd7\", \"#d2bab0\", \"#a18072\", \"#846358\"]\n};\nconst COMMON_ELEMENT_SHADES = pick(COLOR_PALETTE, [\"cyan\", \"blue\", \"violet\", \"grape\", \"pink\", \"green\", \"teal\", \"yellow\", \"orange\", \"red\"]); // quick picks defaults\n// -----------------------------------------------------------------------------\n// ORDER matters for positioning in quick picker\n\nconst DEFAULT_ELEMENT_STROKE_PICKS = [COLOR_PALETTE.black, COLOR_PALETTE.red[DEFAULT_ELEMENT_STROKE_COLOR_INDEX], COLOR_PALETTE.green[DEFAULT_ELEMENT_STROKE_COLOR_INDEX], COLOR_PALETTE.blue[DEFAULT_ELEMENT_STROKE_COLOR_INDEX], COLOR_PALETTE.yellow[DEFAULT_ELEMENT_STROKE_COLOR_INDEX]]; // ORDER matters for positioning in quick picker\n\nconst DEFAULT_ELEMENT_BACKGROUND_PICKS = [COLOR_PALETTE.transparent, COLOR_PALETTE.red[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX], COLOR_PALETTE.green[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX], COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX], COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]]; // ORDER matters for positioning in quick picker\n\nconst DEFAULT_CANVAS_BACKGROUND_PICKS = [COLOR_PALETTE.white, // radix slate2\n\"#f8f9fa\", // radix blue2\n\"#f5faff\", // radix yellow2\n\"#fffce8\", // radix bronze2\n\"#fdf8f6\"]; // palette defaults\n// -----------------------------------------------------------------------------\n\nconst DEFAULT_ELEMENT_STROKE_COLOR_PALETTE = Object.assign({\n // 1st row\n transparent: COLOR_PALETTE.transparent,\n white: COLOR_PALETTE.white,\n gray: COLOR_PALETTE.gray,\n black: COLOR_PALETTE.black,\n bronze: COLOR_PALETTE.bronze\n}, COMMON_ELEMENT_SHADES); // ORDER matters for positioning in pallete (5x3 grid)s\n\nconst DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE = Object.assign({\n transparent: COLOR_PALETTE.transparent,\n white: COLOR_PALETTE.white,\n gray: COLOR_PALETTE.gray,\n black: COLOR_PALETTE.black,\n bronze: COLOR_PALETTE.bronze\n}, COMMON_ELEMENT_SHADES); // color palette helpers\n// -----------------------------------------------------------------------------\n// !!!MUST BE WITHOUT GRAY, TRANSPARENT AND BLACK!!!\n\nconst getAllColorsSpecificShade = index => [// 2nd row\nCOLOR_PALETTE.cyan[index], COLOR_PALETTE.blue[index], COLOR_PALETTE.violet[index], COLOR_PALETTE.grape[index], COLOR_PALETTE.pink[index], // 3rd row\nCOLOR_PALETTE.green[index], COLOR_PALETTE.teal[index], COLOR_PALETTE.yellow[index], COLOR_PALETTE.orange[index], COLOR_PALETTE.red[index]]; // -----------------------------------------------------------------------------\n// other helpers\n// -----------------------------------------------------------------------------\n\nconst rgbToHex = (r, g, b, a) => {\n // (1 << 24) adds 0x1000000 to ensure the hex string is always 7 chars,\n // then slice(1) removes the leading \"1\" to get exactly 6 hex digits\n // e.g. rgb(0,0,0) -> 0x1000000 -> \"1000000\" -> \"000000\"\n const hex6 = `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;\n\n if (a !== undefined && a < 1) {\n // convert alpha from 0-1 float to 0-255 int, then to 2-digit hex\n // e.g. 0.5 -> 128 -> \"80\"\n const alphaHex = Math.round(a * 255).toString(16).padStart(2, \"0\");\n return `${hex6}${alphaHex}`;\n }\n\n return hex6;\n};\n/**\n * @returns #RRGGBB or #RRGGBBAA based on color containing non-opaque alpha,\n * null if not valid color\n */\n\nconst colorToHex = color => {\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n\n if (!tc.isValid()) {\n return null;\n }\n\n const {\n r,\n g,\n b,\n a\n } = tc.toRgb();\n return rgbToHex(r, g, b, a);\n};\nconst isTransparent = color => {\n return (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color).getAlpha() === 0;\n}; // -----------------------------------------------------------------------------\n// color contract helpers\n// -----------------------------------------------------------------------------\n\nconst COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;\n\nconst calculateContrast = (r, g, b) => {\n const yiq = (r * 299 + g * 587 + b * 114) / 1000;\n return yiq;\n}; // YIQ algo, inspiration from https://stackoverflow.com/a/11868398\n\n\nconst isColorDark = (color, threshold = 160) => {\n // no color (\"\") -> assume it default to black\n if (!color) {\n return true;\n }\n\n if (isTransparent(color)) {\n return false;\n }\n\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n\n if (!tc.isValid()) {\n // invalid color -> assume it defaults to black\n return true;\n }\n\n const {\n r,\n g,\n b\n } = tc.toRgb();\n return calculateContrast(r, g, b) < threshold;\n}; // -----------------------------------------------------------------------------\n// normalization\n// -----------------------------------------------------------------------------\n\n/**\n * tries to keep the input color as-is if it's valid, making minimal adjustments\n * (trimming whitespace or adding `#` to hex colors)\n */\n\nconst normalizeInputColor = color => {\n color = color.trim();\n\n if (isTransparent(color)) {\n return color;\n }\n\n const tc = (0,tinycolor2__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(color);\n\n if (tc.isValid()) {\n // testing for `#` first fixes a bug on Electron (more specfically, an\n // Obsidian popout window), where a hex color without `#` is considered valid\n if ([\"hex\", \"hex8\"].includes(tc.getFormat()) && !color.startsWith(\"#\")) {\n return `#${color}`;\n }\n\n return color;\n }\n\n return null;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/colors.ts?");
14284
14284
 
14285
14285
  /***/ }),
14286
14286
 
@@ -14423,7 +14423,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
14423
14423
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14424
14424
 
14425
14425
  "use strict";
14426
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ allowFullScreen: () => (/* binding */ allowFullScreen),\n/* harmony export */ arrayToList: () => (/* binding */ arrayToList),\n/* harmony export */ arrayToMap: () => (/* binding */ arrayToMap),\n/* harmony export */ arrayToMapWithIndex: () => (/* binding */ arrayToMapWithIndex),\n/* harmony export */ arrayToObject: () => (/* binding */ arrayToObject),\n/* harmony export */ assertNever: () => (/* binding */ assertNever),\n/* harmony export */ bytesToHexString: () => (/* binding */ bytesToHexString),\n/* harmony export */ capitalizeString: () => (/* binding */ capitalizeString),\n/* harmony export */ castArray: () => (/* binding */ castArray),\n/* harmony export */ chunk: () => (/* binding */ chunk),\n/* harmony export */ cloneJSON: () => (/* binding */ cloneJSON),\n/* harmony export */ composeEventHandlers: () => (/* binding */ composeEventHandlers),\n/* harmony export */ debounce: () => (/* binding */ debounce),\n/* harmony export */ distance: () => (/* binding */ distance),\n/* harmony export */ easeOut: () => (/* binding */ easeOut),\n/* harmony export */ easeToValuesRAF: () => (/* binding */ easeToValuesRAF),\n/* harmony export */ escapeDoubleQuotes: () => (/* binding */ escapeDoubleQuotes),\n/* harmony export */ exitFullScreen: () => (/* binding */ exitFullScreen),\n/* harmony export */ findIndex: () => (/* binding */ findIndex),\n/* harmony export */ findLastIndex: () => (/* binding */ findLastIndex),\n/* harmony export */ focusNearestParent: () => (/* binding */ focusNearestParent),\n/* harmony export */ getDateTime: () => (/* binding */ getDateTime),\n/* harmony export */ getFeatureFlag: () => (/* binding */ getFeatureFlag),\n/* harmony export */ getFontFamilyString: () => (/* binding */ getFontFamilyString),\n/* harmony export */ getFontString: () => (/* binding */ getFontString),\n/* harmony export */ getFrame: () => (/* binding */ getFrame),\n/* harmony export */ getGlobalCSSVariable: () => (/* binding */ getGlobalCSSVariable),\n/* harmony export */ getNearestScrollableContainer: () => (/* binding */ getNearestScrollableContainer),\n/* harmony export */ getSvgPathFromStroke: () => (/* binding */ getSvgPathFromStroke),\n/* harmony export */ getUpdatedTimestamp: () => (/* binding */ getUpdatedTimestamp),\n/* harmony export */ getVersion: () => (/* binding */ getVersion),\n/* harmony export */ invariant: () => (/* binding */ invariant),\n/* harmony export */ isAnyTrue: () => (/* binding */ isAnyTrue),\n/* harmony export */ isDevEnv: () => (/* binding */ isDevEnv),\n/* harmony export */ isFullScreen: () => (/* binding */ isFullScreen),\n/* harmony export */ isInputLike: () => (/* binding */ isInputLike),\n/* harmony export */ isInteractive: () => (/* binding */ isInteractive),\n/* harmony export */ isMemberOf: () => (/* binding */ isMemberOf),\n/* harmony export */ isPrimitive: () => (/* binding */ isPrimitive),\n/* harmony export */ isProdEnv: () => (/* binding */ isProdEnv),\n/* harmony export */ isPromiseLike: () => (/* binding */ isPromiseLike),\n/* harmony export */ isRTL: () => (/* binding */ isRTL),\n/* harmony export */ isReadonlyArray: () => (/* binding */ isReadonlyArray),\n/* harmony export */ isRunningInIframe: () => (/* binding */ isRunningInIframe),\n/* harmony export */ isSelectionLikeTool: () => (/* binding */ isSelectionLikeTool),\n/* harmony export */ isServerEnv: () => (/* binding */ isServerEnv),\n/* harmony export */ isShallowEqual: () => (/* binding */ isShallowEqual),\n/* harmony export */ isTestEnv: () => (/* binding */ isTestEnv),\n/* harmony export */ isToolIcon: () => (/* binding */ isToolIcon),\n/* harmony export */ isWritableElement: () => (/* binding */ isWritableElement),\n/* harmony export */ mapFind: () => (/* binding */ mapFind),\n/* harmony export */ memoize: () => (/* binding */ memoize),\n/* harmony export */ muteFSAbortError: () => (/* binding */ muteFSAbortError),\n/* harmony export */ nFormatter: () => (/* binding */ nFormatter),\n/* harmony export */ nextAnimationFrame: () => (/* binding */ nextAnimationFrame),\n/* harmony export */ normalizeEOL: () => (/* binding */ normalizeEOL),\n/* harmony export */ oneOf: () => (/* binding */ oneOf),\n/* harmony export */ preventUnload: () => (/* binding */ preventUnload),\n/* harmony export */ promiseTry: () => (/* binding */ promiseTry),\n/* harmony export */ queryFocusableElements: () => (/* binding */ queryFocusableElements),\n/* harmony export */ reduceToCommonValue: () => (/* binding */ reduceToCommonValue),\n/* harmony export */ removeSelection: () => (/* binding */ removeSelection),\n/* harmony export */ resolvablePromise: () => (/* binding */ resolvablePromise),\n/* harmony export */ safelyParseJSON: () => (/* binding */ safelyParseJSON),\n/* harmony export */ sceneCoordsToViewportCoords: () => (/* binding */ sceneCoordsToViewportCoords),\n/* harmony export */ selectNode: () => (/* binding */ selectNode),\n/* harmony export */ setDateTimeForTests: () => (/* binding */ setDateTimeForTests),\n/* harmony export */ setFeatureFlag: () => (/* binding */ setFeatureFlag),\n/* harmony export */ sizeOf: () => (/* binding */ sizeOf),\n/* harmony export */ supportsEmoji: () => (/* binding */ supportsEmoji),\n/* harmony export */ throttleRAF: () => (/* binding */ throttleRAF),\n/* harmony export */ toArray: () => (/* binding */ toArray),\n/* harmony export */ toBrandedType: () => (/* binding */ toBrandedType),\n/* harmony export */ toIterable: () => (/* binding */ toIterable),\n/* harmony export */ tupleToCoors: () => (/* binding */ tupleToCoors),\n/* harmony export */ updateActiveTool: () => (/* binding */ updateActiveTool),\n/* harmony export */ updateObject: () => (/* binding */ updateObject),\n/* harmony export */ updateStable: () => (/* binding */ updateStable),\n/* harmony export */ viewportCoordsToSceneCoords: () => (/* binding */ viewportCoordsToSceneCoords),\n/* harmony export */ wrapEvent: () => (/* binding */ wrapEvent)\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 _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ \"../common/src/constants.ts\");\n\n\nlet mockDateTime = null;\nconst setDateTimeForTests = dateTime => {\n mockDateTime = dateTime;\n};\nconst getDateTime = () => {\n if (mockDateTime) {\n return mockDateTime;\n }\n\n const date = new Date();\n const year = date.getFullYear();\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const hr = `${date.getHours()}`.padStart(2, \"0\");\n const min = `${date.getMinutes()}`.padStart(2, \"0\");\n return `${year}-${month}-${day}-${hr}${min}`;\n};\nconst capitalizeString = str => str.charAt(0).toUpperCase() + str.slice(1);\nconst isToolIcon = target => target instanceof HTMLElement && target.className.includes(\"ToolIcon\");\nconst isInputLike = target => target instanceof HTMLElement && target.dataset.type === \"wysiwyg\" || target instanceof HTMLBRElement || // newline in wysiwyg\ntarget instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement;\nconst isInteractive = target => {\n return isInputLike(target) || target instanceof Element && !!target.closest(\"label, button\");\n};\nconst isWritableElement = target => target instanceof HTMLElement && target.dataset.type === \"wysiwyg\" || target instanceof HTMLBRElement || // newline in wysiwyg\ntarget instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === \"text\" || target.type === \"number\" || target.type === \"password\" || target.type === \"search\") || target instanceof HTMLElement && target.closest(\".cm-editor\") !== null;\nconst getFontFamilyString = ({\n fontFamily\n}) => {\n for (const [fontFamilyString, id] of Object.entries(_constants__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY)) {\n if (id === fontFamily) {\n return `${fontFamilyString}${(0,_constants__WEBPACK_IMPORTED_MODULE_1__.getFontFamilyFallbacks)(id).map(x => `, ${x}`).join(\"\")}`;\n }\n }\n\n return _constants__WEBPACK_IMPORTED_MODULE_1__.WINDOWS_EMOJI_FALLBACK_FONT;\n};\n/** returns fontSize+fontFamily string for assignment to DOM elements */\n\nconst getFontString = ({\n fontSize,\n fontFamily\n}) => {\n return `${fontSize}px ${getFontFamilyString({\n fontFamily\n })}`;\n};\n/** executes callback in the frame that's after the current one */\n\nconst nextAnimationFrame = async cb => {\n requestAnimationFrame(() => requestAnimationFrame(cb));\n};\nconst debounce = (fn, timeout) => {\n let handle = 0;\n let lastArgs = null;\n\n const ret = (...args) => {\n lastArgs = args;\n clearTimeout(handle);\n handle = window.setTimeout(() => {\n lastArgs = null;\n fn(...args);\n }, timeout);\n };\n\n ret.flush = () => {\n clearTimeout(handle);\n\n if (lastArgs) {\n const _lastArgs = lastArgs;\n lastArgs = null;\n fn(..._lastArgs);\n }\n };\n\n ret.cancel = () => {\n lastArgs = null;\n clearTimeout(handle);\n };\n\n return ret;\n}; // throttle callback to execute once per animation frame using the latest args\n\nconst throttleRAF = fn => {\n let timerId = null;\n let lastArgs = null;\n\n const scheduleFunc = () => {\n timerId = window.requestAnimationFrame(() => {\n timerId = null;\n const args = lastArgs;\n lastArgs = null;\n\n if (args) {\n fn(...args);\n }\n });\n };\n\n const ret = (...args) => {\n lastArgs = args;\n\n if (timerId === null) {\n scheduleFunc();\n }\n };\n\n ret.flush = () => {\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n\n if (lastArgs) {\n fn(...lastArgs);\n lastArgs = null;\n }\n };\n\n ret.cancel = () => {\n lastArgs = null;\n\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n };\n\n return ret;\n};\n/**\n * Exponential ease-out method\n *\n * @param {number} k - The value to be tweened.\n * @returns {number} The tweened value.\n */\n\nconst easeOut = k => {\n return 1 - Math.pow(1 - k, 4);\n};\n\nconst easeOutInterpolate = (from, to, progress) => {\n return (to - from) * easeOut(progress) + from;\n};\n/**\n * Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.\n * Executes the `onStep` callback on each step with the interpolated values.\n * Returns a function that can be called to cancel the animation.\n *\n * @example\n * // Example usage:\n * const fromValues = { x: 0, y: 0 };\n * const toValues = { x: 100, y: 200 };\n * const onStep = ({x, y}) => {\n * setState(x, y)\n * };\n * const onCancel = () => {\n * console.log(\"Animation canceled\");\n * };\n *\n * const cancelAnimation = easeToValuesRAF({\n * fromValues,\n * toValues,\n * onStep,\n * onCancel,\n * });\n *\n * // To cancel the animation:\n * cancelAnimation();\n */\n\n\nconst easeToValuesRAF = ({\n fromValues,\n toValues,\n onStep,\n duration = 250,\n interpolateValue,\n onStart,\n onEnd,\n onCancel\n}) => {\n let canceled = false;\n let frameId = 0;\n let startTime;\n\n function step(timestamp) {\n if (canceled) {\n return;\n }\n\n if (startTime === undefined) {\n startTime = timestamp;\n onStart === null || onStart === void 0 ? void 0 : onStart();\n }\n\n const elapsed = Math.min(timestamp - startTime, duration);\n const factor = easeOut(elapsed / duration);\n const newValues = {};\n Object.keys(fromValues).forEach(key => {\n const _key = key;\n const result = (toValues[_key] - fromValues[_key]) * factor + fromValues[_key];\n newValues[_key] = result;\n });\n onStep(newValues);\n\n if (elapsed < duration) {\n const progress = elapsed / duration;\n const newValues = {};\n Object.keys(fromValues).forEach(key => {\n const _key = key;\n const startValue = fromValues[_key];\n const endValue = toValues[_key];\n let result;\n result = interpolateValue ? interpolateValue(startValue, endValue, progress, _key) : easeOutInterpolate(startValue, endValue, progress);\n\n if (result == null) {\n result = easeOutInterpolate(startValue, endValue, progress);\n }\n\n newValues[_key] = result;\n });\n onStep(newValues);\n frameId = window.requestAnimationFrame(step);\n } else {\n onStep(toValues);\n onEnd === null || onEnd === void 0 ? void 0 : onEnd();\n }\n }\n\n frameId = window.requestAnimationFrame(step);\n return () => {\n onCancel === null || onCancel === void 0 ? void 0 : onCancel();\n canceled = true;\n window.cancelAnimationFrame(frameId);\n };\n}; // https://github.com/lodash/lodash/blob/es/chunk.js\n\nconst chunk = (array, size) => {\n if (!array.length || size < 1) {\n return [];\n }\n\n let index = 0;\n let resIndex = 0;\n const result = Array(Math.ceil(array.length / size));\n\n while (index < array.length) {\n result[resIndex++] = array.slice(index, index += size);\n }\n\n return result;\n};\nconst selectNode = node => {\n const selection = window.getSelection();\n\n if (selection) {\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n};\nconst removeSelection = () => {\n const selection = window.getSelection();\n\n if (selection) {\n selection.removeAllRanges();\n }\n};\nconst distance = (x, y) => Math.abs(x - y);\nconst isSelectionLikeTool = type => {\n return type === \"selection\" || type === \"lasso\";\n};\nconst updateActiveTool = (appState, data) => {\n var _a, _b, _c;\n\n if (data.type === \"custom\") {\n return Object.assign(Object.assign({}, appState.activeTool), {\n type: \"custom\",\n customType: data.customType,\n locked: (_a = data.locked) !== null && _a !== void 0 ? _a : appState.activeTool.locked\n });\n }\n\n return Object.assign(Object.assign({}, appState.activeTool), {\n lastActiveTool: data.lastActiveToolBeforeEraser === undefined ? appState.activeTool.lastActiveTool : data.lastActiveToolBeforeEraser,\n type: data.type,\n customType: null,\n locked: (_b = data.locked) !== null && _b !== void 0 ? _b : appState.activeTool.locked,\n fromSelection: (_c = data.fromSelection) !== null && _c !== void 0 ? _c : false\n });\n};\nconst isFullScreen = () => {\n var _a;\n\n return ((_a = document.fullscreenElement) === null || _a === void 0 ? void 0 : _a.nodeName) === \"HTML\";\n};\nconst allowFullScreen = () => document.documentElement.requestFullscreen();\nconst exitFullScreen = () => document.exitFullscreen();\nconst viewportCoordsToSceneCoords = ({\n clientX,\n clientY\n}, {\n zoom,\n offsetLeft,\n offsetTop,\n scrollX,\n scrollY\n}) => {\n const x = (clientX - offsetLeft) / zoom.value - scrollX;\n const y = (clientY - offsetTop) / zoom.value - scrollY;\n return {\n x,\n y\n };\n};\nconst sceneCoordsToViewportCoords = ({\n sceneX,\n sceneY\n}, {\n zoom,\n offsetLeft,\n offsetTop,\n scrollX,\n scrollY\n}) => {\n const x = (sceneX + scrollX) * zoom.value + offsetLeft;\n const y = (sceneY + scrollY) * zoom.value + offsetTop;\n return {\n x,\n y\n };\n};\nconst getGlobalCSSVariable = name => getComputedStyle(document.documentElement).getPropertyValue(`--${name}`);\nconst RS_LTR_CHARS = \"A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF\" + \"\\u2C00-\\uFB1C\\uFDFE-\\uFE6F\\uFEFD-\\uFFFF\";\nconst RS_RTL_CHARS = \"\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC\";\nconst RE_RTL_CHECK = new RegExp(`^[^${RS_LTR_CHARS}]*[${RS_RTL_CHARS}]`);\n/**\n * Checks whether first directional character is RTL. Meaning whether it starts\n * with RTL characters, or indeterminate (numbers etc.) characters followed by\n * RTL.\n * See https://github.com/excalidraw/excalidraw/pull/1722#discussion_r436340171\n */\n\nconst isRTL = text => RE_RTL_CHECK.test(text);\nconst tupleToCoors = xyTuple => {\n const [x, y] = xyTuple;\n return {\n x,\n y\n };\n};\n/** use as a rejectionHandler to mute filesystem Abort errors */\n\nconst muteFSAbortError = error => {\n if ((error === null || error === void 0 ? void 0 : error.name) === \"AbortError\") {\n console.warn(error);\n return;\n }\n\n throw error;\n};\nconst findIndex = (array, cb, fromIndex = 0) => {\n if (fromIndex < 0) {\n fromIndex = array.length + fromIndex;\n }\n\n fromIndex = Math.min(array.length, Math.max(fromIndex, 0));\n let index = fromIndex - 1;\n\n while (++index < array.length) {\n if (cb(array[index], index, array)) {\n return index;\n }\n }\n\n return -1;\n};\nconst findLastIndex = (array, cb, fromIndex = array.length - 1) => {\n if (fromIndex < 0) {\n fromIndex = array.length + fromIndex;\n }\n\n fromIndex = Math.min(array.length - 1, Math.max(fromIndex, 0));\n let index = fromIndex + 1;\n\n while (--index > -1) {\n if (cb(array[index], index, array)) {\n return index;\n }\n }\n\n return -1;\n};\n/** returns the first non-null mapped value */\n\nconst mapFind = (collection, iteratee) => {\n for (let idx = 0; idx < collection.length; idx++) {\n const result = iteratee(collection[idx], idx);\n\n if (result != null) {\n return result;\n }\n }\n\n return undefined;\n};\nconst resolvablePromise = () => {\n let resolve;\n let reject;\n const promise = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n promise.resolve = resolve;\n promise.reject = reject;\n return promise;\n}; //https://stackoverflow.com/a/9462382/8418\n\nconst nFormatter = (num, digits) => {\n const si = [{\n value: 1,\n symbol: \"b\"\n }, {\n value: 1e3,\n symbol: \"k\"\n }, {\n value: 1e6,\n symbol: \"M\"\n }, {\n value: 1e9,\n symbol: \"G\"\n }];\n const rx = /\\.0+$|(\\.[0-9]*[1-9])0+$/;\n let index;\n\n for (index = si.length - 1; index > 0; index--) {\n if (num >= si[index].value) {\n break;\n }\n }\n\n return (num / si[index].value).toFixed(digits).replace(rx, \"$1\") + si[index].symbol;\n};\nconst getVersion = () => {\n var _a;\n\n return ((_a = document.querySelector('meta[name=\"version\"]')) === null || _a === void 0 ? void 0 : _a.content) || _constants__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_VERSION;\n}; // Adapted from https://github.com/Modernizr/Modernizr/blob/master/feature-detects/emoji.js\n\nconst supportsEmoji = () => {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n\n if (!ctx) {\n return false;\n }\n\n const offset = 12;\n ctx.fillStyle = \"#f00\";\n ctx.textBaseline = \"top\";\n ctx.font = \"32px Arial\"; // Modernizr used 🐨, but it is sort of supported on Windows 7.\n // Luckily 😀 isn't supported.\n\n ctx.fillText(\"😀\", 0, 0);\n return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0;\n};\nconst getNearestScrollableContainer = element => {\n let parent = element.parentElement;\n\n while (parent) {\n if (parent === document.body) {\n return document;\n }\n\n const {\n overflowY\n } = window.getComputedStyle(parent);\n const hasScrollableContent = parent.scrollHeight > parent.clientHeight;\n\n if (hasScrollableContent && (overflowY === \"auto\" || overflowY === \"scroll\" || overflowY === \"overlay\")) {\n return parent;\n }\n\n parent = parent.parentElement;\n }\n\n return document;\n};\nconst focusNearestParent = element => {\n let parent = element.parentElement;\n\n while (parent) {\n if (parent.tabIndex > -1) {\n parent.focus();\n return;\n }\n\n parent = parent.parentElement;\n }\n};\nconst preventUnload = event => {\n event.preventDefault(); // NOTE: modern browsers no longer allow showing a custom message here\n\n event.returnValue = \"\";\n};\nconst bytesToHexString = bytes => {\n return Array.from(bytes).map(byte => `0${byte.toString(16)}`.slice(-2)).join(\"\");\n};\nconst getUpdatedTimestamp = () => isTestEnv() ? 1 : Date.now();\n/**\n * Transforms array of objects containing `id` attribute,\n * or array of ids (strings), into a Map, keyd by `id`.\n */\n\nconst arrayToMap = items => {\n if (items instanceof Map) {\n return items;\n }\n\n return items.reduce((acc, element) => {\n acc.set(typeof element === \"string\" ? element : element.id, element);\n return acc;\n }, new Map());\n};\nconst arrayToMapWithIndex = elements => elements.reduce((acc, element, idx) => {\n acc.set(element.id, [element, idx]);\n return acc;\n}, new Map());\n/**\n * Transform array into an object, use only when array order is irrelevant.\n */\n\nconst arrayToObject = (array, groupBy) => array.reduce((acc, value, idx) => {\n acc[groupBy ? groupBy(value) : idx] = value;\n return acc;\n}, {});\n/**\n * Creates a circular doubly linked list by adding `prev` and `next` props to the existing array nodes.\n */\n\nconst arrayToList = array => array.reduce((acc, curr, index) => {\n const node = Object.assign(Object.assign({}, curr), {\n prev: null,\n next: null\n }); // no-op for first item, we don't want circular references on a single item\n\n if (index !== 0) {\n const prevNode = acc[index - 1];\n node.prev = prevNode;\n prevNode.next = node;\n\n if (index === array.length - 1) {\n // make the references circular and connect head & tail\n const firstNode = acc[0];\n node.next = firstNode;\n firstNode.prev = node;\n }\n }\n\n acc.push(node);\n return acc;\n}, []);\n/**\n * Converts a readonly array or map into an iterable.\n * Useful for avoiding entry allocations when iterating object / map on each iteration.\n */\n\nconst toIterable = values => {\n return Array.isArray(values) ? values : values.values();\n};\n/**\n * Converts a readonly array or map into an array.\n */\n\nconst toArray = values => {\n return Array.isArray(values) ? values : Array.from(toIterable(values));\n};\nconst isTestEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_1__.ENV.TEST;\nconst isDevEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_1__.ENV.DEVELOPMENT;\nconst isProdEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_1__.ENV.PRODUCTION;\nconst isServerEnv = () => {\n var _a;\n\n return typeof process !== \"undefined\" && !!((_a = process === null || process === void 0 ? void 0 : ({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.0-94\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true})) === null || _a === void 0 ? void 0 : _a.NODE_ENV);\n};\nconst wrapEvent = (name, nativeEvent) => {\n return new CustomEvent(name, {\n detail: {\n nativeEvent\n },\n cancelable: true\n });\n};\nconst updateObject = (obj, updates) => {\n let didChange = false;\n\n for (const key in updates) {\n const value = updates[key];\n\n if (typeof value !== \"undefined\") {\n if (obj[key] === value && ( // if object, always update because its attrs could have changed\n typeof value !== \"object\" || value === null)) {\n continue;\n }\n\n didChange = true;\n }\n }\n\n if (!didChange) {\n return obj;\n }\n\n return Object.assign(Object.assign({}, obj), updates);\n};\nconst isPrimitive = val => {\n const type = typeof val;\n return val == null || type !== \"object\" && type !== \"function\";\n};\nconst getFrame = () => {\n try {\n return window.self === window.top ? \"top\" : \"iframe\";\n } catch (error) {\n return \"iframe\";\n }\n};\nconst isRunningInIframe = () => getFrame() === \"iframe\";\nconst isPromiseLike = value => {\n return !!value && typeof value === \"object\" && \"then\" in value && \"catch\" in value && \"finally\" in value;\n};\nconst queryFocusableElements = container => {\n const focusableElements = container === null || container === void 0 ? void 0 : container.querySelectorAll(\"button, a, input, select, textarea, div[tabindex], label[tabindex]\");\n return focusableElements ? Array.from(focusableElements).filter(element => element.tabIndex > -1 && !element.disabled) : [];\n};\n/** use as a fallback after identity check (for perf reasons) */\n\nconst _defaultIsShallowComparatorFallback = (a, b) => {\n // consider two empty arrays equal\n if (Array.isArray(a) && Array.isArray(b) && a.length === 0 && b.length === 0) {\n return true;\n }\n\n return a === b;\n};\n/**\n * Returns whether object/array is shallow equal.\n * Considers empty object/arrays as equal (whether top-level or second-level).\n */\n\n\nconst isShallowEqual = (objA, objB, comparators, debug = false) => {\n const aKeys = Object.keys(objA);\n const bKeys = Object.keys(objB);\n\n if (aKeys.length !== bKeys.length) {\n if (debug) {\n console.warn(`%cisShallowEqual: objects don't have same properties ->`, \"color: #8B4000\", objA, objB);\n }\n\n return false;\n }\n\n if (comparators && Array.isArray(comparators)) {\n for (const key of comparators) {\n const ret = objA[key] === objB[key] || _defaultIsShallowComparatorFallback(objA[key], objB[key]);\n\n if (!ret) {\n if (debug) {\n console.warn(`%cisShallowEqual: ${key} not equal ->`, \"color: #8B4000\", objA[key], objB[key]);\n }\n\n return false;\n }\n }\n\n return true;\n }\n\n return aKeys.every(key => {\n const comparator = comparators === null || comparators === void 0 ? void 0 : comparators[key];\n const ret = comparator ? comparator(objA[key], objB[key]) : objA[key] === objB[key] || _defaultIsShallowComparatorFallback(objA[key], objB[key]);\n\n if (!ret && debug) {\n console.warn(`%cisShallowEqual: ${key} not equal ->`, \"color: #8B4000\", objA[key], objB[key]);\n }\n\n return ret;\n });\n}; // taken from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx\n\nconst composeEventHandlers = (originalEventHandler, ourEventHandler, {\n checkForDefaultPrevented = true\n} = {}) => {\n return function handleEvent(event) {\n originalEventHandler === null || originalEventHandler === void 0 ? void 0 : originalEventHandler(event);\n\n if (!checkForDefaultPrevented || !(event === null || event === void 0 ? void 0 : event.defaultPrevented)) {\n return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);\n }\n };\n};\n/**\n * supply `null` as message if non-never value is valid, you just need to\n * typecheck against it\n */\n\nconst assertNever = (value, message, softAssert) => {\n if (!message) {\n return value;\n }\n\n if (softAssert) {\n console.error(message);\n return value;\n }\n\n throw new Error(message);\n};\nfunction invariant(condition, message) {\n if (!condition) {\n throw new Error(message);\n }\n}\n/**\n * Memoizes on values of `opts` object (strict equality).\n */\n\nconst memoize = func => {\n let lastArgs;\n let lastResult;\n\n const ret = function (opts) {\n const currentArgs = Object.entries(opts);\n\n if (lastArgs) {\n let argsAreEqual = true;\n\n for (const [key, value] of currentArgs) {\n if (lastArgs.get(key) !== value) {\n argsAreEqual = false;\n break;\n }\n }\n\n if (argsAreEqual) {\n return lastResult;\n }\n }\n\n const result = func(opts);\n lastArgs = new Map(currentArgs);\n lastResult = result;\n return result;\n };\n\n ret.clear = () => {\n lastArgs = undefined;\n lastResult = undefined;\n };\n\n return ret;\n};\n/** Checks if value is inside given collection. Useful for type-safety. */\n\nconst isMemberOf = (\n/** Set/Map/Array/Object */\ncollection,\n/** value to look for */\nvalue) => {\n return collection instanceof Set || collection instanceof Map ? collection.has(value) : \"includes\" in collection ? collection.includes(value) : collection.hasOwnProperty(value);\n};\nconst cloneJSON = obj => JSON.parse(JSON.stringify(obj));\nconst updateStable = (prevValue, nextValue) => {\n if (isShallowEqual(prevValue, nextValue)) {\n return prevValue;\n }\n\n return nextValue;\n}; // implem\n\nfunction addEventListener(\n/**\n * allows for falsy values so you don't have to type check when adding\n * event listeners to optional elements\n */\ntarget, type, listener, options) {\n var _a;\n\n if (!target) {\n return () => {};\n }\n\n (_a = target === null || target === void 0 ? void 0 : target.addEventListener) === null || _a === void 0 ? void 0 : _a.call(target, type, listener, options);\n return () => {\n var _a;\n\n (_a = target === null || target === void 0 ? void 0 : target.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(target, type, listener, options);\n };\n}\nfunction getSvgPathFromStroke(points, closed = true) {\n const len = points.length;\n\n if (len < 4) {\n return ``;\n }\n\n let a = points[0];\n let b = points[1];\n const c = points[2];\n let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(b[0], c[0]).toFixed(2)},${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(b[1], c[1]).toFixed(2)} T`;\n\n for (let i = 2, max = len - 1; i < max; i++) {\n a = points[i];\n b = points[i + 1];\n result += `${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(a[0], b[0]).toFixed(2)},${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(a[1], b[1]).toFixed(2)} `;\n }\n\n if (closed) {\n result += \"Z\";\n }\n\n return result;\n}\nconst normalizeEOL = str => {\n return str.replace(/\\r?\\n|\\r/g, \"\\n\");\n};\nfunction toBrandedType(value) {\n return value;\n} // -----------------------------------------------------------------------------\n// Promise.try, adapted from https://github.com/sindresorhus/p-try\n\nconst promiseTry = async (fn, ...args) => {\n return new Promise(resolve => {\n resolve(fn(...args));\n });\n};\nconst isAnyTrue = (...args) => Math.max(...args.map(arg => arg ? 1 : 0)) > 0;\nconst safelyParseJSON = json => {\n try {\n return JSON.parse(json);\n } catch (_a) {\n return null;\n }\n};\n/**\n * use when you need to render unsafe string as HTML attribute, but MAKE SURE\n * the attribute is double-quoted when constructing the HTML string\n */\n\nconst escapeDoubleQuotes = str => {\n return str.replace(/\"/g, \"&quot;\");\n};\nconst castArray = value => Array.isArray(value) ? value : [value];\n/** hack for Array.isArray type guard not working with readonly value[] */\n\nconst isReadonlyArray = value => {\n return Array.isArray(value);\n};\nconst sizeOf = value => {\n return isReadonlyArray(value) ? value.length : value instanceof Map || value instanceof Set ? value.size : Object.keys(value).length;\n};\nconst reduceToCommonValue = (collection, getValue) => {\n if (sizeOf(collection) === 0) {\n return null;\n }\n\n const valueExtractor = getValue || (item => item);\n\n let commonValue = null;\n\n for (const item of collection) {\n const value = valueExtractor(item);\n\n if ((commonValue === null || commonValue === value) && value != null) {\n commonValue = value;\n } else {\n return null;\n }\n }\n\n return commonValue;\n};\nconst FEATURE_FLAGS_STORAGE_KEY = \"excalidraw-feature-flags\";\nconst DEFAULT_FEATURE_FLAGS = {\n COMPLEX_BINDINGS: false\n};\nlet featureFlags = null;\nconst getFeatureFlag = flag => {\n if (!featureFlags) {\n try {\n const serializedFlags = localStorage.getItem(FEATURE_FLAGS_STORAGE_KEY);\n\n if (serializedFlags) {\n const flags = JSON.parse(serializedFlags);\n featureFlags = flags !== null && flags !== void 0 ? flags : DEFAULT_FEATURE_FLAGS;\n }\n } catch (_a) {}\n }\n\n return (featureFlags || DEFAULT_FEATURE_FLAGS)[flag];\n};\nconst setFeatureFlag = (flag, value) => {\n try {\n featureFlags = Object.assign(Object.assign({}, featureFlags || DEFAULT_FEATURE_FLAGS), {\n [flag]: value\n });\n localStorage.setItem(FEATURE_FLAGS_STORAGE_KEY, JSON.stringify(featureFlags));\n } catch (e) {\n console.error(\"unable to set feature flag\", e);\n }\n};\nconst oneOf = (needle, haystack) => {\n return haystack.includes(needle);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/utils.ts?");
14426
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ allowFullScreen: () => (/* binding */ allowFullScreen),\n/* harmony export */ arrayToList: () => (/* binding */ arrayToList),\n/* harmony export */ arrayToMap: () => (/* binding */ arrayToMap),\n/* harmony export */ arrayToMapWithIndex: () => (/* binding */ arrayToMapWithIndex),\n/* harmony export */ arrayToObject: () => (/* binding */ arrayToObject),\n/* harmony export */ assertNever: () => (/* binding */ assertNever),\n/* harmony export */ bytesToHexString: () => (/* binding */ bytesToHexString),\n/* harmony export */ capitalizeString: () => (/* binding */ capitalizeString),\n/* harmony export */ castArray: () => (/* binding */ castArray),\n/* harmony export */ chunk: () => (/* binding */ chunk),\n/* harmony export */ cloneJSON: () => (/* binding */ cloneJSON),\n/* harmony export */ composeEventHandlers: () => (/* binding */ composeEventHandlers),\n/* harmony export */ debounce: () => (/* binding */ debounce),\n/* harmony export */ distance: () => (/* binding */ distance),\n/* harmony export */ easeOut: () => (/* binding */ easeOut),\n/* harmony export */ easeToValuesRAF: () => (/* binding */ easeToValuesRAF),\n/* harmony export */ escapeDoubleQuotes: () => (/* binding */ escapeDoubleQuotes),\n/* harmony export */ exitFullScreen: () => (/* binding */ exitFullScreen),\n/* harmony export */ findIndex: () => (/* binding */ findIndex),\n/* harmony export */ findLastIndex: () => (/* binding */ findLastIndex),\n/* harmony export */ focusNearestParent: () => (/* binding */ focusNearestParent),\n/* harmony export */ getDateTime: () => (/* binding */ getDateTime),\n/* harmony export */ getFeatureFlag: () => (/* binding */ getFeatureFlag),\n/* harmony export */ getFontFamilyString: () => (/* binding */ getFontFamilyString),\n/* harmony export */ getFontString: () => (/* binding */ getFontString),\n/* harmony export */ getFrame: () => (/* binding */ getFrame),\n/* harmony export */ getGlobalCSSVariable: () => (/* binding */ getGlobalCSSVariable),\n/* harmony export */ getNearestScrollableContainer: () => (/* binding */ getNearestScrollableContainer),\n/* harmony export */ getSvgPathFromStroke: () => (/* binding */ getSvgPathFromStroke),\n/* harmony export */ getUpdatedTimestamp: () => (/* binding */ getUpdatedTimestamp),\n/* harmony export */ getVersion: () => (/* binding */ getVersion),\n/* harmony export */ invariant: () => (/* binding */ invariant),\n/* harmony export */ isAnyTrue: () => (/* binding */ isAnyTrue),\n/* harmony export */ isDevEnv: () => (/* binding */ isDevEnv),\n/* harmony export */ isFullScreen: () => (/* binding */ isFullScreen),\n/* harmony export */ isInputLike: () => (/* binding */ isInputLike),\n/* harmony export */ isInteractive: () => (/* binding */ isInteractive),\n/* harmony export */ isMemberOf: () => (/* binding */ isMemberOf),\n/* harmony export */ isPrimitive: () => (/* binding */ isPrimitive),\n/* harmony export */ isProdEnv: () => (/* binding */ isProdEnv),\n/* harmony export */ isPromiseLike: () => (/* binding */ isPromiseLike),\n/* harmony export */ isRTL: () => (/* binding */ isRTL),\n/* harmony export */ isReadonlyArray: () => (/* binding */ isReadonlyArray),\n/* harmony export */ isRunningInIframe: () => (/* binding */ isRunningInIframe),\n/* harmony export */ isSelectionLikeTool: () => (/* binding */ isSelectionLikeTool),\n/* harmony export */ isServerEnv: () => (/* binding */ isServerEnv),\n/* harmony export */ isShallowEqual: () => (/* binding */ isShallowEqual),\n/* harmony export */ isTestEnv: () => (/* binding */ isTestEnv),\n/* harmony export */ isToolIcon: () => (/* binding */ isToolIcon),\n/* harmony export */ isWritableElement: () => (/* binding */ isWritableElement),\n/* harmony export */ mapFind: () => (/* binding */ mapFind),\n/* harmony export */ memoize: () => (/* binding */ memoize),\n/* harmony export */ muteFSAbortError: () => (/* binding */ muteFSAbortError),\n/* harmony export */ nFormatter: () => (/* binding */ nFormatter),\n/* harmony export */ nextAnimationFrame: () => (/* binding */ nextAnimationFrame),\n/* harmony export */ normalizeEOL: () => (/* binding */ normalizeEOL),\n/* harmony export */ oneOf: () => (/* binding */ oneOf),\n/* harmony export */ preventUnload: () => (/* binding */ preventUnload),\n/* harmony export */ promiseTry: () => (/* binding */ promiseTry),\n/* harmony export */ queryFocusableElements: () => (/* binding */ queryFocusableElements),\n/* harmony export */ reduceToCommonValue: () => (/* binding */ reduceToCommonValue),\n/* harmony export */ removeSelection: () => (/* binding */ removeSelection),\n/* harmony export */ resolvablePromise: () => (/* binding */ resolvablePromise),\n/* harmony export */ safelyParseJSON: () => (/* binding */ safelyParseJSON),\n/* harmony export */ sceneCoordsToViewportCoords: () => (/* binding */ sceneCoordsToViewportCoords),\n/* harmony export */ selectNode: () => (/* binding */ selectNode),\n/* harmony export */ setDateTimeForTests: () => (/* binding */ setDateTimeForTests),\n/* harmony export */ setFeatureFlag: () => (/* binding */ setFeatureFlag),\n/* harmony export */ sizeOf: () => (/* binding */ sizeOf),\n/* harmony export */ supportsEmoji: () => (/* binding */ supportsEmoji),\n/* harmony export */ throttleRAF: () => (/* binding */ throttleRAF),\n/* harmony export */ toArray: () => (/* binding */ toArray),\n/* harmony export */ toBrandedType: () => (/* binding */ toBrandedType),\n/* harmony export */ toIterable: () => (/* binding */ toIterable),\n/* harmony export */ tupleToCoors: () => (/* binding */ tupleToCoors),\n/* harmony export */ updateActiveTool: () => (/* binding */ updateActiveTool),\n/* harmony export */ updateObject: () => (/* binding */ updateObject),\n/* harmony export */ updateStable: () => (/* binding */ updateStable),\n/* harmony export */ viewportCoordsToSceneCoords: () => (/* binding */ viewportCoordsToSceneCoords),\n/* harmony export */ wrapEvent: () => (/* binding */ wrapEvent)\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 _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ \"../common/src/constants.ts\");\n\n\nlet mockDateTime = null;\nconst setDateTimeForTests = dateTime => {\n mockDateTime = dateTime;\n};\nconst getDateTime = () => {\n if (mockDateTime) {\n return mockDateTime;\n }\n\n const date = new Date();\n const year = date.getFullYear();\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const hr = `${date.getHours()}`.padStart(2, \"0\");\n const min = `${date.getMinutes()}`.padStart(2, \"0\");\n return `${year}-${month}-${day}-${hr}${min}`;\n};\nconst capitalizeString = str => str.charAt(0).toUpperCase() + str.slice(1);\nconst isToolIcon = target => target instanceof HTMLElement && target.className.includes(\"ToolIcon\");\nconst isInputLike = target => target instanceof HTMLElement && target.dataset.type === \"wysiwyg\" || target instanceof HTMLBRElement || // newline in wysiwyg\ntarget instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement;\nconst isInteractive = target => {\n return isInputLike(target) || target instanceof Element && !!target.closest(\"label, button\");\n};\nconst isWritableElement = target => target instanceof HTMLElement && target.dataset.type === \"wysiwyg\" || target instanceof HTMLBRElement || // newline in wysiwyg\ntarget instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === \"text\" || target.type === \"number\" || target.type === \"password\" || target.type === \"search\") || target instanceof HTMLElement && target.closest(\".cm-editor\") !== null;\nconst getFontFamilyString = ({\n fontFamily\n}) => {\n for (const [fontFamilyString, id] of Object.entries(_constants__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY)) {\n if (id === fontFamily) {\n return `${fontFamilyString}${(0,_constants__WEBPACK_IMPORTED_MODULE_1__.getFontFamilyFallbacks)(id).map(x => `, ${x}`).join(\"\")}`;\n }\n }\n\n return _constants__WEBPACK_IMPORTED_MODULE_1__.WINDOWS_EMOJI_FALLBACK_FONT;\n};\n/** returns fontSize+fontFamily string for assignment to DOM elements */\n\nconst getFontString = ({\n fontSize,\n fontFamily\n}) => {\n return `${fontSize}px ${getFontFamilyString({\n fontFamily\n })}`;\n};\n/** executes callback in the frame that's after the current one */\n\nconst nextAnimationFrame = async cb => {\n requestAnimationFrame(() => requestAnimationFrame(cb));\n};\nconst debounce = (fn, timeout) => {\n let handle = 0;\n let lastArgs = null;\n\n const ret = (...args) => {\n lastArgs = args;\n clearTimeout(handle);\n handle = window.setTimeout(() => {\n lastArgs = null;\n fn(...args);\n }, timeout);\n };\n\n ret.flush = () => {\n clearTimeout(handle);\n\n if (lastArgs) {\n const _lastArgs = lastArgs;\n lastArgs = null;\n fn(..._lastArgs);\n }\n };\n\n ret.cancel = () => {\n lastArgs = null;\n clearTimeout(handle);\n };\n\n return ret;\n}; // throttle callback to execute once per animation frame using the latest args\n\nconst throttleRAF = fn => {\n let timerId = null;\n let lastArgs = null;\n\n const scheduleFunc = () => {\n timerId = window.requestAnimationFrame(() => {\n timerId = null;\n const args = lastArgs;\n lastArgs = null;\n\n if (args) {\n fn(...args);\n }\n });\n };\n\n const ret = (...args) => {\n lastArgs = args;\n\n if (timerId === null) {\n scheduleFunc();\n }\n };\n\n ret.flush = () => {\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n\n if (lastArgs) {\n fn(...lastArgs);\n lastArgs = null;\n }\n };\n\n ret.cancel = () => {\n lastArgs = null;\n\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n };\n\n return ret;\n};\n/**\n * Exponential ease-out method\n *\n * @param {number} k - The value to be tweened.\n * @returns {number} The tweened value.\n */\n\nconst easeOut = k => {\n return 1 - Math.pow(1 - k, 4);\n};\n\nconst easeOutInterpolate = (from, to, progress) => {\n return (to - from) * easeOut(progress) + from;\n};\n/**\n * Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.\n * Executes the `onStep` callback on each step with the interpolated values.\n * Returns a function that can be called to cancel the animation.\n *\n * @example\n * // Example usage:\n * const fromValues = { x: 0, y: 0 };\n * const toValues = { x: 100, y: 200 };\n * const onStep = ({x, y}) => {\n * setState(x, y)\n * };\n * const onCancel = () => {\n * console.log(\"Animation canceled\");\n * };\n *\n * const cancelAnimation = easeToValuesRAF({\n * fromValues,\n * toValues,\n * onStep,\n * onCancel,\n * });\n *\n * // To cancel the animation:\n * cancelAnimation();\n */\n\n\nconst easeToValuesRAF = ({\n fromValues,\n toValues,\n onStep,\n duration = 250,\n interpolateValue,\n onStart,\n onEnd,\n onCancel\n}) => {\n let canceled = false;\n let frameId = 0;\n let startTime;\n\n function step(timestamp) {\n if (canceled) {\n return;\n }\n\n if (startTime === undefined) {\n startTime = timestamp;\n onStart === null || onStart === void 0 ? void 0 : onStart();\n }\n\n const elapsed = Math.min(timestamp - startTime, duration);\n const factor = easeOut(elapsed / duration);\n const newValues = {};\n Object.keys(fromValues).forEach(key => {\n const _key = key;\n const result = (toValues[_key] - fromValues[_key]) * factor + fromValues[_key];\n newValues[_key] = result;\n });\n onStep(newValues);\n\n if (elapsed < duration) {\n const progress = elapsed / duration;\n const newValues = {};\n Object.keys(fromValues).forEach(key => {\n const _key = key;\n const startValue = fromValues[_key];\n const endValue = toValues[_key];\n let result;\n result = interpolateValue ? interpolateValue(startValue, endValue, progress, _key) : easeOutInterpolate(startValue, endValue, progress);\n\n if (result == null) {\n result = easeOutInterpolate(startValue, endValue, progress);\n }\n\n newValues[_key] = result;\n });\n onStep(newValues);\n frameId = window.requestAnimationFrame(step);\n } else {\n onStep(toValues);\n onEnd === null || onEnd === void 0 ? void 0 : onEnd();\n }\n }\n\n frameId = window.requestAnimationFrame(step);\n return () => {\n onCancel === null || onCancel === void 0 ? void 0 : onCancel();\n canceled = true;\n window.cancelAnimationFrame(frameId);\n };\n}; // https://github.com/lodash/lodash/blob/es/chunk.js\n\nconst chunk = (array, size) => {\n if (!array.length || size < 1) {\n return [];\n }\n\n let index = 0;\n let resIndex = 0;\n const result = Array(Math.ceil(array.length / size));\n\n while (index < array.length) {\n result[resIndex++] = array.slice(index, index += size);\n }\n\n return result;\n};\nconst selectNode = node => {\n const selection = window.getSelection();\n\n if (selection) {\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n};\nconst removeSelection = () => {\n const selection = window.getSelection();\n\n if (selection) {\n selection.removeAllRanges();\n }\n};\nconst distance = (x, y) => Math.abs(x - y);\nconst isSelectionLikeTool = type => {\n return type === \"selection\" || type === \"lasso\";\n};\nconst updateActiveTool = (appState, data) => {\n var _a, _b, _c;\n\n if (data.type === \"custom\") {\n return Object.assign(Object.assign({}, appState.activeTool), {\n type: \"custom\",\n customType: data.customType,\n locked: (_a = data.locked) !== null && _a !== void 0 ? _a : appState.activeTool.locked\n });\n }\n\n return Object.assign(Object.assign({}, appState.activeTool), {\n lastActiveTool: data.lastActiveToolBeforeEraser === undefined ? appState.activeTool.lastActiveTool : data.lastActiveToolBeforeEraser,\n type: data.type,\n customType: null,\n locked: (_b = data.locked) !== null && _b !== void 0 ? _b : appState.activeTool.locked,\n fromSelection: (_c = data.fromSelection) !== null && _c !== void 0 ? _c : false\n });\n};\nconst isFullScreen = () => {\n var _a;\n\n return ((_a = document.fullscreenElement) === null || _a === void 0 ? void 0 : _a.nodeName) === \"HTML\";\n};\nconst allowFullScreen = () => document.documentElement.requestFullscreen();\nconst exitFullScreen = () => document.exitFullscreen();\nconst viewportCoordsToSceneCoords = ({\n clientX,\n clientY\n}, {\n zoom,\n offsetLeft,\n offsetTop,\n scrollX,\n scrollY\n}) => {\n const x = (clientX - offsetLeft) / zoom.value - scrollX;\n const y = (clientY - offsetTop) / zoom.value - scrollY;\n return {\n x,\n y\n };\n};\nconst sceneCoordsToViewportCoords = ({\n sceneX,\n sceneY\n}, {\n zoom,\n offsetLeft,\n offsetTop,\n scrollX,\n scrollY\n}) => {\n const x = (sceneX + scrollX) * zoom.value + offsetLeft;\n const y = (sceneY + scrollY) * zoom.value + offsetTop;\n return {\n x,\n y\n };\n};\nconst getGlobalCSSVariable = name => getComputedStyle(document.documentElement).getPropertyValue(`--${name}`);\nconst RS_LTR_CHARS = \"A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF\" + \"\\u2C00-\\uFB1C\\uFDFE-\\uFE6F\\uFEFD-\\uFFFF\";\nconst RS_RTL_CHARS = \"\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC\";\nconst RE_RTL_CHECK = new RegExp(`^[^${RS_LTR_CHARS}]*[${RS_RTL_CHARS}]`);\n/**\n * Checks whether first directional character is RTL. Meaning whether it starts\n * with RTL characters, or indeterminate (numbers etc.) characters followed by\n * RTL.\n * See https://github.com/excalidraw/excalidraw/pull/1722#discussion_r436340171\n */\n\nconst isRTL = text => RE_RTL_CHECK.test(text);\nconst tupleToCoors = xyTuple => {\n const [x, y] = xyTuple;\n return {\n x,\n y\n };\n};\n/** use as a rejectionHandler to mute filesystem Abort errors */\n\nconst muteFSAbortError = error => {\n if ((error === null || error === void 0 ? void 0 : error.name) === \"AbortError\") {\n console.warn(error);\n return;\n }\n\n throw error;\n};\nconst findIndex = (array, cb, fromIndex = 0) => {\n if (fromIndex < 0) {\n fromIndex = array.length + fromIndex;\n }\n\n fromIndex = Math.min(array.length, Math.max(fromIndex, 0));\n let index = fromIndex - 1;\n\n while (++index < array.length) {\n if (cb(array[index], index, array)) {\n return index;\n }\n }\n\n return -1;\n};\nconst findLastIndex = (array, cb, fromIndex = array.length - 1) => {\n if (fromIndex < 0) {\n fromIndex = array.length + fromIndex;\n }\n\n fromIndex = Math.min(array.length - 1, Math.max(fromIndex, 0));\n let index = fromIndex + 1;\n\n while (--index > -1) {\n if (cb(array[index], index, array)) {\n return index;\n }\n }\n\n return -1;\n};\n/** returns the first non-null mapped value */\n\nconst mapFind = (collection, iteratee) => {\n for (let idx = 0; idx < collection.length; idx++) {\n const result = iteratee(collection[idx], idx);\n\n if (result != null) {\n return result;\n }\n }\n\n return undefined;\n};\nconst resolvablePromise = () => {\n let resolve;\n let reject;\n const promise = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n promise.resolve = resolve;\n promise.reject = reject;\n return promise;\n}; //https://stackoverflow.com/a/9462382/8418\n\nconst nFormatter = (num, digits) => {\n const si = [{\n value: 1,\n symbol: \"b\"\n }, {\n value: 1e3,\n symbol: \"k\"\n }, {\n value: 1e6,\n symbol: \"M\"\n }, {\n value: 1e9,\n symbol: \"G\"\n }];\n const rx = /\\.0+$|(\\.[0-9]*[1-9])0+$/;\n let index;\n\n for (index = si.length - 1; index > 0; index--) {\n if (num >= si[index].value) {\n break;\n }\n }\n\n return (num / si[index].value).toFixed(digits).replace(rx, \"$1\") + si[index].symbol;\n};\nconst getVersion = () => {\n var _a;\n\n return ((_a = document.querySelector('meta[name=\"version\"]')) === null || _a === void 0 ? void 0 : _a.content) || _constants__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_VERSION;\n}; // Adapted from https://github.com/Modernizr/Modernizr/blob/master/feature-detects/emoji.js\n\nconst supportsEmoji = () => {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n\n if (!ctx) {\n return false;\n }\n\n const offset = 12;\n ctx.fillStyle = \"#f00\";\n ctx.textBaseline = \"top\";\n ctx.font = \"32px Arial\"; // Modernizr used 🐨, but it is sort of supported on Windows 7.\n // Luckily 😀 isn't supported.\n\n ctx.fillText(\"😀\", 0, 0);\n return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0;\n};\nconst getNearestScrollableContainer = element => {\n let parent = element.parentElement;\n\n while (parent) {\n if (parent === document.body) {\n return document;\n }\n\n const {\n overflowY\n } = window.getComputedStyle(parent);\n const hasScrollableContent = parent.scrollHeight > parent.clientHeight;\n\n if (hasScrollableContent && (overflowY === \"auto\" || overflowY === \"scroll\" || overflowY === \"overlay\")) {\n return parent;\n }\n\n parent = parent.parentElement;\n }\n\n return document;\n};\nconst focusNearestParent = element => {\n let parent = element.parentElement;\n\n while (parent) {\n if (parent.tabIndex > -1) {\n parent.focus();\n return;\n }\n\n parent = parent.parentElement;\n }\n};\nconst preventUnload = event => {\n event.preventDefault(); // NOTE: modern browsers no longer allow showing a custom message here\n\n event.returnValue = \"\";\n};\nconst bytesToHexString = bytes => {\n return Array.from(bytes).map(byte => `0${byte.toString(16)}`.slice(-2)).join(\"\");\n};\nconst getUpdatedTimestamp = () => isTestEnv() ? 1 : Date.now();\n/**\n * Transforms array of objects containing `id` attribute,\n * or array of ids (strings), into a Map, keyd by `id`.\n */\n\nconst arrayToMap = items => {\n if (items instanceof Map) {\n return items;\n }\n\n return items.reduce((acc, element) => {\n acc.set(typeof element === \"string\" ? element : element.id, element);\n return acc;\n }, new Map());\n};\nconst arrayToMapWithIndex = elements => elements.reduce((acc, element, idx) => {\n acc.set(element.id, [element, idx]);\n return acc;\n}, new Map());\n/**\n * Transform array into an object, use only when array order is irrelevant.\n */\n\nconst arrayToObject = (array, groupBy) => array.reduce((acc, value, idx) => {\n acc[groupBy ? groupBy(value) : idx] = value;\n return acc;\n}, {});\n/**\n * Creates a circular doubly linked list by adding `prev` and `next` props to the existing array nodes.\n */\n\nconst arrayToList = array => array.reduce((acc, curr, index) => {\n const node = Object.assign(Object.assign({}, curr), {\n prev: null,\n next: null\n }); // no-op for first item, we don't want circular references on a single item\n\n if (index !== 0) {\n const prevNode = acc[index - 1];\n node.prev = prevNode;\n prevNode.next = node;\n\n if (index === array.length - 1) {\n // make the references circular and connect head & tail\n const firstNode = acc[0];\n node.next = firstNode;\n firstNode.prev = node;\n }\n }\n\n acc.push(node);\n return acc;\n}, []);\n/**\n * Converts a readonly array or map into an iterable.\n * Useful for avoiding entry allocations when iterating object / map on each iteration.\n */\n\nconst toIterable = values => {\n return Array.isArray(values) ? values : values.values();\n};\n/**\n * Converts a readonly array or map into an array.\n */\n\nconst toArray = values => {\n return Array.isArray(values) ? values : Array.from(toIterable(values));\n};\nconst isTestEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_1__.ENV.TEST;\nconst isDevEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_1__.ENV.DEVELOPMENT;\nconst isProdEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_1__.ENV.PRODUCTION;\nconst isServerEnv = () => {\n var _a;\n\n return typeof process !== \"undefined\" && !!((_a = process === null || process === void 0 ? void 0 : ({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.95\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true})) === null || _a === void 0 ? void 0 : _a.NODE_ENV);\n};\nconst wrapEvent = (name, nativeEvent) => {\n return new CustomEvent(name, {\n detail: {\n nativeEvent\n },\n cancelable: true\n });\n};\nconst updateObject = (obj, updates) => {\n let didChange = false;\n\n for (const key in updates) {\n const value = updates[key];\n\n if (typeof value !== \"undefined\") {\n if (obj[key] === value && ( // if object, always update because its attrs could have changed\n typeof value !== \"object\" || value === null)) {\n continue;\n }\n\n didChange = true;\n }\n }\n\n if (!didChange) {\n return obj;\n }\n\n return Object.assign(Object.assign({}, obj), updates);\n};\nconst isPrimitive = val => {\n const type = typeof val;\n return val == null || type !== \"object\" && type !== \"function\";\n};\nconst getFrame = () => {\n try {\n return window.self === window.top ? \"top\" : \"iframe\";\n } catch (error) {\n return \"iframe\";\n }\n};\nconst isRunningInIframe = () => getFrame() === \"iframe\";\nconst isPromiseLike = value => {\n return !!value && typeof value === \"object\" && \"then\" in value && \"catch\" in value && \"finally\" in value;\n};\nconst queryFocusableElements = container => {\n const focusableElements = container === null || container === void 0 ? void 0 : container.querySelectorAll(\"button, a, input, select, textarea, div[tabindex], label[tabindex]\");\n return focusableElements ? Array.from(focusableElements).filter(element => element.tabIndex > -1 && !element.disabled) : [];\n};\n/** use as a fallback after identity check (for perf reasons) */\n\nconst _defaultIsShallowComparatorFallback = (a, b) => {\n // consider two empty arrays equal\n if (Array.isArray(a) && Array.isArray(b) && a.length === 0 && b.length === 0) {\n return true;\n }\n\n return a === b;\n};\n/**\n * Returns whether object/array is shallow equal.\n * Considers empty object/arrays as equal (whether top-level or second-level).\n */\n\n\nconst isShallowEqual = (objA, objB, comparators, debug = false) => {\n const aKeys = Object.keys(objA);\n const bKeys = Object.keys(objB);\n\n if (aKeys.length !== bKeys.length) {\n if (debug) {\n console.warn(`%cisShallowEqual: objects don't have same properties ->`, \"color: #8B4000\", objA, objB);\n }\n\n return false;\n }\n\n if (comparators && Array.isArray(comparators)) {\n for (const key of comparators) {\n const ret = objA[key] === objB[key] || _defaultIsShallowComparatorFallback(objA[key], objB[key]);\n\n if (!ret) {\n if (debug) {\n console.warn(`%cisShallowEqual: ${key} not equal ->`, \"color: #8B4000\", objA[key], objB[key]);\n }\n\n return false;\n }\n }\n\n return true;\n }\n\n return aKeys.every(key => {\n const comparator = comparators === null || comparators === void 0 ? void 0 : comparators[key];\n const ret = comparator ? comparator(objA[key], objB[key]) : objA[key] === objB[key] || _defaultIsShallowComparatorFallback(objA[key], objB[key]);\n\n if (!ret && debug) {\n console.warn(`%cisShallowEqual: ${key} not equal ->`, \"color: #8B4000\", objA[key], objB[key]);\n }\n\n return ret;\n });\n}; // taken from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx\n\nconst composeEventHandlers = (originalEventHandler, ourEventHandler, {\n checkForDefaultPrevented = true\n} = {}) => {\n return function handleEvent(event) {\n originalEventHandler === null || originalEventHandler === void 0 ? void 0 : originalEventHandler(event);\n\n if (!checkForDefaultPrevented || !(event === null || event === void 0 ? void 0 : event.defaultPrevented)) {\n return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);\n }\n };\n};\n/**\n * supply `null` as message if non-never value is valid, you just need to\n * typecheck against it\n */\n\nconst assertNever = (value, message, softAssert) => {\n if (!message) {\n return value;\n }\n\n if (softAssert) {\n console.error(message);\n return value;\n }\n\n throw new Error(message);\n};\nfunction invariant(condition, message) {\n if (!condition) {\n throw new Error(message);\n }\n}\n/**\n * Memoizes on values of `opts` object (strict equality).\n */\n\nconst memoize = func => {\n let lastArgs;\n let lastResult;\n\n const ret = function (opts) {\n const currentArgs = Object.entries(opts);\n\n if (lastArgs) {\n let argsAreEqual = true;\n\n for (const [key, value] of currentArgs) {\n if (lastArgs.get(key) !== value) {\n argsAreEqual = false;\n break;\n }\n }\n\n if (argsAreEqual) {\n return lastResult;\n }\n }\n\n const result = func(opts);\n lastArgs = new Map(currentArgs);\n lastResult = result;\n return result;\n };\n\n ret.clear = () => {\n lastArgs = undefined;\n lastResult = undefined;\n };\n\n return ret;\n};\n/** Checks if value is inside given collection. Useful for type-safety. */\n\nconst isMemberOf = (\n/** Set/Map/Array/Object */\ncollection,\n/** value to look for */\nvalue) => {\n return collection instanceof Set || collection instanceof Map ? collection.has(value) : \"includes\" in collection ? collection.includes(value) : collection.hasOwnProperty(value);\n};\nconst cloneJSON = obj => JSON.parse(JSON.stringify(obj));\nconst updateStable = (prevValue, nextValue) => {\n if (isShallowEqual(prevValue, nextValue)) {\n return prevValue;\n }\n\n return nextValue;\n}; // implem\n\nfunction addEventListener(\n/**\n * allows for falsy values so you don't have to type check when adding\n * event listeners to optional elements\n */\ntarget, type, listener, options) {\n var _a;\n\n if (!target) {\n return () => {};\n }\n\n (_a = target === null || target === void 0 ? void 0 : target.addEventListener) === null || _a === void 0 ? void 0 : _a.call(target, type, listener, options);\n return () => {\n var _a;\n\n (_a = target === null || target === void 0 ? void 0 : target.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(target, type, listener, options);\n };\n}\nfunction getSvgPathFromStroke(points, closed = true) {\n const len = points.length;\n\n if (len < 4) {\n return ``;\n }\n\n let a = points[0];\n let b = points[1];\n const c = points[2];\n let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(b[0], c[0]).toFixed(2)},${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(b[1], c[1]).toFixed(2)} T`;\n\n for (let i = 2, max = len - 1; i < max; i++) {\n a = points[i];\n b = points[i + 1];\n result += `${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(a[0], b[0]).toFixed(2)},${(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.average)(a[1], b[1]).toFixed(2)} `;\n }\n\n if (closed) {\n result += \"Z\";\n }\n\n return result;\n}\nconst normalizeEOL = str => {\n return str.replace(/\\r?\\n|\\r/g, \"\\n\");\n};\nfunction toBrandedType(value) {\n return value;\n} // -----------------------------------------------------------------------------\n// Promise.try, adapted from https://github.com/sindresorhus/p-try\n\nconst promiseTry = async (fn, ...args) => {\n return new Promise(resolve => {\n resolve(fn(...args));\n });\n};\nconst isAnyTrue = (...args) => Math.max(...args.map(arg => arg ? 1 : 0)) > 0;\nconst safelyParseJSON = json => {\n try {\n return JSON.parse(json);\n } catch (_a) {\n return null;\n }\n};\n/**\n * use when you need to render unsafe string as HTML attribute, but MAKE SURE\n * the attribute is double-quoted when constructing the HTML string\n */\n\nconst escapeDoubleQuotes = str => {\n return str.replace(/\"/g, \"&quot;\");\n};\nconst castArray = value => Array.isArray(value) ? value : [value];\n/** hack for Array.isArray type guard not working with readonly value[] */\n\nconst isReadonlyArray = value => {\n return Array.isArray(value);\n};\nconst sizeOf = value => {\n return isReadonlyArray(value) ? value.length : value instanceof Map || value instanceof Set ? value.size : Object.keys(value).length;\n};\nconst reduceToCommonValue = (collection, getValue) => {\n if (sizeOf(collection) === 0) {\n return null;\n }\n\n const valueExtractor = getValue || (item => item);\n\n let commonValue = null;\n\n for (const item of collection) {\n const value = valueExtractor(item);\n\n if ((commonValue === null || commonValue === value) && value != null) {\n commonValue = value;\n } else {\n return null;\n }\n }\n\n return commonValue;\n};\nconst FEATURE_FLAGS_STORAGE_KEY = \"excalidraw-feature-flags\";\nconst DEFAULT_FEATURE_FLAGS = {\n COMPLEX_BINDINGS: false\n};\nlet featureFlags = null;\nconst getFeatureFlag = flag => {\n if (!featureFlags) {\n try {\n const serializedFlags = localStorage.getItem(FEATURE_FLAGS_STORAGE_KEY);\n\n if (serializedFlags) {\n const flags = JSON.parse(serializedFlags);\n featureFlags = flags !== null && flags !== void 0 ? flags : DEFAULT_FEATURE_FLAGS;\n }\n } catch (_a) {}\n }\n\n return (featureFlags || DEFAULT_FEATURE_FLAGS)[flag];\n};\nconst setFeatureFlag = (flag, value) => {\n try {\n featureFlags = Object.assign(Object.assign({}, featureFlags || DEFAULT_FEATURE_FLAGS), {\n [flag]: value\n });\n localStorage.setItem(FEATURE_FLAGS_STORAGE_KEY, JSON.stringify(featureFlags));\n } catch (e) {\n console.error(\"unable to set feature flag\", e);\n }\n};\nconst oneOf = (needle, haystack) => {\n return haystack.includes(needle);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/utils.ts?");
14427
14427
 
14428
14428
  /***/ }),
14429
14429
 
@@ -14797,7 +14797,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
14797
14797
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14798
14798
 
14799
14799
  "use strict";
14800
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_LINK_SIZE: () => (/* binding */ DEFAULT_LINK_SIZE),\n/* harmony export */ elementWithCanvasCache: () => (/* binding */ elementWithCanvasCache),\n/* harmony export */ getFreedrawOutlineAsSegments: () => (/* binding */ getFreedrawOutlineAsSegments),\n/* harmony export */ getRenderOpacity: () => (/* binding */ getRenderOpacity),\n/* harmony export */ renderElement: () => (/* binding */ renderElement),\n/* harmony export */ renderSelectionElement: () => (/* binding */ renderSelectionElement)\n/* harmony export */ });\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _cropElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _linearElementEditor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _textElement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _textMeasurements__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _frame__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils */ \"../element/src/utils.ts\");\n/* harmony import */ var _shape__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shape */ \"../element/src/shape.ts\");\n/* harmony import */ var _freedrawPath__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freedrawPath */ \"../element/src/freedrawPath.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst isPendingImageElement = (element, renderConfig) => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isInitializedImageElement)(element) && !renderConfig.imageCache.has(element.fileId);\n\nconst getCanvasPadding = element => {\n switch (element.type) {\n case \"freedraw\":\n return element.strokeWidth * 12;\n\n case \"text\":\n return element.fontSize / 2;\n\n case \"arrow\":\n if (element.endArrowhead || element.endArrowhead) {\n return 40;\n }\n\n return 20;\n\n default:\n return 20;\n }\n};\n\nconst getRenderOpacity = (element, containingFrame, elementsPendingErasure, pendingNodes, globalAlpha = 1) => {\n var _a; // multiplying frame opacity with element opacity to combine them\n // (e.g. frame 50% and element 50% opacity should result in 25% opacity)\n\n\n let opacity = ((_a = containingFrame === null || containingFrame === void 0 ? void 0 : containingFrame.opacity) !== null && _a !== void 0 ? _a : 100) * element.opacity / 10000 * globalAlpha; // if pending erasure, multiply again to combine further\n // (so that erasing always results in lower opacity than original)\n\n if (elementsPendingErasure.has(element.id) || pendingNodes && pendingNodes.some(node => node.id === element.id) || containingFrame && elementsPendingErasure.has(containingFrame.id)) {\n opacity *= _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_READY_TO_ERASE_OPACITY / 100;\n }\n\n return opacity;\n};\n\nconst cappedElementCanvasSize = (element, elementsMap, zoom) => {\n // these limits are ballpark, they depend on specific browsers and device.\n // We've chosen lower limits to be safe. We might want to change these limits\n // based on browser/device type, if we get reports of low quality rendering\n // on zoom.\n //\n // ~ safari mobile canvas area limit\n const AREA_LIMIT = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getAreaLimit)(); //zsviczian\n // ~ safari width/height limit based on developer.mozilla.org.\n\n const WIDTH_HEIGHT_LIMIT = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getWidthHeightLimit)(); //zsviczian\n\n const padding = getCanvasPadding(element);\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n const elementWidth = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isLinearElement)(element) || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isFreeDrawElement)(element) ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(x1, x2) : element.width;\n const elementHeight = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isLinearElement)(element) || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isFreeDrawElement)(element) ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(y1, y2) : element.height;\n let width = elementWidth * window.devicePixelRatio + padding * 2;\n let height = elementHeight * window.devicePixelRatio + padding * 2;\n let scale = zoom.value; // rescale to ensure width and height is within limits\n\n if (width * scale > WIDTH_HEIGHT_LIMIT || height * scale > WIDTH_HEIGHT_LIMIT) {\n scale = Math.min(WIDTH_HEIGHT_LIMIT / width, WIDTH_HEIGHT_LIMIT / height);\n } // rescale to ensure canvas area is within limits\n\n\n if (width * height * scale * scale > AREA_LIMIT) {\n scale = Math.sqrt(AREA_LIMIT / (width * height));\n }\n\n width = Math.floor(width * scale);\n height = Math.floor(height * scale);\n return {\n width,\n height,\n scale\n };\n};\n\nconst generateElementCanvas = (element, elementsMap, zoom, renderConfig, appState) => {\n var _a, _b;\n\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n const padding = getCanvasPadding(element);\n const {\n width,\n height,\n scale\n } = cappedElementCanvasSize(element, elementsMap, zoom);\n\n if (!width || !height) {\n return null;\n }\n\n canvas.width = width;\n canvas.height = height;\n let canvasOffsetX = -100;\n let canvasOffsetY = 0;\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isLinearElement)(element) || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isFreeDrawElement)(element)) {\n const [x1, y1] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n canvasOffsetX = element.x > x1 ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(element.x, x1) * window.devicePixelRatio * scale : 0;\n canvasOffsetY = element.y > y1 ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(element.y, y1) * window.devicePixelRatio * scale : 0;\n context.translate(canvasOffsetX, canvasOffsetY);\n }\n\n context.save();\n context.translate(padding * scale, padding * scale);\n context.scale(window.devicePixelRatio * scale, window.devicePixelRatio * scale);\n const rc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].canvas(canvas);\n drawElementOnCanvas(element, rc, context, renderConfig);\n context.restore();\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap);\n const boundTextCanvas = document.createElement(\"canvas\");\n const boundTextCanvasContext = boundTextCanvas.getContext(\"2d\");\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement) {\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap); // Take max dimensions of arrow canvas so that when canvas is rotated\n // the arrow doesn't get clipped\n\n const maxDim = Math.max((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(x1, x2), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(y1, y2));\n boundTextCanvas.width = maxDim * window.devicePixelRatio * scale + padding * scale * 10;\n boundTextCanvas.height = maxDim * window.devicePixelRatio * scale + padding * scale * 10;\n boundTextCanvasContext.translate(boundTextCanvas.width / 2, boundTextCanvas.height / 2);\n boundTextCanvasContext.rotate(element.angle);\n boundTextCanvasContext.drawImage(canvas, -canvas.width / 2, -canvas.height / 2, canvas.width, canvas.height);\n const [,,,, boundTextCx, boundTextCy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(boundTextElement, elementsMap);\n boundTextCanvasContext.rotate(-element.angle);\n const offsetX = (boundTextCanvas.width - canvas.width) / 2;\n const offsetY = (boundTextCanvas.height - canvas.height) / 2;\n const shiftX = boundTextCanvas.width / 2 - (boundTextCx - x1) * window.devicePixelRatio * scale - offsetX - padding * scale;\n const shiftY = boundTextCanvas.height / 2 - (boundTextCy - y1) * window.devicePixelRatio * scale - offsetY - padding * scale;\n boundTextCanvasContext.translate(-shiftX, -shiftY); // Clear the bound text area\n\n boundTextCanvasContext.clearRect(-(boundTextElement.width / 2 + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING) * window.devicePixelRatio * scale, -(boundTextElement.height / 2 + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING) * window.devicePixelRatio * scale, (boundTextElement.width + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING * 2) * window.devicePixelRatio * scale, (boundTextElement.height + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING * 2) * window.devicePixelRatio * scale);\n }\n\n return {\n element,\n canvas,\n theme: appState.theme,\n scale,\n zoomValue: zoom.value,\n canvasOffsetX,\n canvasOffsetY,\n boundTextElementVersion: ((_a = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap)) === null || _a === void 0 ? void 0 : _a.version) || null,\n containingFrameOpacity: ((_b = (0,_frame__WEBPACK_IMPORTED_MODULE_9__.getContainingFrame)(element, elementsMap)) === null || _b === void 0 ? void 0 : _b.opacity) || 100,\n boundTextCanvas,\n angle: element.angle,\n imageCrop: (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isImageElement)(element) ? element.crop : null\n };\n};\n\nconst DEFAULT_LINK_SIZE = 14;\nconst IMAGE_PLACEHOLDER_IMG = typeof document !== \"undefined\" ? document.createElement(\"img\") : {\n src: \"\"\n}; // mock image element outside of browser\n\nIMAGE_PLACEHOLDER_IMG.src = `data:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.MIME_TYPES.svg},${encodeURIComponent(`<svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"fas\" data-icon=\"image\" class=\"svg-inline--fa fa-image fa-w-16\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"#888\" d=\"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z\"></path></svg>`)}`;\nconst IMAGE_ERROR_PLACEHOLDER_IMG = typeof document !== \"undefined\" ? document.createElement(\"img\") : {\n src: \"\"\n}; // mock image element outside of browser\n\nIMAGE_ERROR_PLACEHOLDER_IMG.src = `data:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.MIME_TYPES.svg},${encodeURIComponent(`<svg viewBox=\"0 0 668 668\" xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2\"><path d=\"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z\" style=\"fill:#888;fill-rule:nonzero\" transform=\"matrix(.81709 0 0 .81709 124.825 145.825)\"/><path d=\"M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z\" style=\"fill:#888;fill-rule:nonzero\" transform=\"matrix(.30366 0 0 .30366 506.822 60.065)\"/></svg>`)}`;\n\nconst drawImagePlaceholder = (element, context, theme) => {\n context.fillStyle = theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK ? \"#2E2E2E\" : \"#E7E7E7\";\n context.fillRect(0, 0, element.width, element.height);\n const imageMinWidthOrHeight = Math.min(element.width, element.height);\n const size = Math.min(imageMinWidthOrHeight, Math.min(imageMinWidthOrHeight * 0.4, 100));\n context.drawImage(element.status === \"error\" ? IMAGE_ERROR_PLACEHOLDER_IMG : IMAGE_PLACEHOLDER_IMG, element.width / 2 - size / 2, element.height / 2 - size / 2, size, size);\n};\n\nconst drawElementOnCanvas = (element, rc, context, renderConfig) => {\n var _a, _b, _c, _d, _e;\n\n switch (element.type) {\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n case \"diamond\":\n case \"ellipse\":\n {\n context.lineJoin = \"round\";\n context.lineCap = \"round\";\n rc.draw(_shape__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.generateElementShape(element, renderConfig));\n break;\n }\n\n case \"arrow\":\n case \"line\":\n {\n context.lineJoin = \"round\";\n context.lineCap = \"round\";\n _shape__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.generateElementShape(element, renderConfig).forEach(shape => {\n rc.draw(shape);\n });\n break;\n }\n\n case \"freedraw\":\n {\n // Draw directly to canvas\n context.save();\n const shapes = _shape__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.generateElementShape(element, renderConfig);\n\n for (const shape of shapes) {\n if (typeof shape === \"string\") {\n const {\n path,\n fillStyle\n } = (() => {\n var _a, _b, _c, _d, _e;\n\n const path = new Path2D((0,_freedrawPath__WEBPACK_IMPORTED_MODULE_12__.getFreeDrawSvgPath)(element));\n const hasOutline = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.strokeOptions) === null || _b === void 0 ? void 0 : _b.hasOutline;\n const outlineWidth = (_e = (_d = (_c = element.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.outlineWidth) !== null && _e !== void 0 ? _e : 1;\n const fillColor = hasOutline ? element.backgroundColor : element.strokeColor;\n const fillStyle = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(fillColor) : fillColor;\n\n if (hasOutline) {\n context.lineWidth = element.strokeWidth * outlineWidth;\n context.strokeStyle = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor;\n context.stroke(path);\n }\n\n return {\n path,\n fillStyle\n };\n })();\n\n context.fillStyle = fillStyle; //zsviczian\n\n context.fill(path); //zsviczian\n\n /*\n context.fillStyle =\n renderConfig.theme === THEME.DARK\n ? applyDarkModeFilter(element.strokeColor)\n : element.strokeColor;\n context.fill(new Path2D(shape));\n */\n //zsviczian\n } else {\n rc.draw(shape);\n }\n }\n\n context.restore();\n break;\n }\n\n case \"image\":\n {\n context.save();\n const cacheEntry = element.fileId !== null ? renderConfig.imageCache.get(element.fileId) : null;\n const img = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isInitializedImageElement)(element) ? cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.image : undefined;\n\n if (img != null && !(img instanceof Promise)) {\n if (element.roundness && context.roundRect) {\n context.beginPath();\n context.roundRect(0, 0, element.width, element.height, (0,_utils__WEBPACK_IMPORTED_MODULE_10__.getCornerRadius)(Math.min(element.width, element.height), element));\n context.clip();\n }\n\n const {\n x,\n y,\n width,\n height\n } = element.crop ? element.crop : {\n x: 0,\n y: 0,\n width: img.naturalWidth,\n height: img.naturalHeight\n };\n const shouldInvertImage = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK && ((cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.mimeType) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.MIME_TYPES.svg && !((_a = element.customData) === null || _a === void 0 ? void 0 : _a.doNotInvertSVGInDarkMode) || !!((_b = element.customData) === null || _b === void 0 ? void 0 : _b.pdfPageViewProps) && ((_d = (_c = element.customData) === null || _c === void 0 ? void 0 : _c.invertBitmapInDarkmode) !== null && _d !== void 0 ? _d : true) || !!((_e = element.customData) === null || _e === void 0 ? void 0 : _e.invertBitmapInDarkmode)); //zsviczian\n\n if (shouldInvertImage && _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isIOS) {\n const devicePixelRatio = window.devicePixelRatio || 1;\n const tempCanvas = document.createElement(\"canvas\");\n tempCanvas.width = element.width * devicePixelRatio;\n tempCanvas.height = element.height * devicePixelRatio;\n const tempContext = tempCanvas.getContext(\"2d\");\n\n if (tempContext) {\n tempContext.scale(devicePixelRatio, devicePixelRatio);\n tempContext.drawImage(img, x, y, width, height, 0, 0, element.width, element.height);\n const imageData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);\n const data = imageData.data;\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n }\n\n tempContext.putImageData(imageData, 0, 0);\n context.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, 0, 0, element.width, element.height);\n }\n } else {\n if (shouldInvertImage) {\n context.filter = _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DARK_THEME_FILTER;\n }\n\n context.drawImage(img, x, y, width, height, 0\n /* hardcoded for the selection box*/\n , 0, element.width, element.height);\n }\n } else {\n drawImagePlaceholder(element, context, renderConfig.theme);\n }\n\n context.restore();\n break;\n }\n\n default:\n {\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isTextElement)(element)) {\n const rtl = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isRTL)(element.text);\n const shouldTemporarilyAttach = rtl && !context.canvas.isConnected;\n\n if (shouldTemporarilyAttach) {\n // to correctly render RTL text mixed with LTR, we have to append it\n // to the DOM\n document.body.appendChild(context.canvas);\n }\n\n context.canvas.setAttribute(\"dir\", rtl ? \"rtl\" : \"ltr\");\n context.save();\n context.font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getFontString)(element);\n context.fillStyle = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor;\n context.textAlign = element.textAlign; // Canvas does not support multiline text by default\n\n const lines = element.text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const horizontalOffset = element.textAlign === \"center\" ? element.width / 2 : element.textAlign === \"right\" ? element.width : 0;\n const lineHeightPx = (0,_textMeasurements__WEBPACK_IMPORTED_MODULE_7__.getLineHeightInPx)(element.fontSize, element.lineHeight);\n const verticalOffset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getVerticalOffset)(element.fontFamily, element.fontSize, lineHeightPx);\n\n for (let index = 0; index < lines.length; index++) {\n context.fillText(lines[index], horizontalOffset, index * lineHeightPx + verticalOffset);\n }\n\n context.restore();\n\n if (shouldTemporarilyAttach) {\n context.canvas.remove();\n }\n } else {\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n }\n};\n\nconst elementWithCanvasCache = new WeakMap();\n\nconst generateElementWithCanvas = (element, elementsMap, renderConfig, appState) => {\n var _a;\n\n const zoom = renderConfig ? appState.zoom : {\n value: 1\n };\n const prevElementWithCanvas = elementWithCanvasCache.get(element);\n const shouldRegenerateBecauseZoom = prevElementWithCanvas && prevElementWithCanvas.zoomValue !== zoom.value && !(appState === null || appState === void 0 ? void 0 : appState.shouldCacheIgnoreZoom);\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap);\n const boundTextElementVersion = (boundTextElement === null || boundTextElement === void 0 ? void 0 : boundTextElement.version) || null;\n const imageCrop = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isImageElement)(element) ? element.crop : null;\n const containingFrameOpacity = ((_a = (0,_frame__WEBPACK_IMPORTED_MODULE_9__.getContainingFrame)(element, elementsMap)) === null || _a === void 0 ? void 0 : _a.opacity) || 100;\n\n if (!prevElementWithCanvas || shouldRegenerateBecauseZoom || prevElementWithCanvas.theme !== appState.theme || prevElementWithCanvas.boundTextElementVersion !== boundTextElementVersion || prevElementWithCanvas.imageCrop !== imageCrop || prevElementWithCanvas.containingFrameOpacity !== containingFrameOpacity || // since we rotate the canvas when copying from cached canvas, we don't\n // regenerate the cached canvas. But we need to in case of labels which are\n // cached alongside the arrow, and we want the labels to remain unrotated\n // with respect to the arrow.\n (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement && element.angle !== prevElementWithCanvas.angle) {\n const elementWithCanvas = generateElementCanvas(element, elementsMap, zoom, renderConfig, appState);\n\n if (!elementWithCanvas) {\n return null;\n }\n\n elementWithCanvasCache.set(element, elementWithCanvas);\n return elementWithCanvas;\n }\n\n return prevElementWithCanvas;\n};\n\nconst drawElementFromCanvas = (elementWithCanvas, context, renderConfig, appState, allElementsMap) => {\n const element = elementWithCanvas.element;\n const padding = getCanvasPadding(element);\n const zoom = elementWithCanvas.scale;\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, allElementsMap);\n const cx = ((x1 + x2) / 2 + appState.scrollX) * window.devicePixelRatio;\n const cy = ((y1 + y2) / 2 + appState.scrollY) * window.devicePixelRatio;\n context.save();\n context.scale(1 / window.devicePixelRatio, 1 / window.devicePixelRatio);\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, allElementsMap);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement) {\n const offsetX = (elementWithCanvas.boundTextCanvas.width - elementWithCanvas.canvas.width) / 2;\n const offsetY = (elementWithCanvas.boundTextCanvas.height - elementWithCanvas.canvas.height) / 2;\n context.translate(cx, cy);\n context.drawImage(elementWithCanvas.boundTextCanvas, -(x2 - x1) / 2 * window.devicePixelRatio - offsetX / zoom - padding, -(y2 - y1) / 2 * window.devicePixelRatio - offsetY / zoom - padding, elementWithCanvas.boundTextCanvas.width / zoom, elementWithCanvas.boundTextCanvas.height / zoom);\n } else {\n // we translate context to element center so that rotation and scale\n // originates from the element center\n context.translate(cx, cy);\n context.rotate(element.angle);\n\n if (\"scale\" in elementWithCanvas.element && !isPendingImageElement(element, renderConfig) && !(0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isIframeLikeElement)(element) //zsviczian\n ) {\n context.scale(elementWithCanvas.element.scale[0], elementWithCanvas.element.scale[1]);\n } // revert afterwards we don't have account for it during drawing\n\n\n context.translate(-cx, -cy);\n context.drawImage(elementWithCanvas.canvas, (x1 + appState.scrollX) * window.devicePixelRatio - padding * elementWithCanvas.scale / elementWithCanvas.scale, (y1 + appState.scrollY) * window.devicePixelRatio - padding * elementWithCanvas.scale / elementWithCanvas.scale, elementWithCanvas.canvas.width / elementWithCanvas.scale, elementWithCanvas.canvas.height / elementWithCanvas.scale);\n\n if (false) {}\n }\n\n context.restore(); // Clear the nested element we appended to the DOM\n};\n\nconst renderSelectionElement = (element, context, appState, selectionColor) => {\n context.save();\n context.translate(element.x + appState.scrollX, element.y + appState.scrollY);\n context.fillStyle = \"rgba(0, 0, 200, 0.04)\"; // render from 0.5px offset to get 1px wide line\n // https://stackoverflow.com/questions/7530593/html5-canvas-and-line-width/7531540#7531540\n // TODO can be be improved by offseting to the negative when user selects\n // from right to left\n\n const offset = 0.5 / appState.zoom.value;\n context.fillRect(offset, offset, element.width, element.height);\n context.lineWidth = 1.5 / appState.zoom.value; //zsviczian changed from 1 to 1.5\n\n context.strokeStyle = selectionColor;\n context.strokeRect(offset, offset, element.width, element.height);\n context.restore();\n};\nconst renderElement = (element, elementsMap, allElementsMap, rc, context, renderConfig, appState) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;\n\n const reduceAlphaForSelection = ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\" && !appState.selectedElementIds[element.id] && !appState.hoveredElementIds[element.id];\n context.globalAlpha = getRenderOpacity(element, (0,_frame__WEBPACK_IMPORTED_MODULE_9__.getContainingFrame)(element, elementsMap), renderConfig.elementsPendingErasure, renderConfig.pendingFlowchartNodes, reduceAlphaForSelection ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1);\n\n switch (element.type) {\n case \"magicframe\":\n case \"frame\":\n {\n if ( //zsviczian\n appState.frameRendering.enabled && appState.frameRendering.outline && !(!appState.frameRendering.markerEnabled && element.frameRole === \"marker\")) {\n context.save();\n context.translate(element.x + appState.scrollX, element.y + appState.scrollY);\n context.fillStyle = (_f = (_d = (_c = (_b = element.customData) === null || _b === void 0 ? void 0 : _b.frameColor) === null || _c === void 0 ? void 0 : _c.fill) !== null && _d !== void 0 ? _d : (_e = appState === null || appState === void 0 ? void 0 : appState.frameColor) === null || _e === void 0 ? void 0 : _e.fill) !== null && _f !== void 0 ? _f : \"rgba(0, 0, 200, 0.04)\"; //zsviczian\n\n context.lineWidth = _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.strokeWidth / appState.zoom.value;\n context.strokeStyle = appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)((_l = (_j = (_h = (_g = element.customData) === null || _g === void 0 ? void 0 : _g.frameColor) === null || _h === void 0 ? void 0 : _h.stroke) !== null && _j !== void 0 ? _j : (_k = appState === null || appState === void 0 ? void 0 : appState.frameColor) === null || _k === void 0 ? void 0 : _k.stroke) !== null && _l !== void 0 ? _l : _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.strokeColor) : (_r = (_p = (_o = (_m = element.customData) === null || _m === void 0 ? void 0 : _m.frameColor) === null || _o === void 0 ? void 0 : _o.stroke) !== null && _p !== void 0 ? _p : (_q = appState === null || appState === void 0 ? void 0 : appState.frameColor) === null || _q === void 0 ? void 0 : _q.stroke) !== null && _r !== void 0 ? _r : _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.strokeColor; //zsviczian\n // TODO change later to only affect AI frames\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isMagicFrameElement)(element)) {\n context.strokeStyle = appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.LIGHT ? \"#7affd7\" : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(\"#1d8264\");\n } //zsviczian\n\n\n if (element.frameRole === \"marker\") {\n const dash = 8 / appState.zoom.value;\n const gap = 6 / appState.zoom.value;\n context.setLineDash([dash, gap]);\n }\n\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.radius && context.roundRect && element.frameRole !== \"marker\") {\n //zsviczian\n context.beginPath();\n context.roundRect(0, 0, element.width, element.height, _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.radius / appState.zoom.value);\n context.stroke();\n context.closePath();\n } else {\n context.strokeRect(0, 0, element.width, element.height);\n }\n\n context.restore();\n }\n\n break;\n }\n\n case \"freedraw\":\n {\n if (renderConfig.isExporting) {\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n const cx = (x1 + x2) / 2 + appState.scrollX;\n const cy = (y1 + y2) / 2 + appState.scrollY;\n const shiftX = (x2 - x1) / 2 - (element.x - x1);\n const shiftY = (y2 - y1) / 2 - (element.y - y1);\n context.save();\n context.translate(cx, cy);\n context.rotate(element.angle);\n context.translate(-shiftX, -shiftY);\n drawElementOnCanvas(element, rc, context, renderConfig);\n context.restore();\n } else {\n const elementWithCanvas = generateElementWithCanvas(element, allElementsMap, renderConfig, appState);\n\n if (!elementWithCanvas) {\n return;\n }\n\n drawElementFromCanvas(elementWithCanvas, context, renderConfig, appState, allElementsMap);\n }\n\n break;\n }\n\n case \"rectangle\":\n case \"diamond\":\n case \"ellipse\":\n case \"line\":\n case \"arrow\":\n case \"image\":\n case \"text\":\n case \"iframe\":\n case \"embeddable\":\n {\n if (renderConfig.isExporting) {\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n const cx = (x1 + x2) / 2 + appState.scrollX;\n const cy = (y1 + y2) / 2 + appState.scrollY;\n let shiftX = (x2 - x1) / 2 - (element.x - x1);\n let shiftY = (y2 - y1) / 2 - (element.y - y1);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isTextElement)(element)) {\n const container = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getContainerElement)(element, elementsMap);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(container)) {\n const boundTextCoords = _linearElementEditor__WEBPACK_IMPORTED_MODULE_5__.LinearElementEditor.getBoundTextElementPosition(container, element, elementsMap);\n shiftX = (x2 - x1) / 2 - (boundTextCoords.x - x1);\n shiftY = (y2 - y1) / 2 - (boundTextCoords.y - y1);\n }\n }\n\n context.save();\n context.translate(cx, cy);\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement) {\n const tempCanvas = document.createElement(\"canvas\");\n const tempCanvasContext = tempCanvas.getContext(\"2d\"); // Take max dimensions of arrow canvas so that when canvas is rotated\n // the arrow doesn't get clipped\n\n const maxDim = Math.max((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(x1, x2), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(y1, y2));\n const padding = getCanvasPadding(element);\n tempCanvas.width = maxDim * appState.exportScale + padding * 10 * appState.exportScale;\n tempCanvas.height = maxDim * appState.exportScale + padding * 10 * appState.exportScale;\n tempCanvasContext.translate(tempCanvas.width / 2, tempCanvas.height / 2);\n tempCanvasContext.scale(appState.exportScale, appState.exportScale); // Shift the canvas to left most point of the arrow\n\n shiftX = element.width / 2 - (element.x - x1);\n shiftY = element.height / 2 - (element.y - y1);\n tempCanvasContext.rotate(element.angle);\n const tempRc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].canvas(tempCanvas);\n tempCanvasContext.translate(-shiftX, -shiftY);\n drawElementOnCanvas(element, tempRc, tempCanvasContext, renderConfig);\n tempCanvasContext.translate(shiftX, shiftY);\n tempCanvasContext.rotate(-element.angle); // Shift the canvas to center of bound text\n\n const [,,,, boundTextCx, boundTextCy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(boundTextElement, elementsMap);\n const boundTextShiftX = (x1 + x2) / 2 - boundTextCx;\n const boundTextShiftY = (y1 + y2) / 2 - boundTextCy;\n tempCanvasContext.translate(-boundTextShiftX, -boundTextShiftY); // Clear the bound text area\n\n tempCanvasContext.clearRect(-boundTextElement.width / 2, -boundTextElement.height / 2, boundTextElement.width, boundTextElement.height);\n context.scale(1 / appState.exportScale, 1 / appState.exportScale);\n context.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2, tempCanvas.width, tempCanvas.height);\n } else {\n context.rotate(element.angle);\n\n if (element.type === \"image\") {\n // note: scale must be applied *after* rotating\n context.scale(element.scale[0], element.scale[1]);\n }\n\n context.translate(-shiftX, -shiftY);\n drawElementOnCanvas(element, rc, context, renderConfig);\n }\n\n context.restore(); // not exporting → optimized rendering (cache & render from element\n // canvases)\n } else {\n const elementWithCanvas = generateElementWithCanvas(element, allElementsMap, renderConfig, appState);\n\n if (!elementWithCanvas) {\n return;\n }\n\n const currentImageSmoothingStatus = context.imageSmoothingEnabled;\n\n if ( // do not disable smoothing during zoom as blurry shapes look better\n // on low resolution (while still zooming in) than sharp ones\n !(appState === null || appState === void 0 ? void 0 : appState.shouldCacheIgnoreZoom) && ( // angle is 0 -> always disable smoothing\n !element.angle || // or check if angle is a right angle in which case we can still\n // disable smoothing without adversely affecting the result\n // We need less-than comparison because of FP artihmetic\n (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.isRightAngleRads)(element.angle))) {\n // Disabling smoothing makes output much sharper, especially for\n // text. Unless for non-right angles, where the aliasing is really\n // terrible on Chromium.\n //\n // Note that `context.imageSmoothingQuality=\"high\"` has almost\n // zero effect.\n //\n context.imageSmoothingEnabled = false;\n }\n\n if (element.id === appState.croppingElementId && (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isImageElement)(elementWithCanvas.element) && elementWithCanvas.element.crop !== null) {\n context.save();\n context.globalAlpha = 0.1;\n const uncroppedElementCanvas = generateElementCanvas((0,_cropElement__WEBPACK_IMPORTED_MODULE_4__.getUncroppedImageElement)(elementWithCanvas.element, elementsMap), allElementsMap, appState.zoom, renderConfig, appState);\n\n if (uncroppedElementCanvas) {\n drawElementFromCanvas(uncroppedElementCanvas, context, renderConfig, appState, allElementsMap);\n }\n\n context.restore();\n }\n\n drawElementFromCanvas(elementWithCanvas, context, renderConfig, appState, allElementsMap); // reset\n\n context.imageSmoothingEnabled = currentImageSmoothingStatus;\n }\n\n break;\n }\n\n default:\n {\n // @ts-ignore\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n\n context.globalAlpha = 1;\n};\nfunction getFreedrawOutlineAsSegments(element, points, elementsMap) {\n const bounds = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementBounds)(Object.assign(Object.assign({}, element), {\n angle: 0\n }), elementsMap);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)((bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2);\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.invariant)(points.length >= 2, \"Freepath outline must have at least 2 points\");\n return points.slice(2).reduce((acc, curr) => {\n acc.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(acc[acc.length - 1][1], (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(curr[0] + element.x, curr[1] + element.y), center, element.angle)));\n return acc;\n }, [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(points[0][0] + element.x, points[0][1] + element.y), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(points[1][0] + element.x, points[1][1] + element.y), center, element.angle))]);\n}\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/renderElement.ts?");
14800
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_LINK_SIZE: () => (/* binding */ DEFAULT_LINK_SIZE),\n/* harmony export */ elementWithCanvasCache: () => (/* binding */ elementWithCanvasCache),\n/* harmony export */ getFreedrawOutlineAsSegments: () => (/* binding */ getFreedrawOutlineAsSegments),\n/* harmony export */ getRenderOpacity: () => (/* binding */ getRenderOpacity),\n/* harmony export */ renderElement: () => (/* binding */ renderElement),\n/* harmony export */ renderSelectionElement: () => (/* binding */ renderSelectionElement)\n/* harmony export */ });\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _cropElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _linearElementEditor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _textElement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _textMeasurements__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @excalidraw/element/typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _frame__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils */ \"../element/src/utils.ts\");\n/* harmony import */ var _shape__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shape */ \"../element/src/shape.ts\");\n/* harmony import */ var _freedrawPath__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freedrawPath */ \"../element/src/freedrawPath.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst isPendingImageElement = (element, renderConfig) => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isInitializedImageElement)(element) && !renderConfig.imageCache.has(element.fileId);\n\nconst getCanvasPadding = element => {\n switch (element.type) {\n case \"freedraw\":\n return element.strokeWidth * 12;\n\n case \"text\":\n return element.fontSize / 2;\n\n case \"arrow\":\n if (element.endArrowhead || element.endArrowhead) {\n return 40;\n }\n\n return 20;\n\n default:\n return 20;\n }\n};\n\nconst getRenderOpacity = (element, containingFrame, elementsPendingErasure, pendingNodes, globalAlpha = 1) => {\n var _a; // multiplying frame opacity with element opacity to combine them\n // (e.g. frame 50% and element 50% opacity should result in 25% opacity)\n\n\n let opacity = ((_a = containingFrame === null || containingFrame === void 0 ? void 0 : containingFrame.opacity) !== null && _a !== void 0 ? _a : 100) * element.opacity / 10000 * globalAlpha; // if pending erasure, multiply again to combine further\n // (so that erasing always results in lower opacity than original)\n\n if (elementsPendingErasure.has(element.id) || pendingNodes && pendingNodes.some(node => node.id === element.id) || containingFrame && elementsPendingErasure.has(containingFrame.id)) {\n opacity *= _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_READY_TO_ERASE_OPACITY / 100;\n }\n\n return opacity;\n};\n\nconst cappedElementCanvasSize = (element, elementsMap, zoom) => {\n // these limits are ballpark, they depend on specific browsers and device.\n // We've chosen lower limits to be safe. We might want to change these limits\n // based on browser/device type, if we get reports of low quality rendering\n // on zoom.\n //\n // ~ safari mobile canvas area limit\n const AREA_LIMIT = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getAreaLimit)(); //zsviczian\n // ~ safari width/height limit based on developer.mozilla.org.\n\n const WIDTH_HEIGHT_LIMIT = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getWidthHeightLimit)(); //zsviczian\n\n const padding = getCanvasPadding(element);\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n const elementWidth = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isLinearElement)(element) || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isFreeDrawElement)(element) ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(x1, x2) : element.width;\n const elementHeight = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isLinearElement)(element) || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isFreeDrawElement)(element) ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(y1, y2) : element.height;\n let width = elementWidth * window.devicePixelRatio + padding * 2;\n let height = elementHeight * window.devicePixelRatio + padding * 2;\n let scale = zoom.value; // rescale to ensure width and height is within limits\n\n if (width * scale > WIDTH_HEIGHT_LIMIT || height * scale > WIDTH_HEIGHT_LIMIT) {\n scale = Math.min(WIDTH_HEIGHT_LIMIT / width, WIDTH_HEIGHT_LIMIT / height);\n } // rescale to ensure canvas area is within limits\n\n\n if (width * height * scale * scale > AREA_LIMIT) {\n scale = Math.sqrt(AREA_LIMIT / (width * height));\n }\n\n width = Math.floor(width * scale);\n height = Math.floor(height * scale);\n return {\n width,\n height,\n scale\n };\n};\n\nconst generateElementCanvas = (element, elementsMap, zoom, renderConfig, appState) => {\n var _a, _b;\n\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n const padding = getCanvasPadding(element);\n const {\n width,\n height,\n scale\n } = cappedElementCanvasSize(element, elementsMap, zoom);\n\n if (!width || !height) {\n return null;\n }\n\n canvas.width = width;\n canvas.height = height;\n let canvasOffsetX = -100;\n let canvasOffsetY = 0;\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isLinearElement)(element) || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isFreeDrawElement)(element)) {\n const [x1, y1] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n canvasOffsetX = element.x > x1 ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(element.x, x1) * window.devicePixelRatio * scale : 0;\n canvasOffsetY = element.y > y1 ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(element.y, y1) * window.devicePixelRatio * scale : 0;\n context.translate(canvasOffsetX, canvasOffsetY);\n }\n\n context.save();\n context.translate(padding * scale, padding * scale);\n context.scale(window.devicePixelRatio * scale, window.devicePixelRatio * scale);\n const rc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].canvas(canvas);\n drawElementOnCanvas(element, rc, context, renderConfig);\n context.restore();\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap);\n const boundTextCanvas = document.createElement(\"canvas\");\n const boundTextCanvasContext = boundTextCanvas.getContext(\"2d\");\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement) {\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap); // Take max dimensions of arrow canvas so that when canvas is rotated\n // the arrow doesn't get clipped\n\n const maxDim = Math.max((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(x1, x2), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(y1, y2));\n boundTextCanvas.width = maxDim * window.devicePixelRatio * scale + padding * scale * 10;\n boundTextCanvas.height = maxDim * window.devicePixelRatio * scale + padding * scale * 10;\n boundTextCanvasContext.translate(boundTextCanvas.width / 2, boundTextCanvas.height / 2);\n boundTextCanvasContext.rotate(element.angle);\n boundTextCanvasContext.drawImage(canvas, -canvas.width / 2, -canvas.height / 2, canvas.width, canvas.height);\n const [,,,, boundTextCx, boundTextCy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(boundTextElement, elementsMap);\n boundTextCanvasContext.rotate(-element.angle);\n const offsetX = (boundTextCanvas.width - canvas.width) / 2;\n const offsetY = (boundTextCanvas.height - canvas.height) / 2;\n const shiftX = boundTextCanvas.width / 2 - (boundTextCx - x1) * window.devicePixelRatio * scale - offsetX - padding * scale;\n const shiftY = boundTextCanvas.height / 2 - (boundTextCy - y1) * window.devicePixelRatio * scale - offsetY - padding * scale;\n boundTextCanvasContext.translate(-shiftX, -shiftY); // Clear the bound text area\n\n boundTextCanvasContext.clearRect(-(boundTextElement.width / 2 + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING) * window.devicePixelRatio * scale, -(boundTextElement.height / 2 + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING) * window.devicePixelRatio * scale, (boundTextElement.width + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING * 2) * window.devicePixelRatio * scale, (boundTextElement.height + _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.BOUND_TEXT_PADDING * 2) * window.devicePixelRatio * scale);\n }\n\n return {\n element,\n canvas,\n theme: appState.theme,\n scale,\n zoomValue: zoom.value,\n canvasOffsetX,\n canvasOffsetY,\n boundTextElementVersion: ((_a = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap)) === null || _a === void 0 ? void 0 : _a.version) || null,\n containingFrameOpacity: ((_b = (0,_frame__WEBPACK_IMPORTED_MODULE_9__.getContainingFrame)(element, elementsMap)) === null || _b === void 0 ? void 0 : _b.opacity) || 100,\n boundTextCanvas,\n angle: element.angle,\n imageCrop: (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isImageElement)(element) ? element.crop : null\n };\n};\n\nconst DEFAULT_LINK_SIZE = 14;\nconst IMAGE_PLACEHOLDER_IMG = typeof document !== \"undefined\" ? document.createElement(\"img\") : {\n src: \"\"\n}; // mock image element outside of browser\n\nIMAGE_PLACEHOLDER_IMG.src = `data:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.MIME_TYPES.svg},${encodeURIComponent(`<svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"fas\" data-icon=\"image\" class=\"svg-inline--fa fa-image fa-w-16\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"#888\" d=\"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z\"></path></svg>`)}`;\nconst IMAGE_ERROR_PLACEHOLDER_IMG = typeof document !== \"undefined\" ? document.createElement(\"img\") : {\n src: \"\"\n}; // mock image element outside of browser\n\nIMAGE_ERROR_PLACEHOLDER_IMG.src = `data:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.MIME_TYPES.svg},${encodeURIComponent(`<svg viewBox=\"0 0 668 668\" xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2\"><path d=\"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z\" style=\"fill:#888;fill-rule:nonzero\" transform=\"matrix(.81709 0 0 .81709 124.825 145.825)\"/><path d=\"M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z\" style=\"fill:#888;fill-rule:nonzero\" transform=\"matrix(.30366 0 0 .30366 506.822 60.065)\"/></svg>`)}`;\n\nconst drawImagePlaceholder = (element, context, theme) => {\n context.fillStyle = theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK ? \"#2E2E2E\" : \"#E7E7E7\";\n context.fillRect(0, 0, element.width, element.height);\n const imageMinWidthOrHeight = Math.min(element.width, element.height);\n const size = Math.min(imageMinWidthOrHeight, Math.min(imageMinWidthOrHeight * 0.4, 100));\n context.drawImage(element.status === \"error\" ? IMAGE_ERROR_PLACEHOLDER_IMG : IMAGE_PLACEHOLDER_IMG, element.width / 2 - size / 2, element.height / 2 - size / 2, size, size);\n};\n\nconst drawElementOnCanvas = (element, rc, context, renderConfig) => {\n var _a, _b, _c, _d, _e;\n\n switch (element.type) {\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n case \"diamond\":\n case \"ellipse\":\n {\n context.lineJoin = \"round\";\n context.lineCap = \"round\";\n rc.draw(_shape__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.generateElementShape(element, renderConfig));\n break;\n }\n\n case \"arrow\":\n case \"line\":\n {\n context.lineJoin = \"round\";\n context.lineCap = \"round\";\n _shape__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.generateElementShape(element, renderConfig).forEach(shape => {\n rc.draw(shape);\n });\n break;\n }\n\n case \"freedraw\":\n {\n // Draw directly to canvas\n context.save();\n const shapes = _shape__WEBPACK_IMPORTED_MODULE_11__.ShapeCache.generateElementShape(element, renderConfig);\n\n for (const shape of shapes) {\n if (typeof shape === \"string\") {\n const {\n path,\n fillStyle\n } = (() => {\n var _a, _b, _c, _d, _e;\n\n const path = new Path2D((0,_freedrawPath__WEBPACK_IMPORTED_MODULE_12__.getFreeDrawSvgPath)(element));\n const hasOutline = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.strokeOptions) === null || _b === void 0 ? void 0 : _b.hasOutline;\n const outlineWidth = (_e = (_d = (_c = element.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.outlineWidth) !== null && _e !== void 0 ? _e : 1;\n const fillColor = hasOutline ? element.backgroundColor : element.strokeColor;\n const fillStyle = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(fillColor, renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK);\n\n if (hasOutline) {\n context.lineWidth = element.strokeWidth * outlineWidth;\n context.strokeStyle = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(element.strokeColor, renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK);\n context.stroke(path);\n }\n\n return {\n path,\n fillStyle\n };\n })();\n\n context.fillStyle = fillStyle; //zsviczian\n\n context.fill(path); //zsviczian\n\n /*\n context.fillStyle = applyDarkModeFilter(\n element.strokeColor,\n renderConfig.theme === THEME.DARK,\n );\n context.fill(new Path2D(shape));\n */\n //zsviczian\n } else {\n rc.draw(shape);\n }\n }\n\n context.restore();\n break;\n }\n\n case \"image\":\n {\n context.save();\n const cacheEntry = element.fileId !== null ? renderConfig.imageCache.get(element.fileId) : null;\n const img = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isInitializedImageElement)(element) ? cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.image : undefined;\n\n if (img != null && !(img instanceof Promise)) {\n if (element.roundness && context.roundRect) {\n context.beginPath();\n context.roundRect(0, 0, element.width, element.height, (0,_utils__WEBPACK_IMPORTED_MODULE_10__.getCornerRadius)(Math.min(element.width, element.height), element));\n context.clip();\n }\n\n const {\n x,\n y,\n width,\n height\n } = element.crop ? element.crop : {\n x: 0,\n y: 0,\n width: img.naturalWidth,\n height: img.naturalHeight\n };\n const shouldInvertImage = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK && ((cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.mimeType) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.MIME_TYPES.svg && !((_a = element.customData) === null || _a === void 0 ? void 0 : _a.doNotInvertSVGInDarkMode) || !!((_b = element.customData) === null || _b === void 0 ? void 0 : _b.pdfPageViewProps) && ((_d = (_c = element.customData) === null || _c === void 0 ? void 0 : _c.invertBitmapInDarkmode) !== null && _d !== void 0 ? _d : true) || !!((_e = element.customData) === null || _e === void 0 ? void 0 : _e.invertBitmapInDarkmode)); //zsviczian\n\n if (shouldInvertImage && _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isIOS) {\n const devicePixelRatio = window.devicePixelRatio || 1;\n const tempCanvas = document.createElement(\"canvas\");\n tempCanvas.width = element.width * devicePixelRatio;\n tempCanvas.height = element.height * devicePixelRatio;\n const tempContext = tempCanvas.getContext(\"2d\");\n\n if (tempContext) {\n tempContext.scale(devicePixelRatio, devicePixelRatio);\n tempContext.drawImage(img, x, y, width, height, 0, 0, element.width, element.height);\n const imageData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);\n const data = imageData.data;\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n }\n\n tempContext.putImageData(imageData, 0, 0);\n context.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, 0, 0, element.width, element.height);\n }\n } else {\n if (shouldInvertImage) {\n context.filter = _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DARK_THEME_FILTER;\n }\n\n context.drawImage(img, x, y, width, height, 0\n /* hardcoded for the selection box*/\n , 0, element.width, element.height);\n }\n } else {\n drawImagePlaceholder(element, context, renderConfig.theme);\n }\n\n context.restore();\n break;\n }\n\n default:\n {\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isTextElement)(element)) {\n const rtl = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isRTL)(element.text);\n const shouldTemporarilyAttach = rtl && !context.canvas.isConnected;\n\n if (shouldTemporarilyAttach) {\n // to correctly render RTL text mixed with LTR, we have to append it\n // to the DOM\n document.body.appendChild(context.canvas);\n }\n\n context.canvas.setAttribute(\"dir\", rtl ? \"rtl\" : \"ltr\");\n context.save();\n context.font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getFontString)(element);\n context.fillStyle = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(element.strokeColor, renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK);\n context.textAlign = element.textAlign; // Canvas does not support multiline text by default\n\n const lines = element.text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const horizontalOffset = element.textAlign === \"center\" ? element.width / 2 : element.textAlign === \"right\" ? element.width : 0;\n const lineHeightPx = (0,_textMeasurements__WEBPACK_IMPORTED_MODULE_7__.getLineHeightInPx)(element.fontSize, element.lineHeight);\n const verticalOffset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.getVerticalOffset)(element.fontFamily, element.fontSize, lineHeightPx);\n\n for (let index = 0; index < lines.length; index++) {\n context.fillText(lines[index], horizontalOffset, index * lineHeightPx + verticalOffset);\n }\n\n context.restore();\n\n if (shouldTemporarilyAttach) {\n context.canvas.remove();\n }\n } else {\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n }\n};\n\nconst elementWithCanvasCache = new WeakMap();\n\nconst generateElementWithCanvas = (element, elementsMap, renderConfig, appState) => {\n var _a;\n\n const zoom = renderConfig ? appState.zoom : {\n value: 1\n };\n const prevElementWithCanvas = elementWithCanvasCache.get(element);\n const shouldRegenerateBecauseZoom = prevElementWithCanvas && prevElementWithCanvas.zoomValue !== zoom.value && !(appState === null || appState === void 0 ? void 0 : appState.shouldCacheIgnoreZoom);\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap);\n const boundTextElementVersion = (boundTextElement === null || boundTextElement === void 0 ? void 0 : boundTextElement.version) || null;\n const imageCrop = (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isImageElement)(element) ? element.crop : null;\n const containingFrameOpacity = ((_a = (0,_frame__WEBPACK_IMPORTED_MODULE_9__.getContainingFrame)(element, elementsMap)) === null || _a === void 0 ? void 0 : _a.opacity) || 100;\n\n if (!prevElementWithCanvas || shouldRegenerateBecauseZoom || prevElementWithCanvas.theme !== appState.theme || prevElementWithCanvas.boundTextElementVersion !== boundTextElementVersion || prevElementWithCanvas.imageCrop !== imageCrop || prevElementWithCanvas.containingFrameOpacity !== containingFrameOpacity || // since we rotate the canvas when copying from cached canvas, we don't\n // regenerate the cached canvas. But we need to in case of labels which are\n // cached alongside the arrow, and we want the labels to remain unrotated\n // with respect to the arrow.\n (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement && element.angle !== prevElementWithCanvas.angle) {\n const elementWithCanvas = generateElementCanvas(element, elementsMap, zoom, renderConfig, appState);\n\n if (!elementWithCanvas) {\n return null;\n }\n\n elementWithCanvasCache.set(element, elementWithCanvas);\n return elementWithCanvas;\n }\n\n return prevElementWithCanvas;\n};\n\nconst drawElementFromCanvas = (elementWithCanvas, context, renderConfig, appState, allElementsMap) => {\n const element = elementWithCanvas.element;\n const padding = getCanvasPadding(element);\n const zoom = elementWithCanvas.scale;\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, allElementsMap);\n const cx = ((x1 + x2) / 2 + appState.scrollX) * window.devicePixelRatio;\n const cy = ((y1 + y2) / 2 + appState.scrollY) * window.devicePixelRatio;\n context.save();\n context.scale(1 / window.devicePixelRatio, 1 / window.devicePixelRatio);\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, allElementsMap);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement) {\n const offsetX = (elementWithCanvas.boundTextCanvas.width - elementWithCanvas.canvas.width) / 2;\n const offsetY = (elementWithCanvas.boundTextCanvas.height - elementWithCanvas.canvas.height) / 2;\n context.translate(cx, cy);\n context.drawImage(elementWithCanvas.boundTextCanvas, -(x2 - x1) / 2 * window.devicePixelRatio - offsetX / zoom - padding, -(y2 - y1) / 2 * window.devicePixelRatio - offsetY / zoom - padding, elementWithCanvas.boundTextCanvas.width / zoom, elementWithCanvas.boundTextCanvas.height / zoom);\n } else {\n // we translate context to element center so that rotation and scale\n // originates from the element center\n context.translate(cx, cy);\n context.rotate(element.angle);\n\n if (\"scale\" in elementWithCanvas.element && !isPendingImageElement(element, renderConfig) && !(0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isIframeLikeElement)(element) //zsviczian\n ) {\n context.scale(elementWithCanvas.element.scale[0], elementWithCanvas.element.scale[1]);\n } // revert afterwards we don't have account for it during drawing\n\n\n context.translate(-cx, -cy);\n context.drawImage(elementWithCanvas.canvas, (x1 + appState.scrollX) * window.devicePixelRatio - padding * elementWithCanvas.scale / elementWithCanvas.scale, (y1 + appState.scrollY) * window.devicePixelRatio - padding * elementWithCanvas.scale / elementWithCanvas.scale, elementWithCanvas.canvas.width / elementWithCanvas.scale, elementWithCanvas.canvas.height / elementWithCanvas.scale);\n\n if (false) {}\n }\n\n context.restore(); // Clear the nested element we appended to the DOM\n};\n\nconst renderSelectionElement = (element, context, appState, selectionColor) => {\n context.save();\n context.translate(element.x + appState.scrollX, element.y + appState.scrollY);\n context.fillStyle = \"rgba(0, 0, 200, 0.04)\"; // render from 0.5px offset to get 1px wide line\n // https://stackoverflow.com/questions/7530593/html5-canvas-and-line-width/7531540#7531540\n // TODO can be be improved by offseting to the negative when user selects\n // from right to left\n\n const offset = 0.5 / appState.zoom.value;\n context.fillRect(offset, offset, element.width, element.height);\n context.lineWidth = 1.5 / appState.zoom.value; //zsviczian changed from 1 to 1.5\n\n context.strokeStyle = selectionColor;\n context.strokeRect(offset, offset, element.width, element.height);\n context.restore();\n};\nconst renderElement = (element, elementsMap, allElementsMap, rc, context, renderConfig, appState) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n const reduceAlphaForSelection = ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\" && !appState.selectedElementIds[element.id] && !appState.hoveredElementIds[element.id];\n context.globalAlpha = getRenderOpacity(element, (0,_frame__WEBPACK_IMPORTED_MODULE_9__.getContainingFrame)(element, elementsMap), renderConfig.elementsPendingErasure, renderConfig.pendingFlowchartNodes, reduceAlphaForSelection ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1);\n\n switch (element.type) {\n case \"magicframe\":\n case \"frame\":\n {\n if ( //zsviczian\n appState.frameRendering.enabled && appState.frameRendering.outline && !(!appState.frameRendering.markerEnabled && element.frameRole === \"marker\")) {\n context.save();\n context.translate(element.x + appState.scrollX, element.y + appState.scrollY);\n context.fillStyle = (_f = (_d = (_c = (_b = element.customData) === null || _b === void 0 ? void 0 : _b.frameColor) === null || _c === void 0 ? void 0 : _c.fill) !== null && _d !== void 0 ? _d : (_e = appState === null || appState === void 0 ? void 0 : appState.frameColor) === null || _e === void 0 ? void 0 : _e.fill) !== null && _f !== void 0 ? _f : \"rgba(0, 0, 200, 0.04)\"; //zsviczian\n\n context.lineWidth = _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.strokeWidth / appState.zoom.value;\n context.strokeStyle = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)((_l = (_j = (_h = (_g = element.customData) === null || _g === void 0 ? void 0 : _g.frameColor) === null || _h === void 0 ? void 0 : _h.stroke) !== null && _j !== void 0 ? _j : (_k = appState === null || appState === void 0 ? void 0 : appState.frameColor) === null || _k === void 0 ? void 0 : _k.stroke) !== null && _l !== void 0 ? _l : _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.strokeColor, //zsviczian\n appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.DARK); // TODO change later to only affect AI frames\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isMagicFrameElement)(element)) {\n context.strokeStyle = appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.THEME.LIGHT ? \"#7affd7\" : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.applyDarkModeFilter)(\"#1d8264\");\n } //zsviczian\n\n\n if (element.frameRole === \"marker\") {\n const dash = 8 / appState.zoom.value;\n const gap = 6 / appState.zoom.value;\n context.setLineDash([dash, gap]);\n }\n\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.radius && context.roundRect && element.frameRole !== \"marker\") {\n //zsviczian\n context.beginPath();\n context.roundRect(0, 0, element.width, element.height, _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.FRAME_STYLE.radius / appState.zoom.value);\n context.stroke();\n context.closePath();\n } else {\n context.strokeRect(0, 0, element.width, element.height);\n }\n\n context.restore();\n }\n\n break;\n }\n\n case \"freedraw\":\n {\n if (renderConfig.isExporting) {\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n const cx = (x1 + x2) / 2 + appState.scrollX;\n const cy = (y1 + y2) / 2 + appState.scrollY;\n const shiftX = (x2 - x1) / 2 - (element.x - x1);\n const shiftY = (y2 - y1) / 2 - (element.y - y1);\n context.save();\n context.translate(cx, cy);\n context.rotate(element.angle);\n context.translate(-shiftX, -shiftY);\n drawElementOnCanvas(element, rc, context, renderConfig);\n context.restore();\n } else {\n const elementWithCanvas = generateElementWithCanvas(element, allElementsMap, renderConfig, appState);\n\n if (!elementWithCanvas) {\n return;\n }\n\n drawElementFromCanvas(elementWithCanvas, context, renderConfig, appState, allElementsMap);\n }\n\n break;\n }\n\n case \"rectangle\":\n case \"diamond\":\n case \"ellipse\":\n case \"line\":\n case \"arrow\":\n case \"image\":\n case \"text\":\n case \"iframe\":\n case \"embeddable\":\n {\n if (renderConfig.isExporting) {\n const [x1, y1, x2, y2] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(element, elementsMap);\n const cx = (x1 + x2) / 2 + appState.scrollX;\n const cy = (y1 + y2) / 2 + appState.scrollY;\n let shiftX = (x2 - x1) / 2 - (element.x - x1);\n let shiftY = (y2 - y1) / 2 - (element.y - y1);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isTextElement)(element)) {\n const container = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getContainerElement)(element, elementsMap);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(container)) {\n const boundTextCoords = _linearElementEditor__WEBPACK_IMPORTED_MODULE_5__.LinearElementEditor.getBoundTextElementPosition(container, element, elementsMap);\n shiftX = (x2 - x1) / 2 - (boundTextCoords.x - x1);\n shiftY = (y2 - y1) / 2 - (boundTextCoords.y - y1);\n }\n }\n\n context.save();\n context.translate(cx, cy);\n const boundTextElement = (0,_textElement__WEBPACK_IMPORTED_MODULE_6__.getBoundTextElement)(element, elementsMap);\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isArrowElement)(element) && boundTextElement) {\n const tempCanvas = document.createElement(\"canvas\");\n const tempCanvasContext = tempCanvas.getContext(\"2d\"); // Take max dimensions of arrow canvas so that when canvas is rotated\n // the arrow doesn't get clipped\n\n const maxDim = Math.max((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(x1, x2), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.distance)(y1, y2));\n const padding = getCanvasPadding(element);\n tempCanvas.width = maxDim * appState.exportScale + padding * 10 * appState.exportScale;\n tempCanvas.height = maxDim * appState.exportScale + padding * 10 * appState.exportScale;\n tempCanvasContext.translate(tempCanvas.width / 2, tempCanvas.height / 2);\n tempCanvasContext.scale(appState.exportScale, appState.exportScale); // Shift the canvas to left most point of the arrow\n\n shiftX = element.width / 2 - (element.x - x1);\n shiftY = element.height / 2 - (element.y - y1);\n tempCanvasContext.rotate(element.angle);\n const tempRc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].canvas(tempCanvas);\n tempCanvasContext.translate(-shiftX, -shiftY);\n drawElementOnCanvas(element, tempRc, tempCanvasContext, renderConfig);\n tempCanvasContext.translate(shiftX, shiftY);\n tempCanvasContext.rotate(-element.angle); // Shift the canvas to center of bound text\n\n const [,,,, boundTextCx, boundTextCy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementAbsoluteCoords)(boundTextElement, elementsMap);\n const boundTextShiftX = (x1 + x2) / 2 - boundTextCx;\n const boundTextShiftY = (y1 + y2) / 2 - boundTextCy;\n tempCanvasContext.translate(-boundTextShiftX, -boundTextShiftY); // Clear the bound text area\n\n tempCanvasContext.clearRect(-boundTextElement.width / 2, -boundTextElement.height / 2, boundTextElement.width, boundTextElement.height);\n context.scale(1 / appState.exportScale, 1 / appState.exportScale);\n context.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2, tempCanvas.width, tempCanvas.height);\n } else {\n context.rotate(element.angle);\n\n if (element.type === \"image\") {\n // note: scale must be applied *after* rotating\n context.scale(element.scale[0], element.scale[1]);\n }\n\n context.translate(-shiftX, -shiftY);\n drawElementOnCanvas(element, rc, context, renderConfig);\n }\n\n context.restore(); // not exporting → optimized rendering (cache & render from element\n // canvases)\n } else {\n const elementWithCanvas = generateElementWithCanvas(element, allElementsMap, renderConfig, appState);\n\n if (!elementWithCanvas) {\n return;\n }\n\n const currentImageSmoothingStatus = context.imageSmoothingEnabled;\n\n if ( // do not disable smoothing during zoom as blurry shapes look better\n // on low resolution (while still zooming in) than sharp ones\n !(appState === null || appState === void 0 ? void 0 : appState.shouldCacheIgnoreZoom) && ( // angle is 0 -> always disable smoothing\n !element.angle || // or check if angle is a right angle in which case we can still\n // disable smoothing without adversely affecting the result\n // We need less-than comparison because of FP artihmetic\n (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.isRightAngleRads)(element.angle))) {\n // Disabling smoothing makes output much sharper, especially for\n // text. Unless for non-right angles, where the aliasing is really\n // terrible on Chromium.\n //\n // Note that `context.imageSmoothingQuality=\"high\"` has almost\n // zero effect.\n //\n context.imageSmoothingEnabled = false;\n }\n\n if (element.id === appState.croppingElementId && (0,_typeChecks__WEBPACK_IMPORTED_MODULE_8__.isImageElement)(elementWithCanvas.element) && elementWithCanvas.element.crop !== null) {\n context.save();\n context.globalAlpha = 0.1;\n const uncroppedElementCanvas = generateElementCanvas((0,_cropElement__WEBPACK_IMPORTED_MODULE_4__.getUncroppedImageElement)(elementWithCanvas.element, elementsMap), allElementsMap, appState.zoom, renderConfig, appState);\n\n if (uncroppedElementCanvas) {\n drawElementFromCanvas(uncroppedElementCanvas, context, renderConfig, appState, allElementsMap);\n }\n\n context.restore();\n }\n\n drawElementFromCanvas(elementWithCanvas, context, renderConfig, appState, allElementsMap); // reset\n\n context.imageSmoothingEnabled = currentImageSmoothingStatus;\n }\n\n break;\n }\n\n default:\n {\n // @ts-ignore\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n\n context.globalAlpha = 1;\n};\nfunction getFreedrawOutlineAsSegments(element, points, elementsMap) {\n const bounds = (0,_bounds__WEBPACK_IMPORTED_MODULE_3__.getElementBounds)(Object.assign(Object.assign({}, element), {\n angle: 0\n }), elementsMap);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)((bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2);\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.invariant)(points.length >= 2, \"Freepath outline must have at least 2 points\");\n return points.slice(2).reduce((acc, curr) => {\n acc.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)(acc[acc.length - 1][1], (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(curr[0] + element.x, curr[1] + element.y), center, element.angle)));\n return acc;\n }, [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.lineSegment)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(points[0][0] + element.x, points[0][1] + element.y), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(points[1][0] + element.x, points[1][1] + element.y), center, element.angle))]);\n}\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/renderElement.ts?");
14801
14801
 
14802
14802
  /***/ }),
14803
14803
 
@@ -14841,7 +14841,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
14841
14841
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14842
14842
 
14843
14843
  "use strict";
14844
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ShapeCache: () => (/* binding */ ShapeCache),\n/* harmony export */ generateLinearCollisionShape: () => (/* binding */ generateLinearCollisionShape),\n/* harmony export */ generateRoughOptions: () => (/* binding */ generateRoughOptions),\n/* harmony export */ getElementShape: () => (/* binding */ getElementShape),\n/* harmony export */ getFreedrawOutlinePoints: () => (/* binding */ getFreedrawOutlinePoints),\n/* harmony export */ toggleLinePolygonState: () => (/* binding */ toggleLinePolygonState)\n/* harmony export */ });\n/* harmony import */ var points_on_curve__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! points-on-curve */ \"../../node_modules/points-on-curve/lib/index.js\");\n/* harmony import */ var perfect_freehand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! perfect-freehand */ \"../../node_modules/perfect-freehand/dist/esm/index.js\");\n/* harmony import */ var _excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/utils/shape */ \"../utils/src/shape.ts\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var roughjs_bin_generator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! roughjs/bin/generator */ \"../../node_modules/roughjs/bin/generator.js\");\n/* harmony import */ var _renderElement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./renderElement */ \"../element/src/renderElement.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils */ \"../element/src/utils.ts\");\n/* harmony import */ var _heading__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./heading */ \"../element/src/heading.ts\");\n/* harmony import */ var _comparisons__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./comparisons */ \"../element/src/comparisons.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _collision__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./collision */ \"../element/src/collision.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nclass ShapeCache {}\nShapeCache.rg = new roughjs_bin_generator__WEBPACK_IMPORTED_MODULE_5__.RoughGenerator();\nShapeCache.cache = new WeakMap();\n/**\n * Retrieves shape from cache if available. Use this only if shape\n * is optional and you have a fallback in case it's not cached.\n */\n\nShapeCache.get = (element, theme) => {\n const cached = ShapeCache.cache.get(element);\n\n if (cached && (theme === null || cached.theme === theme)) {\n return cached.shape;\n }\n\n return undefined;\n};\n\nShapeCache.delete = element => {\n ShapeCache.cache.delete(element);\n _renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache.delete(element);\n};\n\nShapeCache.destroy = () => {\n ShapeCache.cache = new WeakMap();\n\n if (_renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache) {\n //zsviczian\n Object.values(_renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache).forEach(value => {\n _renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache.delete(value);\n });\n }\n};\n/**\n * Generates & caches shape for element if not already cached, otherwise\n * returns cached shape.\n */\n\n\nShapeCache.generateElementShape = (element, renderConfig) => {\n // when exporting, always regenerated to guarantee the latest shape\n const cachedShape = (renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.isExporting) ? undefined : ShapeCache.get(element, renderConfig ? renderConfig.theme : null); // `null` indicates no rc shape applicable for this element type,\n // but it's considered a valid cache value (= do not regenerate)\n\n if (cachedShape !== undefined) {\n return cachedShape;\n }\n\n _renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache.delete(element);\n\n const shape = _generateElementShape(element, ShapeCache.rg, renderConfig || {\n isExporting: false,\n canvasBackgroundColor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.COLOR_PALETTE.white,\n embedsValidationStatus: null,\n theme: _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.THEME.LIGHT\n });\n\n if (!(renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.isExporting)) {\n ShapeCache.cache.set(element, {\n shape,\n theme: (renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.theme) || _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.THEME.LIGHT\n });\n }\n\n return shape;\n};\n\nconst getDashArrayDashed = strokeWidth => [8, 8 + strokeWidth];\n\nconst getDashArrayDotted = strokeWidth => [1.5, 6 + strokeWidth];\n\nfunction adjustRoughness(element) {\n const roughness = element.roughness;\n const maxSize = Math.max(element.width, element.height);\n const minSize = Math.min(element.width, element.height); // don't reduce roughness if\n\n if ( // both sides relatively big\n minSize >= 20 && maxSize >= 50 || // is round & both sides above 15px\n minSize >= 15 && !!element.roundness && (0,_comparisons__WEBPACK_IMPORTED_MODULE_10__.canChangeRoundness)(element.type) || // relatively long linear element\n (0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element) && maxSize >= 50) {\n return roughness;\n }\n\n return Math.min(roughness / (maxSize < 10 ? 3 : 2), 2.5);\n}\n\nconst generateRoughOptions = (element, continuousPath = false, isDarkMode = false) => {\n const options = {\n seed: element.seed,\n strokeLineDash: element.strokeStyle === \"dashed\" ? getDashArrayDashed(element.strokeWidth) : element.strokeStyle === \"dotted\" ? getDashArrayDotted(element.strokeWidth) : undefined,\n // for non-solid strokes, disable multiStroke because it tends to make\n // dashes/dots overlay each other\n disableMultiStroke: element.strokeStyle !== \"solid\",\n // for non-solid strokes, increase the width a bit to make it visually\n // similar to solid strokes, because we're also disabling multiStroke\n strokeWidth: element.strokeStyle !== \"solid\" ? element.strokeWidth + 0.5 : element.strokeWidth,\n // when increasing strokeWidth, we must explicitly set fillWeight and\n // hachureGap because if not specified, roughjs uses strokeWidth to\n // calculate them (and we don't want the fills to be modified)\n fillWeight: element.strokeWidth / 2,\n hachureGap: element.strokeWidth * 4,\n roughness: adjustRoughness(element),\n stroke: isDarkMode ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor,\n preserveVertices: continuousPath || element.roughness < _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.ROUGHNESS.cartoonist\n };\n\n switch (element.type) {\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n case \"diamond\":\n case \"ellipse\":\n {\n options.fillStyle = element.fillStyle;\n options.fill = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.backgroundColor) ? undefined : isDarkMode ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.backgroundColor) : element.backgroundColor;\n\n if (element.type === \"ellipse\") {\n options.curveFitting = 1;\n }\n\n return options;\n }\n\n case \"line\":\n case \"freedraw\":\n {\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_8__.isPathALoop)(element.points)) {\n options.fillStyle = element.fillStyle;\n options.fill = element.backgroundColor === \"transparent\" ? undefined : isDarkMode ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.backgroundColor) : element.backgroundColor;\n }\n\n return options;\n }\n\n case \"arrow\":\n return options;\n\n default:\n {\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n};\n\nconst modifyIframeLikeForRoughOptions = (element, isExporting, embedsValidationStatus) => {\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(element) && (isExporting || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(element) && (embedsValidationStatus === null || embedsValidationStatus === void 0 ? void 0 : embedsValidationStatus.get(element.id)) !== true) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.backgroundColor) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.strokeColor)) {\n return Object.assign(Object.assign({}, element), {\n roughness: 0,\n backgroundColor: \"#d3d3d3\",\n fillStyle: \"solid\"\n });\n } else if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(element)) {\n return Object.assign(Object.assign({}, element), {\n strokeColor: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.strokeColor) ? \"#000000\" : element.strokeColor,\n backgroundColor: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.backgroundColor) ? \"#f4f4f6\" : element.backgroundColor\n });\n }\n\n return element;\n};\n\nconst generateArrowheadCardinalityOne = (generator, arrowheadPoints, lineOptions) => {\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [,, x3, y3, x4, y4] = arrowheadPoints;\n return [generator.line(x3, y3, x4, y4, lineOptions)];\n};\n\nconst generateArrowheadLinesToTip = (generator, arrowheadPoints, lineOptions) => {\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x2, y2, x3, y3, x4, y4] = arrowheadPoints;\n return [generator.line(x3, y3, x2, y2, lineOptions), generator.line(x4, y4, x2, y2, lineOptions)];\n};\n\nconst getArrowheadLineOptions = (element, options) => {\n const lineOptions = Object.assign({}, options);\n\n if (element.strokeStyle === \"dotted\") {\n // for dotted arrows caps, reduce gap to make it more legible\n const dash = getDashArrayDotted(element.strokeWidth - 1);\n lineOptions.strokeLineDash = [dash[0], dash[1] - 1];\n } else {\n // for solid/dashed, keep solid arrow cap\n delete lineOptions.strokeLineDash;\n }\n\n lineOptions.roughness = Math.min(1, lineOptions.roughness || 0);\n return lineOptions;\n};\n\nconst generateArrowheadOutlineCircle = (generator, options, strokeColor, arrowheadPoints, fill, diameterScale = 1) => {\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x, y, diameter] = arrowheadPoints;\n const circleOptions = Object.assign(Object.assign({}, options), {\n fill,\n fillStyle: \"solid\",\n stroke: strokeColor,\n roughness: Math.min(0.5, options.roughness || 0)\n });\n delete circleOptions.strokeLineDash;\n return [generator.circle(x, y, diameter * diameterScale, circleOptions)];\n};\n\nconst getArrowheadShapes = (element, shape, position, arrowhead, generator, options, canvasBackgroundColor, isDarkMode) => {\n if (arrowhead === null) {\n return [];\n }\n\n const strokeColor = isDarkMode ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor;\n const backgroundFillColor = isDarkMode ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(canvasBackgroundColor) : canvasBackgroundColor;\n const cardinalityOneOrManyOffset = -0.25;\n const cardinalityZeroCircleScale = 0.8;\n\n switch (arrowhead) {\n case \"circle\":\n case \"circle_outline\":\n {\n return generateArrowheadOutlineCircle(generator, options, strokeColor, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), arrowhead === \"circle_outline\" ? backgroundFillColor : strokeColor);\n }\n\n case \"triangle\":\n case \"triangle_outline\":\n {\n const arrowheadPoints = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead);\n\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x, y, x2, y2, x3, y3] = arrowheadPoints;\n const triangleOptions = Object.assign(Object.assign({}, options), {\n fill: arrowhead === \"triangle_outline\" ? backgroundFillColor : strokeColor,\n fillStyle: \"solid\",\n roughness: Math.min(1, options.roughness || 0)\n }); // always use solid stroke for arrowhead\n\n delete triangleOptions.strokeLineDash;\n return [generator.polygon([[x, y], [x2, y2], [x3, y3], [x, y]], triangleOptions)];\n }\n\n case \"diamond\":\n case \"diamond_outline\":\n {\n const arrowheadPoints = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead);\n\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x, y, x2, y2, x3, y3, x4, y4] = arrowheadPoints;\n const diamondOptions = Object.assign(Object.assign({}, options), {\n fill: arrowhead === \"diamond_outline\" ? backgroundFillColor : strokeColor,\n fillStyle: \"solid\",\n roughness: Math.min(1, options.roughness || 0)\n }); // always use solid stroke for arrowhead\n\n delete diamondOptions.strokeLineDash;\n return [generator.polygon([[x, y], [x2, y2], [x3, y3], [x4, y4], [x, y]], diamondOptions)];\n }\n\n case \"cardinality_one\":\n return generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), getArrowheadLineOptions(element, options));\n\n case \"cardinality_many\":\n return generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), getArrowheadLineOptions(element, options));\n\n case \"cardinality_one_or_many\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_many\"), lineOptions), ...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\", cardinalityOneOrManyOffset), lineOptions)];\n }\n\n case \"cardinality_exactly_one\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\", -0.5), lineOptions), ...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\"), lineOptions)];\n }\n\n case \"cardinality_zero_or_one\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadOutlineCircle(generator, options, strokeColor, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"circle_outline\", 1.5), backgroundFillColor, cardinalityZeroCircleScale), ...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\", -0.5), lineOptions)];\n }\n\n case \"cardinality_zero_or_many\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_many\"), lineOptions), ...generateArrowheadOutlineCircle(generator, options, strokeColor, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"circle_outline\", 1.5), backgroundFillColor, cardinalityZeroCircleScale)];\n }\n\n case \"bar\":\n case \"arrow\":\n default:\n {\n return generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), getArrowheadLineOptions(element, options));\n }\n }\n};\n\nconst generateLinearCollisionShape = (element, elementsMap) => {\n const generator = new roughjs_bin_generator__WEBPACK_IMPORTED_MODULE_5__.RoughGenerator();\n const options = {\n seed: element.seed,\n disableMultiStroke: true,\n disableMultiStrokeFill: true,\n roughness: 0,\n preserveVertices: true\n };\n const center = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.elementCenterPoint)(element, elementsMap);\n\n switch (element.type) {\n case \"line\":\n case \"arrow\":\n {\n // points array can be empty in the beginning, so it is important to add\n // initial position to it\n const points = element.points.length ? element.points : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(0, 0)];\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element)) {\n return generator.path(generateElbowArrowShape(points, 16), options).sets[0].ops;\n } else if (!element.roundness) {\n return points.map((point, idx) => {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + point[0], element.y + point[1]), center, element.angle);\n return {\n op: idx === 0 ? \"move\" : \"lineTo\",\n data: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)\n };\n });\n }\n\n return generator.curve(points, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {\n if (i === 0) {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle);\n return {\n op: \"move\",\n data: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)\n };\n }\n\n return {\n op: \"bcurveTo\",\n data: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[2], element.y + op.data[3]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[4], element.y + op.data[5]), center, element.angle)].map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)).flat()\n };\n });\n }\n\n case \"freedraw\":\n {\n if (element.points.length < 2) {\n return [];\n }\n\n const simplifiedPoints = (0,points_on_curve__WEBPACK_IMPORTED_MODULE_0__.simplify)(element.points, 0.75);\n return generator.curve(simplifiedPoints, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {\n if (i === 0) {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle);\n return {\n op: \"move\",\n data: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)\n };\n }\n\n return {\n op: \"bcurveTo\",\n data: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[2], element.y + op.data[3]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[4], element.y + op.data[5]), center, element.angle)].map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)).flat()\n };\n });\n }\n }\n};\n/**\n * Generates the roughjs shape for given element.\n *\n * Low-level. Use `ShapeCache.generateElementShape` instead.\n *\n * @private\n */\n\nconst _generateElementShape = (element, generator, {\n isExporting,\n canvasBackgroundColor,\n embedsValidationStatus,\n theme\n}) => {\n const isDarkMode = theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.THEME.DARK;\n\n switch (element.type) {\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n {\n let shape; // this is for rendering the stroke/bg of the embeddable, especially\n // when the src url is not set\n\n if (element.roundness) {\n const w = element.width;\n const h = element.height;\n const r = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.getCornerRadius)(Math.min(w, h), element);\n shape = generator.path(`M ${r} 0 L ${w - r} 0 Q ${w} 0, ${w} ${r} L ${w} ${h - r} Q ${w} ${h}, ${w - r} ${h} L ${r} ${h} Q 0 ${h}, 0 ${h - r} L 0 ${r} Q 0 0, ${r} 0`, generateRoughOptions(modifyIframeLikeForRoughOptions(element, isExporting, embedsValidationStatus), true, isDarkMode));\n } else {\n shape = generator.rectangle(0, 0, element.width, element.height, generateRoughOptions(modifyIframeLikeForRoughOptions(element, isExporting, embedsValidationStatus), false, isDarkMode));\n }\n\n return shape;\n }\n\n case \"diamond\":\n {\n let shape;\n const [topX, topY, rightX, rightY, bottomX, bottomY, leftX, leftY] = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getDiamondPoints)(element);\n\n if (element.roundness) {\n const verticalRadius = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.getCornerRadius)(Math.abs(topX - leftX), element);\n const horizontalRadius = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.getCornerRadius)(Math.abs(rightY - topY), element);\n shape = generator.path(`M ${topX + verticalRadius} ${topY + horizontalRadius} L ${rightX - verticalRadius} ${rightY - horizontalRadius}\n C ${rightX} ${rightY}, ${rightX} ${rightY}, ${rightX - verticalRadius} ${rightY + horizontalRadius}\n L ${bottomX + verticalRadius} ${bottomY - horizontalRadius}\n C ${bottomX} ${bottomY}, ${bottomX} ${bottomY}, ${bottomX - verticalRadius} ${bottomY - horizontalRadius}\n L ${leftX + verticalRadius} ${leftY + horizontalRadius}\n C ${leftX} ${leftY}, ${leftX} ${leftY}, ${leftX + verticalRadius} ${leftY - horizontalRadius}\n L ${topX - verticalRadius} ${topY + horizontalRadius}\n C ${topX} ${topY}, ${topX} ${topY}, ${topX + verticalRadius} ${topY + horizontalRadius}`, generateRoughOptions(element, true, isDarkMode));\n } else {\n shape = generator.polygon([[topX, topY], [rightX, rightY], [bottomX, bottomY], [leftX, leftY]], generateRoughOptions(element, false, isDarkMode));\n }\n\n return shape;\n }\n\n case \"ellipse\":\n {\n const shape = generator.ellipse(element.width / 2, element.height / 2, element.width, element.height, generateRoughOptions(element, false, isDarkMode));\n return shape;\n }\n\n case \"line\":\n case \"arrow\":\n {\n let shape;\n const options = generateRoughOptions(element, false, isDarkMode); // points array can be empty in the beginning, so it is important to add\n // initial position to it\n\n const points = element.points.length ? element.points : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(0, 0)];\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element)) {\n // NOTE (mtolmacs): Temporary fix for extremely big arrow shapes\n if (!points.every(point => Math.abs(point[0]) <= 1e6 && Math.abs(point[1]) <= 1e6)) {\n console.error(`Elbow arrow with extreme point positions detected. Arrow not rendered.`, element.id, JSON.stringify(points));\n shape = [];\n } else {\n shape = [generator.path(generateElbowArrowShape(points, 16), generateRoughOptions(element, true, isDarkMode))];\n }\n } else if (!element.roundness) {\n // curve is always the first element\n // this simplifies finding the curve for an element\n if (options.fill) {\n shape = [generator.polygon(points, options)];\n } else {\n shape = [generator.linearPath(points, options)];\n }\n } else {\n shape = [generator.curve(points, options)];\n } // add lines only in arrow\n\n\n if (element.type === \"arrow\") {\n const {\n startArrowhead = null,\n endArrowhead = \"arrow\"\n } = element;\n\n if (startArrowhead !== null) {\n const shapes = getArrowheadShapes(element, shape, \"start\", startArrowhead, generator, options, canvasBackgroundColor, isDarkMode);\n shape.push(...shapes);\n }\n\n if (endArrowhead !== null) {\n if (endArrowhead === undefined) {// Hey, we have an old arrow here!\n }\n\n const shapes = getArrowheadShapes(element, shape, \"end\", endArrowhead, generator, options, canvasBackgroundColor, isDarkMode);\n shape.push(...shapes);\n }\n }\n\n return shape;\n }\n\n case \"freedraw\":\n {\n // oredered in terms of z-index [background, stroke]\n const shapes = []; // (1) background fill (rc shape), optional\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_8__.isPathALoop)(element.points)) {\n // generate rough polygon to fill freedraw shape\n const simplifiedPoints = (0,points_on_curve__WEBPACK_IMPORTED_MODULE_0__.simplify)(element.points, 0.75);\n shapes.push(generator.curve(simplifiedPoints, Object.assign(Object.assign({}, generateRoughOptions(element, false, isDarkMode)), {\n stroke: \"none\"\n })));\n } // (2) stroke\n\n\n shapes.push(getFreeDrawSvgPath(element));\n return shapes;\n }\n\n case \"frame\":\n case \"magicframe\":\n case \"text\":\n case \"image\":\n {\n const shape = null; // we return (and cache) `null` to make sure we don't regenerate\n // `element.canvas` on rerenders\n\n return shape;\n }\n\n default:\n {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.assertNever)(element, `generateElementShape(): Unimplemented type ${element === null || element === void 0 ? void 0 : element.type}`);\n return null;\n }\n }\n};\n\nconst generateElbowArrowShape = (points, radius) => {\n const subpoints = [];\n\n for (let i = 1; i < points.length - 1; i += 1) {\n const prev = points[i - 1];\n const next = points[i + 1];\n const point = points[i];\n const prevIsHorizontal = (0,_heading__WEBPACK_IMPORTED_MODULE_9__.headingForPointIsHorizontal)(point, prev);\n const nextIsHorizontal = (0,_heading__WEBPACK_IMPORTED_MODULE_9__.headingForPointIsHorizontal)(next, point);\n const corner = Math.min(radius, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointDistance)(points[i], next) / 2, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointDistance)(points[i], prev) / 2);\n\n if (prevIsHorizontal) {\n if (prev[0] < point[0]) {\n // LEFT\n subpoints.push([points[i][0] - corner, points[i][1]]);\n } else {\n // RIGHT\n subpoints.push([points[i][0] + corner, points[i][1]]);\n }\n } else if (prev[1] < point[1]) {\n // UP\n subpoints.push([points[i][0], points[i][1] - corner]);\n } else {\n subpoints.push([points[i][0], points[i][1] + corner]);\n }\n\n subpoints.push(points[i]);\n\n if (nextIsHorizontal) {\n if (next[0] < point[0]) {\n // LEFT\n subpoints.push([points[i][0] - corner, points[i][1]]);\n } else {\n // RIGHT\n subpoints.push([points[i][0] + corner, points[i][1]]);\n }\n } else if (next[1] < point[1]) {\n // UP\n subpoints.push([points[i][0], points[i][1] - corner]);\n } else {\n // DOWN\n subpoints.push([points[i][0], points[i][1] + corner]);\n }\n }\n\n const d = [`M ${points[0][0]} ${points[0][1]}`];\n\n for (let i = 0; i < subpoints.length; i += 3) {\n d.push(`L ${subpoints[i][0]} ${subpoints[i][1]}`);\n d.push(`Q ${subpoints[i + 1][0]} ${subpoints[i + 1][1]}, ${subpoints[i + 2][0]} ${subpoints[i + 2][1]}`);\n }\n\n d.push(`L ${points[points.length - 1][0]} ${points[points.length - 1][1]}`);\n return d.join(\" \");\n};\n/**\n * get the pure geometric shape of an excalidraw elementw\n * which is then used for hit detection\n */\n\n\nconst getElementShape = (element, elementsMap) => {\n switch (element.type) {\n case \"rectangle\":\n case \"diamond\":\n case \"frame\":\n case \"magicframe\":\n case \"embeddable\":\n case \"image\":\n case \"iframe\":\n case \"text\":\n case \"selection\":\n return (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getPolygonShape)(element);\n\n case \"arrow\":\n case \"line\":\n {\n const roughShape = ShapeCache.generateElementShape(element, null)[0];\n const [,,,, cx, cy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getElementAbsoluteCoords)(element, elementsMap);\n return (0,_collision__WEBPACK_IMPORTED_MODULE_12__.shouldTestInside)(element) ? (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getClosedCurveShape)(element, roughShape, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x, element.y), element.angle, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(cx, cy)) : (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getCurveShape)(roughShape, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x, element.y), element.angle, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(cx, cy));\n }\n\n case \"ellipse\":\n return (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getEllipseShape)(element);\n\n case \"freedraw\":\n {\n const [,,,, cx, cy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getElementAbsoluteCoords)(element, elementsMap);\n return (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getFreedrawShape)(element, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(cx, cy), (0,_collision__WEBPACK_IMPORTED_MODULE_12__.shouldTestInside)(element));\n }\n }\n};\nconst toggleLinePolygonState = (element, nextPolygonState) => {\n const updatedPoints = [...element.points];\n\n if (nextPolygonState) {\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.canBecomePolygon)(element.points)) {\n return null;\n }\n\n const firstPoint = updatedPoints[0];\n const lastPoint = updatedPoints[updatedPoints.length - 1];\n const distance = Math.hypot(firstPoint[0] - lastPoint[0], firstPoint[1] - lastPoint[1]);\n\n if (distance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.LINE_POLYGON_POINT_MERGE_DISTANCE || updatedPoints.length < 4) {\n updatedPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(firstPoint[0], firstPoint[1]));\n } else {\n updatedPoints[updatedPoints.length - 1] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(firstPoint[0], firstPoint[1]);\n }\n } // TODO: satisfies ElementUpdate<ExcalidrawLineElement>\n\n\n const ret = {\n polygon: nextPolygonState,\n points: updatedPoints\n };\n return ret;\n}; // -----------------------------------------------------------------------------\n// freedraw shape helper\n// -----------------------------------------------------------------------------\n// NOTE not cached (-> for SVG export)\n\nconst getFreeDrawSvgPath = element => {\n return getSvgPathFromStroke(getFreedrawOutlinePoints(element));\n};\n\nconst getFreedrawOutlinePoints = element => {\n // If input points are empty (should they ever be?) return a dot\n const inputPoints = element.simulatePressure ? element.points : element.points.length ? element.points.map(([x, y], i) => [x, y, element.pressures[i]]) : [[0, 0, 0.5]];\n return (0,perfect_freehand__WEBPACK_IMPORTED_MODULE_1__.getStroke)(inputPoints, {\n simulatePressure: element.simulatePressure,\n size: element.strokeWidth * 4.25,\n thinning: 0.6,\n smoothing: 0.5,\n streamline: 0.5,\n easing: t => Math.sin(t * Math.PI / 2),\n // https://easings.net/#easeOutSine\n last: true\n });\n};\n\nconst med = (A, B) => {\n return [(A[0] + B[0]) / 2, (A[1] + B[1]) / 2];\n}; // Trim SVG path data so number are each two decimal points. This\n// improves SVG exports, and prevents rendering errors on points\n// with long decimals.\n\n\nconst TO_FIXED_PRECISION = /(\\s?[A-Z]?,?-?[0-9]*\\.[0-9]{0,2})(([0-9]|e|-)*)/g;\n\nconst getSvgPathFromStroke = points => {\n if (!points.length) {\n return \"\";\n }\n\n const max = points.length - 1;\n return points.reduce((acc, point, i, arr) => {\n if (i === max) {\n acc.push(point, med(point, arr[0]), \"L\", arr[0], \"Z\");\n } else {\n acc.push(point, med(point, arr[i + 1]));\n }\n\n return acc;\n }, [\"M\", points[0], \"Q\"]).join(\" \").replace(TO_FIXED_PRECISION, \"$1\");\n}; // -----------------------------------------------------------------------------\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/shape.ts?");
14844
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ShapeCache: () => (/* binding */ ShapeCache),\n/* harmony export */ generateLinearCollisionShape: () => (/* binding */ generateLinearCollisionShape),\n/* harmony export */ generateRoughOptions: () => (/* binding */ generateRoughOptions),\n/* harmony export */ getElementShape: () => (/* binding */ getElementShape),\n/* harmony export */ getFreedrawOutlinePoints: () => (/* binding */ getFreedrawOutlinePoints),\n/* harmony export */ toggleLinePolygonState: () => (/* binding */ toggleLinePolygonState)\n/* harmony export */ });\n/* harmony import */ var points_on_curve__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! points-on-curve */ \"../../node_modules/points-on-curve/lib/index.js\");\n/* harmony import */ var perfect_freehand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! perfect-freehand */ \"../../node_modules/perfect-freehand/dist/esm/index.js\");\n/* harmony import */ var _excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/utils/shape */ \"../utils/src/shape.ts\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var roughjs_bin_generator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! roughjs/bin/generator */ \"../../node_modules/roughjs/bin/generator.js\");\n/* harmony import */ var _renderElement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./renderElement */ \"../element/src/renderElement.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils */ \"../element/src/utils.ts\");\n/* harmony import */ var _heading__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./heading */ \"../element/src/heading.ts\");\n/* harmony import */ var _comparisons__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./comparisons */ \"../element/src/comparisons.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _collision__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./collision */ \"../element/src/collision.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nclass ShapeCache {}\nShapeCache.rg = new roughjs_bin_generator__WEBPACK_IMPORTED_MODULE_5__.RoughGenerator();\nShapeCache.cache = new WeakMap();\n/**\n * Retrieves shape from cache if available. Use this only if shape\n * is optional and you have a fallback in case it's not cached.\n */\n\nShapeCache.get = (element, theme) => {\n const cached = ShapeCache.cache.get(element);\n\n if (cached && (theme === null || cached.theme === theme)) {\n return cached.shape;\n }\n\n return undefined;\n};\n\nShapeCache.delete = element => {\n ShapeCache.cache.delete(element);\n _renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache.delete(element);\n};\n\nShapeCache.destroy = () => {\n ShapeCache.cache = new WeakMap();\n\n if (_renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache) {\n //zsviczian\n Object.values(_renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache).forEach(value => {\n _renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache.delete(value);\n });\n }\n};\n/**\n * Generates & caches shape for element if not already cached, otherwise\n * returns cached shape.\n */\n\n\nShapeCache.generateElementShape = (element, renderConfig) => {\n // when exporting, always regenerated to guarantee the latest shape\n const cachedShape = (renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.isExporting) ? undefined : ShapeCache.get(element, renderConfig ? renderConfig.theme : null); // `null` indicates no rc shape applicable for this element type,\n // but it's considered a valid cache value (= do not regenerate)\n\n if (cachedShape !== undefined) {\n return cachedShape;\n }\n\n _renderElement__WEBPACK_IMPORTED_MODULE_6__.elementWithCanvasCache.delete(element);\n\n const shape = _generateElementShape(element, ShapeCache.rg, renderConfig || {\n isExporting: false,\n canvasBackgroundColor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.COLOR_PALETTE.white,\n embedsValidationStatus: null,\n theme: _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.THEME.LIGHT\n });\n\n if (!(renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.isExporting)) {\n ShapeCache.cache.set(element, {\n shape,\n theme: (renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.theme) || _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.THEME.LIGHT\n });\n }\n\n return shape;\n};\n\nconst getDashArrayDashed = strokeWidth => [8, 8 + strokeWidth];\n\nconst getDashArrayDotted = strokeWidth => [1.5, 6 + strokeWidth];\n\nfunction adjustRoughness(element) {\n const roughness = element.roughness;\n const maxSize = Math.max(element.width, element.height);\n const minSize = Math.min(element.width, element.height); // don't reduce roughness if\n\n if ( // both sides relatively big\n minSize >= 20 && maxSize >= 50 || // is round & both sides above 15px\n minSize >= 15 && !!element.roundness && (0,_comparisons__WEBPACK_IMPORTED_MODULE_10__.canChangeRoundness)(element.type) || // relatively long linear element\n (0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element) && maxSize >= 50) {\n return roughness;\n }\n\n return Math.min(roughness / (maxSize < 10 ? 3 : 2), 2.5);\n}\n\nconst generateRoughOptions = (element, continuousPath = false, isDarkMode = false) => {\n const options = {\n seed: element.seed,\n strokeLineDash: element.strokeStyle === \"dashed\" ? getDashArrayDashed(element.strokeWidth) : element.strokeStyle === \"dotted\" ? getDashArrayDotted(element.strokeWidth) : undefined,\n // for non-solid strokes, disable multiStroke because it tends to make\n // dashes/dots overlay each other\n disableMultiStroke: element.strokeStyle !== \"solid\",\n // for non-solid strokes, increase the width a bit to make it visually\n // similar to solid strokes, because we're also disabling multiStroke\n strokeWidth: element.strokeStyle !== \"solid\" ? element.strokeWidth + 0.5 : element.strokeWidth,\n // when increasing strokeWidth, we must explicitly set fillWeight and\n // hachureGap because if not specified, roughjs uses strokeWidth to\n // calculate them (and we don't want the fills to be modified)\n fillWeight: element.strokeWidth / 2,\n hachureGap: element.strokeWidth * 4,\n roughness: adjustRoughness(element),\n stroke: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.strokeColor, isDarkMode),\n preserveVertices: continuousPath || element.roughness < _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.ROUGHNESS.cartoonist\n };\n\n switch (element.type) {\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n case \"diamond\":\n case \"ellipse\":\n {\n options.fillStyle = element.fillStyle;\n options.fill = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.backgroundColor) ? undefined : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.backgroundColor, isDarkMode);\n\n if (element.type === \"ellipse\") {\n options.curveFitting = 1;\n }\n\n return options;\n }\n\n case \"line\":\n case \"freedraw\":\n {\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_8__.isPathALoop)(element.points)) {\n options.fillStyle = element.fillStyle;\n options.fill = element.backgroundColor === \"transparent\" ? undefined : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.backgroundColor, isDarkMode);\n }\n\n return options;\n }\n\n case \"arrow\":\n return options;\n\n default:\n {\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n};\n\nconst modifyIframeLikeForRoughOptions = (element, isExporting, embedsValidationStatus) => {\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(element) && (isExporting || (0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(element) && (embedsValidationStatus === null || embedsValidationStatus === void 0 ? void 0 : embedsValidationStatus.get(element.id)) !== true) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.backgroundColor) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.strokeColor)) {\n return Object.assign(Object.assign({}, element), {\n roughness: 0,\n backgroundColor: \"#d3d3d3\",\n fillStyle: \"solid\"\n });\n } else if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(element)) {\n return Object.assign(Object.assign({}, element), {\n strokeColor: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.strokeColor) ? \"#000000\" : element.strokeColor,\n backgroundColor: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.isTransparent)(element.backgroundColor) ? \"#f4f4f6\" : element.backgroundColor\n });\n }\n\n return element;\n};\n\nconst generateArrowheadCardinalityOne = (generator, arrowheadPoints, lineOptions) => {\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [,, x3, y3, x4, y4] = arrowheadPoints;\n return [generator.line(x3, y3, x4, y4, lineOptions)];\n};\n\nconst generateArrowheadLinesToTip = (generator, arrowheadPoints, lineOptions) => {\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x2, y2, x3, y3, x4, y4] = arrowheadPoints;\n return [generator.line(x3, y3, x2, y2, lineOptions), generator.line(x4, y4, x2, y2, lineOptions)];\n};\n\nconst getArrowheadLineOptions = (element, options) => {\n const lineOptions = Object.assign({}, options);\n\n if (element.strokeStyle === \"dotted\") {\n // for dotted arrows caps, reduce gap to make it more legible\n const dash = getDashArrayDotted(element.strokeWidth - 1);\n lineOptions.strokeLineDash = [dash[0], dash[1] - 1];\n } else {\n // for solid/dashed, keep solid arrow cap\n delete lineOptions.strokeLineDash;\n }\n\n lineOptions.roughness = Math.min(1, lineOptions.roughness || 0);\n return lineOptions;\n};\n\nconst generateArrowheadOutlineCircle = (generator, options, strokeColor, arrowheadPoints, fill, diameterScale = 1) => {\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x, y, diameter] = arrowheadPoints;\n const circleOptions = Object.assign(Object.assign({}, options), {\n fill,\n fillStyle: \"solid\",\n stroke: strokeColor,\n roughness: Math.min(0.5, options.roughness || 0)\n });\n delete circleOptions.strokeLineDash;\n return [generator.circle(x, y, diameter * diameterScale, circleOptions)];\n};\n\nconst getArrowheadShapes = (element, shape, position, arrowhead, generator, options, canvasBackgroundColor, isDarkMode) => {\n if (arrowhead === null) {\n return [];\n }\n\n const strokeColor = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(element.strokeColor, isDarkMode);\n const backgroundFillColor = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter)(canvasBackgroundColor, isDarkMode);\n const cardinalityOneOrManyOffset = -0.25;\n const cardinalityZeroCircleScale = 0.8;\n\n switch (arrowhead) {\n case \"circle\":\n case \"circle_outline\":\n {\n return generateArrowheadOutlineCircle(generator, options, strokeColor, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), arrowhead === \"circle_outline\" ? backgroundFillColor : strokeColor);\n }\n\n case \"triangle\":\n case \"triangle_outline\":\n {\n const arrowheadPoints = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead);\n\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x, y, x2, y2, x3, y3] = arrowheadPoints;\n const triangleOptions = Object.assign(Object.assign({}, options), {\n fill: arrowhead === \"triangle_outline\" ? backgroundFillColor : strokeColor,\n fillStyle: \"solid\",\n roughness: Math.min(1, options.roughness || 0)\n }); // always use solid stroke for arrowhead\n\n delete triangleOptions.strokeLineDash;\n return [generator.polygon([[x, y], [x2, y2], [x3, y3], [x, y]], triangleOptions)];\n }\n\n case \"diamond\":\n case \"diamond_outline\":\n {\n const arrowheadPoints = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead);\n\n if (arrowheadPoints === null) {\n return [];\n }\n\n const [x, y, x2, y2, x3, y3, x4, y4] = arrowheadPoints;\n const diamondOptions = Object.assign(Object.assign({}, options), {\n fill: arrowhead === \"diamond_outline\" ? backgroundFillColor : strokeColor,\n fillStyle: \"solid\",\n roughness: Math.min(1, options.roughness || 0)\n }); // always use solid stroke for arrowhead\n\n delete diamondOptions.strokeLineDash;\n return [generator.polygon([[x, y], [x2, y2], [x3, y3], [x4, y4], [x, y]], diamondOptions)];\n }\n\n case \"cardinality_one\":\n return generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), getArrowheadLineOptions(element, options));\n\n case \"cardinality_many\":\n return generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), getArrowheadLineOptions(element, options));\n\n case \"cardinality_one_or_many\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_many\"), lineOptions), ...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\", cardinalityOneOrManyOffset), lineOptions)];\n }\n\n case \"cardinality_exactly_one\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\", -0.5), lineOptions), ...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\"), lineOptions)];\n }\n\n case \"cardinality_zero_or_one\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadOutlineCircle(generator, options, strokeColor, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"circle_outline\", 1.5), backgroundFillColor, cardinalityZeroCircleScale), ...generateArrowheadCardinalityOne(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_one\", -0.5), lineOptions)];\n }\n\n case \"cardinality_zero_or_many\":\n {\n const lineOptions = getArrowheadLineOptions(element, options);\n return [...generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"cardinality_many\"), lineOptions), ...generateArrowheadOutlineCircle(generator, options, strokeColor, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, \"circle_outline\", 1.5), backgroundFillColor, cardinalityZeroCircleScale)];\n }\n\n case \"bar\":\n case \"arrow\":\n default:\n {\n return generateArrowheadLinesToTip(generator, (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getArrowheadPoints)(element, shape, position, arrowhead), getArrowheadLineOptions(element, options));\n }\n }\n};\n\nconst generateLinearCollisionShape = (element, elementsMap) => {\n const generator = new roughjs_bin_generator__WEBPACK_IMPORTED_MODULE_5__.RoughGenerator();\n const options = {\n seed: element.seed,\n disableMultiStroke: true,\n disableMultiStrokeFill: true,\n roughness: 0,\n preserveVertices: true\n };\n const center = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.elementCenterPoint)(element, elementsMap);\n\n switch (element.type) {\n case \"line\":\n case \"arrow\":\n {\n // points array can be empty in the beginning, so it is important to add\n // initial position to it\n const points = element.points.length ? element.points : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(0, 0)];\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element)) {\n return generator.path(generateElbowArrowShape(points, 16), options).sets[0].ops;\n } else if (!element.roundness) {\n return points.map((point, idx) => {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + point[0], element.y + point[1]), center, element.angle);\n return {\n op: idx === 0 ? \"move\" : \"lineTo\",\n data: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)\n };\n });\n }\n\n return generator.curve(points, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {\n if (i === 0) {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle);\n return {\n op: \"move\",\n data: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)\n };\n }\n\n return {\n op: \"bcurveTo\",\n data: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[2], element.y + op.data[3]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[4], element.y + op.data[5]), center, element.angle)].map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)).flat()\n };\n });\n }\n\n case \"freedraw\":\n {\n if (element.points.length < 2) {\n return [];\n }\n\n const simplifiedPoints = (0,points_on_curve__WEBPACK_IMPORTED_MODULE_0__.simplify)(element.points, 0.75);\n return generator.curve(simplifiedPoints, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {\n if (i === 0) {\n const p = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle);\n return {\n op: \"move\",\n data: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)\n };\n }\n\n return {\n op: \"bcurveTo\",\n data: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[0], element.y + op.data[1]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[2], element.y + op.data[3]), center, element.angle), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x + op.data[4], element.y + op.data[5]), center, element.angle)].map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(p[0] - element.x, p[1] - element.y)).flat()\n };\n });\n }\n }\n};\n/**\n * Generates the roughjs shape for given element.\n *\n * Low-level. Use `ShapeCache.generateElementShape` instead.\n *\n * @private\n */\n\nconst _generateElementShape = (element, generator, {\n isExporting,\n canvasBackgroundColor,\n embedsValidationStatus,\n theme\n}) => {\n const isDarkMode = theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.THEME.DARK;\n\n switch (element.type) {\n case \"rectangle\":\n case \"iframe\":\n case \"embeddable\":\n {\n let shape; // this is for rendering the stroke/bg of the embeddable, especially\n // when the src url is not set\n\n if (element.roundness) {\n const w = element.width;\n const h = element.height;\n const r = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.getCornerRadius)(Math.min(w, h), element);\n shape = generator.path(`M ${r} 0 L ${w - r} 0 Q ${w} 0, ${w} ${r} L ${w} ${h - r} Q ${w} ${h}, ${w - r} ${h} L ${r} ${h} Q 0 ${h}, 0 ${h - r} L 0 ${r} Q 0 0, ${r} 0`, generateRoughOptions(modifyIframeLikeForRoughOptions(element, isExporting, embedsValidationStatus), true, isDarkMode));\n } else {\n shape = generator.rectangle(0, 0, element.width, element.height, generateRoughOptions(modifyIframeLikeForRoughOptions(element, isExporting, embedsValidationStatus), false, isDarkMode));\n }\n\n return shape;\n }\n\n case \"diamond\":\n {\n let shape;\n const [topX, topY, rightX, rightY, bottomX, bottomY, leftX, leftY] = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getDiamondPoints)(element);\n\n if (element.roundness) {\n const verticalRadius = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.getCornerRadius)(Math.abs(topX - leftX), element);\n const horizontalRadius = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.getCornerRadius)(Math.abs(rightY - topY), element);\n shape = generator.path(`M ${topX + verticalRadius} ${topY + horizontalRadius} L ${rightX - verticalRadius} ${rightY - horizontalRadius}\n C ${rightX} ${rightY}, ${rightX} ${rightY}, ${rightX - verticalRadius} ${rightY + horizontalRadius}\n L ${bottomX + verticalRadius} ${bottomY - horizontalRadius}\n C ${bottomX} ${bottomY}, ${bottomX} ${bottomY}, ${bottomX - verticalRadius} ${bottomY - horizontalRadius}\n L ${leftX + verticalRadius} ${leftY + horizontalRadius}\n C ${leftX} ${leftY}, ${leftX} ${leftY}, ${leftX + verticalRadius} ${leftY - horizontalRadius}\n L ${topX - verticalRadius} ${topY + horizontalRadius}\n C ${topX} ${topY}, ${topX} ${topY}, ${topX + verticalRadius} ${topY + horizontalRadius}`, generateRoughOptions(element, true, isDarkMode));\n } else {\n shape = generator.polygon([[topX, topY], [rightX, rightY], [bottomX, bottomY], [leftX, leftY]], generateRoughOptions(element, false, isDarkMode));\n }\n\n return shape;\n }\n\n case \"ellipse\":\n {\n const shape = generator.ellipse(element.width / 2, element.height / 2, element.width, element.height, generateRoughOptions(element, false, isDarkMode));\n return shape;\n }\n\n case \"line\":\n case \"arrow\":\n {\n let shape;\n const options = generateRoughOptions(element, false, isDarkMode); // points array can be empty in the beginning, so it is important to add\n // initial position to it\n\n const points = element.points.length ? element.points : [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(0, 0)];\n\n if ((0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element)) {\n // NOTE (mtolmacs): Temporary fix for extremely big arrow shapes\n if (!points.every(point => Math.abs(point[0]) <= 1e6 && Math.abs(point[1]) <= 1e6)) {\n console.error(`Elbow arrow with extreme point positions detected. Arrow not rendered.`, element.id, JSON.stringify(points));\n shape = [];\n } else {\n shape = [generator.path(generateElbowArrowShape(points, 16), generateRoughOptions(element, true, isDarkMode))];\n }\n } else if (!element.roundness) {\n // curve is always the first element\n // this simplifies finding the curve for an element\n if (options.fill) {\n shape = [generator.polygon(points, options)];\n } else {\n shape = [generator.linearPath(points, options)];\n }\n } else {\n shape = [generator.curve(points, options)];\n } // add lines only in arrow\n\n\n if (element.type === \"arrow\") {\n const {\n startArrowhead = null,\n endArrowhead = \"arrow\"\n } = element;\n\n if (startArrowhead !== null) {\n const shapes = getArrowheadShapes(element, shape, \"start\", startArrowhead, generator, options, canvasBackgroundColor, isDarkMode);\n shape.push(...shapes);\n }\n\n if (endArrowhead !== null) {\n if (endArrowhead === undefined) {// Hey, we have an old arrow here!\n }\n\n const shapes = getArrowheadShapes(element, shape, \"end\", endArrowhead, generator, options, canvasBackgroundColor, isDarkMode);\n shape.push(...shapes);\n }\n }\n\n return shape;\n }\n\n case \"freedraw\":\n {\n // oredered in terms of z-index [background, stroke]\n const shapes = []; // (1) background fill (rc shape), optional\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_8__.isPathALoop)(element.points)) {\n // generate rough polygon to fill freedraw shape\n const simplifiedPoints = (0,points_on_curve__WEBPACK_IMPORTED_MODULE_0__.simplify)(element.points, 0.75);\n shapes.push(generator.curve(simplifiedPoints, Object.assign(Object.assign({}, generateRoughOptions(element, false, isDarkMode)), {\n stroke: \"none\"\n })));\n } // (2) stroke\n\n\n shapes.push(getFreeDrawSvgPath(element));\n return shapes;\n }\n\n case \"frame\":\n case \"magicframe\":\n case \"text\":\n case \"image\":\n {\n const shape = null; // we return (and cache) `null` to make sure we don't regenerate\n // `element.canvas` on rerenders\n\n return shape;\n }\n\n default:\n {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.assertNever)(element, `generateElementShape(): Unimplemented type ${element === null || element === void 0 ? void 0 : element.type}`);\n return null;\n }\n }\n};\n\nconst generateElbowArrowShape = (points, radius) => {\n const subpoints = [];\n\n for (let i = 1; i < points.length - 1; i += 1) {\n const prev = points[i - 1];\n const next = points[i + 1];\n const point = points[i];\n const prevIsHorizontal = (0,_heading__WEBPACK_IMPORTED_MODULE_9__.headingForPointIsHorizontal)(point, prev);\n const nextIsHorizontal = (0,_heading__WEBPACK_IMPORTED_MODULE_9__.headingForPointIsHorizontal)(next, point);\n const corner = Math.min(radius, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointDistance)(points[i], next) / 2, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointDistance)(points[i], prev) / 2);\n\n if (prevIsHorizontal) {\n if (prev[0] < point[0]) {\n // LEFT\n subpoints.push([points[i][0] - corner, points[i][1]]);\n } else {\n // RIGHT\n subpoints.push([points[i][0] + corner, points[i][1]]);\n }\n } else if (prev[1] < point[1]) {\n // UP\n subpoints.push([points[i][0], points[i][1] - corner]);\n } else {\n subpoints.push([points[i][0], points[i][1] + corner]);\n }\n\n subpoints.push(points[i]);\n\n if (nextIsHorizontal) {\n if (next[0] < point[0]) {\n // LEFT\n subpoints.push([points[i][0] - corner, points[i][1]]);\n } else {\n // RIGHT\n subpoints.push([points[i][0] + corner, points[i][1]]);\n }\n } else if (next[1] < point[1]) {\n // UP\n subpoints.push([points[i][0], points[i][1] - corner]);\n } else {\n // DOWN\n subpoints.push([points[i][0], points[i][1] + corner]);\n }\n }\n\n const d = [`M ${points[0][0]} ${points[0][1]}`];\n\n for (let i = 0; i < subpoints.length; i += 3) {\n d.push(`L ${subpoints[i][0]} ${subpoints[i][1]}`);\n d.push(`Q ${subpoints[i + 1][0]} ${subpoints[i + 1][1]}, ${subpoints[i + 2][0]} ${subpoints[i + 2][1]}`);\n }\n\n d.push(`L ${points[points.length - 1][0]} ${points[points.length - 1][1]}`);\n return d.join(\" \");\n};\n/**\n * get the pure geometric shape of an excalidraw elementw\n * which is then used for hit detection\n */\n\n\nconst getElementShape = (element, elementsMap) => {\n switch (element.type) {\n case \"rectangle\":\n case \"diamond\":\n case \"frame\":\n case \"magicframe\":\n case \"embeddable\":\n case \"image\":\n case \"iframe\":\n case \"text\":\n case \"selection\":\n return (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getPolygonShape)(element);\n\n case \"arrow\":\n case \"line\":\n {\n const roughShape = ShapeCache.generateElementShape(element, null)[0];\n const [,,,, cx, cy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getElementAbsoluteCoords)(element, elementsMap);\n return (0,_collision__WEBPACK_IMPORTED_MODULE_12__.shouldTestInside)(element) ? (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getClosedCurveShape)(element, roughShape, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x, element.y), element.angle, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(cx, cy)) : (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getCurveShape)(roughShape, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(element.x, element.y), element.angle, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(cx, cy));\n }\n\n case \"ellipse\":\n return (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getEllipseShape)(element);\n\n case \"freedraw\":\n {\n const [,,,, cx, cy] = (0,_bounds__WEBPACK_IMPORTED_MODULE_11__.getElementAbsoluteCoords)(element, elementsMap);\n return (0,_excalidraw_utils_shape__WEBPACK_IMPORTED_MODULE_2__.getFreedrawShape)(element, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(cx, cy), (0,_collision__WEBPACK_IMPORTED_MODULE_12__.shouldTestInside)(element));\n }\n }\n};\nconst toggleLinePolygonState = (element, nextPolygonState) => {\n const updatedPoints = [...element.points];\n\n if (nextPolygonState) {\n if (!(0,_typeChecks__WEBPACK_IMPORTED_MODULE_7__.canBecomePolygon)(element.points)) {\n return null;\n }\n\n const firstPoint = updatedPoints[0];\n const lastPoint = updatedPoints[updatedPoints.length - 1];\n const distance = Math.hypot(firstPoint[0] - lastPoint[0], firstPoint[1] - lastPoint[1]);\n\n if (distance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_4__.LINE_POLYGON_POINT_MERGE_DISTANCE || updatedPoints.length < 4) {\n updatedPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(firstPoint[0], firstPoint[1]));\n } else {\n updatedPoints[updatedPoints.length - 1] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_3__.pointFrom)(firstPoint[0], firstPoint[1]);\n }\n } // TODO: satisfies ElementUpdate<ExcalidrawLineElement>\n\n\n const ret = {\n polygon: nextPolygonState,\n points: updatedPoints\n };\n return ret;\n}; // -----------------------------------------------------------------------------\n// freedraw shape helper\n// -----------------------------------------------------------------------------\n// NOTE not cached (-> for SVG export)\n\nconst getFreeDrawSvgPath = element => {\n return getSvgPathFromStroke(getFreedrawOutlinePoints(element));\n};\n\nconst getFreedrawOutlinePoints = element => {\n // If input points are empty (should they ever be?) return a dot\n const inputPoints = element.simulatePressure ? element.points : element.points.length ? element.points.map(([x, y], i) => [x, y, element.pressures[i]]) : [[0, 0, 0.5]];\n return (0,perfect_freehand__WEBPACK_IMPORTED_MODULE_1__.getStroke)(inputPoints, {\n simulatePressure: element.simulatePressure,\n size: element.strokeWidth * 4.25,\n thinning: 0.6,\n smoothing: 0.5,\n streamline: 0.5,\n easing: t => Math.sin(t * Math.PI / 2),\n // https://easings.net/#easeOutSine\n last: true\n });\n};\n\nconst med = (A, B) => {\n return [(A[0] + B[0]) / 2, (A[1] + B[1]) / 2];\n}; // Trim SVG path data so number are each two decimal points. This\n// improves SVG exports, and prevents rendering errors on points\n// with long decimals.\n\n\nconst TO_FIXED_PRECISION = /(\\s?[A-Z]?,?-?[0-9]*\\.[0-9]{0,2})(([0-9]|e|-)*)/g;\n\nconst getSvgPathFromStroke = points => {\n if (!points.length) {\n return \"\";\n }\n\n const max = points.length - 1;\n return points.reduce((acc, point, i, arr) => {\n if (i === max) {\n acc.push(point, med(point, arr[0]), \"L\", arr[0], \"Z\");\n } else {\n acc.push(point, med(point, arr[i + 1]));\n }\n\n return acc;\n }, [\"M\", points[0], \"Q\"]).join(\" \").replace(TO_FIXED_PRECISION, \"$1\");\n}; // -----------------------------------------------------------------------------\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/shape.ts?");
14845
14845
 
14846
14846
  /***/ }),
14847
14847
 
@@ -15677,7 +15677,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
15677
15677
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
15678
15678
 
15679
15679
  "use strict";
15680
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ trackEvent: () => (/* binding */ trackEvent)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n// place here categories that you want to track. We want to track just a\n // small subset of categories at a given time.\n\nconst ALLOWED_CATEGORIES_TO_TRACK = new Set([\"command_palette\", \"export\"]);\nconst trackEvent = (category, action, label, value) => {\n try {\n if (typeof window === \"undefined\" || ({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.0-94\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).VITE_WORKER_ID || \"true\" !== \"true\") {\n return;\n }\n\n if (!ALLOWED_CATEGORIES_TO_TRACK.has(category)) {\n return;\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isDevEnv)()) {\n // comment out to debug in dev\n return;\n }\n\n if (true) {\n console.info(\"trackEvent\", {\n category,\n action,\n label,\n value\n });\n }\n\n if (window.sa_event) {\n window.sa_event(action, {\n category,\n label,\n value\n });\n }\n } catch (error) {\n console.error(\"error during analytics\", error);\n }\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./analytics.ts?");
15680
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ trackEvent: () => (/* binding */ trackEvent)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n// place here categories that you want to track. We want to track just a\n // small subset of categories at a given time.\n\nconst ALLOWED_CATEGORIES_TO_TRACK = new Set([\"command_palette\", \"export\"]);\nconst trackEvent = (category, action, label, value) => {\n try {\n if (typeof window === \"undefined\" || ({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.95\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).VITE_WORKER_ID || \"true\" !== \"true\") {\n return;\n }\n\n if (!ALLOWED_CATEGORIES_TO_TRACK.has(category)) {\n return;\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isDevEnv)()) {\n // comment out to debug in dev\n return;\n }\n\n if (true) {\n console.info(\"trackEvent\", {\n category,\n action,\n label,\n value\n });\n }\n\n if (window.sa_event) {\n window.sa_event(action, {\n category,\n label,\n value\n });\n }\n } catch (error) {\n console.error(\"error during analytics\", error);\n }\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./analytics.ts?");
15681
15681
 
15682
15682
  /***/ }),
15683
15683
 
@@ -15842,7 +15842,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
15842
15842
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
15843
15843
 
15844
15844
  "use strict";
15845
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawAPIContext: () => (/* binding */ ExcalidrawAPIContext),\n/* harmony export */ ExcalidrawAPISetContext: () => (/* binding */ ExcalidrawAPISetContext),\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 */ useEditorInterface: () => (/* binding */ useEditorInterface),\n/* harmony export */ useExcalidrawAPI: () => (/* binding */ useExcalidrawAPI),\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 */ useStylesPanelMode: () => (/* binding */ useStylesPanelMode)\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_73__ = __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_common__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../actions/actionBoundText */ \"./actions/actionBoundText.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../actions/actionClipboard */ \"./actions/actionClipboard.tsx\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../actions/actionElementLock */ \"./actions/actionElementLock.ts\");\n/* harmony import */ var _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../actions/actionFrame */ \"./actions/actionFrame.ts\");\n/* harmony import */ var _actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../actions/actionHistory */ \"./actions/actionHistory.tsx\");\n/* harmony import */ var _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../actions/actionTextAutoResize */ \"./actions/actionTextAutoResize.ts\");\n/* harmony import */ var _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../actions/actionToggleViewMode */ \"./actions/actionToggleViewMode.tsx\");\n/* harmony import */ var _actions_manager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../actions/manager */ \"./actions/manager.tsx\");\n/* harmony import */ var _actions_register__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../actions/register */ \"./actions/register.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../data */ \"./data/index.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../data/library */ \"./data/library.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _gesture__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../gesture */ \"./gesture.ts\");\n/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../history */ \"./history.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_filesystem__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../data/filesystem */ \"./data/filesystem.ts\");\n/* harmony import */ var _components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ../components/hyperlink/Hyperlink */ \"./components/hyperlink/Hyperlink.tsx\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _snapping__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ../snapping */ \"./snapping.ts\");\n/* harmony import */ var _scene_Renderer__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ../scene/Renderer */ \"./scene/Renderer.ts\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ../components/ElementCanvasButtons */ \"./components/ElementCanvasButtons.tsx\");\n/* harmony import */ var _laserTrails__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ../laserTrails */ \"./laserTrails.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _textAutoResizeHandle__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ../textAutoResizeHandle */ \"./textAutoResizeHandle.ts\");\n/* harmony import */ var _wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ../wysiwyg/textWysiwyg */ \"./wysiwyg/textWysiwyg.tsx\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _mermaid__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ../mermaid */ \"./mermaid.ts\");\n/* harmony import */ var _lasso__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ../lasso */ \"./lasso/index.ts\");\n/* harmony import */ var _eraser__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ../eraser */ \"./eraser/index.ts\");\n/* harmony import */ var _shortcut__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ../shortcut */ \"./shortcut.ts\");\n/* harmony import */ var _charts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ../charts */ \"./charts/index.ts\");\n/* harmony import */ var _ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ./ConvertElementTypePopup */ \"./components/ConvertElementTypePopup.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ./BraveMeasureTextError */ \"./components/BraveMeasureTextError.tsx\");\n/* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ./ContextMenu */ \"./components/ContextMenu.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ./FollowMode/FollowMode */ \"./components/FollowMode/FollowMode.tsx\");\n/* harmony import */ var _LayerUI__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ./LayerUI */ \"./components/LayerUI.tsx\");\n/* harmony import */ var _MagicButton__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ./MagicButton */ \"./components/MagicButton.tsx\");\n/* harmony import */ var _SVGLayer__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ./SVGLayer */ \"./components/SVGLayer.tsx\");\n/* harmony import */ var _SearchMenu__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ./SearchMenu */ \"./components/SearchMenu.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _canvases__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ./canvases */ \"./components/canvases/index.tsx\");\n/* harmony import */ var _canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ./canvases/NewElementCanvas */ \"./components/canvases/NewElementCanvas.tsx\");\n/* harmony import */ var _hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ./hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _AppStateObserver__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ./AppStateObserver */ \"./components/AppStateObserver.ts\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _UnlockPopup__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ./UnlockPopup */ \"./components/UnlockPopup.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ./Tooltip */ \"./components/Tooltip.tsx\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_72__ = __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\nconst AppContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst AppPropsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst editorInterfaceContextInitialValue = {\n formFactor: \"desktop\",\n desktopUIMode: \"full\",\n userAgent: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.createUserAgentDescriptor)(typeof navigator !== \"undefined\" ? navigator.userAgent : \"\"),\n isTouchScreen: false,\n canFitSidebar: false,\n isLandscape: true\n};\nconst EditorInterfaceContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(editorInterfaceContextInitialValue);\nEditorInterfaceContext.displayName = \"EditorInterfaceContext\";\nconst editorLifecycleEventBehavior = {\n \"editor:mount\": {\n cardinality: \"once\",\n replay: \"last\"\n },\n \"editor:initialize\": {\n cardinality: \"once\",\n replay: \"last\"\n },\n \"editor:unmount\": {\n cardinality: \"once\",\n replay: \"last\"\n }\n};\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_22__.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 ExcalidrawAPIContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawAPIContext.displayName = \"ExcalidrawAPIContext\";\nconst ExcalidrawAPISetContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawAPISetContext.displayName = \"ExcalidrawAPISetContext\";\nconst useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppContext);\nconst useAppProps = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppPropsContext);\nconst useEditorInterface = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(EditorInterfaceContext);\nconst useStylesPanelMode = () => (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(useEditorInterface());\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);\n/**\n * Requires wrapping your component in <ExcalidrawAPIContext.Provider>\n */\n\nconst useExcalidrawAPI = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawAPIContext);\nlet didTapTwice = false;\nlet tappedTwiceTimer = 0;\nlet firstTapPosition = null;\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/**\n * Map of youtube embed video states\n */\n\nconst YOUTUBE_VIDEO_STATES = new Map();\nconst MAX_EMBEDDABLE_VIEWPORT_SCALE = 4;\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 createExcalidrawAPI() {\n const api = {\n isDestroyed: false,\n updateScene: this.updateScene,\n applyDeltas: this.applyDeltas,\n mutateElement: this.mutateElement,\n updateLibrary: this.library.updateLibrary,\n addFiles: this.addFiles,\n resetScene: this.resetScene,\n getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,\n getSceneElementsMapIncludingDeleted: this.getSceneElementsMapIncludingDeleted,\n history: {\n clear: this.resetHistory,\n undo: this.undo,\n //zsviczian\n redo: this.redo //zsviczian\n\n },\n scrollToContent: this.scrollToContent,\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 id: this.id,\n setActiveTool: this.setActiveTool,\n setCursor: this.setCursor,\n resetCursor: this.resetCursor,\n getEditorInterface: () => this.editorInterface,\n updateFrameRendering: this.updateFrameRendering,\n toggleSidebar: this.toggleSidebar,\n onChange: cb => this.onChangeEmitter.on(cb),\n onIncrement: cb => this.store.onStoreIncrementEmitter.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 onStateChange: this.onStateChange,\n onEvent: this.onEvent,\n setForceRenderAllEmbeddables: this.setForceRenderAllEmbeddables,\n //zsviczian\n zoomToFit: this.zoomToFit,\n //zsviczian\n refreshEditorInterface: this.refreshEditorInterface,\n //zsviczian\n setDesktopUIMode: this.setDesktopUIMode,\n //zsviczian\n setMobileModeAllowed: this.setMobileModeAllowed,\n //zsviczian\n isTouchScreen: this.isTouchScreen,\n //zsviczian\n isTrayModeEnabled: this.isTrayModeEnabled,\n //zsviczian\n getColorAtScenePoint: this.getColorAtScenePoint,\n //zsviczian\n startLineEditor: this.startLineEditor,\n //zsviczian\n refreshAllArrows: this.refreshAllArrows,\n //zsviczian\n updateContainerSize: this.updateContainerSize,\n //zsviczian\n selectElements: this.selectElements,\n //zsviczian\n sendBackward: this.sendBackward,\n //zsviczian\n bringForward: this.bringForward,\n //zsviczian\n sendToBack: this.sendToBack,\n //zsviczian\n bringToFront: this.bringToFront,\n //zsviczian\n getHTMLIFrameElement: id => this.getHTMLIFrameElement(id) //zsviczian\n\n };\n return api;\n }\n\n constructor(props) {\n super(props);\n this.interactiveCanvas = null;\n this.unmounted = false;\n this.editorInterface = editorInterfaceContextInitialValue;\n this.stylesPanelMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(editorInterfaceContextInitialValue);\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 /**\n * Indicates whether the embeddable's url has been validated for rendering.\n * If value not set, indicates that the validation is pending.\n * Initially or on url change the flag is not reset so that we can guarantee\n * the validation came from a trusted source (the editor).\n **/\n\n this.embedsValidationStatus = new Map();\n /** embeds that have been inserted to DOM (as a perf optim, we don't want to\n * insert to DOM before user initially scrolls to them) */\n\n this.initializedEmbeds = new Set();\n this.elementsPendingErasure = new Set();\n this._initialized = false;\n this.editorLifecycleEvents = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.AppEventBus(editorLifecycleEventBehavior);\n this.onEvent = this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents);\n this.appStateObserver = new _AppStateObserver__WEBPACK_IMPORTED_MODULE_67__.AppStateObserver(() => this.state);\n this.onStateChange = this.appStateObserver.onStateChange;\n this.flowChartCreator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartCreator();\n this.flowChartNavigator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartNavigator();\n this.bindModeHandler = null;\n this.lastPointerDownEvent = null;\n this.lastPointerUpEvent = null; // TODO this is a hack and we should ideally unify touch and pointer events\n // and implement our own double click handling end-to-end (currently we're\n // using a mix of native browser for click events and manual for touch -\n // and browser doubleClick sucks to begin with)\n\n this.lastPointerUpIsDoubleClick = false;\n this.lastPointerMoveEvent = null;\n /** current frame pointer cords */\n\n this.lastPointerMoveCoords = null;\n this.lastCompletedCanvasClicks = [];\n /** previous frame pointer coords */\n\n this.previousPointerMoveCoords = null;\n this.lastViewportPosition = {\n x: 0,\n y: 0\n };\n this.allowMobileMode = true; //zsviczian\n\n this.laserTrails = new _laserTrails__WEBPACK_IMPORTED_MODULE_42__.LaserTrails(this);\n this.eraserTrail = new _eraser__WEBPACK_IMPORTED_MODULE_49__.EraserTrail(this);\n this.lassoTrail = new _lasso__WEBPACK_IMPORTED_MODULE_48__.LassoTrail(this);\n this.onChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerDownEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerUpEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onUserFollowEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onScrollChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.missingPointerEventCleanupEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onRemoveEventListenersEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n\n this.updateEditorAtom = (atom, ...args) => {\n const result = _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.set(atom, ...args);\n this.triggerRender();\n return result;\n };\n\n this.previousHoveredBindableElement = null;\n /**\n * Returns gridSize taking into account `gridModeEnabled`.\n * If disabled, returns null.\n */\n\n this.getEffectiveGridSize = () => {\n return (0,_snapping__WEBPACK_IMPORTED_MODULE_38__.isGridModeEnabled)(this) ? this.state.gridSize : null;\n };\n\n this.getTextCreationGridPoint = (x, y) => {\n const effectiveGridSize = this.getEffectiveGridSize();\n\n if (effectiveGridSize === null) {\n return null;\n }\n\n const getTextCreationGridCoordinate = coordinate => {\n const topLeftGridPoint = Math.floor(coordinate / effectiveGridSize) * effectiveGridSize;\n return topLeftGridPoint;\n };\n\n return {\n x: getTextCreationGridCoordinate(x),\n y: getTextCreationGridCoordinate(y)\n };\n };\n\n this.handleIframeLikeElementHover = ({\n hitElement,\n scenePointer,\n moveEvent\n }) => {\n var _a;\n\n if (hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && (this.state.viewModeEnabled || this.state.activeTool.type === \"laser\" || this.isIframeLikeElementCenter(hitElement, moveEvent, scenePointer.x, scenePointer.y))) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"hover\"\n }\n });\n return true;\n } else if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.state) === \"hover\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n\n return false;\n };\n\n this.isDoubleClick = (lastPointerEvent, currentPointerEvent) => {\n return lastPointerEvent != null && currentPointerEvent.timeStamp - lastPointerEvent.timeStamp <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TAP_TWICE_TIMEOUT;\n };\n\n this.updateEmbedValidationStatus = (element, status) => {\n this.embedsValidationStatus.set(element.id, status);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(element)) {\n iframeLikes.add(element.id);\n\n if (!this.embedsValidationStatus.has(element.id)) {\n updated = true;\n const validated = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(element.link, this.props.validateEmbeddable);\n this.updateEmbedValidationStatus(element, validated);\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.viewportCoordsToSceneCoords)({\n clientX: box.x,\n clientY: box.y\n }, this.state);\n const boxSceneBottomRight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 /**\n * @private\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 var _a;\n\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_6__.THEME.DARK; //zsviczian\n\n const nonDeletedFramesLikes = this.state.frameRendering.markerName && this.state.frameRendering.markerEnabled ? this.scene.getNonDeletedFramesLikes() : this.scene.getNonDeletedFramesLikes().filter(f => f.frameRole !== \"marker\");\n const focusedSearchMatch = nonDeletedFramesLikes.length > 0 ? ((_a = this.state.searchMatches) === null || _a === void 0 ? void 0 : _a.focusedId) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(this.scene.getElement(this.state.searchMatches.focusedId)) ? this.state.searchMatches.matches.find(sm => sm.focus) : null : null;\n return nonDeletedFramesLikes.map(f => {\n var _a, _b;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.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_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.resetEditingFrame(f);\n }\n },\n style: {\n background: isDarkTheme ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.applyDarkModeFilter)(this.state.viewBackgroundColor) : this.state.viewBackgroundColor,\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 //zsviczian (change to container)\n fontFamily: \"Assistant\",\n fontSize: `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameFontSize}px`,\n transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`,\n color: isDarkTheme ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorLightTheme,\n overflow: \"hidden\",\n maxWidth: `${(0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.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 className: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CLASSES.FRAME_NAME,\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_6__.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_6__.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_6__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorLightTheme,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameLineHeight,\n width: \"max-content\",\n maxWidth: (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.id) === f.id && (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.focus) ? \"none\" : `${f.width * this.state.zoom.value}px`,\n overflow: f.id === this.state.editingFrame ? \"visible\" : \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n cursor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE,\n pointerEvents: this.state.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.getSceneElementsMapIncludingDeleted = () => {\n return this.scene.getElementsMapIncludingDeleted();\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_21__.trackEvent)(\"export\", type, \"ui\");\n const fileHandle = await (0,_data__WEBPACK_IMPORTED_MODULE_24__.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_6__.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_32__.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_6__.TOOL_TYPE.magicframe\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"tool-select (empty-selection)\", \"d2c\");\n } else {\n const selectedMagicFrame = selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(el) || el.frameId)) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe\n });\n return;\n }\n\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.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__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const padding = 50;\n frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.insertNewElement(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_56__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n } else {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemBackgroundColor: color\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n [shouldUpdateStrokeColor ? \"strokeColor\" : \"backgroundColor\"]: color\n });\n }\n\n return el;\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n },\n keepOpenOnAlt: false\n });\n };\n\n this.dismissLinearEditor = () => {\n setTimeout(() => {\n var _a;\n\n if ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isEditing: false\n })\n });\n }\n });\n };\n\n this.syncActionResult = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(actionResult => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.unmounted || actionResult === false) {\n return;\n }\n\n this.store.scheduleAction(actionResult.captureUpdate);\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_6__.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_7__.isNonDeletedElement)(element) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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) {\n this.scene.triggerUpdate();\n }\n }); // Lifecycle\n\n this.onBlur = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(() => {\n isHoldingSpace = false;\n this.setState({\n isBindingEnabled: this.state.bindingPreference === \"enabled\"\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 }; // zsviczian\n\n\n this.undo = () => this.actionManager.executeAction(this.actionManager.actions.undo, \"api\"); // zsviczian\n\n\n this.redo = () => this.actionManager.executeAction(this.actionManager.actions.redo, \"api\");\n\n this.resetStore = () => {\n this.store.clear();\n };\n /**\n * Resets scene & history.\n * ! Do not use to clear scene user action !\n */\n\n\n this.resetScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(opts => {\n this.scene.replaceAllElements([]);\n this.setState(state => Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_22__.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 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 restoredElements = (0,_data_restore__WEBPACK_IMPORTED_MODULE_26__.restoreElements)(initialData === null || initialData === void 0 ? void 0 : initialData.elements, null, {\n repairBindings: true,\n deleteInvisibleElements: true\n });\n let restoredAppState = (0,_data_restore__WEBPACK_IMPORTED_MODULE_26__.restoreAppState)(initialData === null || initialData === void 0 ? void 0 : initialData.appState, null);\n const activeTool = restoredAppState.activeTool;\n\n if (!restoredAppState.preferredSelectionTool.initialized) {\n restoredAppState.preferredSelectionTool = {\n type: this.editorInterface.formFactor === \"phone\" ? \"lasso\" : \"selection\",\n initialized: true\n };\n }\n\n restoredAppState = Object.assign(Object.assign({}, restoredAppState), {\n theme: this.props.theme || restoredAppState.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: (restoredAppState === null || restoredAppState === void 0 ? void 0 : restoredAppState.openSidebar) || this.state.openSidebar,\n activeTool: activeTool.type === \"image\" || activeTool.type === \"lasso\" || activeTool.type === \"selection\" ? Object.assign(Object.assign({}, activeTool), {\n type: restoredAppState.preferredSelectionTool.type\n }) : restoredAppState.activeTool,\n isLoading: false,\n toast: this.state.toast\n });\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.scrollToContent) {\n restoredAppState = Object.assign(Object.assign({}, restoredAppState), (0,_scene__WEBPACK_IMPORTED_MODULE_30__.calculateScrollCenter)(restoredElements, Object.assign(Object.assign({}, restoredAppState), {\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({\n elements: restoredElements,\n appState: restoredAppState,\n files: initialData === null || initialData === void 0 ? void 0 : initialData.files,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(window.location.href)) {\n this.scrollToContent(window.location.href, {\n animate: false\n });\n }\n };\n\n this.getFormFactor = (editorWidth, editorHeight) => {\n var _a, _b, _c, _d, _e;\n\n if (((_b = (_a = this.props.UIOptions).getFormFactor) === null || _b === void 0 ? void 0 : _b.call(_a, editorWidth, editorHeight)) === \"phone\" && !this.allowMobileMode) {\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFormFactor)(editorWidth, editorHeight, this.allowMobileMode); //zsviczian\n }\n\n return (_e = (_d = (_c = this.props.UIOptions).getFormFactor) === null || _d === void 0 ? void 0 : _d.call(_c, editorWidth, editorHeight)) !== null && _e !== void 0 ? _e : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFormFactor)(editorWidth, editorHeight, this.allowMobileMode) //zsviczian\n ;\n };\n\n this.refreshEditorInterface = () => {\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 storedDesktopUIMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.loadDesktopUIModePreference)();\n const userAgentDescriptor = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.createUserAgentDescriptor)(typeof navigator !== \"undefined\" ? navigator.userAgent : \"\"); // allow host app to control formFactor and desktopUIMode via props\n\n const sidebarBreakpoint = this.props.UIOptions.dockedSidebarBreakpoint != null ? this.props.UIOptions.dockedSidebarBreakpoint : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_RIGHT_SIDEBAR_MIN_WIDTH;\n const nextEditorInterface = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.editorInterface, {\n desktopUIMode: storedDesktopUIMode !== null && storedDesktopUIMode !== void 0 ? storedDesktopUIMode : this.editorInterface.desktopUIMode,\n formFactor: this.getFormFactor(editorWidth, editorHeight),\n userAgent: userAgentDescriptor,\n canFitSidebar: editorWidth > sidebarBreakpoint,\n isLandscape: editorWidth > editorHeight\n });\n this.editorInterface = nextEditorInterface;\n this.reconcileStylesPanelMode(nextEditorInterface);\n };\n\n this.reconcileStylesPanelMode = nextEditorInterface => {\n const nextStylesPanelMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(nextEditorInterface);\n\n if (nextStylesPanelMode === this.stylesPanelMode) {\n return;\n }\n\n const prevStylesPanelMode = this.stylesPanelMode;\n this.stylesPanelMode = nextStylesPanelMode;\n\n if (prevStylesPanelMode !== \"full\" && nextStylesPanelMode === \"full\" || prevStylesPanelMode !== \"tray\" && nextStylesPanelMode === \"tray\" //zsviczian\n ) {\n this.setState(prevState => ({\n preferredSelectionTool: {\n type: \"selection\",\n initialized: true\n }\n }));\n }\n };\n /** TO BE USED LATER */\n\n\n this.setDesktopUIMode = mode => {\n const nextMode = mode; //setDesktopUIMode(mode); //zsviczian\n\n this.editorInterface = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.editorInterface, {\n desktopUIMode: nextMode\n });\n this.reconcileStylesPanelMode(this.editorInterface);\n this.refreshEditorInterface(); //zsviczian (set formfactor for mobile if needed (phone or tablet))\n\n this.triggerRender(true); //zsviczian\n }; //zsviczian\n\n\n this.isTouchScreen = () => {\n return this.editorInterface.isTouchScreen;\n }; //zsviczian\n\n\n this.isTrayModeEnabled = () => {\n return this.editorInterface.desktopUIMode === \"tray\";\n };\n\n this.onResize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(() => {\n this.scene.getElementsIncludingDeleted().forEach(element => _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element));\n this.refreshEditorInterface();\n this.updateDOMRect();\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_6__.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_6__.SCROLL_TIMEOUT); // Copy/paste\n\n this.onCut = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n this.onCopy = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.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_6__.isIOS) {\n event.preventDefault();\n }\n\n if (!didTapTwice) {\n didTapTwice = true;\n\n if (event.touches.length === 1) {\n firstTapPosition = {\n x: event.touches[0].clientX,\n y: event.touches[0].clientY\n };\n }\n\n clearTimeout(tappedTwiceTimer);\n tappedTwiceTimer = window.setTimeout(App.resetTapTwice, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TAP_TWICE_TIMEOUT);\n return;\n } // insert text only if we tapped twice with a single finger at approximately the same position\n // event.touches.length === 1 will also prevent inserting text when user's zooming\n\n\n if (didTapTwice && event.touches.length === 1 && firstTapPosition) {\n const touch = event.touches[0];\n const distance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(touch.clientX, touch.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(firstTapPosition.x, firstTapPosition.y)); // only create text if the second tap is within the threshold of the first tap\n // this prevents accidental text creation during dragging/selection\n\n if (distance <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DOUBLE_TAP_POSITION_THRESHOLD) {\n // end lasso trail and deselect elements just in case\n this.lassoTrail.endPath();\n this.deselectElements();\n this.handleCanvasDoubleClick({\n clientX: touch.clientX,\n clientY: touch.clientY,\n type: \"touch\",\n altKey: false,\n ctrlKey: false,\n metaKey: false,\n shiftKey: false\n });\n }\n\n didTapTwice = false;\n clearTimeout(tappedTwiceTimer);\n }\n\n if (event.touches.length === 2) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n } else {\n gesture.pointers.clear();\n }\n };\n\n this.pasteFromClipboard = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(async event => {\n var _a;\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_6__.isWritableElement)(target))) {\n return;\n } // 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\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_23__.parseDataTransferEvent)(event);\n const filesList = dataTransferList.getFiles();\n const data = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_23__.parseClipboard)(dataTransferList, isPlainPaste);\n\n if (this.props.onPaste) {\n try {\n if ((await this.props.onPaste(data, event, filesList)) === false) {\n //zsviczian\n return;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n await this.insertClipboardContent(data, filesList, isPlainPaste);\n this.setActiveTool({\n type: this.state.preferredSelectionTool.type\n }, true);\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_26__.restoreElements)(opts.elements, null, {\n deleteInvisibleElements: true\n });\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(elements);\n const elementsCenterX = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(minX, maxX) / 2;\n const elementsCenterY = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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_6__.getGridPoint)(dx, dy, this.getEffectiveGridSize());\n const {\n duplicatedElements\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: elements.map(element => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(element, {\n x: element.x + gridX - minX,\n y: element.y + gridY - minY\n });\n }),\n randomizeSeed: !opts.retainSeed,\n preserveFrameChildrenOrder: opts.preserveFrameChildrenOrder\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__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(nextElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(duplicatedElements));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n\n if (topLayerFrame) {\n const eligibleElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.filterElementsEligibleAsFrameChildren)(duplicatedElements, topLayerFrame);\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, eligibleElements, topLayerFrame);\n }\n\n this.scene.replaceAllElements(nextElements);\n duplicatedElements.forEach(newElement => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(newElement)) {\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(newElement, this.scene.getElementsMapIncludingDeleted());\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_35__.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 const nextElementsToSelect = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.excludeElementsInFramesFromSelection)(duplicatedElements);\n this.store.scheduleCapture();\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.editorInterface.canFitSidebar && _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_62__.isSidebarDockedAtom) ? this.state.openSidebar : null\n }), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: null,\n selectedElementIds: nextElementsToSelect.reduce((acc, element) => {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: this.state.preferredSelectionTool.type\n }, true);\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_21__.trackEvent)(\"toolbar\", \"toggleLock\", `${source} (${this.editorInterface.formFactor === \"phone\" ? \"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_6__.updateActiveTool)(this.state, prevState.activeTool.locked ? {\n type: this.state.preferredSelectionTool.type\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, _e, _f;\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 //zsviczian\n markerName: (_e = next === null || next === void 0 ? void 0 : next.markerName) !== null && _e !== void 0 ? _e : prevState.frameRendering.markerName,\n markerEnabled: (_f = next === null || next === void 0 ? void 0 : next.markerEnabled) !== null && _f !== void 0 ? _f : prevState.frameRendering.markerEnabled\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_10__.actionToggleHandTool));\n };\n /**\n * Zooms on canvas viewport center\n */\n\n\n this.zoomCanvas = (\n /**\n * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.\n * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom\n */\n value) => {\n this.setState(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_31__.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_30__.getNormalizedZoom)(value)\n }, this.state)));\n };\n\n this.cancelInProgressAnimation = null;\n\n this.scrollToContent = (\n /**\n * target to scroll to\n *\n * - string - id of element or group, or url containing elementLink\n * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects\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__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n id = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n this.setState({\n toast: {\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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_10__.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_30__.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_6__.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_6__.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_70__.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_10__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(el)) {\n return;\n } // First select the element\n\n\n this.setState({\n selectedElementIds: {\n [el.id]: true\n }\n }, () => {\n // Then set up the editor\n const linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(el, this.scene.getNonDeletedElementsMap());\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n isEditing: true,\n selectedPointsIndices\n })\n });\n });\n }; //zsviczian\n\n\n this.refreshAllArrows = () => {\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.refreshAllArrows)(this.scene, this.store);\n }; //zsviczian\n\n\n this.updateContainerSize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(containers => {\n containers.forEach(element => {\n // Get absolute coordinates for the bottom-right corner\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getNextSingleWidthAndHeightFromPointer)(element, element, \"se\", pointerX, pointerY);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.APP_NAME, window.location.pathname);\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n };\n /**\n * adds supplied files to existing files in the appState.\n * NOTE if file already exists in editor state, the file data is not updated\n * */\n\n\n this.addFiles = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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 this.allowMobileMode = allow;\n this.refreshEditorInterface();\n this.triggerRender();\n this.setDesktopUIMode(this.editorInterface.desktopUIMode);\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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_8__.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_8__.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_8__.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_8__.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_6__.MIME_TYPES.svg) {\n try {\n const restoredDataURL = (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.getDataURL_sync)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)((0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.dataURLToString)(fileData.dataURL)), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdates)(sceneData => {\n const {\n elements,\n appState,\n collaborators,\n captureUpdate\n } = sceneData;\n\n if (captureUpdate) {\n const nextElements = elements ? elements : undefined;\n const observedAppState = appState ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getObservedAppState)(Object.assign(Object.assign({}, this.store.snapshot.appState), appState)) : undefined;\n this.store.scheduleMicroAction({\n action: captureUpdate,\n elements: nextElements,\n appState: observedAppState\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 (appState) {\n this.setState(appState);\n }\n });\n } else if (appState) {\n this.setState(appState);\n }\n\n if (elements) {\n this.scene.replaceAllElements(elements);\n }\n\n if (collaborators) {\n this.laserTrails.updateCollabTrails(collaborators);\n this.setState({\n collaborators\n });\n }\n });\n\n this.applyDeltas = (deltas, options) => {\n // squash all deltas together, starting with a fresh new delta instance\n const aggregatedDelta = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.squash(...deltas); // create new instance of elements map & appState, so we don't accidentaly mutate existing ones\n\n const nextAppState = Object.assign({}, this.state);\n const nextElements = new Map(this.scene.getElementsMapIncludingDeleted());\n return _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.applyTo(aggregatedDelta, nextElements, nextAppState, options);\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 /**\n * @returns whether the menu was toggled on or off\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_43__.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_29__.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_43__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\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_6__.isInputLike)(event.target)) {\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) && this.state.croppingElementId) {\n this.finishImageCropping();\n return;\n }\n\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_30__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0]) && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.startImageCropping(selectedElements[0]);\n return;\n } // Shape switching\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom, null);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.CLASSES.CONVERT_ELEMENT_TYPE_POPUP)))) {\n event.preventDefault();\n const conversionType = (0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.getConversionTypeFromElements)(selectedElements);\n\n if (((_c = _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom)) === null || _c === void 0 ? void 0 : _c.type) === \"panel\") {\n if ((0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypes)(this, {\n conversionType,\n direction: event.shiftKey ? \"left\" : \"right\"\n })) {\n this.store.scheduleCapture();\n }\n }\n\n if (conversionType) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom, {\n type: \"panel\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.isArrowKey)(event.key);\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && arrowKeyPressed && !event.shiftKey) {\n event.preventDefault();\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_30__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFlowchartNodeElement)(selectedElements[0])) {\n this.flowChartCreator.createNodes(selectedElements[0], this.state, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key), this.scene);\n }\n\n if (((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_30__.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__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key));\n\n if (nextId) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [nextId]: true\n }, prevState)\n }));\n const nextNode = this.scene.getNonDeletedElementsMap().get(nextId);\n\n if (nextNode && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.P && !event.shiftKey && !event.altKey) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"commandPalette.shortcutHint\", {\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__.getShortcutFromShortcutName)(\"commandPalette\")\n })\n });\n event.preventDefault();\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n if (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.isWritableElement)(event.target) && // unless pressing escape (finalize action)\n event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || // or unless using arrows (to move between buttons)\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target)) {\n return;\n } //mfuria #329. open context menu with 'm' if not editing text and container focused\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isPanWithRightMouseEnabled)() && event.key.toLowerCase() === 'm' && !this.state.editingTextElement && // don't trigger when typing in inputs\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target) && ( // ensure focus is within excalidraw container\n (_f = (_e = this.excalidrawContainerRef) === null || _e === void 0 ? void 0 : _e.current) === null || _f === void 0 ? void 0 : _f.contains(document.activeElement))) {\n // open context menu at current cursor position\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = this.lastViewportPosition.x - offsetLeft;\n const top = this.lastViewportPosition.y - offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, 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 this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n event.preventDefault();\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.E && event.shiftKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.PAGE_UP || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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 (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") {\n return;\n } // Handle Alt key for bind mode\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT) {\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleSkipBindMode();\n } else {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n }\n\n if (this.actionManager.handleKeyDown(event)) {\n return;\n } // view mode hardcoded from upstream -> disable tool switching for now\n\n\n const shouldPreventToolSwitching = this.props.viewModeEnabled === true;\n\n if (!shouldPreventToolSwitching && this.state.viewModeEnabled && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE) {\n this.setActiveTool({\n type: \"selection\"\n });\n return;\n }\n\n if (!shouldPreventToolSwitching && !event.ctrlKey && !event.altKey && !event.metaKey && !this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged) {\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_68__.findShapeByKey)(event.key, this);\n\n if (this.state.viewModeEnabled && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.oneOf)(shape, [\"laser\", \"hand\"])) {\n return;\n }\n\n if (shape) {\n if (this.state.activeTool.type !== shape) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"toolbar\", shape, `keyboard (${this.editorInterface.formFactor === \"phone\" ? \"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_6__.ARROW_TYPE.sharp ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round : prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.sharp\n }));\n }\n\n if (shape === \"lasso\" && this.state.activeTool.type === \"laser\") {\n this.setActiveTool({\n type: this.state.preferredSelectionTool.type\n });\n } else {\n this.setActiveTool({\n type: shape\n });\n }\n\n event.stopPropagation();\n return;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.Q) {\n this.toggleLock(\"keyboard\");\n event.stopPropagation();\n return;\n }\n }\n\n if (this.state.viewModeEnabled) {\n // revert to selection in case a key is pressed (K is handled above)\n if (event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K) {\n this.setActiveTool({\n type: \"selection\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !event.repeat) {\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.resetDelayedBindMode();\n }\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n isBindingEnabled: this.state.bindingPreference !== \"enabled\"\n });\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n let selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n const arrowIdsToRemove = new Set();\n selectedElements.filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(el)).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_6__.ELEMENT_TRANSLATE_AMOUNT : this.getEffectiveGridSize()) || (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_SHIFT_TRANSLATE_AMOUNT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_TRANSLATE_AMOUNT);\n let offsetX = 0;\n let offsetY = 0;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_LEFT) {\n offsetX = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_RIGHT) {\n offsetX = step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_UP) {\n offsetY = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene, {\n simultaneouslyUpdated: selectedElements\n });\n });\n this.scene.triggerUpdate();\n event.preventDefault();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedElement)) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElement)) {\n if (!((_h = this.state.selectedLinearElement) === null || _h === void 0 ? void 0 : _h.isEditing) || this.state.selectedLinearElement.elementId !== selectedElement.id) {\n this.store.scheduleCapture();\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElement)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n }\n }\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isValidTextContainer)(selectedElement)) {\n let container;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n container = selectedElement;\n }\n\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(selectedElement)) {\n this.setState({\n editingFrame: selectedElement.id\n });\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(selectedElement)) {\n //zsviczian\n this.setState({\n activeEmbeddable: {\n element: selectedElement,\n state: \"active\"\n }\n });\n }\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE && gesture.pointers.size === 0) {\n isHoldingSpace = true;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n event.preventDefault();\n }\n\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.G && ((0,_scene__WEBPACK_IMPORTED_MODULE_30__.hasBackground)(this.state.activeTool.type) || selectedElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_30__.hasBackground)(element.type)))) {\n this.setState({\n openPopup: \"elementBackground\"\n });\n event.stopPropagation();\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) {\n this.setState({\n openPopup: \"elementStroke\"\n });\n event.stopPropagation();\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(element, this.scene.getNonDeletedElementsMap()))) {\n event.preventDefault();\n this.setState({\n openPopup: \"fontFamily\"\n });\n }\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.BACKSPACE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.DELETE)) {\n this.updateEditorAtom(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_53__.activeConfirmDialogAtom, \"clearCanvas\");\n } // eye dropper\n // -----------------------------------------------------------------------\n\n\n const lowerCased = event.key.toLocaleLowerCase();\n const isPickingStroke = lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S && event.shiftKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD];\n const isPickingBackground = event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.I || lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdates)(event => {\n var _a, _b, _c;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE) {\n if (this.state.viewModeEnabled && this.state.activeTool.type !== \"laser\" || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(this.state.activeTool.type)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n isHoldingSpace = false;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT && this.state.bindMode === \"skip\" || !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state)) {\n // Handle Alt key release for bind mode\n this.setState({\n bindMode: \"orbit\"\n }); // Restart the timer if we're creating/editing a linear element and hovering over an element\n\n if (this.lastPointerMoveEvent && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastPointerMoveEvent.clientX,\n clientY: this.lastPointerMoveEvent.clientY\n }, this.state);\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap());\n\n if (this.state.selectedLinearElement) {\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n this.handleDelayedBindModeChange(element, hoveredElement);\n }\n }\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n const preferenceEnabled = this.state.bindingPreference === \"enabled\";\n\n if (this.state.isBindingEnabled !== preferenceEnabled) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n isBindingEnabled: preferenceEnabled\n });\n });\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindBindingElements)(this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement), this.scene, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow).forEach(element => {\n // Update the fixed point bindings for non-elbow arrows\n // when the pointer is released, so that they are correctly positioned\n // after the drag.\n if (element.startBinding) {\n this.scene.mutateElement(element, {\n startBinding: Object.assign(Object.assign({}, element.startBinding), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.calculateFixedPointForNonElbowArrowBinding)(element, elementsMap.get(element.startBinding.elementId), \"start\", elementsMap))\n });\n }\n\n if (element.endBinding) {\n this.scene.mutateElement(element, {\n endBinding: Object.assign(Object.assign({}, element.endBinding), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.calculateFixedPointForNonElbowArrowBinding)(element, elementsMap.get(element.endBinding.elementId), \"end\", elementsMap))\n });\n }\n });\n this.setState({\n suggestedBinding: null\n });\n }\n\n if (!event.altKey) {\n if (this.flowChartNavigator.isExploring) {\n this.flowChartNavigator.clear();\n this.syncActionResult({\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (this.flowChartCreator.isCreatingChart) {\n if ((_b = this.flowChartCreator.pendingNodes) === null || _b === void 0 ? void 0 : _b.length) {\n this.insertNewElements(this.flowChartCreator.pendingNodes);\n }\n\n const firstNode = (_c = this.flowChartCreator.pendingNodes) === null || _c === void 0 ? void 0 : _c[0];\n\n if (firstNode) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [firstNode.id]: true\n }, prevState)\n }));\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 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_6__.updateActiveTool)(this.state, tool);\n\n if (nextActiveTool.type === \"hand\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (!isHoldingSpace) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, Object.assign(Object.assign({}, this.state), {\n activeTool: nextActiveTool\n }));\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isToolIcon)(document.activeElement)) {\n this.focusContainer();\n }\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElementType)(nextActiveTool.type)) {\n this.setState({\n suggestedBinding: null\n });\n }\n\n if (nextActiveTool.type === \"image\") {\n this.onImageToolbarButtonClick();\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 selectedLinearElement: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(nextActiveTool.type) ? prevState.selectedLinearElement : null,\n frameToHighlight: null\n };\n\n if (nextActiveTool.type === \"freedraw\") {\n this.store.scheduleCapture();\n }\n\n if (nextActiveTool.type === \"lasso\") {\n return Object.assign(Object.assign(Object.assign(Object.assign({}, prevState), commonResets), {\n activeTool: nextActiveTool\n }), keepSelection ? {} : {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n });\n } else if (nextActiveTool.type !== \"selection\") {\n return Object.assign(Object.assign(Object.assign({}, prevState), commonResets), {\n activeTool: nextActiveTool,\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextActiveTool.type === \"mermaid\" //zsviczian\n ? this.state.selectedElementIds : {}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n });\n }\n\n return Object.assign(Object.assign(Object.assign({}, prevState), commonResets), {\n activeTool: nextActiveTool\n });\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_40__.setCursor)(this.interactiveCanvas, cursor);\n };\n\n this.resetCursor = () => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n };\n /**\n * returns whether user is making a gesture with >= 2 fingers (points)\n * on o touch screen (not on a trackpad). Currently only relates to Darwin\n * (iOS/iPadOS,MacOS), but may work on other devices in the future if\n * GestureEvent is standardized.\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_29__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`;\n }; // fires only on Safari\n\n\n this.onGestureStart = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(event => {\n //zsviczian - start\n // If an embeddable is active and the pinch starts over it, let it handle the gesture.\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.shouldDisableZoom)(this.state)) {\n gesture.initialScale = null;\n return;\n }\n\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__WEBPACK_IMPORTED_MODULE_7__.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_43__.withBatchedUpdates)(event => {\n //zsviczian\n if (!gesture.initialScale) {\n return;\n }\n\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_31__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_30__.getNormalizedZoom)(initialScale * event.scale)\n }, state)));\n }\n }); // fires only on Safari\n\n this.onGestureEnd = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n }\n\n gesture.initialScale = null;\n });\n\n this.isHittingTextAutoResizeHandle = (selectedElements, point) => {\n const activeTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getActiveTextElement)(selectedElements, this.state);\n\n if (activeTextElement && !activeTextElement.isDeleted && !activeTextElement.autoResize && (0,_textAutoResizeHandle__WEBPACK_IMPORTED_MODULE_44__.isPointHittingTextAutoResizeHandle)(point, activeTextElement, this.state.zoom.value, this.editorInterface.formFactor)) {\n return true;\n }\n\n return false;\n };\n\n this.handleTextAutoResizeHandlePointerDown = (selectedElements, point) => {\n const activeTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getActiveTextElement)(selectedElements, this.state);\n\n if (!activeTextElement || !this.isHittingTextAutoResizeHandle(selectedElements, point)) {\n return false;\n }\n\n this.actionManager.executeAction(_actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__.actionTextAutoResize, \"ui\", // we need to pass down the element since it may already be deselected\n // due to the pointerdown\n activeTextElement);\n this.resetCursor();\n return true;\n };\n\n this.startTextEditing = ({\n sceneX,\n sceneY,\n insertAtParentCenter = true,\n container,\n autoEdit = true,\n initialCaretSceneCoords\n }) => {\n var _a, _b;\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__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(container, this.scene.getNonDeletedElementsMap());\n\n if (!boundTextElementToContainer) {\n shouldBindToContainer = true;\n }\n }\n\n const existingTextElement = this.getSelectedTextElement(container) || this.getTextElementAtPosition(sceneX, sceneY);\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_6__.getLineHeight)(fontFamily);\n const fontSize = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_72__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value); //zsviczian\n\n if (!existingTextElement && shouldBindToContainer && container && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n const fontString = {\n fontSize,\n fontFamily\n };\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getApproxMinLineWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)(fontString), lineHeight);\n const minHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 textCreationGridPoint = this.getTextCreationGridPoint(sceneX, sceneY);\n const newTextElementPosition = parentCenterPosition ? {\n x: parentCenterPosition.elementCenterX,\n y: parentCenterPosition.elementCenterY\n } : !existingTextElement ? {\n x: (_a = textCreationGridPoint === null || textCreationGridPoint === void 0 ? void 0 : textCreationGridPoint.x) !== null && _a !== void 0 ? _a : sceneX,\n y: textCreationGridPoint === null ? // Free text starts from a point cursor, so center the first line box on it.\n sceneY - (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLineHeightInPx)(fontSize, lineHeight) / 2 : textCreationGridPoint.y\n } : {\n x: sceneX,\n y: sceneY\n };\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: newTextElementPosition.x,\n y: newTextElementPosition.y\n }); // container has higher priority. Only add to frame if container is in the same frame.\n\n const frameId = topLayerFrame && (!shouldBindToContainer || !container || container.frameId === topLayerFrame.id) ? topLayerFrame.id : null;\n const element = existingTextElement || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newTextElement)({\n x: newTextElementPosition.x,\n y: newTextElementPosition.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 roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text: \"\",\n rawText: \"\",\n //zsviczian\n fontSize,\n fontFamily,\n textAlign: parentCenterPosition ? \"center\" : this.state.currentItemTextAlign,\n verticalAlign: parentCenterPosition ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.VERTICAL_ALIGN.MIDDLE : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n containerId: shouldBindToContainer ? container === null || container === void 0 ? void 0 : container.id : undefined,\n groupIds: (_b = container === null || container === void 0 ? void 0 : container.groupIds) !== null && _b !== void 0 ? _b : [],\n lineHeight,\n angle: container ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) ? 0 : container.angle : 0,\n frameId\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); // TODO should use insertNewElement, after we update it to handle\n // elements with containerId + frameId at the same time (containerId\n // should take precedence when it comes to z-index)\n\n this.scene.insertElementsAtIndex([element], containerIndex + 1);\n } else {\n this.insertNewElement(element);\n }\n }\n\n if (autoEdit || existingTextElement || container) {\n this.handleTextWysiwyg(element, {\n isExistingElement: !!existingTextElement,\n initialCaretSceneCoords: existingTextElement ? initialCaretSceneCoords : null\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.scheduleCapture();\n this.setState({\n croppingElementId: image.id\n });\n };\n\n this.finishImageCropping = () => {\n if (this.state.croppingElementId) {\n this.store.scheduleCapture();\n this.setState({\n croppingElementId: null\n });\n }\n };\n\n this.shouldHandleBrowserCanvasDoubleClick = type => {\n // TODO remove this once we consolidate double-click logic and handle\n // ourselves for all event types together\n if (type === \"touch\") {\n return true;\n }\n\n if (this.lastCompletedCanvasClicks.length === 0) {\n return true;\n }\n\n if (this.lastCompletedCanvasClicks.length < 2) {\n return false;\n }\n\n const [firstClick, secondClick] = this.lastCompletedCanvasClicks;\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(firstClick.x, firstClick.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(secondClick.x, secondClick.y)) <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DOUBLE_TAP_POSITION_THRESHOLD;\n };\n\n this.handleCanvasDoubleClick = event => {\n var _a, _b, _c, _d;\n\n if (this.state.editingTextElement || !this.shouldHandleBrowserCanvasDoubleClick(event.type)) {\n return;\n } // 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_70__.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_10__.actionToggleEraserTool.perform([], this.state, null, this));\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 !== this.state.preferredSelectionTool.type) {\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_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0])) {\n const selectedLinearElement = selectedElements[0];\n\n if ((event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow)(selectedLinearElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) && (!((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.isEditing) || this.state.selectedLinearElement.elementId !== selectedLinearElement.id)) {\n // Use the proper action to ensure immediate history capture\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n return;\n } else if (this.state.selectedLinearElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) {\n const hitCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(this.state.selectedLinearElement, {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const midPoint = hitCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, hitCoords, this.scene.getNonDeletedElementsMap()) : -1;\n\n if (midPoint && midPoint > -1) {\n this.store.scheduleCapture();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.deleteFixedSegment(selectedElements[0], this.scene, midPoint);\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n segmentMidpoint: {\n index: nextIndex,\n value: hitCoords,\n added: false\n }\n }),\n segmentMidPointHoveredCoords: nextCoords\n })\n });\n return;\n }\n } else if (((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing) && this.state.selectedLinearElement.elementId === selectedLinearElement.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) {\n return;\n }\n }\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0])) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n const selectedGroupIds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIds)(this.state);\n\n if (selectedGroupIds.length > 0) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n const selectedGroupId = hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIdForElement)(hitElement, this.state.selectedGroupIds);\n\n if (selectedGroupId) {\n this.store.scheduleCapture();\n this.setState(prevState => Object.assign(Object.assign({}, prevState), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_40__.resetCursor)(this.interactiveCanvas);\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !this.state.viewModeEnabled) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement)) {\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"active\"\n }\n });\n return;\n } // shouldn't edit/create text when inside line editor (often false positive)\n\n\n if (!((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing)) {\n const container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if (container) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hasBoundTextElement)(container) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isTransparent)(container.backgroundColor) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(sceneX, sceneY),\n element: container,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(container)\n })) {\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_70__.disableDoubleClickTextEditing)()) {\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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\n this.handleCanvasClick = event => {\n if (event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN) {\n this.lastCompletedCanvasClicks = [];\n return;\n }\n\n this.lastCompletedCanvasClicks = [...this.lastCompletedCanvasClicks.slice(-1), {\n x: event.clientX,\n y: event.clientY\n }];\n };\n\n this.getElementLinkAtPosition = (scenePointer, hitElementMightBeLocked) => {\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n return undefined;\n }\n\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 (hitElementMightBeLocked && element.id === hitElementMightBeLocked.id) {\n hitElementIndex = index;\n }\n\n if ((element.link || element.hasTextLink) && //zsviczian\n index >= hitElementIndex && (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__.isPointHittingLink)(element, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.editorInterface.formFactor === \"phone\")) {\n return element;\n }\n }\n };\n\n this.handleElementLinkClick = event => {\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_6__.DRAGGING_THRESHOLD) {\n return;\n }\n\n const lastPointerDownCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerDownEvent, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const lastPointerDownHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerDownCoords.x, lastPointerDownCoords.y), this.editorInterface.formFactor === \"phone\");\n const lastPointerUpCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerUpEvent, this.state);\n const lastPointerUpHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerUpCoords.x, lastPointerUpCoords.y), this.editorInterface.formFactor === \"phone\");\n\n if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_34__.hideHyperlinkToolip)();\n let url = this.hitLinkElement.link;\n\n if (url || this.hitLinkElement.hasTextLink) {\n //zsviczian\n url = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(url !== null && url !== void 0 ? url : \"\"); //zsviczian\n\n let customEvent;\n\n if (this.props.onLinkOpen) {\n customEvent = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.wrapEvent)(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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 * finds candidate frame under cursor (when dragging frame children/elements\n * inside frames)\n */\n\n\n this.getTopLayerFrameAtSceneCoords = (\n /**\n * should be already grid aligned (basically should be what the call site\n * sets the element's coords to, if applicable)\n */\n sceneCoords, opts) => {\n var _a, _b;\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const framesUnderCursor = this.scene.getNonDeletedFramesLikes().filter(frame => !frame.locked && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isCursorInFrame)(sceneCoords, frame, elementsMap) && frame.frameRole !== \"marker\");\n\n if (!framesUnderCursor.length) {\n return null;\n }\n\n const topLayerFrame = framesUnderCursor.at(-1);\n const hitElement = this.getElementsAtPosition(sceneCoords.x, sceneCoords.y, {\n includeLockedElements: true\n }).findLast(element => {\n var _a;\n\n return !((_a = opts === null || opts === void 0 ? void 0 : opts.excludeElementIds) === null || _a === void 0 ? void 0 : _a[element.id]);\n });\n\n if (hitElement) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement) && // case: we're hitting a locked frame itself (frame's outline\n // or later its bg once implemented)\n !hitElement.locked) {\n return topLayerFrame;\n }\n\n const hitElementIndex = this.scene.getElementIndex(hitElement.id);\n const topLayerFrameIndex = this.scene.getElementIndex(topLayerFrame.id);\n\n if (hitElementIndex !== -1 && topLayerFrameIndex !== -1 && hitElementIndex <= topLayerFrameIndex) {\n return topLayerFrame;\n } // to support a case of dragging a pre-existing frame child underneath\n // a non-frame element covering the cursor\n\n\n const currentFrame = (opts === null || opts === void 0 ? void 0 : opts.currentFrameId) ? (_a = framesUnderCursor.find(frame => frame.id === opts.currentFrameId)) !== null && _a !== void 0 ? _a : null : null;\n\n if (currentFrame) {\n return currentFrame;\n }\n\n return hitElement.frameId ? (_b = framesUnderCursor.find(frame => frame.id === hitElement.frameId)) !== null && _b !== void 0 ? _b : null : null;\n }\n\n return topLayerFrame;\n };\n\n this.updateFrameToHighlight = frameToHighlight => {\n if (this.state.frameToHighlight !== frameToHighlight) {\n this.setState({\n frameToHighlight\n });\n }\n };\n\n this.maybeUpdateFrameToHighlightOnPointerMove = (sceneCoords, isOverScrollBar) => {\n // currently this function is being called even during pointerdown so we\n // need to make sure we don't re-set the state when dragging and similar\n //\n // But, we still want to reset on pointermove in case the state is stale\n // so we updte even for non-eligible tool types\n if (this.state.newElement || this.state.multiElement || this.state.selectionElement || this.state.selectedElementsAreBeingDragged) {\n return;\n }\n\n this.updateFrameToHighlight(!isOverScrollBar && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEligibleFrameChildType)(this.state.activeTool.type) ? this.getTopLayerFrameAtSceneCoords(sceneCoords) : null);\n };\n\n this.insertNewElements = (elements, idx) => {\n //zsviczian added idx for highligher pens\n if (!elements.length) {\n return;\n }\n\n const chunkedElements = [];\n\n for (const element of elements) {\n const currentChunk = chunkedElements[chunkedElements.length - 1];\n\n if ((currentChunk === null || currentChunk === void 0 ? void 0 : currentChunk[0].frameId) === element.frameId) {\n currentChunk.push(element);\n } else {\n chunkedElements.push([element]);\n }\n }\n\n for (const chunk of chunkedElements) {\n const frameId = chunk[0].frameId;\n const insertionIndex = frameId ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildrenInsertionIndex)(this.scene.getElementsIncludingDeleted(), frameId) : null;\n this.scene.insertElementsAtIndex(chunk, idx !== null && idx !== void 0 ? idx : insertionIndex);\n }\n };\n\n this.insertNewElement = (element, idx) => {\n //zsviczian added idx for highligher pens\n this.insertNewElements([element], idx); //zsviczian\n\n const frame = element.frameId ? this.scene.getNonDeletedElement(element.frameId) : null;\n this.updateFrameToHighlight(frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(frame) ? frame : null);\n };\n\n this.handleCanvasPointerMove = event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n\n this.savePointer(event.clientX, event.clientY, this.state.cursorButton);\n this.lastPointerMoveEvent = event.nativeEvent;\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n this.lastPointerMoveCoords = {\n x: scenePointerX,\n y: scenePointerY\n };\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_27__.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_27__.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_30__.getNormalizedZoom)(initialScale * scaleFactor) : this.state.zoom.value;\n this.setState(state => {\n const zoomState = (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_31__.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 return null;\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_22__.isHandToolActive)(this.state)) {\n return;\n }\n\n const isPointerOverScrollBars = (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_46__.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_40__.resetCursor)(this.interactiveCanvas);\n } else if (isPenFreedraw && this.interactiveCanvas && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.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_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n this.maybeUpdateFrameToHighlightOnPointerMove({\n x: scenePointerX,\n y: scenePointerY\n }, isOverScrollBar);\n\n if (!this.state.newElement && (0,_snapping__WEBPACK_IMPORTED_MODULE_38__.isActiveToolNonLinearSnappable)(this.state.activeTool.type)) {\n const {\n originOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_38__.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_6__.updateStable)(prevState.snapLines, snapLines);\n const nextOriginOffset = prevState.originSnapOffset ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 (((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !this.state.selectedLinearElement.isDragging) {\n const editingLinearElement = this.state.newElement ? null : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMoveInEditMode(event, scenePointerX, scenePointerY, this);\n\n if (editingLinearElement && editingLinearElement !== this.state.selectedLinearElement) {\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 selectedLinearElement: editingLinearElement\n });\n });\n }\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 (!newElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state)) {\n const globalPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(globalPoint, this.scene.getNonDeletedElements(), elementsMap, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maxBindingDistance_simple)(this.state.zoom));\n\n if (hoveredElement) {\n this.setState({\n suggestedBinding: {\n element: hoveredElement,\n midPoint: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSnapOutlineMidPoint)(globalPoint, hoveredElement, elementsMap, this.state.zoom)\n }\n });\n } else if (this.state.suggestedBinding) {\n this.setState({\n suggestedBinding: null\n });\n }\n }\n }\n\n if (this.state.multiElement && this.state.selectedLinearElement) {\n const {\n multiElement,\n selectedLinearElement\n } = this.state;\n const {\n x: rx,\n y: ry,\n points\n } = multiElement;\n const lastPoint = points[points.length - 1];\n const {\n lastCommittedPoint\n } = selectedLinearElement;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n\n if (lastPoint === lastCommittedPoint) {\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(this.state.newElement) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maxBindingDistance_simple)(this.state.zoom));\n\n if (hoveredElement) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: event.nativeEvent,\n sceneCoords: {\n x: scenePointerX,\n y: scenePointerY\n }\n });\n this.setState({\n suggestedBinding: null\n });\n\n if (!this.state.activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n }),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(multiElement, this.scene.getNonDeletedElementsMap())\n }));\n }\n } else if ( // if we haven't yet created a temp point and we're beyond commit-zone\n // threshold, add a point\n (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_6__.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 (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.initialState, \"initialState must be set\");\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n lastCommittedPoint: points[points.length - 1],\n selectedPointsIndices: [multiElement.points.length - 1],\n initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n lastClickedPoint: multiElement.points.length - 1\n })\n })\n });\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.LINE_CONFIRM_THRESHOLD) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.scene.mutateElement(multiElement, {\n points: points.slice(0, -1)\n }, {\n informMutation: false,\n isDragging: false\n });\n const newLastIdx = multiElement.points.length - 1;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, selectedLinearElement), {\n selectedPointsIndices: selectedLinearElement.selectedPointsIndices ? [...new Set(selectedLinearElement.selectedPointsIndices.map(idx => Math.min(idx, newLastIdx)))] : selectedLinearElement.selectedPointsIndices,\n lastCommittedPoint: multiElement.points[newLastIdx],\n initialState: Object.assign(Object.assign({}, selectedLinearElement.initialState), {\n lastClickedPoint: newLastIdx\n })\n })\n });\n } else {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(points, this.state.zoom.value)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } // Update arrow points\n\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow)(multiElement)) {\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY), this.scene.getNonDeletedElements(), elementsMap);\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleDelayedBindModeChange(multiElement, hoveredElement);\n }\n }\n\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.state.selectedLinearElement, \"Expected selectedLinearElement to be set to operate on a linear element\");\n const newState = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event.nativeEvent, this, scenePointerX, scenePointerY, this.state.selectedLinearElement);\n\n if (newState) {\n this.setState(newState);\n }\n }\n\n return;\n }\n\n if (this.state.activeTool.type === \"arrow\") {\n const hit = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maxBindingDistance_simple)(this.state.zoom));\n const scenePointer = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (hit && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPointInElement)(scenePointer, hit, elementsMap)) {\n this.setState({\n suggestedBinding: {\n element: hit,\n midPoint: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSnapOutlineMidPoint)(scenePointer, hit, elementsMap, this.state.zoom)\n }\n });\n }\n }\n\n const isPressingAnyButton = Boolean(event.buttons);\n const isLaserTool = this.state.activeTool.type === \"laser\";\n\n if (isPressingAnyButton || // checking against laser so that if you mouseover with a laser tool\n // over a link/embeddable, we change the cursor\n !isLaserTool && this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\" && 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 (this.isHittingTextAutoResizeHandle(selectedElements, scenePointer)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n return;\n }\n\n if (selectedElements.length === 1 && !isOverScrollBar && !((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing)) {\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) && ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) !== \"elementLinkSelector\" && !(selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) && // HACK: Disable transform handles for linear elements on mobile until a\n // better way of showing them is found\n !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && (this.editorInterface.userAgent.isMobileDevice || selectedElements[0].points.length === 2))) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.editorInterface);\n\n if (elementWithTransformHandleType && elementWithTransformHandleType.transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)(elementWithTransformHandleType));\n return;\n }\n }\n } else if (selectedElements.length > 1 && !isOverScrollBar && ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== \"elementLinkSelector\") {\n const transformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.editorInterface);\n\n if (transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)({\n transformHandleType\n }));\n return;\n }\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_22__.isEraserActive)(this.state)) {\n return;\n }\n\n const hitElementMightBeLocked = this.getElementAtPosition(scenePointerX, scenePointerY, {\n preferSelected: true,\n includeLockedElements: true\n });\n let hitElement = null;\n\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n hitElement = null;\n } else {\n hitElement = hitElementMightBeLocked;\n }\n\n if (!this.handleIframeLikeElementHover({\n hitElement,\n scenePointer,\n moveEvent: event\n })) {\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElementMightBeLocked);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_34__.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_34__.hideHyperlinkToolip)();\n\n if (isLaserTool) {\n return;\n }\n\n if (hitElement && (hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_40__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(hitElement) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.TEXT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.CROSSHAIR);\n } else if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n } else if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if ( // if using cmd/ctrl, we're not dragging\n !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && // editing text -> don't show move cursor when hovering over its bbox\n (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) !== ((_g = this.state.editingTextElement) === null || _g === void 0 ? void 0 : _g.id)) {\n if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) && !(hitElement === null || hitElement === void 0 ? void 0 : hitElement.locked)) {\n if (!hitElement || // Elbow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(hitElement) || !(hitElement.startBinding || hitElement.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || selectedElements.length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n }\n\n if (((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) === \"elementLinkSelector\" && hitElement) {\n this.setState(prevState => {\n return {\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.hoveredElementIds, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this).selectedElementIds)\n };\n });\n } else if (((_j = this.state.openDialog) === null || _j === void 0 ? void 0 : _j.name) === \"elementLinkSelector\" && !hitElement) {\n this.setState(prevState => ({\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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, _d, _e; //mfuria #329. Right-click pan support when enabled via host plugin setting\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isPanWithRightMouseEnabled)() && event.pointerType === \"mouse\" && event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.SECONDARY && !this.state.editingTextElement) {\n // prevent native context menu\n const onContextMenu = e => {\n e.preventDefault();\n };\n\n window.addEventListener('contextmenu', onContextMenu, {\n once: true\n }); // Start right-click panning\n\n this.startRightClickPanning(event);\n return;\n } //zsviczian - begin\n\n\n const isInsideEmbeddableContainer = !!((_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest) === null || _b === void 0 ? void 0 : _b.call(_a, \".excalidraw__embeddable-container\"));\n\n if (!isInsideEmbeddableContainer) {\n this.focusContainer();\n } //zsviczian - end\n\n\n const selectedElements = this.scene.getSelectedElements(this.state); // If Ctrl is not held, ensure isBindingEnabled reflects the user preference.\n\n if (!event.ctrlKey) {\n const preferenceEnabled = this.state.bindingPreference === \"enabled\";\n\n if (this.state.isBindingEnabled !== preferenceEnabled) {\n this.setState({\n isBindingEnabled: preferenceEnabled\n });\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n this.lastPointerMoveCoords = {\n x: scenePointerX,\n y: scenePointerY\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 return {\n searchMatches: state.searchMatches && {\n focusedId: null,\n matches: state.searchMatches.matches.map(searchMatch => Object.assign(Object.assign({}, searchMatch), {\n focus: false\n }))\n }\n };\n });\n this.updateEditorAtom(_SearchMenu__WEBPACK_IMPORTED_MODULE_61__.searchItemInFocusAtom, null);\n }\n\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom)) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.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 if (this.state.openPopup) {\n this.setState({\n openPopup: null\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 suggestedBinding: null,\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: ((_c = this.state.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.EVENTUALLY : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.editorInterface.isTouchScreen && [\"pen\", \"touch\"].includes(event.pointerType)) {\n this.editorInterface = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.editorInterface, {\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)) {\n return;\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_6__.POINTER_BUTTON.ERASER && this.state.activeTool.type !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.eraser) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_22__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, Object.assign(Object.assign({}, this.state.activeTool.lastActiveTool || {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.selection\n }), {\n lastActiveToolBeforeEraser: null\n }))\n });\n }\n };\n\n const unsubPointerUp = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.POINTER_BUTTON.MAIN && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.TOUCH && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.handleTextAutoResizeHandlePointerDown(selectedElements, pointerDownState.origin)) {\n return;\n }\n\n if (this.handleDraggingScrollBar(event, pointerDownState)) {\n return;\n }\n\n this.clearSelectionIfNotUsingSelection();\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 const hitSelectedElement = pointerDownState.hit.element && this.isASelectedElement(pointerDownState.hit.element);\n const shouldForceLassoReselect = event.altKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !pointerDownState.resize.handleType;\n const shouldStartLassoSelection = shouldForceLassoReselect || !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements && !pointerDownState.resize.handleType && !hitSelectedElement;\n\n if (shouldStartLassoSelection) {\n if (!this.lassoTrail.hasCurrentTrail) {\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n } // block dragging after lasso selection on PCs until the next pointer down\n // (on mobile or tablet, we want to allow user to drag immediately)\n\n\n pointerDownState.drag.blockDragging = this.editorInterface.formFactor === \"desktop\";\n } // only for mobile or tablet, if we hit an element, select it immediately like normal selection\n\n\n if (this.editorInterface.formFactor !== \"desktop\" && pointerDownState.hit.element && !hitSelectedElement) {\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [pointerDownState.hit.element.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 });\n const hitElement = pointerDownState.hit.element; // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\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 === \"freedraw\") {\n this.handleFreeDrawElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"custom\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n } else if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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\" && //zsviczian\n this.state.activeTool.type !== \"image\") {\n this.createGenericElementOnPointerDown(this.state.activeTool.type, pointerDownState);\n }\n\n (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.onPointerDown) === null || _e === void 0 ? void 0 : _e.call(_d, 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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, onKeyDown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.resetDelayedBindMode();\n }\n\n this.removePointer(event);\n this.lastPointerUpIsDoubleClick = this.isDoubleClick(this.lastPointerUpEvent, event);\n this.lastPointerUpEvent = event;\n\n if (!event.ctrlKey) {\n const preferenceEnabled = this.state.bindingPreference === \"enabled\";\n\n if (this.state.isBindingEnabled !== preferenceEnabled) {\n this.setState({\n isBindingEnabled: preferenceEnabled\n });\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: event.clientX,\n clientY: event.clientY\n }, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n this.lastPointerMoveCoords = {\n x: scenePointerX,\n y: scenePointerY\n };\n\n if (this.handleIframeLikeCenterClick()) {\n return;\n }\n\n if (this.editorInterface.isTouchScreen) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y, {\n includeLockedElements: true\n });\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n this.handleElementLinkClick(event);\n } else if (this.state.viewModeEnabled) {\n this.setState({\n activeEmbeddable: null,\n selectedElementIds: {}\n });\n }\n };\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices = event => {\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isContextMenuDisabled)()) {\n return;\n } // deal with opening context menu on touch devices\n\n\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 && !this.state.isResizing) {\n //zsviczian - avoid context menu during resizing on Mobiles\n this.handleCanvasContextMenu(event);\n }\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOUCH_CTX_MENU_TIMEOUT);\n }\n }\n };\n\n this.resetContextMenuTimer = () => {\n clearTimeout(touchTimeout);\n touchTimeout = 0;\n invalidateContextMenu = false;\n };\n /**\n * pointerup may not fire in certian cases (user tabs away...), so in order\n * to properly cleanup pointerdown state, we need to fire any hanging\n * pointerup handlers manually\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_6__.POINTER_BUTTON.WHEEL || event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN && isHoldingSpace || (0,_appState__WEBPACK_IMPORTED_MODULE_22__.isHandToolActive)(this.state) || (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isTouchInPenMode)(this.state, event) || //zsviczian\n this.state.viewModeEnabled && this.state.activeTool.type !== \"laser\"))) {\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_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n /*\n * Prevent paste event if we move while middle clicking on Linux.\n * See issue #1383.\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_6__.EVENT.PASTE, preventNextPaste);\n event.stopPropagation();\n };\n /*\n * Reenable next paste in case of disabled middle click paste for\n * any reason:\n * - right click paste\n * - empty clipboard\n */\n\n\n const enableNextPaste = () => {\n setTimeout(() => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, enableNextPaste);\n }, 100);\n };\n\n document.body.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdates)(lastPointerUp = () => {\n lastPointerUp = null;\n isPanning = false;\n\n if (!isHoldingSpace) {\n if (this.state.viewModeEnabled && this.state.activeTool.type !== \"laser\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n return true;\n };\n\n this.clearSelectionIfNotUsingSelection = () => {\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(this.state.activeTool.type)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n };\n /**\n * @returns whether the pointer event has been completely handled\n */\n\n\n this.handleSelectionOnPointerDown = (event, pointerDownState) => {\n var _a, _b, _c, _d, _e, _f, _g;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(this.state.activeTool.type)) {\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 && !((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]) && !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && (this.editorInterface.userAgent.isMobileDevice || selectedElements[0].points.length === 2)) && !(this.state.selectedLinearElement && this.state.selectedLinearElement.hoverPointIndex !== -1)) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.editorInterface);\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__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.editorInterface);\n }\n\n if (pointerDownState.resize.handleType) {\n pointerDownState.resize.isResizing = true;\n pointerDownState.resize.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeOffsetXY)(pointerDownState.resize.handleType, selectedElements, elementsMap, pointerDownState.origin.x, pointerDownState.origin.y));\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && selectedElements[0].points.length === 2) {\n pointerDownState.resize.arrowDirection = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeArrowDirection)(pointerDownState.resize.handleType, selectedElements[0]);\n }\n } else {\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.selectedLinearElement;\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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\n if (ret.didAddPoint) {\n return true;\n } // Also check at current pointer position if focus point is being hovered\n // (in case we're clicking directly without a prior move event)\n\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const arrow = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (arrow && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(arrow)) {\n const {\n hitFocusPoint,\n pointerOffset\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointPointerDown)(arrow, pointerDownState, elementsMap, this.state); // If focus point is hit, update state and prevent element selection\n\n if (hitFocusPoint) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n hoveredFocusPointBinding: hitFocusPoint,\n draggedFocusPointBinding: hitFocusPoint,\n pointerOffset\n })\n });\n return false;\n }\n }\n }\n\n const allHitElements = this.getElementsAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n includeLockedElements: true\n });\n const unlockedHitElements = allHitElements.filter(e => !e.locked); // Cannot set preferSelected in getElementAtPosition as we do in pointer move; consider:\n // A & B: both unlocked, A selected, B on top, A & B overlaps in some way\n // we want to select B when clicking on the overlapping area\n\n const hitElementMightBeLocked = this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n allHitElements\n });\n\n if (!hitElementMightBeLocked || hitElementMightBeLocked.id !== this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n const isUnlockedHitElSelected = unlockedHitElements.some(el => this.state.selectedElementIds[el.id]); //zsviczian\n // Prioritize unlocked elements over locked ones\n\n if (!isUnlockedHitElSelected && unlockedHitElements.length > 0) {\n //zsviczian https://github.com/excalidraw/excalidraw/pull/9582\n // If there are unlocked elements, use the topmost one\n pointerDownState.hit.element = unlockedHitElements[unlockedHitElements.length - 1];\n } else if (hitElementMightBeLocked && hitElementMightBeLocked.locked && !isUnlockedHitElSelected //zsviczian\n ) {\n pointerDownState.hit.element = null;\n } else {\n // hitElement may already be set above, so check first\n pointerDownState.hit.element = (_b = pointerDownState.hit.element) !== null && _b !== void 0 ? _b : this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n }\n\n this.hitLinkElement = this.getElementLinkAtPosition(pointerDownState.origin, hitElementMightBeLocked);\n\n if (this.hitLinkElement) {\n return true;\n }\n\n if (this.state.croppingElementId && ((_c = pointerDownState.hit.element) === null || _c === void 0 ? void 0 : _c.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 = unlockedHitElements;\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 && (!((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) || hitElement && (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) !== ((_e = this.state.selectedLinearElement) === null || _e === void 0 ? void 0 : _e.elementId))) {\n this.clearSelection(hitElement);\n }\n\n if ((_f = this.state.selectedLinearElement) === null || _f === void 0 ? void 0 : _f.isEditing) {\n this.setState(prevState => {\n var _a;\n\n return {\n selectedLinearElement: prevState.selectedLinearElement ? Object.assign(Object.assign({}, prevState.selectedLinearElement), {\n isEditing: !!hitElement && hitElement.id === ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId)\n }) : null,\n selectedElementIds: prevState.selectedLinearElement ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [prevState.selectedLinearElement.elementId]: true\n }, this.state) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState)\n };\n }); // If we click on something\n } else if (hitElement != null) {\n // == deep selection ==\n // on CMD/CTRL, drill down to hit element regardless of groups etc.\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (event.altKey) {\n // ctrl + alt means we're lasso selecting - start lasso trail and switch to lasso tool\n // Close any open dialogs that might interfere with lasso selection\n if (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") {\n this.setOpenDialog(null);\n }\n\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n });\n return false;\n }\n\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, this.state.editingGroupId)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 initialCaretSceneCoords: {\n x: sceneX,\n y: sceneY\n }\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n\n if (!this.state.activeTool.locked) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\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_6__.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__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(element, 0);\n } else {\n this.insertNewElement(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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n this.setState({\n newElement: element,\n suggestedBinding: null\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_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(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_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_29__.t)(\"toast.unrecognizedLinkFormat\"),\n closable: true\n });\n }\n\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(element);\n return element;\n };\n\n this.newImagePlaceholder = ({\n sceneX,\n sceneY,\n addToFrameUnderCursor = true\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = addToFrameUnderCursor ? this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n }) : null;\n const placeholderSize = 100 / this.state.zoom.value;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newImageElement)({\n type: \"image\",\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 x: gridX - placeholderSize / 2,\n y: gridY - placeholderSize / 2,\n width: placeholderSize,\n height: placeholderSize\n });\n };\n\n this.handleLinearElementOnPointerDown = (event, elementType, pointerDownState) => {\n var _a, _b, _c, _d;\n\n if (event.ctrlKey) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n isBindingEnabled: this.state.bindingPreference !== \"enabled\"\n });\n });\n }\n\n if (this.state.multiElement) {\n const {\n multiElement,\n selectedLinearElement\n } = this.state;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(selectedLinearElement, \"selectedLinearElement is expected to be set\"); // finalize if completing a loop\n\n if (multiElement.type === \"line\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(multiElement.points, this.state.zoom.value)) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, selectedLinearElement), {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1],\n initialState: Object.assign(Object.assign({}, selectedLinearElement.initialState), {\n lastClickedPoint: -1\n })\n })\n });\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.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__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(multiElement) && multiElement.points.length > 1) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: event.nativeEvent,\n sceneCoords: {\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }\n });\n return;\n }\n\n const {\n x: rx,\n y: ry\n } = multiElement;\n const {\n lastCommittedPoint\n } = selectedLinearElement;\n const hoveredElementForBinding = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((_b = (_a = this.lastPointerMoveCoords) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : rx + multiElement.points[multiElement.points.length - 1][0], (_d = (_c = this.lastPointerMoveCoords) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : ry + multiElement.points[multiElement.points.length - 1][1]), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap()); // clicking inside commit zone → finalize arrow\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(multiElement) && hoveredElementForBinding || 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_6__.LINE_CONFIRM_THRESHOLD) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: event.nativeEvent,\n sceneCoords: {\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }\n });\n return;\n }\n\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState)\n }));\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.\n If so, we want it to be null for start and \"arrow\" for end. If the linear item is not\n an arrow, we want it to be null for both. Otherwise, we want it to use the\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__WEBPACK_IMPORTED_MODULE_7__.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_6__.ARROW_TYPE.round ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.ARROW_TYPE.elbow,\n fixedSegments: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow ? [] : null\n }) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n const point = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const boundElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(point, this.scene.getNonDeletedElements(), elementsMap) : null;\n this.scene.mutateElement(element, {\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)]\n });\n this.insertNewElement(element);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n // Do the initial binding so the binding strategy has the initial state\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindBindingElement)(element, new Map([[0, {\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0),\n isDragging: false\n }]]), point[0], point[1], this.scene, this.state, {\n newArrow: true,\n altKey: event.altKey,\n initialBinding: true,\n angleLocked: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event.nativeEvent)\n });\n } // NOTE: We need the flushSync here for the\n // delayed bind mode change to see the right state\n // (specifically the `newElement`)\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => {\n let linearElementEditor = null;\n let nextSelectedElementIds = prevState.selectedElementIds;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element)) {\n linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(element, this.scene.getNonDeletedElementsMap());\n const endIdx = element.points.length - 1;\n linearElementEditor = Object.assign(Object.assign({}, linearElementEditor), {\n selectedPointsIndices: [endIdx],\n initialState: Object.assign(Object.assign({}, linearElementEditor.initialState), {\n arrowStartIsInside: event.altKey,\n lastClickedPoint: endIdx,\n origin: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)\n })\n });\n }\n\n nextSelectedElementIds = !this.state.activeTool.locked ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [element.id]: true\n }, prevState) : prevState.selectedElementIds;\n return Object.assign(Object.assign({}, prevState), {\n bindMode: \"orbit\",\n newElement: element,\n startBoundElement: boundElement,\n suggestedBinding: boundElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element) ? {\n element: boundElement,\n midPoint: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSnapOutlineMidPoint)(point, boundElement, elementsMap, this.state.zoom)\n } : null,\n selectedElementIds: nextSelectedElementIds,\n selectedLinearElement: linearElementEditor\n });\n });\n });\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleDelayedBindModeChange(element, boundElement);\n }\n }\n };\n\n this.createGenericElementOnPointerDown = (elementType, pointerDownState) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.newEmbeddableElement)(Object.assign({\n type: \"embeddable\"\n }, baseElementAttributes));\n } else {\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(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_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const constructorOpts = Object.assign(Object.assign(Object.assign({\n x: gridX,\n y: gridY,\n opacity: this.state.currentItemOpacity,\n locked: false\n }, type === \"frame\" && this.state.currentItemFrameRole ? {\n frameRole: this.state.currentItemFrameRole\n } : {}), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.TOOL_TYPE.magicframe ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(constructorOpts) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newFrameElement)(constructorOpts, this.scene.getNonDeletedElements()); //zsviczian\n\n this.insertNewElement(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; // Binding is double accounted on both elements and if one of them is\n // deleted, the binding should be removed\n\n this.elementsPendingErasure.forEach(id => {\n var _a;\n\n const element = this.scene.getElement(id);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n if (element.startBinding) {\n const bindable = this.scene.getElement(element.startBinding.elementId); // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(bindable, this.scene.getElementsMapIncludingDeleted(), {\n boundElements: bindable.boundElements.filter(e => e.id !== element.id)\n });\n }\n\n if (element.endBinding) {\n const bindable = this.scene.getElement(element.endBinding.elementId); // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(bindable, this.scene.getElementsMapIncludingDeleted(), {\n boundElements: bindable.boundElements.filter(e => e.id !== element.id)\n });\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindableElement)(element)) {\n (_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.forEach(boundElement => {\n var _a, _b;\n\n if (boundElement.type === \"arrow\") {\n const arrow = this.scene.getElement(boundElement.id);\n\n if (((_a = arrow === null || arrow === void 0 ? void 0 : arrow.startBinding) === null || _a === void 0 ? void 0 : _a.elementId) === element.id) {\n // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(arrow, this.scene.getElementsMapIncludingDeleted(), {\n startBinding: null\n });\n }\n\n if (((_b = arrow === null || arrow === void 0 ? void 0 : arrow.endBinding) === null || _b === void 0 ? void 0 : _b.elementId) === element.id) {\n // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(arrow, this.scene.getElementsMapIncludingDeleted(), {\n endBinding: null\n });\n }\n }\n });\n }\n });\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__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(ele) && this.elementsPendingErasure.has(ele.containerId)) {\n didChange = true;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(ele, {\n isDeleted: true\n });\n }\n\n return ele;\n });\n this.elementsPendingErasure = new Set();\n\n if (didChange) {\n this.store.scheduleCapture();\n this.scene.replaceAllElements(elements);\n }\n };\n\n this.initializeImage = async (placeholderImageElement, imageFile) => {\n var _a, _b, _c; // 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_32__.isSupportedImageFile)(imageFile)) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.unsupportedFileType\"));\n }\n\n const mimeType = imageFile.type;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, \"wait\");\n\n if (mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg) {\n try {\n imageFile = (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.SVGStringToFile)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)(await imageFile.text()), imageFile.name);\n } catch (error) {\n console.warn(error);\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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_32__.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_29__.t)(\"errors.imageInsertError\"));\n }\n\n const existingFileData = this.files[fileId];\n\n if (!(existingFileData === null || existingFileData === void 0 ? void 0 : existingFileData.dataURL)) {\n const {\n maxWidthOrHeight,\n maxFileSizeBytes\n } = this.props.imageOptions;\n\n try {\n imageFile = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.resizeImageFile)(imageFile, {\n maxWidthOrHeight\n });\n } catch (error) {\n console.error(\"Error trying to resizing image file on insertion\", error);\n }\n\n if (imageFile.size > maxFileSizeBytes) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.fileTooBig\", {\n maxSize: `${Math.trunc(maxFileSizeBytes / 1024 / 1024)}MB`\n }));\n }\n }\n\n const dataURL = ((_c = this.files[fileId]) === null || _c === void 0 ? void 0 : _c.dataURL) || (await (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.getDataURL)(imageFile));\n return new Promise(async (resolve, reject) => {\n var _a, _b;\n\n try {\n let initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\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\n if (!this.imageCache.get(fileId)) {\n this.addNewImagesToImageCache();\n const {\n erroredFiles\n } = await this.updateImageCache([initializedImageElement]);\n\n if (erroredFiles.size) {\n throw new Error(\"Image cache update resulted with an error.\");\n }\n }\n\n const imageHTML = await ((_a = this.imageCache.get(fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (imageHTML && ((_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.id) !== initializedImageElement.id) {\n initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\n const naturalDimensions = this.getImageNaturalDimensions(initializedImageElement, imageHTML); // no need to create a new instance anymore, just assign the natural dimensions\n\n Object.assign(initializedImageElement, naturalDimensions);\n }\n\n resolve(initializedImageElement);\n } catch (error) {\n console.error(error);\n reject(new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.imageInsertError\")));\n }\n });\n };\n /**\n * use during async image initialization,\n * when the placeholder image could have been modified in the meantime,\n * and when you don't want to loose those modifications\n */\n\n\n this.getLatestInitializedImageElement = (imagePlaceholder, fileId) => {\n var _a;\n\n const latestImageElement = (_a = this.scene.getElement(imagePlaceholder.id)) !== null && _a !== void 0 ? _a : imagePlaceholder;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(latestImageElement, {\n fileId\n });\n };\n\n this.onImageToolbarButtonClick = async () => {\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_6__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const imageFiles = await (0,_data_filesystem__WEBPACK_IMPORTED_MODULE_33__.fileOpen)({\n description: \"Image\",\n extensions: Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.IMAGE_MIME_TYPES),\n multiple: true\n });\n this.insertImages(imageFiles, x, y);\n } catch (error) {\n if (error.name !== \"AbortError\") {\n console.error(error);\n } else {\n console.warn(error);\n }\n\n this.setState({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n })\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n }\n };\n\n this.getImageNaturalDimensions = (imageElement, imageHTML) => {\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(imageHTML.naturalHeight, maxHeight);\n const width = height * (imageHTML.naturalWidth / imageHTML.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 return {\n x,\n y,\n width,\n height,\n crop: null\n };\n };\n /** updates image cache, refreshing updated elements and/or setting status\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__WEBPACK_IMPORTED_MODULE_7__.updateImageCache)({\n imageCache: this.imageCache,\n fileIds: elements.map(element => element.fileId),\n files\n });\n\n if (erroredFiles.size) {\n this.store.scheduleAction(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER);\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && erroredFiles.has(element.fileId)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 for (const element of uncachedImageElements) {\n if (updatedFiles.has(element.fileId)) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n }\n }\n\n if (updatedFiles.size) {\n this.scene.triggerUpdate();\n }\n }\n };\n /** generally you should use `addNewImagesToImageCache()` directly if you need\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_6__.IMAGE_RENDER_TIMEOUT);\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_6__.EVENT.TOUCH_START, this.onTouchStart, {\n passive: false\n });\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd); // -----------------------------------------------------------------------\n } else {\n (_a = this.interactiveCanvas) === null || _a === void 0 ? void 0 : _a.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_START, this.onTouchStart);\n (_b = this.interactiveCanvas) === null || _b === void 0 ? void 0 : _b.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd);\n }\n };\n\n this.insertImages = async (imageFiles, sceneX, sceneY) => {\n const gridPadding = 50 / this.state.zoom.value; // Create, position, and insert placeholders\n\n const placeholders = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(imageFiles.map(() => this.newImagePlaceholder({\n sceneX,\n sceneY\n })), sceneX, sceneY, gridPadding);\n this.insertNewElements(placeholders); // Create, position, insert and select initialized (replacing placeholders)\n\n const initialized = await Promise.all(placeholders.map(async (placeholder, i) => {\n try {\n return await this.initializeImage(placeholder, await (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.normalizeFile)(imageFiles[i]));\n } catch (error) {\n this.setState({\n errorMessage: error.message || (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.imageInsertError\")\n });\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(placeholder, {\n isDeleted: true\n });\n }\n }));\n const initializedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(initialized);\n const positioned = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(initialized.filter(el => !el.isDeleted), sceneX, sceneY, gridPadding);\n const positionedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(positioned);\n const nextElements = this.scene.getElementsIncludingDeleted().map(el => {\n var _a, _b;\n\n return (_b = (_a = positionedMap.get(el.id)) !== null && _a !== void 0 ? _a : initializedMap.get(el.id)) !== null && _b !== void 0 ? _b : el;\n });\n this.updateScene({\n appState: {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.fromEntries(positioned.map(el => [el.id, true])), this.state)\n },\n elements: nextElements,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n this.setState({}, () => {\n // actionFinalize after all state values have been updated\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n };\n\n this.handleAppOnDrop = async event => {\n var _a;\n\n if (this.props.onDrop) {\n //zsviczian\n try {\n if ((await this.props.onDrop(event)) === false) {\n return;\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_23__.parseDataTransferEvent)(event); // must be retrieved first, in the same frame\n\n const fileItems = dataTransferList.getFiles();\n\n if (fileItems.length === 1) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file && (file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.png || file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg)) {\n try {\n const scene = await (0,_data__WEBPACK_IMPORTED_MODULE_24__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n return;\n } catch (error) {\n if (error.name !== \"EncodingError\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"alerts.couldNotLoadInvalidFile\"));\n } // if EncodingError, fall through to insert as regular image\n\n }\n }\n }\n\n const imageFiles = fileItems.map(data => data.file).filter(file => (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.isSupportedImageFile)(file));\n\n if (imageFiles.length > 0 && this.isToolSupported(\"image\")) {\n return this.insertImages(imageFiles, sceneX, sceneY);\n }\n\n const excalidrawLibrary_ids = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlibIds);\n const excalidrawLibrary_data = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlib);\n\n if (excalidrawLibrary_ids || excalidrawLibrary_data) {\n try {\n let libraryItems = null;\n\n if (excalidrawLibrary_ids) {\n const {\n itemIds\n } = JSON.parse(excalidrawLibrary_ids);\n const allLibraryItems = await this.library.getLatestLibrary();\n libraryItems = allLibraryItems.filter(item => itemIds.includes(item.id)); // legacy library dataTransfer format\n } else if (excalidrawLibrary_data) {\n libraryItems = (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.parseLibraryJSON)(excalidrawLibrary_data);\n }\n\n if (libraryItems === null || libraryItems === void 0 ? void 0 : libraryItems.length) {\n libraryItems = libraryItems.map(item => Object.assign(Object.assign({}, item), {\n // #6465\n elements: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: item.elements,\n randomizeSeed: true,\n preserveFrameChildrenOrder: true\n }).duplicatedElements\n }));\n this.addElementsFromPasteOrLibrary({\n elements: (0,_data_library__WEBPACK_IMPORTED_MODULE_25__.distributeLibraryItemsOnSquareGrid)(libraryItems),\n position: event,\n files: null\n });\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n\n return;\n }\n\n if (fileItems.length > 0) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file) {\n // Attempt to parse an excalidraw/excalidrawlib file\n await this.loadFileToCanvas(file, fileHandle);\n }\n }\n\n const textItem = dataTransferList.findByType(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.text);\n\n if (textItem) {\n const text = textItem.value;\n\n if (text && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(text, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(text) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(text)) === null || _a === void 0 ? void 0 : _a.type) === \"video\")) {\n const embeddable = this.insertEmbeddableElement({\n sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(text)\n });\n\n if (embeddable) {\n this.store.scheduleCapture();\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_32__.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_32__.loadSceneOrLibraryFromBlob)(file, this.state, elements, fileHandle);\n } catch (error) {\n const imageSceneDataError = error instanceof _errors__WEBPACK_IMPORTED_MODULE_37__.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_29__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const errorMessage = imageSceneDataError ? (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"alerts.cannotRestoreFromImage\") : (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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_6__.MIME_TYPES.excalidraw) {\n // restore the fractional indices by mutating elements\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncInvalidIndices)(elements.concat(ret.data.elements)); // don't capture and only update the store snapshot for old elements,\n // otherwise we would end up with duplicated fractional indices on undo\n\n this.store.scheduleMicroAction({\n action: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER,\n elements,\n appState: undefined\n });\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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n } else if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_29__.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 (this.state.disableContextMenu) {\n //zsviczian\n return;\n } //mfuria #329. if right-click pan is enabled, we suppress opening our custom menu too.\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isPanWithRightMouseEnabled)()) {\n return;\n }\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_6__.POINTER_BUTTON.SECONDARY) && this.state.activeTool.type !== this.state.preferredSelectionTool.type) {\n return;\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_21__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 && pointerDownState.boxSelection.hasOccurred && this.state.activeTool.type !== \"eraser\") {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.distance)(pointerDownState.origin.x, pointerCoords.x),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.origin.y, pointerCoords.y),\n shouldMaintainAspectRatio: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_38__.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\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.distance)(pointerDownState.originInGrid.x, gridX),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.originInGrid.y, gridY),\n shouldMaintainAspectRatio: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(newElement) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event),\n zoom: this.state.zoom.value,\n scene: this.scene,\n widthAspectRatio: aspectRatio,\n originOffset: this.state.originSnapOffset,\n informMutation\n });\n }\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_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe) {\n this.setState({\n elementsToHighlight: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement)) {\n const croppingAtStateStart = pointerDownState.originalElements.get(croppingElement.id);\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_a = this.imageCache.get(croppingElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (croppingAtStateStart && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingAtStateStart) && image && !(image instanceof Promise)) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_38__.snapResizingElements)([croppingElement], [croppingAtStateStart], this, event, dragOffset, transformHandleType);\n this.scene.mutateElement(croppingElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.cropElement)(croppingElement, this.scene.getNonDeletedElementsMap(), transformHandleType, image.naturalWidth, image.naturalHeight, x + snapOffset.x, y + snapOffset.y, event.shiftKey ? croppingAtStateStart.width / croppingAtStateStart.height : undefined));\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(croppingElement, this.scene);\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const frameElementsOffsetsMap = new Map();\n selectedFrames.forEach(frame => {\n const elementsInFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_38__.snapResizingElements)(selectedElements, (0,_scene__WEBPACK_IMPORTED_MODULE_30__.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__WEBPACK_IMPORTED_MODULE_7__.transformElements)(pointerDownState.originalElements, transformHandleType, selectedElements, this.scene, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event), selectedElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(element)) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event), resizeX, resizeY, pointerDownState.resize.center.x, pointerDownState.resize.center.y)) {\n const elementsToHighlight = new Set();\n selectedFrames.forEach(frame => {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), frame, this.state, this.scene.getNonDeletedElementsMap()).forEach(element => elementsToHighlight.add(element));\n });\n this.setState({\n elementsToHighlight: [...elementsToHighlight]\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_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg); // canvas contextMenu\n // -------------------------------------------------------------------------\n\n if (type === \"canvas\") {\n if (this.state.viewModeEnabled) {\n return [...options, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats, _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleLaserPointer];\n }\n\n return [_actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg, _actions__WEBPACK_IMPORTED_MODULE_8__.copyText, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSelectAll, _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__.actionUnlockAllElements, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleObjectsSnapMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleArrowBinding, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleMidpointSnapping, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats];\n } // element contextMenu\n // -------------------------------------------------------------------------\n\n\n options.push(_actions__WEBPACK_IMPORTED_MODULE_8__.copyText);\n\n if (this.state.viewModeEnabled) {\n return [_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, ...options];\n }\n\n const zIndexActions = this.editorInterface.formFactor === \"desktop\" ? [_ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendBackward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringForward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendToBack, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringToFront] : [];\n return [_ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionSelectAllElementsInFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionRemoveAllElementsFromFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionWrapSelectionInFrame, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleCropEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, ...options, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyStyles, _actions__WEBPACK_IMPORTED_MODULE_8__.actionPasteStyles, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionGroup, _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__.actionTextAutoResize, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUnbindText, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBindText, _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__.actionWrapTextInContainer, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUngroup, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionAddToLibrary, ...zIndexActions, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipHorizontal, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipVertical, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__.actionCopyElementLink, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDuplicateSelection, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleElementLock, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDeleteSelected];\n };\n\n this.handleWheel = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d; // if not scrolling on canvas/wysiwyg, ignore\n //zsviczian - begin\n\n\n const path = (_b = (_a = event).composedPath) === null || _b === void 0 ? void 0 : _b.call(_a);\n const isOnExcalidrawCanvas = (path === null || path === void 0 ? void 0 : path.some(n => {\n var _a;\n\n return n instanceof HTMLCanvasElement && ((_a = n.classList) === null || _a === void 0 ? void 0 : _a.contains(\"excalidraw__canvas\"));\n })) || ((_d = (_c = event.target) === null || _c === void 0 ? void 0 : _c.closest) === null || _d === void 0 ? void 0 : _d.call(_c, \"canvas.excalidraw__canvas\")) != null; //zsviczian - end\n\n if (!(isOnExcalidrawCanvas || //zsviczian\n event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLIFrameElement || event.target instanceof HTMLElement && event.target.classList.contains(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CLASSES.FRAME_NAME))) {\n // prevent zooming the browser (but allow scrolling DOM)\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.getZoomStep)() * 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_31__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_30__.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_6__.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_6__.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 this.watchState = () => {};\n\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_22__.getDefaultAppState)();\n const {\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_29__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`\n } = props;\n this.state = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultAppState), {\n theme,\n exportWithDarkMode: theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK,\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.refreshEditorInterface();\n this.stylesPanelMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(this.editorInterface);\n this.id = (0,nanoid__WEBPACK_IMPORTED_MODULE_73__.nanoid)();\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.initializeObsidianUtils)();\n this.library = new _data_library__WEBPACK_IMPORTED_MODULE_25__[\"default\"](this);\n this.actionManager = new _actions_manager__WEBPACK_IMPORTED_MODULE_18__.ActionManager(this.syncActionResult, () => this.state, () => this.scene.getElementsIncludingDeleted(), this);\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\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_39__.Renderer(this.scene);\n this.visibleElements = [];\n this.store = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Store(this);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_28__.History(this.store);\n this.excalidrawContainerValue = {\n container: this.excalidrawContainerRef.current,\n id: this.id\n };\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_35__.Fonts(this.scene);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_28__.History(this.store);\n this.actionManager.registerAll(_actions_register__WEBPACK_IMPORTED_MODULE_19__.actions);\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createUndoAction)(this.history));\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createRedoAction)(this.history)); // in case internal editor APIs call this early, otherwise we need\n // to construct this in componentDidMount because componentWillUnmount\n // will invalidate it (so in StrictMode, doing this in constructor alone\n // would be a problem)\n\n this.api = this.createExcalidrawAPI();\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_6__.YOUTUBE_STATES).includes(playerState)) {\n YOUTUBE_VIDEO_STATES.set(id, playerState);\n }\n }\n\n break;\n }\n }\n\n handleSkipBindMode() {\n var _a, _b, _c, _d, _e;\n\n if (((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.initialState) && !this.state.selectedLinearElement.initialState.arrowStartIsInside) {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.lastPointerMoveCoords, \"Missing last pointer move coords when changing bind skip mode for arrow start\");\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerMoveCoords.x, this.lastPointerMoveCoords.y), this.scene.getNonDeletedElements(), elementsMap);\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, elementsMap);\n\n if ((element === null || element === void 0 ? void 0 : element.startBinding) && (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) === element.startBinding.elementId) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n arrowStartIsInside: true\n })\n })\n });\n }\n }\n\n if (this.state.bindMode === \"orbit\") {\n if (this.bindModeHandler) {\n clearTimeout(this.bindModeHandler);\n this.bindModeHandler = null;\n } // PERF: It's okay since it's a single trigger from a key handler\n // or single call from pointer move handler because the bindMode check\n // will not pass the second time\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n bindMode: \"skip\"\n });\n });\n\n if (this.lastPointerMoveCoords && ((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) && ((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.selectedPointsIndices.length)) {\n const {\n x,\n y\n } = this.lastPointerMoveCoords;\n const event = (_d = this.lastPointerMoveEvent) !== null && _d !== void 0 ? _d : (_e = this.lastPointerDownEvent) === null || _e === void 0 ? void 0 : _e.nativeEvent;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(event, \"Last event must exist\");\n const deltaX = x - this.state.selectedLinearElement.pointerOffset.x;\n const deltaY = y - this.state.selectedLinearElement.pointerOffset.y;\n const newState = this.state.multiElement ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event, this, deltaX, deltaY, this.state.selectedLinearElement) : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, deltaX, deltaY, this.state.selectedLinearElement);\n\n if (newState) {\n this.setState(newState);\n }\n }\n }\n }\n\n resetDelayedBindMode() {\n if (this.bindModeHandler) {\n clearTimeout(this.bindModeHandler);\n this.bindModeHandler = null;\n }\n\n if (this.state.bindMode !== \"orbit\") {\n // We need this iteration to complete binding and change\n // back to orbit mode after that\n setTimeout(() => this.setState({\n bindMode: \"orbit\"\n }));\n }\n }\n\n handleDelayedBindModeChange(arrow, hoveredElement) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;\n\n if (arrow.isDeleted || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(arrow)) {\n return;\n }\n\n const effector = () => {\n var _a, _b, _c, _d;\n\n this.bindModeHandler = null;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.lastPointerMoveCoords, \"Expected lastPointerMoveCoords to be set\");\n\n if (!this.state.multiElement) {\n if (!this.state.selectedLinearElement || !this.state.selectedLinearElement.selectedPointsIndices || !this.state.selectedLinearElement.selectedPointsIndices.length) {\n return;\n }\n\n const startDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(0);\n const endDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(arrow.points.length - 1); // Check if the whole arrow is dragged by selecting all endpoints\n\n if (!startDragged && !endDragged || startDragged && endDragged) {\n return;\n }\n }\n\n const {\n x,\n y\n } = this.lastPointerMoveCoords;\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap());\n\n if (hoveredElement && this.state.bindMode !== \"skip\") {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId) === arrow.id, \"The selectedLinearElement is expected to not change while a bind mode timeout is ticking\"); // Once the start is set to inside binding, it remains so\n\n const arrowStartIsInside = this.state.selectedLinearElement.initialState.arrowStartIsInside || ((_b = arrow.startBinding) === null || _b === void 0 ? void 0 : _b.elementId) === hoveredElement.id; // Change the global binding mode\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.state.selectedLinearElement, \"this.state.selectedLinearElement must exist\");\n this.setState({\n bindMode: \"inside\",\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n arrowStartIsInside\n })\n })\n });\n });\n const event = (_c = this.lastPointerMoveEvent) !== null && _c !== void 0 ? _c : (_d = this.lastPointerDownEvent) === null || _d === void 0 ? void 0 : _d.nativeEvent;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(event, \"Last event must exist\");\n const deltaX = x - this.state.selectedLinearElement.pointerOffset.x;\n const deltaY = y - this.state.selectedLinearElement.pointerOffset.y;\n const newState = this.state.multiElement ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event, this, deltaX, deltaY, this.state.selectedLinearElement) : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, deltaX, deltaY, this.state.selectedLinearElement);\n\n if (newState) {\n this.setState(newState);\n }\n }\n };\n\n let isOverlapping = false;\n\n if ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.selectedPointsIndices) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const startDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(0);\n const endDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(arrow.points.length - 1);\n const startElement = startDragged ? hoveredElement : arrow.startBinding && elementsMap.get(arrow.startBinding.elementId);\n const endElement = endDragged ? hoveredElement : arrow.endBinding && elementsMap.get(arrow.endBinding.elementId);\n const startBounds = startElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementBounds)(startElement, elementsMap);\n const endBounds = endElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementBounds)(endElement, elementsMap);\n isOverlapping = !!(startBounds && endBounds && startElement.id !== endElement.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.doBoundsIntersect)(startBounds, endBounds));\n }\n\n const startDragged = (_c = (_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) === null || _c === void 0 ? void 0 : _c.includes(0);\n const endDragged = (_e = (_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.selectedPointsIndices) === null || _e === void 0 ? void 0 : _e.includes(arrow.points.length - 1);\n const currentBinding = startDragged ? \"startBinding\" : endDragged ? \"endBinding\" : null;\n const otherBinding = startDragged ? \"endBinding\" : endDragged ? \"startBinding\" : null;\n const isAlreadyInsideBindingToSameElement = otherBinding && ((_f = arrow[otherBinding]) === null || _f === void 0 ? void 0 : _f.mode) === \"inside\" && ((_g = arrow[otherBinding]) === null || _g === void 0 ? void 0 : _g.elementId) === (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) || currentBinding && ((_h = arrow[currentBinding]) === null || _h === void 0 ? void 0 : _h.mode) === \"inside\" && (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) === ((_j = arrow[currentBinding]) === null || _j === void 0 ? void 0 : _j.elementId);\n\n if (currentBinding && otherBinding && ((_k = arrow[currentBinding]) === null || _k === void 0 ? void 0 : _k.mode) === \"inside\" && (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) !== ((_l = arrow[currentBinding]) === null || _l === void 0 ? void 0 : _l.elementId) && ((_m = arrow[otherBinding]) === null || _m === void 0 ? void 0 : _m.elementId) !== ((_o = arrow[currentBinding]) === null || _o === void 0 ? void 0 : _o.elementId)) {\n // Update binding out of place to orbit mode\n this.scene.mutateElement(arrow, {\n [currentBinding]: Object.assign(Object.assign({}, arrow[currentBinding]), {\n mode: \"orbit\"\n })\n }, {\n informMutation: false,\n isDragging: true\n });\n }\n\n if (!hoveredElement || this.previousHoveredBindableElement && hoveredElement.id !== this.previousHoveredBindableElement.id) {\n // Clear the timeout if we're not hovering a bindable\n if (this.bindModeHandler) {\n clearTimeout(this.bindModeHandler);\n this.bindModeHandler = null;\n } // Clear the inside binding mode too\n\n\n if (this.state.bindMode === \"inside\") {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n bindMode: \"orbit\"\n });\n });\n }\n\n this.previousHoveredBindableElement = null;\n } else if (!this.bindModeHandler && (!this.state.newElement || !arrow.startBinding || isOverlapping) && !isAlreadyInsideBindingToSameElement) {\n // We are hovering a bindable element\n this.bindModeHandler = setTimeout(effector, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.BIND_MODE_TIMEOUT);\n }\n\n this.previousHoveredBindableElement = hoveredElement;\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 /** @returns true if iframe-like element click handled */\n\n\n handleIframeLikeCenterClick() {\n var _a, _b, _c, _d;\n\n if (!this.lastPointerDownEvent || !this.lastPointerUpEvent || // middle-click or something other than primary\n this.lastPointerDownEvent.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN || // panning\n isHoldingSpace || // wrong tool\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.oneOf)(this.state.activeTool.type, [\"laser\", \"selection\", \"lasso\"])) {\n return false;\n }\n\n const viewportClickStart_scenePoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastPointerDownEvent.clientX,\n clientY: this.lastPointerDownEvent.clientY\n }, this.state));\n const viewportClickEnd_scenePoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastPointerUpEvent.clientX,\n clientY: this.lastPointerUpEvent.clientY\n }, this.state));\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)(viewportClickStart_scenePoint, viewportClickEnd_scenePoint);\n\n if (draggedDistance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DRAGGING_THRESHOLD) {\n return false;\n }\n\n const hitElement = this.getElementAtPosition(viewportClickStart_scenePoint[0], viewportClickStart_scenePoint[1]);\n const shouldActivate = hitElement && this.lastPointerUpEvent.timeStamp - this.lastPointerDownEvent.timeStamp <= 300 && gesture.pointers.size < 2 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && (this.state.viewModeEnabled || this.state.activeTool.type === \"laser\" || this.isIframeLikeElementCenter(hitElement, this.lastPointerUpEvent, viewportClickEnd_scenePoint[0], viewportClickEnd_scenePoint[1]));\n\n if (!shouldActivate) {\n return false;\n }\n\n const iframeLikeElement = hitElement;\n\n if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) === iframeLikeElement && ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"active\") {\n return true;\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: iframeLikeElement,\n state: \"active\"\n },\n selectedElementIds: {\n [iframeLikeElement.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n }, 100);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(iframeLikeElement)) {\n return true;\n }\n\n const iframe = this.getHTMLIFrameElement(iframeLikeElement);\n\n if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {\n return true;\n }\n\n if (iframe.src.includes(\"youtube\")) {\n const state = YOUTUBE_VIDEO_STATES.get(iframeLikeElement.id);\n\n if (!state) {\n YOUTUBE_VIDEO_STATES.set(iframeLikeElement.id, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.UNSTARTED);\n iframe.contentWindow.postMessage(JSON.stringify({\n event: \"listening\",\n id: iframeLikeElement.id\n }), \"*\");\n }\n\n switch (state) {\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.PLAYING:\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 return true;\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__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(el) && this.embedsValidationStatus.get(el.id) === true || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.sceneCoordsToViewportCoords)({\n sceneX: el.x,\n sceneY: el.y\n }, this.state); //zsviczian - shouldRenderAllEmbeddables\n\n const isVisible = this.shouldRenderAllEmbeddables || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.toValidURL)(el.link || \"\")); //zsviczian\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.createSrcDoc)(`\n <style>\n html, body {\n width: 100%;\n height: 100%;\n color: ${this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.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})`; // scale video embeds based on zoom (capped) so that smaller embeds\n // on canvas when zoomed are still of legible quality\n // (note: for some embed types like gdrive, the quality is poor when\n // scaling mid playback and works only when you initially start the\n // playback at the higher zoom level)\n\n const shouldScaleEmbeddableViewport = (src === null || src === void 0 ? void 0 : src.type) === \"video\";\n const embeddableViewportScale = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(shouldScaleEmbeddableViewport ? scale : 1, 0.75, MAX_EMBEDDABLE_VIEWPORT_SCALE);\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__WEBPACK_IMPORTED_MODULE_7__.getRenderOpacity)(el, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1),\n [\"--embeddable-radius\"]: `${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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) => {\n if (!this.excalidrawContainerRef.current) {\n return;\n }\n const container = this.excalidrawContainerRef.current;\n const sh = container.scrollHeight;\n const ch = container.clientHeight;\n if (sh !== ch) {\n container.style.height = `${sh}px`;\n setTimeout(() => {\n container.style.height = `100%`;\n });\n }\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_6__.POINTER_EVENTS.enabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_29__.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 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable__content\",\n style: {\n width: `${embeddableViewportScale * 100}%`,\n height: `${embeddableViewportScale * 100}%`,\n transform: `scale(${1 / embeddableViewportScale})`\n }\n }, (_o = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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\" //zsviczian\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 renderTopLeftUI,\n renderCustomStats\n } = this.props;\n const {\n elementsMap,\n visibleElements,\n canvasNonce,\n\n /**\n * element to draw on the <NewElementCanvas> for optimization purposes.\n * Can be null even if this.state.newElement defined\n * (e.g. when its zIndex isn't on top) */\n newElementCanvasElement\n } = this.renderer.getRenderableElements({\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 newElement: this.state.newElement,\n selectedElements,\n selectedElementsAreBeingDragged: this.state.selectedElementsAreBeingDragged,\n frameToHighlight: this.state.frameToHighlight\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 = (_c = (_b = (_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.customData) === null || _b === void 0 ? void 0 : _b.strokeOptions) === null || _c === void 0 ? void 0 : _c.highlighter;\n const showShapeSwitchPanel = ((_d = _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom)) === null || _d === void 0 ? void 0 : _d.type) === \"panel\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n translate: \"no\",\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw excalidraw-container notranslate\", {\n \"excalidraw--view-mode\": this.state.viewModeEnabled || ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) === \"elementLinkSelector\",\n \"excalidraw--mobile\": this.editorInterface.formFactor === \"phone\",\n \"excalidraw--tray\": !(this.state.viewModeEnabled || this.state.zenModeEnabled) && //this.editorInterface.formFactor !== \"phone\" &&\n this.editorInterface.desktopUIMode === \"tray\" //zsviczian\n\n }),\n style: Object.assign(Object.assign({\n //zsviczian\n [\"--ui-pointerEvents\"]: shouldBlockPointerEvents ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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(ExcalidrawAPIContext.Provider, {\n value: this.api\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(EditorInterfaceContext.Provider, {\n value: this.editorInterface\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_58__[\"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_29__.getLanguage)().code,\n renderTopLeftUI: renderTopLeftUI,\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 === this.state.preferredSelectionTool.type && !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_60__.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_34__.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__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(firstSelectedElement) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_41__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_59__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"labels.convertToCode\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_66__.MagicIcon,\n checked: false,\n onChange: () => this.onMagicFrameGenerate(firstSelectedElement, \"button\")\n })), selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_41__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_59__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"labels.copySource\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_66__.copyIcon,\n checked: false,\n onChange: () => this.onIframeSrcCopy(firstSelectedElement)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_59__.ElementCanvasButton, {\n title: \"Enter fullscreen\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_66__.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.contextMenu && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ContextMenu__WEBPACK_IMPORTED_MODULE_55__.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 }), newElementCanvasElement && isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_64__[\"default\"], {\n appState: this.state,\n newElement: newElementCanvasElement,\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 theme: this.state.theme,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_63__.StaticCanvas, {\n canvas: this.canvas,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n visibleElements: visibleElements,\n canvasNonce: canvasNonce,\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_38__.isGridModeEnabled)(this),\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: this.flowChartCreator.pendingNodes,\n theme: this.state.theme,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), newElementCanvasElement && !isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_64__[\"default\"], {\n appState: this.state,\n newElement: newElementCanvasElement,\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 theme: this.state.theme,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_63__.InteractiveCanvas, {\n app: this,\n containerRef: this.excalidrawContainerRef,\n canvas: this.interactiveCanvas,\n elementsMap: elementsMap,\n visibleElements: visibleElements,\n allElementsMap: allElementsMap,\n selectedElements: selectedElements,\n canvasNonce: canvasNonce,\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 editorInterface: this.editorInterface,\n renderInteractiveSceneCallback: this.renderInteractiveSceneCallback,\n handleCanvasRef: this.handleInteractiveCanvasRef,\n onContextMenu: this.handleCanvasContextMenu,\n onClick: this.handleCanvasClick,\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_57__[\"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.state.activeLockedId && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_UnlockPopup__WEBPACK_IMPORTED_MODULE_69__[\"default\"], {\n app: this,\n activeLockedId: this.state.activeLockedId\n }), showShapeSwitchPanel && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__[\"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__WEBPACK_IMPORTED_MODULE_7__.getElementsOverlappingFrame)(this.scene.getNonDeletedElements(), magicFrame, this.scene.getNonDeletedElementsMap()).filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_21__.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_21__.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_21__.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_21__.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_23__.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__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && files[element.fileId]) {\n this.imageCache.delete(element.fileId);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n });\n }\n\n async componentDidMount() {\n var _a, _b, _c, _d, _e;\n\n this.unmounted = false;\n this.api = this.createExcalidrawAPI();\n this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; //zsviczian disabling this code\n\n /*\n if (false && (isTestEnv() || isDevEnv())) {\n const setState = this.setState.bind(this);\n Object.defineProperties(window.h, {\n state: {\n configurable: true,\n get: () => {\n return this.state;\n },\n },\n setState: {\n configurable: true,\n value: (...args: Parameters<typeof setState>) => {\n return this.setState(...args);\n },\n },\n app: {\n configurable: true,\n value: this,\n },\n history: {\n configurable: true,\n value: this.history,\n },\n store: {\n configurable: true,\n value: this.store,\n },\n fonts: {\n configurable: true,\n value: this.fonts,\n },\n });\n }*/\n\n this.store.onDurableIncrementEmitter.on(increment => {\n this.history.record(increment.delta);\n }); // per. optimmisation, only subscribe if there is the `onIncrement` prop registered, to avoid unnecessary computation\n\n if (this.props.onIncrement) {\n this.store.onStoreIncrementEmitter.on(increment => {\n var _a, _b;\n\n (_b = (_a = this.props).onIncrement) === null || _b === void 0 ? void 0 : _b.call(_a, increment);\n });\n }\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 (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.supportsResizeObserver && this.excalidrawContainerRef.current) {\n this.resizeObserver = new ResizeObserver(() => {\n this.refreshEditorInterface();\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_6__.isBrave)() && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMeasureTextSupported)()) {\n this.setState({\n errorMessage: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_54__[\"default\"], null)\n });\n }\n\n const mountPayload = {\n excalidrawAPI: this.api,\n container: this.excalidrawContainerRef.current\n };\n this.editorLifecycleEvents.emit(\"editor:mount\", mountPayload);\n (_c = (_b = this.props).onMount) === null || _c === void 0 ? void 0 : _c.call(_b, mountPayload);\n (_e = (_d = this.props).onExcalidrawAPI) === null || _e === void 0 ? void 0 : _e.call(_d, this.api);\n }\n\n componentWillUnmount() {\n var _a, _b, _c, _d, _e, _f; // we're recreating the api object reference so that the\n // <ExcalidrawAPIContext.Provider/> picks up on it\n\n\n this.api = Object.assign(Object.assign({}, this.api), {\n isDestroyed: true\n });\n\n for (const key of Object.keys(this.api)) {\n if ((key.startsWith(\"get\") || key === \"onStateChange\" || key === \"onEvent\") && typeof this.api[key] === \"function\") {\n this.api[key] = () => {\n throw new Error(\"ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.\");\n };\n }\n }\n\n this.editorLifecycleEvents.emit(\"editor:unmount\");\n (_b = (_a = this.props).onUnmount) === null || _b === void 0 ? void 0 : _b.call(_a);\n (_d = (_c = this.props).onExcalidrawAPI) === null || _d === void 0 ? void 0 : _d.call(_c, null);\n (_e = window.launchQueue) === null || _e === void 0 ? void 0 : _e.setConsumer(() => {});\n this.renderer.destroy();\n this.scene.destroy();\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_35__.Fonts(this.scene);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_39__.Renderer(this.scene);\n this.files = {};\n this.imageCache.clear();\n (_f = this.resizeObserver) === null || _f === void 0 ? void 0 : _f.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 this.store.onDurableIncrementEmitter.clear();\n this.appStateObserver.clear();\n this.editorLifecycleEvents.clear();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.destroy();\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.destroy();\n clearTimeout(touchTimeout);\n _scene__WEBPACK_IMPORTED_MODULE_30__.isSomeElementSelected.clearCache();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements.clearCache();\n touchTimeout = 0;\n document.documentElement.style.overscrollBehaviorX = \"\";\n document.body.removeChild((0,_Tooltip__WEBPACK_IMPORTED_MODULE_71__.getTooltipDiv)()); //clearRenderCache(); //zsviczian\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.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.excalidrawContainerValue = {\n container: null,\n id: \"unknown\"\n }; //zsviczian\n //@ts-ignore\n // this.laserTrails.terminate(); //zsviczian\n // this.eraserTrail.terminate(); //zsviczian\n\n /*\n Object.keys(this).forEach((key) => {\n //@ts-ignore\n delete this[key];\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_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, this.onKeyDown, false));\n }\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.MESSAGE, this.onWindowMessage, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, this.removePointer, {\n passive: false\n }), // #3553\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.COPY, this.onCopy, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, this.onKeyUp, {\n passive: true\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, \"focus\", () => this.triggerRender(true), {\n passive: true\n }), //zsviczian\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_START, this.onGestureStart, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_CHANGE, this.onGestureChange, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_END, this.onGestureEnd, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.FULLSCREENCHANGE, this.onFullscreenChange, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, this.pasteFromClipboard, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.CUT, this.onCut, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.RESIZE, this.onResize, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.UNLOAD, this.onUnload, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, this.onBlur, false),\n /*addEventListener( //zsviczian (duplicate)\n this.excalidrawContainerRef.current,\n EVENT.WHEEL,\n this.handleWheel,\n { passive: false },\n ),*/\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DRAG_OVER, this.disableEvent, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DROP, this.disableEvent, false));\n\n if (this.props.detectScroll) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getNearestScrollableContainer)(this.excalidrawContainerRef.current), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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, _l, _m, _o, _p; // must be updated *before* state change listeners are triggered below\n\n\n if (!this._initialized && !this.state.isLoading) {\n this._initialized = true;\n this.editorLifecycleEvents.emit(\"editor:initialize\", this.api);\n (_b = (_a = this.props).onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, this.api);\n }\n\n this.appStateObserver.flush(prevState);\n this.updateEmbeddables();\n const elements = this.scene.getElementsIncludingDeleted();\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n const shouldExportWithDarkMode = ((_c = this.sessionExportThemeOverride) !== null && _c !== void 0 ? _c : this.state.theme) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK;\n\n if (this.state.exportWithDarkMode !== shouldExportWithDarkMode) {\n this.setState({\n exportWithDarkMode: shouldExportWithDarkMode\n });\n }\n\n if (!this.state.showWelcomeScreen && !elements.length) {\n this.setState({\n showWelcomeScreen: true\n });\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 (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.onScrollChange) === null || _e === void 0 ? void 0 : _e.call(_d, 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_22__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_40__.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_22__.isEraserActive)(prevState) && !(0,_appState__WEBPACK_IMPORTED_MODULE_22__.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 ((((_f = prevState.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\" || ((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") && ((_h = prevState.openDialog) === null || _h === void 0 ? void 0 : _h.name) !== ((_j = this.state.openDialog) === null || _j === void 0 ? void 0 : _j.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 (_k = this.excalidrawContainerRef.current) === null || _k === void 0 ? void 0 : _k.classList.toggle(\"theme--dark\", this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK);\n\n if (((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.isEditing) && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // defer so that the scheduleCapture flag isn't reset via current update\n setTimeout(() => {\n var _a; // 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\n\n ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.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 ((_m = this.state.editingTextElement) === null || _m === void 0 ? void 0 : _m.isDeleted) {\n this.setState({\n editingTextElement: null\n });\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 (_p = (_o = this.props).onChange) === null || _p === void 0 ? void 0 : _p.call(_o, elements, this.state, this.files);\n this.onChangeEmitter.trigger(elements, this.state, this.files);\n }\n }\n\n static resetTapTwice() {\n didTapTwice = false;\n firstTapPosition = null;\n } // TODO: Cover with tests\n\n\n async insertClipboardContent(data, dataTransferFiles, isPlainPaste) {\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state); // ------------------- Error -------------------\n\n if (data.errorMessage) {\n this.setState({\n errorMessage: data.errorMessage\n });\n return;\n } // ------------------- Mixed content with no files -------------------\n\n\n if (dataTransferFiles.length === 0 && !isPlainPaste && data.mixedContent) {\n await this.addElementsFromMixedContentPaste(data.mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n });\n return;\n } // ------------------- Spreadsheet -------------------\n\n\n if (!isPlainPaste && data.text) {\n const result = (0,_charts__WEBPACK_IMPORTED_MODULE_51__.tryParseSpreadsheet)(data.text);\n\n if (result.ok) {\n this.setState({\n openDialog: {\n name: \"charts\",\n data: result.data,\n rawText: data.text\n }\n });\n return;\n }\n } // ------------------- Images or SVG code -------------------\n\n\n const imageFiles = dataTransferFiles.map(data => data.file);\n\n if (imageFiles.length === 0 && data.text && !isPlainPaste) {\n const trimmedText = data.text.trim();\n\n if (trimmedText.startsWith(\"<svg\") && trimmedText.endsWith(\"</svg>\")) {\n // ignore SVG validation/normalization which will be done during image\n // initialization\n imageFiles.push((0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.SVGStringToFile)(trimmedText));\n }\n }\n\n if (imageFiles.length > 0) {\n if (this.isToolSupported(\"image\")) {\n await this.insertImages(imageFiles, sceneX, sceneY);\n } else {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.imageToolNotSupported\")\n });\n }\n\n return;\n } // ------------------- Elements -------------------\n\n\n if (data.elements) {\n const elements = data.programmaticAPI ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: this.editorInterface.formFactor === \"desktop\" ? \"cursor\" : \"center\",\n retainSeed: isPlainPaste,\n preserveFrameChildrenOrder: true\n });\n return;\n } // ------------------- Only textual stuff remaining -------------------\n\n\n if (!data.text) {\n return;\n } // ------------------- Successful Mermaid -------------------\n\n\n if (!isPlainPaste && (0,_mermaid__WEBPACK_IMPORTED_MODULE_47__.isMaybeMermaidDefinition)(data.text)) {\n const api = await Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! @excalidraw/mermaid-to-excalidraw */ \"../../node_modules/@excalidraw/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,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.convertToExcalidrawElements)(skeletonElements, {\n regenerateIds: true\n });\n this.addElementsFromPasteOrLibrary({\n elements,\n files,\n position: this.editorInterface.formFactor === \"desktop\" ? \"cursor\" : \"center\"\n });\n return;\n } catch (err) {\n console.warn(`parsing pasted text as mermaid definition failed: ${err.message}`);\n }\n } // ------------------- Pure embeddable URLs -------------------\n\n\n const nonEmptyLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeEOL)(data.text).split(/\\n+/).map(s => s.trim()).filter(Boolean);\n const embbeddableUrls = nonEmptyLines.map(str => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeParseEmbedSrc)(str)).filter(string => {\n var _a;\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(string, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(string) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(string)) === null || _a === void 0 ? void 0 : _a.type) === \"video\");\n });\n\n if (!isPlainPaste && embbeddableUrls.length > 0 && 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_6__.normalizeLink)(url)\n });\n\n if (embeddable) {\n embeddables.push(embeddable);\n }\n }\n\n if (embeddables.length) {\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: Object.fromEntries(embeddables.map(embeddable => [embeddable.id, true]))\n });\n }\n\n return;\n } // ------------------- Text -------------------\n\n\n this.addTextFromPaste(data.text, isPlainPaste);\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_32__.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_29__.t)(\"errors.failedToFetchImage\");\n } else if (error.cause === \"UNSUPPORTED\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.unsupportedFileType\");\n }\n\n return {\n errorMessage\n };\n }\n }));\n const imageFiles = responses.filter(response => !!response.file).map(response => response.file);\n await this.insertImages(imageFiles, sceneX, sceneY);\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_6__.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_72__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value),\n //zsviczian\n fontFamily: this.state.currentItemFontFamily,\n textAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_TEXT_ALIGN,\n verticalAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n locked: false\n };\n const fontString = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)({\n fontSize: textElementProps.fontSize,\n fontFamily: textElementProps.fontFamily\n });\n const lineHeight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getLineHeight)(textElementProps.fontFamily);\n const [x1,, x2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.measureText)(originalText, fontString, lineHeight);\n const isTextUnwrapped = metrics.width > maxTextWidth;\n const text = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.wrapText)(originalText, fontString, maxTextWidth) : originalText;\n metrics = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElements(textElements);\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.editorInterface.formFactor !== \"phone\") {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"toast.pasteAsSingleElement\", {\n shortcut: (0,_shortcut__WEBPACK_IMPORTED_MODULE_50__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")\n }),\n duration: 5000\n });\n PLAIN_PASTE_TOAST_SHOWN = true;\n }\n }\n\n handleTextWysiwyg(element, {\n isExistingElement = false,\n initialCaretSceneCoords = null\n }) {\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n const updateElement = (nextOriginalText, isDeleted, rawText, //zsviczian\n link, //zsviczian\n hasTextLink) => {\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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: nextOriginalText,\n rawText: rawText !== null && rawText !== void 0 ? rawText : nextOriginalText,\n //zsviczian\n link,\n hasTextLink: hasTextLink !== null && hasTextLink !== void 0 ? hasTextLink : _element.hasTextLink,\n isDeleted: isDeleted !== null && isDeleted !== void 0 ? isDeleted : _element.isDeleted\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n //changing the value of element so this gets edited by textWysiwyg\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: text,\n rawText: text,\n isDeleted: false\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, text)));\n return element;\n }\n\n return _element;\n })]);\n }\n }\n\n (0,_wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_45__.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_6__.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_43__.withBatchedUpdates)(nextOriginalText => {\n updateElement(nextOriginalText, false);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isNonDeletedElement)(element)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene);\n }\n }),\n onSubmit: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(({\n viaKeyboard,\n nextOriginalText\n }) => {\n var _a, _b;\n\n const isDeleted = !nextOriginalText.trim(); //zsviczian insert start\n\n const rawText = nextOriginalText; //should this be originalText??\n\n let link = undefined;\n let hasTextLink = false;\n\n if (this.props.onBeforeTextSubmit) {\n const _element = this.scene.getElementsIncludingDeleted().find(el => el.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(el));\n\n if (_element) {\n const dismensionsData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 hasTextLink = !!nextLink;\n link = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.syncElementLinkWithText)() ? nextLink : (_b = element.link) !== null && _b !== void 0 ? _b : undefined;\n }\n } //zsviczian insert end\n\n\n updateElement(nextOriginalText, isDeleted, rawText, link, hasTextLink); //zsviczian (added rawText, link, text)\n // keyboard-submit keeps focus on the edited object. For bound text, keep\n // the container selected even if the text becomes empty and is deleted.\n\n const elementIdToSelect = viaKeyboard ? element.containerId || (!isDeleted ? element.id : null) : null;\n\n if (elementIdToSelect) {\n // 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 (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [elementIdToSelect]: true\n }), prevState)\n }));\n });\n }\n\n if (isDeleted) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.fixBindingsAfterDeletion)(this.scene.getNonDeletedElements(), [element]);\n }\n\n if (!isDeleted || isExistingElement) {\n this.store.scheduleCapture();\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_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.focusContainer();\n }),\n element,\n excalidrawContainer: this.excalidrawContainerRef.current,\n app: this,\n initialCaretSceneCoords,\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.editorInterface.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n getSelectedTextElement(container) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length !== 1) {\n return null;\n }\n\n const selectedElement = selectedElements[0];\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n return selectedElement;\n }\n\n if (!container) {\n return null;\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(selectedElement, this.scene.getNonDeletedElementsMap());\n }\n\n getSelectedTextEditingContainerAtPosition(hitElement, sceneCoords) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length !== 1 || !hitElement || hitElement.id !== selectedElements[0].id) {\n return null;\n }\n\n const selectedElement = selectedElements[0];\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n return null;\n }\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isValidTextContainer)(selectedElement)) {\n return undefined;\n }\n\n const textElement = this.getSelectedTextElement(selectedElement);\n const hitTextElement = this.getTextElementAtPosition(sceneCoords.x, sceneCoords.y);\n\n if (!textElement || (hitTextElement === null || hitTextElement === void 0 ? void 0 : hitTextElement.id) !== textElement.id) {\n return undefined;\n }\n\n return selectedElement;\n }\n\n getTextElementAtPosition(x, y) {\n const element = this.getElementAtPosition(x, y, {\n includeBoundTextElement: true\n });\n\n if (element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) && !element.isDeleted) {\n return element;\n }\n\n return null;\n } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementAtPosition(x, y, opts) {\n let allHitElements = [];\n\n if (opts && \"allHitElements\" in opts) {\n allHitElements = (opts === null || opts === void 0 ? void 0 : opts.allHitElements) || [];\n } else {\n allHitElements = this.getElementsAtPosition(x, y, {\n includeBoundTextElement: opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement,\n includeLockedElements: opts === null || opts === void 0 ? void 0 : opts.includeLockedElements\n });\n }\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__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elementWithHighestZIndex,\n // when overlapping, we would like to be more precise\n // this also avoids the need to update past tests\n threshold: this.getElementHitThreshold(elementWithHighestZIndex) / 2,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementsAtPosition(x, y, opts) {\n const iframeLikes = [];\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const elements = ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) && (opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) ? this.scene.getNonDeletedElements() : this.scene.getNonDeletedElements().filter(element => ((opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) || !element.locked) && ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) || !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(element, elementsMap);\n return containingFrame && this.state.frameRendering.enabled && this.state.frameRendering.clip ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el)) {\n iframeLikes.push(el);\n return false;\n }\n\n return true;\n }).concat(iframeLikes);\n return elements;\n }\n\n getElementHitThreshold(element) {\n return Math.max(element.strokeWidth / 2 + 0.1, // NOTE: Here be dragons. Do not go under the 0.63 multiplier unless you're\n // willing to test extensively. The hit testing starts to become unreliable\n // due to FP imprecision under 0.63 in high zoom levels.\n 0.85 * (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.hasBoundingBox)([element], this.state, this.editorInterface)) {\n // if hitting the bounding box, return early\n // but if not, we should check for other cases as well (e.g. frame name)\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBox)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap(), this.getElementHitThreshold(element))) {\n return true;\n }\n } // take bound text element into consideration for hit collision as well\n\n\n const hitBoundTextOfElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundText)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap());\n\n if (hitBoundTextOfElement) {\n return true;\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element,\n threshold: this.getElementHitThreshold(element),\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementAbsoluteCoords)(elements[index], this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(elements[index]) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elements[index],\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(elements[index])\n })) {\n hitElement = elements[index];\n break;\n } else if (x1 < x && x < x2 && y1 < y && y < y2) {\n // to allow binding to containers within frames,\n // ignore frames in hit testing\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(elements[index])) {\n continue;\n }\n\n hitElement = elements[index];\n break;\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextBindableContainer)(hitElement, false) ? hitElement : null;\n }\n\n handleHoverSelectedLinearElement(linearElementEditor, scenePointerX, scenePointerY) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY),\n element,\n elementsMap,\n threshold: this.getElementHitThreshold(element)\n })) {\n hoverPointIndex = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointIndexUnderCursor(element, elementsMap, this.state.zoom, scenePointerX, scenePointerY);\n segmentMidPointHoveredCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, {\n x: scenePointerX,\n y: scenePointerY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const isHoveringAPointHandle = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) ? hoverPointIndex === 0 || hoverPointIndex === element.points.length - 1 : hoverPointIndex >= 0;\n\n if (isHoveringAPointHandle || segmentMidPointHoveredCoords) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Elbow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Elbow arrow can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\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__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords, segmentMidPointHoveredCoords)) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords\n })\n });\n } // Check for focus point hover\n\n\n let hoveredFocusPointBinding = null;\n const arrow = element;\n\n if (arrow.startBinding || arrow.endBinding) {\n hoveredFocusPointBinding = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointHover)(element, scenePointerX, scenePointerY, this.scene, this.state);\n }\n\n if (this.state.selectedLinearElement.hoveredFocusPointBinding !== hoveredFocusPointBinding) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isDragging: false,\n hoveredFocusPointBinding\n })\n });\n } // Set cursor to pointer when hovering over a focus point\n\n\n if (hoveredFocusPointBinding) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n } //mfuria #329. start right-click panning\n\n\n startRightClickPanning(event) {\n // Set up right-click panning similar to hand tool\n isPanning = true;\n this.focusContainer();\n\n if (!this.state.editingTextElement) {\n event.preventDefault();\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\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_43__.withBatchedUpdates)(() => {\n isPanning = false;\n\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\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 if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.shouldDisableZoom)(this.state)) {\n //zsviczian\n gesture.initialDistance = null;\n } else {\n gesture.lastCenter = (0,_gesture__WEBPACK_IMPORTED_MODULE_27__.getCenter)(gesture.pointers);\n gesture.initialScale = this.state.zoom.value;\n gesture.initialDistance = (0,_gesture__WEBPACK_IMPORTED_MODULE_27__.getDistance)(Array.from(gesture.pointers.values()));\n }\n }\n }\n\n initialPointerDownState(event) {\n const origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const selectedElements = this.scene.getSelectedElements(this.state);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const isElbowArrowOnly = selectedElements.findIndex(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow) === 0;\n return {\n origin,\n withCmdOrCtrl: event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD],\n originInGrid: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(origin.x, origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || isElbowArrowOnly ? null : this.getEffectiveGridSize())),\n scrollbars: (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_46__.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__WEBPACK_IMPORTED_MODULE_7__.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 blockDragging: false\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_43__.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_43__.withBatchedUpdates)(() => {\n lastPointerUp = null;\n isDraggingScrollBar = false;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n onPointerMove.flush();\n });\n lastPointerUp = onPointerUp;\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 = Math.max(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value, 1);\n const boundsPadding = _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_TRANSFORM_HANDLE_SPACING * 2 / this.state.zoom.value;\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n return point.x > x1 - boundsPadding - threshold && point.x < x2 + boundsPadding + threshold && point.y > y1 - boundsPadding - threshold && point.y < y2 + boundsPadding + threshold;\n }\n\n getCurrentItemRoundness(elementType) {\n return this.state.currentItemRoundness === \"round\" ? {\n type: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isUsingAdaptiveRadius)(elementType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null;\n }\n\n maybeCacheReferenceSnapPoints(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_38__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.getReferenceSnapPoints())) {\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setReferenceSnapPoints((0,_snapping__WEBPACK_IMPORTED_MODULE_38__.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_38__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.getVisibleGaps())) {\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setVisibleGaps((0,_snapping__WEBPACK_IMPORTED_MODULE_38__.getVisibleGaps)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n onKeyDownFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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_43__.withBatchedUpdates)(event => {\n // Prevents focus from escaping excalidraw tab\n event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdatesThrottled)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z; //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_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.elbowed && this.state.selectedLinearElement.initialState.segmentMidpoint.index) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n let index = this.state.selectedLinearElement.initialState.segmentMidpoint.index;\n\n if (index < 0) {\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : -1;\n }\n\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.moveFixedSegment(this.state.selectedLinearElement, index, gridX, gridY, this.scene);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isDragging: true,\n segmentMidPointHoveredCoords: ret.segmentMidPointHoveredCoords,\n initialState: ret.initialState\n })\n });\n return;\n }\n\n const lastPointerCoords = (_b = this.previousPointerMoveCoords) !== null && _b !== void 0 ? _b : pointerDownState.origin;\n this.previousPointerMoveCoords = 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_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_22__.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_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\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.selectedLinearElement; // Handle focus point dragging if needed\n\n if (linearElementEditor.draggedFocusPointBinding) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointDrag)(linearElementEditor, elementsMap, pointerCoords, this.scene, this.state, this.getEffectiveGridSize(), event.altKey);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n isDragging: false,\n selectedPointsIndices: [],\n initialState: Object.assign(Object.assign({}, linearElementEditor.initialState), {\n lastClickedPoint: -1\n })\n })\n });\n return;\n }\n\n if (_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.shouldAddMidpoint(this.state.selectedLinearElement, pointerCoords, this.state, elementsMap)) {\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.addMidpoint(this.state.selectedLinearElement, pointerCoords, this, !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 initialState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n });\n return;\n } else if (linearElementEditor.initialState.segmentMidpoint.value !== null && !linearElementEditor.initialState.segmentMidpoint.added) {\n return;\n } else if (linearElementEditor.initialState.lastClickedPoint > -1) {\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (element === null || element === void 0 ? void 0 : element.isDeleted) {\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), this.scene.getNonDeletedElements(), elementsMap);\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleDelayedBindModeChange(element, hoveredElement);\n }\n }\n\n if (event.altKey && !((_d = (_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.initialState) === null || _d === void 0 ? void 0 : _d.arrowStartIsInside) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleSkipBindMode();\n } // Ignore drag requests if the arrow modification already happened\n\n\n if (linearElementEditor.initialState.lastClickedPoint === -1) {\n return;\n }\n\n const newState = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, pointerCoords.x, pointerCoords.y, linearElementEditor);\n\n if (newState) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n pointerDownState.drag.hasOccurred = true; // NOTE: Optimize setState calls because it\n // affects history and performance\n\n if (newState.suggestedBinding !== this.state.suggestedBinding || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isShallowEqual)((_f = (_e = newState.selectedLinearElement) === null || _e === void 0 ? void 0 : _e.selectedPointsIndices) !== null && _f !== void 0 ? _f : [], (_h = (_g = this.state.selectedLinearElement) === null || _g === void 0 ? void 0 : _g.selectedPointsIndices) !== null && _h !== void 0 ? _h : []) || ((_j = newState.selectedLinearElement) === null || _j === void 0 ? void 0 : _j.hoverPointIndex) !== ((_k = this.state.selectedLinearElement) === null || _k === void 0 ? void 0 : _k.hoverPointIndex) || ((_l = newState.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.customLineAngle) !== ((_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.customLineAngle) || this.state.selectedLinearElement.isDragging !== ((_o = newState.selectedLinearElement) === null || _o === void 0 ? void 0 : _o.isDragging) || ((_q = (_p = this.state.selectedLinearElement) === null || _p === void 0 ? void 0 : _p.initialState) === null || _q === void 0 ? void 0 : _q.altFocusPoint) !== ((_s = (_r = newState.selectedLinearElement) === null || _r === void 0 ? void 0 : _r.initialState) === null || _s === void 0 ? void 0 : _s.altFocusPoint)) {\n this.setState(newState);\n }\n\n return;\n }\n }\n }\n\n const hasHitASelectedElement = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n const isSelectingPointsInLineEditor = ((_t = this.state.selectedLinearElement) === null || _t === void 0 ? void 0 : _t.isEditing) && event.shiftKey && this.state.selectedLinearElement.elementId === ((_u = pointerDownState.hit.element) === null || _u === void 0 ? void 0 : _u.id);\n\n if ((hasHitASelectedElement || pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && !isSelectingPointsInLineEditor && !pointerDownState.drag.blockDragging) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length > 0 && selectedElements.every(element => element.locked)) {\n return;\n }\n\n const selectedElementsHasAFrame = selectedElements.some(e => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(e));\n const frameToHighlight = selectedElementsHasAFrame ? null : this.getTopLayerFrameAtSceneCoords(pointerCoords, {\n currentFrameId: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonFrameId)(selectedElements),\n excludeElementIds: this.state.selectedElementIds\n }); // Only update the state if there is a difference\n\n this.updateFrameToHighlight(frameToHighlight); // Marking that click was used for dragging to check\n // if elements should be deselected on pointerup\n\n pointerDownState.drag.hasOccurred = true; // prevent immediate dragging during lasso selection to avoid element displacement\n // only allow dragging if we're not in the middle of lasso selection\n // (on mobile, allow dragging if we hit an element)\n\n if (this.state.activeTool.type === \"lasso\" && this.lassoTrail.hasCurrentTrail && !(this.editorInterface.formFactor !== \"desktop\" && pointerDownState.hit.element) && !this.state.activeTool.fromSelection) {\n return;\n } // Clear lasso trail when starting to drag selected elements with lasso tool\n // Only clear if we're actually dragging (not during lasso selection)\n\n\n if (this.state.activeTool.type === \"lasso\" && selectedElements.length > 0 && pointerDownState.drag.hasOccurred && !this.state.activeTool.fromSelection) {\n this.lassoTrail.endPath();\n } // 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\n if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl && !this.state.editingTextElement && ((_v = this.state.activeEmbeddable) === null || _v === void 0 ? void 0 : _v.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__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement) && croppingElement.crop !== null && pointerDownState.hit.element === croppingElement) {\n const crop = croppingElement.crop;\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_w = this.imageCache.get(croppingElement.fileId)) === null || _w === void 0 ? void 0 : _w.image);\n\n if (image && !(image instanceof Promise)) {\n const uncroppedSize = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getUncroppedWidthAndHeight)(croppingElement);\n const instantDragOffset = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)(pointerCoords.x - lastPointerCoords.x, pointerCoords.y - lastPointerCoords.y); // to reduce cursor:image drift, we need to take into account\n // the canvas image element scaling so we can accurately\n // track the pixels on movement\n\n instantDragOffset[0] *= image.naturalWidth / uncroppedSize.width;\n instantDragOffset[1] *= image.naturalHeight / uncroppedSize.height;\n const [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_38__.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__WEBPACK_IMPORTED_MODULE_7__.dragSelectedElements)(pointerDownState, selectedElements, dragOffset, this.scene, snapOffset, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 }); // We duplicate the selected element if alt is pressed on pointer move\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__WEBPACK_IMPORTED_MODULE_7__.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_6__.randomInteger)()\n };\n }\n });\n duplicatedElements.forEach(element => {\n pointerDownState.originalElements.set(element.id, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n x: origEl.x,\n y: origEl.y\n });\n }\n }\n\n return el;\n });\n const mappedNewSceneElements = (_y = (_x = this.props).onDuplicate) === null || _y === void 0 ? void 0 : _y.call(_x, mappedClonedElements, elements);\n const elementsWithIndices = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(mappedNewSceneElements || mappedClonedElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.viewportCoordsToSceneCoords)(event, this.state); // switch selected elements to the duplicated ones\n\n this.setState(prevState => Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectionStateForElements)(duplicatedElements, this.scene.getNonDeletedElements(), prevState)));\n this.scene.replaceAllElements(elementsWithIndices);\n selectedElements.forEach(element => {\n var _a;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindableElement)(element) && ((_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.some(other => other.type === \"arrow\"))) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene);\n }\n });\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 return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement) && !newElement.isDeleted) {\n pointerDownState.drag.hasOccurred = true;\n const points = newElement.points;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(points.length > 1, \"Do not create linear elements with less than 2 points\");\n let linearElementEditor = this.state.selectedLinearElement;\n\n if (!linearElementEditor || linearElementEditor.elementId !== newElement.id) {\n linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap());\n }\n\n const lastClickedPointOutOfBounds = linearElementEditor && (linearElementEditor.initialState.lastClickedPoint < 0 || linearElementEditor.initialState.lastClickedPoint >= points.length);\n\n if (lastClickedPointOutOfBounds) {\n console.warn(\"Last clicked point is out of bounds. Attempting to fix it.\");\n linearElementEditor = Object.assign(Object.assign({}, linearElementEditor), {\n selectedPointsIndices: [points.length - 1],\n initialState: Object.assign(Object.assign({}, linearElementEditor.initialState), {\n prevSelectedPointsIndices: null,\n lastClickedPoint: points.length - 1\n }),\n hoverPointIndex: points.length - 1\n });\n }\n\n this.setState(Object.assign({\n newElement\n }, _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, gridX, gridY, linearElementEditor)));\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 ((_z = this.state.selectedLinearElement) === null || _z === void 0 ? void 0 : _z.isEditing) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_30__.isSomeElementSelected)(elements, this.state)) {\n if (pointerDownState.withCmdOrCtrl && pointerDownState.hit.element) {\n this.setState(prevState => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_30__.getElementsWithinSelection)(elements, this.state.selectionElement, this.scene.getNonDeletedElementsMap(), false, this.state.boxSelectionMode) : [];\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(elementsWithinSelection[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(elementsWithinSelection[0], this.scene.getNonDeletedElementsMap()) : null,\n showHyperlinkPopup: elementsWithinSelection.length === 1 && (elementsWithinSelection[0].link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_43__.withBatchedUpdates)(childEvent => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n this.removePointer(childEvent);\n pointerDownState.drag.blockDragging = false;\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_6__.updateStable)(prevState.snapLines, []),\n originSnapOffset: null\n })); // just in case, tool changes mid drag, always clean up\n\n this.lassoTrail.endPath();\n this.previousPointerMoveCoords = null;\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setReferenceSnapPoints(null);\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setVisibleGaps(null);\n this.savePointer(childEvent.clientX, childEvent.clientY, \"up\"); // if current elements are still selected\n // and the pointer is just over a locked element\n // do not allow activeLockedId to be set\n\n const hitElements = pointerDownState.hit.allHitElements;\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: childEvent.clientX,\n clientY: childEvent.clientY\n }, this.state);\n\n if (this.state.activeTool.type === \"selection\" && !pointerDownState.boxSelection.hasOccurred && !pointerDownState.resize.isResizing && !hitElements.some(el => this.state.selectedElementIds[el.id])) {\n const hitLockedElement = this.getElementAtPosition(sceneCoords.x, sceneCoords.y, {\n includeLockedElements: true\n });\n this.store.scheduleCapture();\n\n if (hitLockedElement === null || hitLockedElement === void 0 ? void 0 : hitLockedElement.locked) {\n this.setState({\n activeLockedId: hitLockedElement.groupIds.length > 0 ? hitLockedElement.groupIds.at(-1) || \"\" : hitLockedElement.id\n });\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.resetDelayedBindMode();\n }\n\n this.setState({\n selectedElementsAreBeingDragged: false,\n bindMode: \"orbit\"\n });\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 (((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) && !this.state.newElement && this.state.selectedLinearElement.draggedFocusPointBinding === null) {\n if (!pointerDownState.boxSelection.hasOccurred && ((_f = (_e = pointerDownState.hit) === null || _e === void 0 ? void 0 : _e.element) === null || _f === void 0 ? void 0 : _f.id) !== this.state.selectedLinearElement.elementId && this.state.selectedLinearElement.draggedFocusPointBinding === null) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const editingLinearElement = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerUp(childEvent, this.state.selectedLinearElement, this.state, this.scene);\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n\n if (editingLinearElement !== this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: editingLinearElement,\n suggestedBinding: null\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__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if (element) {\n this.scene.mutateElement(element, {});\n }\n }\n\n if (this.state.selectedLinearElement.draggedFocusPointBinding) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointPointerUp)(this.state.selectedLinearElement, this.scene);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n draggedFocusPointBinding: null\n })\n });\n } else if (((_h = (_g = pointerDownState.hit) === null || _g === void 0 ? void 0 : _g.element) === null || _h === void 0 ? void 0 : _h.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 if (this.state.selectedLinearElement.isDragging) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isDragging: false\n })\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n\n if (this.state.newElement && this.state.multiElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(this.state.newElement) && this.state.selectedLinearElement) {\n const {\n multiElement\n } = this.state;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n })\n });\n }\n }\n\n this.missingPointerEventCleanupEmitter.clear();\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, pointerDownState.eventListeners.onMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, pointerDownState.eventListeners.onUp);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, pointerDownState.eventListeners.onKeyDown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, pointerDownState.eventListeners.onKeyUp);\n (_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.onPointerUp) === null || _k === void 0 ? void 0 : _k.call(_j, 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_6__.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 });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n if (newElement.points.length > 1 && newElement.points[1][0] !== 0 && newElement.points[1][1] !== 0) {\n this.store.scheduleCapture();\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const dragDistance = (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)) * this.state.zoom.value;\n\n if ((!pointerDownState.drag.hasOccurred || dragDistance < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MINIMUM_ARROW_SIZE) && newElement && !multiElement) {\n if (this.editorInterface.isTouchScreen && newElement.points.length > 1) {\n //zsviczian\n const FIXED_DELTA_X = Math.min(this.state.width * 0.7 / this.state.zoom.value, 100);\n this.scene.mutateElement(newElement, {\n x: newElement.x - FIXED_DELTA_X / 2,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(FIXED_DELTA_X, 0)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n this.scene.mutateElement(newElement, {\n points: [newElement.points[0], (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n multiElement: newElement,\n newElement\n });\n }\n } else if (pointerDownState.drag.hasOccurred && !multiElement) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n\n this.setState({\n suggestedBinding: null\n });\n\n if (!activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n }),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap())\n }));\n } else {\n this.setState({\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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement)) {\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getMinTextElementWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n });\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(newElement)) {\n const elementsInsideFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInNewFrame)(this.scene.getElementsIncludingDeleted(), newElement, this.scene.getNonDeletedElementsMap());\n this.scene.replaceAllElements((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(this.scene.getElementsMapIncludingDeleted(), elementsInsideFrame, newElement));\n }\n\n if (newElement) {\n this.scene.mutateElement(newElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(linearElement, elementsMap);\n\n if (frame && linearElement) {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 selectedElements = this.scene.getSelectedElements(this.state);\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(sceneCoords, {\n currentFrameId: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonFrameId)(selectedElements),\n excludeElementIds: this.state.selectedElementIds\n });\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__WEBPACK_IMPORTED_MODULE_7__.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 => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n\n if (this.state.editingGroupId) {\n updateGroupIdsAfterEditingGroup(elementsToAdd);\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, elementsToAdd, topLayerFrame);\n } else if (!topLayerFrame) {\n if (this.state.editingGroupId) {\n const elementsToRemove = selectedElements.filter(element => element.frameId && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n updateGroupIdsAfterEditingGroup(elementsToRemove);\n }\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(nextElements, this.state, this);\n this.scene.replaceAllElements(nextElements);\n }\n }\n\n if (resizingElement) {\n this.store.scheduleCapture();\n }\n\n if (resizingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(this.scene.getElementsIncludingDeleted(), this.state, this);\n const selectedFrames = this.scene.getSelectedElements(this.state).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element));\n\n for (const frame of selectedFrames) {\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.replaceAllElementsInFrame)(nextElements, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getElementsIncludingDeleted(), frame, this.state, elementsMap), frame);\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 (((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.elementId) !== (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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_22__.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_6__.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 !((_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.isEditing) || !pointerDownState.boxSelection.hasOccurred) && // hitElement can be set when alt + ctrl to toggle lasso and we will\n // just respect the selected elements from lasso instead\n this.state.activeTool.type !== \"lasso\") {\n // when inside line editor, shift selects points instead\n if (childEvent.shiftKey && !((_o = this.state.selectedLinearElement) === null || _o === void 0 ? void 0 : _o.isEditing)) {\n if (this.state.selectedElementIds[hitElement.id]) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, _prevState)\n };\n }); // if not dragging a linear element point (outside editor)\n } else if (!((_p = this.state.selectedLinearElement) === null || _p === void 0 ? void 0 : _p.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_30__.getSelectedElements)(this.scene.getNonDeletedElements(), {\n selectedElementIds: newSelectedElementIds\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newSelectedElements[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n selectedLinearElement: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBoxOnly)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y),\n element: hitElement,\n elementsMap,\n threshold: this.getElementHitThreshold(hitElement),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement) ? this.frameNameBoundsCache.get(hitElement) : null\n }, elementsMap) || !hitElement && pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements)) {\n if ((_q = this.state.selectedLinearElement) === null || _q === void 0 ? void 0 : _q.isEditing) {\n // Exit editing mode but keep the element selected\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n } else {\n // Deselect selected elements\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // reset cursor\n\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n return;\n }\n\n const selectedTextEditingContainer = this.getSelectedTextEditingContainerAtPosition(hitElement, sceneCoords);\n\n if (activeTool.type === this.state.preferredSelectionTool.type && !this.state.editingTextElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && !childEvent.shiftKey && !childEvent[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !childEvent.altKey && childEvent.pointerType !== \"touch\" && hitElement && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(hitElement) && this.state.selectedElementIds[hitElement.id] && this.scene.getSelectedElements(this.state).length === 1 || selectedTextEditingContainer)) {\n this.startTextEditing({\n sceneX: sceneCoords.x,\n sceneY: sceneCoords.y,\n container: selectedTextEditingContainer,\n initialCaretSceneCoords: this.lastPointerUpIsDoubleClick ? undefined : sceneCoords\n });\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && newElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n showHyperlinkPopup: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(newElement) && !newElement.link ? \"editor\" : prevState.showHyperlinkPopup\n }));\n }\n\n if (activeTool.type !== \"selection\" || (0,_scene__WEBPACK_IMPORTED_MODULE_30__.isSomeElementSelected)(this.scene.getNonDeletedElements(), this.state) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isShallowEqual)(this.state.previousSelectedElementIds, this.state.selectedElementIds)) {\n this.store.scheduleCapture();\n }\n\n if (pointerDownState.drag.hasOccurred && !this.state.selectedLinearElement || 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__WEBPACK_IMPORTED_MODULE_7__.isArrowElement);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindBindingElements)(linearElements, this.scene, this.state);\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_40__.resetCursor)(this.interactiveCanvas);\n this.setState({\n newElement: null,\n suggestedBinding: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n })\n });\n } else {\n this.setState({\n newElement: null,\n suggestedBinding: null\n });\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, prevState.editingGroupId) ? prevState.editingGroupId : null\n }));\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null,\n previousSelectedElementIds: this.state.selectedElementIds,\n selectedLinearElement: null\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__WEBPACK_IMPORTED_MODULE_7__.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_6__.TEXT_TO_CENTER_SNAP_THRESHOLD;\n\n if (isSnappedToCenter) {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_29__.languages.find(lang => lang.code === this.props.langCode) || _i18n__WEBPACK_IMPORTED_MODULE_29__.defaultLang;\n await (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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\ndeclare global {\n interface Window {\n h: {\n scene: Scene;\n elements: readonly ExcalidrawElement[];\n state: AppState;\n setState: React.Component<any, AppState>[\"setState\"];\n watchState: (prev: any, next: any) => void | undefined;\n app: InstanceType<typeof App>;\n history: History;\n store: Store;\n };\n }\n}\n\nexport const createTestHook = () => {\n if (isTestEnv() || isDevEnv()) {\n window.h = window.h || ({} as Window[\"h\"]);\n\n Object.defineProperties(window.h, {\n elements: {\n configurable: true,\n get() {\n return this.app?.scene.getElementsIncludingDeleted();\n },\n set(elements: ExcalidrawElement[]) {\n return this.app?.scene.replaceAllElements(\n syncInvalidIndices(elements),\n );\n },\n },\n scene: {\n configurable: true,\n get() {\n return this.app?.scene;\n },\n },\n });\n }\n};\n\ncreateTestHook();*/\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/App.tsx?");
15845
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawAPIContext: () => (/* binding */ ExcalidrawAPIContext),\n/* harmony export */ ExcalidrawAPISetContext: () => (/* binding */ ExcalidrawAPISetContext),\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 */ useEditorInterface: () => (/* binding */ useEditorInterface),\n/* harmony export */ useExcalidrawAPI: () => (/* binding */ useExcalidrawAPI),\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 */ useStylesPanelMode: () => (/* binding */ useStylesPanelMode)\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_73__ = __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_common__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../actions/actionBoundText */ \"./actions/actionBoundText.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../actions/actionClipboard */ \"./actions/actionClipboard.tsx\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../actions/actionElementLock */ \"./actions/actionElementLock.ts\");\n/* harmony import */ var _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../actions/actionFrame */ \"./actions/actionFrame.ts\");\n/* harmony import */ var _actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../actions/actionHistory */ \"./actions/actionHistory.tsx\");\n/* harmony import */ var _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../actions/actionTextAutoResize */ \"./actions/actionTextAutoResize.ts\");\n/* harmony import */ var _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../actions/actionToggleViewMode */ \"./actions/actionToggleViewMode.tsx\");\n/* harmony import */ var _actions_manager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../actions/manager */ \"./actions/manager.tsx\");\n/* harmony import */ var _actions_register__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../actions/register */ \"./actions/register.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../data */ \"./data/index.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../data/library */ \"./data/library.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _gesture__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../gesture */ \"./gesture.ts\");\n/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../history */ \"./history.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_filesystem__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../data/filesystem */ \"./data/filesystem.ts\");\n/* harmony import */ var _components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ../components/hyperlink/Hyperlink */ \"./components/hyperlink/Hyperlink.tsx\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _snapping__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ../snapping */ \"./snapping.ts\");\n/* harmony import */ var _scene_Renderer__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ../scene/Renderer */ \"./scene/Renderer.ts\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ../components/ElementCanvasButtons */ \"./components/ElementCanvasButtons.tsx\");\n/* harmony import */ var _laserTrails__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ../laserTrails */ \"./laserTrails.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _textAutoResizeHandle__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ../textAutoResizeHandle */ \"./textAutoResizeHandle.ts\");\n/* harmony import */ var _wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ../wysiwyg/textWysiwyg */ \"./wysiwyg/textWysiwyg.tsx\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _mermaid__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ../mermaid */ \"./mermaid.ts\");\n/* harmony import */ var _lasso__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ../lasso */ \"./lasso/index.ts\");\n/* harmony import */ var _eraser__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ../eraser */ \"./eraser/index.ts\");\n/* harmony import */ var _shortcut__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ../shortcut */ \"./shortcut.ts\");\n/* harmony import */ var _charts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ../charts */ \"./charts/index.ts\");\n/* harmony import */ var _ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ./ConvertElementTypePopup */ \"./components/ConvertElementTypePopup.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ./BraveMeasureTextError */ \"./components/BraveMeasureTextError.tsx\");\n/* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ./ContextMenu */ \"./components/ContextMenu.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ./FollowMode/FollowMode */ \"./components/FollowMode/FollowMode.tsx\");\n/* harmony import */ var _LayerUI__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ./LayerUI */ \"./components/LayerUI.tsx\");\n/* harmony import */ var _MagicButton__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ./MagicButton */ \"./components/MagicButton.tsx\");\n/* harmony import */ var _SVGLayer__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ./SVGLayer */ \"./components/SVGLayer.tsx\");\n/* harmony import */ var _SearchMenu__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ./SearchMenu */ \"./components/SearchMenu.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _canvases__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ./canvases */ \"./components/canvases/index.tsx\");\n/* harmony import */ var _canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ./canvases/NewElementCanvas */ \"./components/canvases/NewElementCanvas.tsx\");\n/* harmony import */ var _hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ./hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _AppStateObserver__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ./AppStateObserver */ \"./components/AppStateObserver.ts\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _UnlockPopup__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ./UnlockPopup */ \"./components/UnlockPopup.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ./Tooltip */ \"./components/Tooltip.tsx\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_72__ = __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\nconst AppContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst AppPropsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst editorInterfaceContextInitialValue = {\n formFactor: \"desktop\",\n desktopUIMode: \"full\",\n userAgent: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.createUserAgentDescriptor)(typeof navigator !== \"undefined\" ? navigator.userAgent : \"\"),\n isTouchScreen: false,\n canFitSidebar: false,\n isLandscape: true\n};\nconst EditorInterfaceContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(editorInterfaceContextInitialValue);\nEditorInterfaceContext.displayName = \"EditorInterfaceContext\";\nconst editorLifecycleEventBehavior = {\n \"editor:mount\": {\n cardinality: \"once\",\n replay: \"last\"\n },\n \"editor:initialize\": {\n cardinality: \"once\",\n replay: \"last\"\n },\n \"editor:unmount\": {\n cardinality: \"once\",\n replay: \"last\"\n }\n};\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_22__.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 ExcalidrawAPIContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawAPIContext.displayName = \"ExcalidrawAPIContext\";\nconst ExcalidrawAPISetContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawAPISetContext.displayName = \"ExcalidrawAPISetContext\";\nconst useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppContext);\nconst useAppProps = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppPropsContext);\nconst useEditorInterface = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(EditorInterfaceContext);\nconst useStylesPanelMode = () => (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(useEditorInterface());\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);\n/**\n * Requires wrapping your component in <ExcalidrawAPIContext.Provider>\n */\n\nconst useExcalidrawAPI = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawAPIContext);\nlet didTapTwice = false;\nlet tappedTwiceTimer = 0;\nlet firstTapPosition = null;\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/**\n * Map of youtube embed video states\n */\n\nconst YOUTUBE_VIDEO_STATES = new Map();\nconst MAX_EMBEDDABLE_VIEWPORT_SCALE = 4;\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 createExcalidrawAPI() {\n const api = {\n isDestroyed: false,\n updateScene: this.updateScene,\n applyDeltas: this.applyDeltas,\n mutateElement: this.mutateElement,\n updateLibrary: this.library.updateLibrary,\n addFiles: this.addFiles,\n resetScene: this.resetScene,\n getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,\n getSceneElementsMapIncludingDeleted: this.getSceneElementsMapIncludingDeleted,\n history: {\n clear: this.resetHistory,\n undo: this.undo,\n //zsviczian\n redo: this.redo //zsviczian\n\n },\n scrollToContent: this.scrollToContent,\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 id: this.id,\n setActiveTool: this.setActiveTool,\n setCursor: this.setCursor,\n resetCursor: this.resetCursor,\n getEditorInterface: () => this.editorInterface,\n updateFrameRendering: this.updateFrameRendering,\n toggleSidebar: this.toggleSidebar,\n onChange: cb => this.onChangeEmitter.on(cb),\n onIncrement: cb => this.store.onStoreIncrementEmitter.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 onStateChange: this.onStateChange,\n onEvent: this.onEvent,\n setForceRenderAllEmbeddables: this.setForceRenderAllEmbeddables,\n //zsviczian\n zoomToFit: this.zoomToFit,\n //zsviczian\n refreshEditorInterface: this.refreshEditorInterface,\n //zsviczian\n setDesktopUIMode: this.setDesktopUIMode,\n //zsviczian\n setMobileModeAllowed: this.setMobileModeAllowed,\n //zsviczian\n isTouchScreen: this.isTouchScreen,\n //zsviczian\n isTrayModeEnabled: this.isTrayModeEnabled,\n //zsviczian\n getColorAtScenePoint: this.getColorAtScenePoint,\n //zsviczian\n startLineEditor: this.startLineEditor,\n //zsviczian\n refreshAllArrows: this.refreshAllArrows,\n //zsviczian\n updateContainerSize: this.updateContainerSize,\n //zsviczian\n selectElements: this.selectElements,\n //zsviczian\n sendBackward: this.sendBackward,\n //zsviczian\n bringForward: this.bringForward,\n //zsviczian\n sendToBack: this.sendToBack,\n //zsviczian\n bringToFront: this.bringToFront,\n //zsviczian\n getHTMLIFrameElement: id => this.getHTMLIFrameElement(id) //zsviczian\n\n };\n return api;\n }\n\n constructor(props) {\n super(props);\n this.interactiveCanvas = null;\n this.unmounted = false;\n this.editorInterface = editorInterfaceContextInitialValue;\n this.stylesPanelMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(editorInterfaceContextInitialValue);\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 /**\n * Indicates whether the embeddable's url has been validated for rendering.\n * If value not set, indicates that the validation is pending.\n * Initially or on url change the flag is not reset so that we can guarantee\n * the validation came from a trusted source (the editor).\n **/\n\n this.embedsValidationStatus = new Map();\n /** embeds that have been inserted to DOM (as a perf optim, we don't want to\n * insert to DOM before user initially scrolls to them) */\n\n this.initializedEmbeds = new Set();\n this.elementsPendingErasure = new Set();\n this._initialized = false;\n this.editorLifecycleEvents = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.AppEventBus(editorLifecycleEventBehavior);\n this.onEvent = this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents);\n this.appStateObserver = new _AppStateObserver__WEBPACK_IMPORTED_MODULE_67__.AppStateObserver(() => this.state);\n this.onStateChange = this.appStateObserver.onStateChange;\n this.flowChartCreator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartCreator();\n this.flowChartNavigator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartNavigator();\n this.bindModeHandler = null;\n this.lastPointerDownEvent = null;\n this.lastPointerUpEvent = null; // TODO this is a hack and we should ideally unify touch and pointer events\n // and implement our own double click handling end-to-end (currently we're\n // using a mix of native browser for click events and manual for touch -\n // and browser doubleClick sucks to begin with)\n\n this.lastPointerUpIsDoubleClick = false;\n this.lastPointerMoveEvent = null;\n /** current frame pointer cords */\n\n this.lastPointerMoveCoords = null;\n this.lastCompletedCanvasClicks = [];\n /** previous frame pointer coords */\n\n this.previousPointerMoveCoords = null;\n this.lastViewportPosition = {\n x: 0,\n y: 0\n };\n this.allowMobileMode = true; //zsviczian\n\n this.laserTrails = new _laserTrails__WEBPACK_IMPORTED_MODULE_42__.LaserTrails(this);\n this.eraserTrail = new _eraser__WEBPACK_IMPORTED_MODULE_49__.EraserTrail(this);\n this.lassoTrail = new _lasso__WEBPACK_IMPORTED_MODULE_48__.LassoTrail(this);\n this.onChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerDownEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerUpEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onUserFollowEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onScrollChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.missingPointerEventCleanupEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onRemoveEventListenersEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n\n this.updateEditorAtom = (atom, ...args) => {\n const result = _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.set(atom, ...args);\n this.triggerRender();\n return result;\n };\n\n this.previousHoveredBindableElement = null;\n /**\n * Returns gridSize taking into account `gridModeEnabled`.\n * If disabled, returns null.\n */\n\n this.getEffectiveGridSize = () => {\n return (0,_snapping__WEBPACK_IMPORTED_MODULE_38__.isGridModeEnabled)(this) ? this.state.gridSize : null;\n };\n\n this.getTextCreationGridPoint = (x, y) => {\n const effectiveGridSize = this.getEffectiveGridSize();\n\n if (effectiveGridSize === null) {\n return null;\n }\n\n const getTextCreationGridCoordinate = coordinate => {\n const topLeftGridPoint = Math.floor(coordinate / effectiveGridSize) * effectiveGridSize;\n return topLeftGridPoint;\n };\n\n return {\n x: getTextCreationGridCoordinate(x),\n y: getTextCreationGridCoordinate(y)\n };\n };\n\n this.handleIframeLikeElementHover = ({\n hitElement,\n scenePointer,\n moveEvent\n }) => {\n var _a;\n\n if (hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && (this.state.viewModeEnabled || this.state.activeTool.type === \"laser\" || this.isIframeLikeElementCenter(hitElement, moveEvent, scenePointer.x, scenePointer.y))) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"hover\"\n }\n });\n return true;\n } else if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.state) === \"hover\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n\n return false;\n };\n\n this.isDoubleClick = (lastPointerEvent, currentPointerEvent) => {\n return lastPointerEvent != null && currentPointerEvent.timeStamp - lastPointerEvent.timeStamp <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TAP_TWICE_TIMEOUT;\n };\n\n this.updateEmbedValidationStatus = (element, status) => {\n this.embedsValidationStatus.set(element.id, status);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(element)) {\n iframeLikes.add(element.id);\n\n if (!this.embedsValidationStatus.has(element.id)) {\n updated = true;\n const validated = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(element.link, this.props.validateEmbeddable);\n this.updateEmbedValidationStatus(element, validated);\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.viewportCoordsToSceneCoords)({\n clientX: box.x,\n clientY: box.y\n }, this.state);\n const boxSceneBottomRight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 /**\n * @private\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 var _a;\n\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_6__.THEME.DARK; //zsviczian\n\n const nonDeletedFramesLikes = this.state.frameRendering.markerName && this.state.frameRendering.markerEnabled ? this.scene.getNonDeletedFramesLikes() : this.scene.getNonDeletedFramesLikes().filter(f => f.frameRole !== \"marker\");\n const focusedSearchMatch = nonDeletedFramesLikes.length > 0 ? ((_a = this.state.searchMatches) === null || _a === void 0 ? void 0 : _a.focusedId) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(this.scene.getElement(this.state.searchMatches.focusedId)) ? this.state.searchMatches.matches.find(sm => sm.focus) : null : null;\n return nonDeletedFramesLikes.map(f => {\n var _a, _b;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.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_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.resetEditingFrame(f);\n }\n },\n style: {\n background: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.applyDarkModeFilter)(this.state.viewBackgroundColor, isDarkTheme),\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 //zsviczian (change to container)\n fontFamily: \"Assistant\",\n fontSize: `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameFontSize}px`,\n transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`,\n color: isDarkTheme ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorLightTheme,\n overflow: \"hidden\",\n maxWidth: `${(0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.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 className: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CLASSES.FRAME_NAME,\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_6__.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_6__.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_6__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorLightTheme,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameLineHeight,\n width: \"max-content\",\n maxWidth: (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.id) === f.id && (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.focus) ? \"none\" : `${f.width * this.state.zoom.value}px`,\n overflow: f.id === this.state.editingFrame ? \"visible\" : \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n cursor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE,\n pointerEvents: this.state.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.getSceneElementsMapIncludingDeleted = () => {\n return this.scene.getElementsMapIncludingDeleted();\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_21__.trackEvent)(\"export\", type, \"ui\");\n const fileHandle = await (0,_data__WEBPACK_IMPORTED_MODULE_24__.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_6__.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_32__.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_6__.TOOL_TYPE.magicframe\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"tool-select (empty-selection)\", \"d2c\");\n } else {\n const selectedMagicFrame = selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(el) || el.frameId)) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe\n });\n return;\n }\n\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.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__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const padding = 50;\n frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.insertNewElement(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_56__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n } else {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemBackgroundColor: color\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n [shouldUpdateStrokeColor ? \"strokeColor\" : \"backgroundColor\"]: color\n });\n }\n\n return el;\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n },\n keepOpenOnAlt: false\n });\n };\n\n this.dismissLinearEditor = () => {\n setTimeout(() => {\n var _a;\n\n if ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isEditing: false\n })\n });\n }\n });\n };\n\n this.syncActionResult = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(actionResult => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.unmounted || actionResult === false) {\n return;\n }\n\n this.store.scheduleAction(actionResult.captureUpdate);\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_6__.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_7__.isNonDeletedElement)(element) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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) {\n this.scene.triggerUpdate();\n }\n }); // Lifecycle\n\n this.onBlur = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(() => {\n isHoldingSpace = false;\n this.setState({\n isBindingEnabled: this.state.bindingPreference === \"enabled\"\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 }; // zsviczian\n\n\n this.undo = () => this.actionManager.executeAction(this.actionManager.actions.undo, \"api\"); // zsviczian\n\n\n this.redo = () => this.actionManager.executeAction(this.actionManager.actions.redo, \"api\");\n\n this.resetStore = () => {\n this.store.clear();\n };\n /**\n * Resets scene & history.\n * ! Do not use to clear scene user action !\n */\n\n\n this.resetScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(opts => {\n this.scene.replaceAllElements([]);\n this.setState(state => Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_22__.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 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 restoredElements = (0,_data_restore__WEBPACK_IMPORTED_MODULE_26__.restoreElements)(initialData === null || initialData === void 0 ? void 0 : initialData.elements, null, {\n repairBindings: true,\n deleteInvisibleElements: true\n });\n let restoredAppState = (0,_data_restore__WEBPACK_IMPORTED_MODULE_26__.restoreAppState)(initialData === null || initialData === void 0 ? void 0 : initialData.appState, null);\n const activeTool = restoredAppState.activeTool;\n\n if (!restoredAppState.preferredSelectionTool.initialized) {\n restoredAppState.preferredSelectionTool = {\n type: this.editorInterface.formFactor === \"phone\" ? \"lasso\" : \"selection\",\n initialized: true\n };\n }\n\n restoredAppState = Object.assign(Object.assign({}, restoredAppState), {\n theme: this.props.theme || restoredAppState.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: (restoredAppState === null || restoredAppState === void 0 ? void 0 : restoredAppState.openSidebar) || this.state.openSidebar,\n activeTool: activeTool.type === \"image\" || activeTool.type === \"lasso\" || activeTool.type === \"selection\" ? Object.assign(Object.assign({}, activeTool), {\n type: restoredAppState.preferredSelectionTool.type\n }) : restoredAppState.activeTool,\n isLoading: false,\n toast: this.state.toast\n });\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.scrollToContent) {\n restoredAppState = Object.assign(Object.assign({}, restoredAppState), (0,_scene__WEBPACK_IMPORTED_MODULE_30__.calculateScrollCenter)(restoredElements, Object.assign(Object.assign({}, restoredAppState), {\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({\n elements: restoredElements,\n appState: restoredAppState,\n files: initialData === null || initialData === void 0 ? void 0 : initialData.files,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(window.location.href)) {\n this.scrollToContent(window.location.href, {\n animate: false\n });\n }\n };\n\n this.getFormFactor = (editorWidth, editorHeight) => {\n var _a, _b, _c, _d, _e;\n\n if (((_b = (_a = this.props.UIOptions).getFormFactor) === null || _b === void 0 ? void 0 : _b.call(_a, editorWidth, editorHeight)) === \"phone\" && !this.allowMobileMode) {\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFormFactor)(editorWidth, editorHeight, this.allowMobileMode); //zsviczian\n }\n\n return (_e = (_d = (_c = this.props.UIOptions).getFormFactor) === null || _d === void 0 ? void 0 : _d.call(_c, editorWidth, editorHeight)) !== null && _e !== void 0 ? _e : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFormFactor)(editorWidth, editorHeight, this.allowMobileMode) //zsviczian\n ;\n };\n\n this.refreshEditorInterface = () => {\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 storedDesktopUIMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.loadDesktopUIModePreference)();\n const userAgentDescriptor = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.createUserAgentDescriptor)(typeof navigator !== \"undefined\" ? navigator.userAgent : \"\"); // allow host app to control formFactor and desktopUIMode via props\n\n const sidebarBreakpoint = this.props.UIOptions.dockedSidebarBreakpoint != null ? this.props.UIOptions.dockedSidebarBreakpoint : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_RIGHT_SIDEBAR_MIN_WIDTH;\n const nextEditorInterface = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.editorInterface, {\n desktopUIMode: storedDesktopUIMode !== null && storedDesktopUIMode !== void 0 ? storedDesktopUIMode : this.editorInterface.desktopUIMode,\n formFactor: this.getFormFactor(editorWidth, editorHeight),\n userAgent: userAgentDescriptor,\n canFitSidebar: editorWidth > sidebarBreakpoint,\n isLandscape: editorWidth > editorHeight\n });\n this.editorInterface = nextEditorInterface;\n this.reconcileStylesPanelMode(nextEditorInterface);\n };\n\n this.reconcileStylesPanelMode = nextEditorInterface => {\n const nextStylesPanelMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(nextEditorInterface);\n\n if (nextStylesPanelMode === this.stylesPanelMode) {\n return;\n }\n\n const prevStylesPanelMode = this.stylesPanelMode;\n this.stylesPanelMode = nextStylesPanelMode;\n\n if (prevStylesPanelMode !== \"full\" && nextStylesPanelMode === \"full\" || prevStylesPanelMode !== \"tray\" && nextStylesPanelMode === \"tray\" //zsviczian\n ) {\n this.setState(prevState => ({\n preferredSelectionTool: {\n type: \"selection\",\n initialized: true\n }\n }));\n }\n };\n /** TO BE USED LATER */\n\n\n this.setDesktopUIMode = mode => {\n const nextMode = mode; //setDesktopUIMode(mode); //zsviczian\n\n this.editorInterface = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.editorInterface, {\n desktopUIMode: nextMode\n });\n this.reconcileStylesPanelMode(this.editorInterface);\n this.refreshEditorInterface(); //zsviczian (set formfactor for mobile if needed (phone or tablet))\n\n this.triggerRender(true); //zsviczian\n }; //zsviczian\n\n\n this.isTouchScreen = () => {\n return this.editorInterface.isTouchScreen;\n }; //zsviczian\n\n\n this.isTrayModeEnabled = () => {\n return this.editorInterface.desktopUIMode === \"tray\";\n };\n\n this.onResize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(() => {\n this.scene.getElementsIncludingDeleted().forEach(element => _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element));\n this.refreshEditorInterface();\n this.updateDOMRect();\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_6__.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_6__.SCROLL_TIMEOUT); // Copy/paste\n\n this.onCut = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n this.onCopy = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.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_6__.isIOS) {\n event.preventDefault();\n }\n\n if (!didTapTwice) {\n didTapTwice = true;\n\n if (event.touches.length === 1) {\n firstTapPosition = {\n x: event.touches[0].clientX,\n y: event.touches[0].clientY\n };\n }\n\n clearTimeout(tappedTwiceTimer);\n tappedTwiceTimer = window.setTimeout(App.resetTapTwice, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TAP_TWICE_TIMEOUT);\n return;\n } // insert text only if we tapped twice with a single finger at approximately the same position\n // event.touches.length === 1 will also prevent inserting text when user's zooming\n\n\n if (didTapTwice && event.touches.length === 1 && firstTapPosition) {\n const touch = event.touches[0];\n const distance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(touch.clientX, touch.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(firstTapPosition.x, firstTapPosition.y)); // only create text if the second tap is within the threshold of the first tap\n // this prevents accidental text creation during dragging/selection\n\n if (distance <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DOUBLE_TAP_POSITION_THRESHOLD) {\n // end lasso trail and deselect elements just in case\n this.lassoTrail.endPath();\n this.deselectElements();\n this.handleCanvasDoubleClick({\n clientX: touch.clientX,\n clientY: touch.clientY,\n type: \"touch\",\n altKey: false,\n ctrlKey: false,\n metaKey: false,\n shiftKey: false\n });\n }\n\n didTapTwice = false;\n clearTimeout(tappedTwiceTimer);\n }\n\n if (event.touches.length === 2) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n } else {\n gesture.pointers.clear();\n }\n };\n\n this.pasteFromClipboard = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(async event => {\n var _a;\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_6__.isWritableElement)(target))) {\n return;\n } // 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\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_23__.parseDataTransferEvent)(event);\n const filesList = dataTransferList.getFiles();\n const data = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_23__.parseClipboard)(dataTransferList, isPlainPaste);\n\n if (this.props.onPaste) {\n try {\n if ((await this.props.onPaste(data, event, filesList)) === false) {\n //zsviczian\n return;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n await this.insertClipboardContent(data, filesList, isPlainPaste);\n this.setActiveTool({\n type: this.state.preferredSelectionTool.type\n }, true);\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_26__.restoreElements)(opts.elements, null, {\n deleteInvisibleElements: true\n });\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(elements);\n const elementsCenterX = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(minX, maxX) / 2;\n const elementsCenterY = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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_6__.getGridPoint)(dx, dy, this.getEffectiveGridSize());\n const {\n duplicatedElements\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: elements.map(element => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(element, {\n x: element.x + gridX - minX,\n y: element.y + gridY - minY\n });\n }),\n randomizeSeed: !opts.retainSeed,\n preserveFrameChildrenOrder: opts.preserveFrameChildrenOrder\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__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(nextElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(duplicatedElements));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n\n if (topLayerFrame) {\n const eligibleElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.filterElementsEligibleAsFrameChildren)(duplicatedElements, topLayerFrame);\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, eligibleElements, topLayerFrame);\n }\n\n this.scene.replaceAllElements(nextElements);\n duplicatedElements.forEach(newElement => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(newElement)) {\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(newElement, this.scene.getElementsMapIncludingDeleted());\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_35__.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 const nextElementsToSelect = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.excludeElementsInFramesFromSelection)(duplicatedElements);\n this.store.scheduleCapture();\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.editorInterface.canFitSidebar && _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_62__.isSidebarDockedAtom) ? this.state.openSidebar : null\n }), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: null,\n selectedElementIds: nextElementsToSelect.reduce((acc, element) => {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: this.state.preferredSelectionTool.type\n }, true);\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_21__.trackEvent)(\"toolbar\", \"toggleLock\", `${source} (${this.editorInterface.formFactor === \"phone\" ? \"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_6__.updateActiveTool)(this.state, prevState.activeTool.locked ? {\n type: this.state.preferredSelectionTool.type\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, _e, _f;\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 //zsviczian\n markerName: (_e = next === null || next === void 0 ? void 0 : next.markerName) !== null && _e !== void 0 ? _e : prevState.frameRendering.markerName,\n markerEnabled: (_f = next === null || next === void 0 ? void 0 : next.markerEnabled) !== null && _f !== void 0 ? _f : prevState.frameRendering.markerEnabled\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_10__.actionToggleHandTool));\n };\n /**\n * Zooms on canvas viewport center\n */\n\n\n this.zoomCanvas = (\n /**\n * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.\n * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom\n */\n value) => {\n this.setState(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_31__.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_30__.getNormalizedZoom)(value)\n }, this.state)));\n };\n\n this.cancelInProgressAnimation = null;\n\n this.scrollToContent = (\n /**\n * target to scroll to\n *\n * - string - id of element or group, or url containing elementLink\n * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects\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__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n id = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n this.setState({\n toast: {\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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_10__.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_30__.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_6__.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_6__.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_70__.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_10__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(el)) {\n return;\n } // First select the element\n\n\n this.setState({\n selectedElementIds: {\n [el.id]: true\n }\n }, () => {\n // Then set up the editor\n const linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(el, this.scene.getNonDeletedElementsMap());\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n isEditing: true,\n selectedPointsIndices\n })\n });\n });\n }; //zsviczian\n\n\n this.refreshAllArrows = () => {\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.refreshAllArrows)(this.scene, this.store);\n }; //zsviczian\n\n\n this.updateContainerSize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(containers => {\n containers.forEach(element => {\n // Get absolute coordinates for the bottom-right corner\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getNextSingleWidthAndHeightFromPointer)(element, element, \"se\", pointerX, pointerY);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.APP_NAME, window.location.pathname);\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n };\n /**\n * adds supplied files to existing files in the appState.\n * NOTE if file already exists in editor state, the file data is not updated\n * */\n\n\n this.addFiles = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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 this.allowMobileMode = allow;\n this.refreshEditorInterface();\n this.triggerRender();\n this.setDesktopUIMode(this.editorInterface.desktopUIMode);\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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_8__.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_8__.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_8__.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_8__.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_6__.MIME_TYPES.svg) {\n try {\n const restoredDataURL = (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.getDataURL_sync)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)((0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.dataURLToString)(fileData.dataURL)), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdates)(sceneData => {\n const {\n elements,\n appState,\n collaborators,\n captureUpdate\n } = sceneData;\n\n if (captureUpdate) {\n const nextElements = elements ? elements : undefined;\n const observedAppState = appState ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getObservedAppState)(Object.assign(Object.assign({}, this.store.snapshot.appState), appState)) : undefined;\n this.store.scheduleMicroAction({\n action: captureUpdate,\n elements: nextElements,\n appState: observedAppState\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 (appState) {\n this.setState(appState);\n }\n });\n } else if (appState) {\n this.setState(appState);\n }\n\n if (elements) {\n this.scene.replaceAllElements(elements);\n }\n\n if (collaborators) {\n this.laserTrails.updateCollabTrails(collaborators);\n this.setState({\n collaborators\n });\n }\n });\n\n this.applyDeltas = (deltas, options) => {\n // squash all deltas together, starting with a fresh new delta instance\n const aggregatedDelta = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.squash(...deltas); // create new instance of elements map & appState, so we don't accidentaly mutate existing ones\n\n const nextAppState = Object.assign({}, this.state);\n const nextElements = new Map(this.scene.getElementsMapIncludingDeleted());\n return _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.applyTo(aggregatedDelta, nextElements, nextAppState, options);\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 /**\n * @returns whether the menu was toggled on or off\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_43__.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_29__.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_43__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\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_6__.isInputLike)(event.target)) {\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) && this.state.croppingElementId) {\n this.finishImageCropping();\n return;\n }\n\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_30__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0]) && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.startImageCropping(selectedElements[0]);\n return;\n } // Shape switching\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom, null);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.CLASSES.CONVERT_ELEMENT_TYPE_POPUP)))) {\n event.preventDefault();\n const conversionType = (0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.getConversionTypeFromElements)(selectedElements);\n\n if (((_c = _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom)) === null || _c === void 0 ? void 0 : _c.type) === \"panel\") {\n if ((0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypes)(this, {\n conversionType,\n direction: event.shiftKey ? \"left\" : \"right\"\n })) {\n this.store.scheduleCapture();\n }\n }\n\n if (conversionType) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom, {\n type: \"panel\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.isArrowKey)(event.key);\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && arrowKeyPressed && !event.shiftKey) {\n event.preventDefault();\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_30__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFlowchartNodeElement)(selectedElements[0])) {\n this.flowChartCreator.createNodes(selectedElements[0], this.state, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key), this.scene);\n }\n\n if (((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_30__.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__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key));\n\n if (nextId) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [nextId]: true\n }, prevState)\n }));\n const nextNode = this.scene.getNonDeletedElementsMap().get(nextId);\n\n if (nextNode && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.P && !event.shiftKey && !event.altKey) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"commandPalette.shortcutHint\", {\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__.getShortcutFromShortcutName)(\"commandPalette\")\n })\n });\n event.preventDefault();\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n if (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.isWritableElement)(event.target) && // unless pressing escape (finalize action)\n event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || // or unless using arrows (to move between buttons)\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target)) {\n return;\n } //mfuria #329. open context menu with 'm' if not editing text and container focused\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isPanWithRightMouseEnabled)() && event.key.toLowerCase() === 'm' && !this.state.editingTextElement && // don't trigger when typing in inputs\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target) && ( // ensure focus is within excalidraw container\n (_f = (_e = this.excalidrawContainerRef) === null || _e === void 0 ? void 0 : _e.current) === null || _f === void 0 ? void 0 : _f.contains(document.activeElement))) {\n // open context menu at current cursor position\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = this.lastViewportPosition.x - offsetLeft;\n const top = this.lastViewportPosition.y - offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, 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 this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n event.preventDefault();\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.E && event.shiftKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.PAGE_UP || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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 (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") {\n return;\n } // Handle Alt key for bind mode\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT) {\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleSkipBindMode();\n } else {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n }\n\n if (this.actionManager.handleKeyDown(event)) {\n return;\n } // view mode hardcoded from upstream -> disable tool switching for now\n\n\n const shouldPreventToolSwitching = this.props.viewModeEnabled === true;\n\n if (!shouldPreventToolSwitching && this.state.viewModeEnabled && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE) {\n this.setActiveTool({\n type: \"selection\"\n });\n return;\n }\n\n if (!shouldPreventToolSwitching && !event.ctrlKey && !event.altKey && !event.metaKey && !this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged) {\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_68__.findShapeByKey)(event.key, this);\n\n if (this.state.viewModeEnabled && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.oneOf)(shape, [\"laser\", \"hand\"])) {\n return;\n }\n\n if (shape) {\n if (this.state.activeTool.type !== shape) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"toolbar\", shape, `keyboard (${this.editorInterface.formFactor === \"phone\" ? \"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_6__.ARROW_TYPE.sharp ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round : prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.sharp\n }));\n }\n\n if (shape === \"lasso\" && this.state.activeTool.type === \"laser\") {\n this.setActiveTool({\n type: this.state.preferredSelectionTool.type\n });\n } else {\n this.setActiveTool({\n type: shape\n });\n }\n\n event.stopPropagation();\n return;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.Q) {\n this.toggleLock(\"keyboard\");\n event.stopPropagation();\n return;\n }\n }\n\n if (this.state.viewModeEnabled) {\n // revert to selection in case a key is pressed (K is handled above)\n if (event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K) {\n this.setActiveTool({\n type: \"selection\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !event.repeat) {\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.resetDelayedBindMode();\n }\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n isBindingEnabled: this.state.bindingPreference !== \"enabled\"\n });\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n let selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n const arrowIdsToRemove = new Set();\n selectedElements.filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(el)).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_6__.ELEMENT_TRANSLATE_AMOUNT : this.getEffectiveGridSize()) || (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_SHIFT_TRANSLATE_AMOUNT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_TRANSLATE_AMOUNT);\n let offsetX = 0;\n let offsetY = 0;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_LEFT) {\n offsetX = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_RIGHT) {\n offsetX = step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_UP) {\n offsetY = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene, {\n simultaneouslyUpdated: selectedElements\n });\n });\n this.scene.triggerUpdate();\n event.preventDefault();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedElement)) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElement)) {\n if (!((_h = this.state.selectedLinearElement) === null || _h === void 0 ? void 0 : _h.isEditing) || this.state.selectedLinearElement.elementId !== selectedElement.id) {\n this.store.scheduleCapture();\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElement)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n }\n }\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isValidTextContainer)(selectedElement)) {\n let container;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n container = selectedElement;\n }\n\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(selectedElement)) {\n this.setState({\n editingFrame: selectedElement.id\n });\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(selectedElement)) {\n //zsviczian\n this.setState({\n activeEmbeddable: {\n element: selectedElement,\n state: \"active\"\n }\n });\n }\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE && gesture.pointers.size === 0) {\n isHoldingSpace = true;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n event.preventDefault();\n }\n\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.KEYS.G && ((0,_scene__WEBPACK_IMPORTED_MODULE_30__.hasBackground)(this.state.activeTool.type) || selectedElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_30__.hasBackground)(element.type)))) {\n this.setState({\n openPopup: \"elementBackground\"\n });\n event.stopPropagation();\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) {\n this.setState({\n openPopup: \"elementStroke\"\n });\n event.stopPropagation();\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(element, this.scene.getNonDeletedElementsMap()))) {\n event.preventDefault();\n this.setState({\n openPopup: \"fontFamily\"\n });\n }\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.BACKSPACE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.DELETE)) {\n this.updateEditorAtom(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_53__.activeConfirmDialogAtom, \"clearCanvas\");\n } // eye dropper\n // -----------------------------------------------------------------------\n\n\n const lowerCased = event.key.toLocaleLowerCase();\n const isPickingStroke = lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S && event.shiftKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD];\n const isPickingBackground = event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.I || lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdates)(event => {\n var _a, _b, _c;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE) {\n if (this.state.viewModeEnabled && this.state.activeTool.type !== \"laser\" || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(this.state.activeTool.type)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n isHoldingSpace = false;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT && this.state.bindMode === \"skip\" || !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state)) {\n // Handle Alt key release for bind mode\n this.setState({\n bindMode: \"orbit\"\n }); // Restart the timer if we're creating/editing a linear element and hovering over an element\n\n if (this.lastPointerMoveEvent && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastPointerMoveEvent.clientX,\n clientY: this.lastPointerMoveEvent.clientY\n }, this.state);\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap());\n\n if (this.state.selectedLinearElement) {\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n this.handleDelayedBindModeChange(element, hoveredElement);\n }\n }\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n const preferenceEnabled = this.state.bindingPreference === \"enabled\";\n\n if (this.state.isBindingEnabled !== preferenceEnabled) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n isBindingEnabled: preferenceEnabled\n });\n });\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeHandleArrowPointlikeDrag)({\n app: this,\n event\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindBindingElements)(this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement), this.scene, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow).forEach(element => {\n // Update the fixed point bindings for non-elbow arrows\n // when the pointer is released, so that they are correctly positioned\n // after the drag.\n if (element.startBinding) {\n this.scene.mutateElement(element, {\n startBinding: Object.assign(Object.assign({}, element.startBinding), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.calculateFixedPointForNonElbowArrowBinding)(element, elementsMap.get(element.startBinding.elementId), \"start\", elementsMap))\n });\n }\n\n if (element.endBinding) {\n this.scene.mutateElement(element, {\n endBinding: Object.assign(Object.assign({}, element.endBinding), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.calculateFixedPointForNonElbowArrowBinding)(element, elementsMap.get(element.endBinding.elementId), \"end\", elementsMap))\n });\n }\n });\n this.setState({\n suggestedBinding: null\n });\n }\n\n if (!event.altKey) {\n if (this.flowChartNavigator.isExploring) {\n this.flowChartNavigator.clear();\n this.syncActionResult({\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (this.flowChartCreator.isCreatingChart) {\n if ((_b = this.flowChartCreator.pendingNodes) === null || _b === void 0 ? void 0 : _b.length) {\n this.insertNewElements(this.flowChartCreator.pendingNodes);\n }\n\n const firstNode = (_c = this.flowChartCreator.pendingNodes) === null || _c === void 0 ? void 0 : _c[0];\n\n if (firstNode) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [firstNode.id]: true\n }, prevState)\n }));\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 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_6__.updateActiveTool)(this.state, tool);\n\n if (nextActiveTool.type === \"hand\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (!isHoldingSpace) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, Object.assign(Object.assign({}, this.state), {\n activeTool: nextActiveTool\n }));\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isToolIcon)(document.activeElement)) {\n this.focusContainer();\n }\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElementType)(nextActiveTool.type)) {\n this.setState({\n suggestedBinding: null\n });\n }\n\n if (nextActiveTool.type === \"image\") {\n this.onImageToolbarButtonClick();\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 selectedLinearElement: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(nextActiveTool.type) ? prevState.selectedLinearElement : null,\n frameToHighlight: null\n };\n\n if (nextActiveTool.type === \"freedraw\") {\n this.store.scheduleCapture();\n }\n\n if (nextActiveTool.type === \"lasso\") {\n return Object.assign(Object.assign(Object.assign(Object.assign({}, prevState), commonResets), {\n activeTool: nextActiveTool\n }), keepSelection ? {} : {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n });\n } else if (nextActiveTool.type !== \"selection\") {\n return Object.assign(Object.assign(Object.assign({}, prevState), commonResets), {\n activeTool: nextActiveTool,\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextActiveTool.type === \"mermaid\" //zsviczian\n ? this.state.selectedElementIds : {}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n });\n }\n\n return Object.assign(Object.assign(Object.assign({}, prevState), commonResets), {\n activeTool: nextActiveTool\n });\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_40__.setCursor)(this.interactiveCanvas, cursor);\n };\n\n this.resetCursor = () => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n };\n /**\n * returns whether user is making a gesture with >= 2 fingers (points)\n * on o touch screen (not on a trackpad). Currently only relates to Darwin\n * (iOS/iPadOS,MacOS), but may work on other devices in the future if\n * GestureEvent is standardized.\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_29__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`;\n }; // fires only on Safari\n\n\n this.onGestureStart = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(event => {\n //zsviczian - start\n // If an embeddable is active and the pinch starts over it, let it handle the gesture.\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.shouldDisableZoom)(this.state)) {\n gesture.initialScale = null;\n return;\n }\n\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__WEBPACK_IMPORTED_MODULE_7__.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_43__.withBatchedUpdates)(event => {\n //zsviczian\n if (!gesture.initialScale) {\n return;\n }\n\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_31__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_30__.getNormalizedZoom)(initialScale * event.scale)\n }, state)));\n }\n }); // fires only on Safari\n\n this.onGestureEnd = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n }\n\n gesture.initialScale = null;\n });\n\n this.isHittingTextAutoResizeHandle = (selectedElements, point) => {\n const activeTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getActiveTextElement)(selectedElements, this.state);\n\n if (activeTextElement && !activeTextElement.isDeleted && !activeTextElement.autoResize && (0,_textAutoResizeHandle__WEBPACK_IMPORTED_MODULE_44__.isPointHittingTextAutoResizeHandle)(point, activeTextElement, this.state.zoom.value, this.editorInterface.formFactor)) {\n return true;\n }\n\n return false;\n };\n\n this.handleTextAutoResizeHandlePointerDown = (selectedElements, point) => {\n const activeTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getActiveTextElement)(selectedElements, this.state);\n\n if (!activeTextElement || !this.isHittingTextAutoResizeHandle(selectedElements, point)) {\n return false;\n }\n\n this.actionManager.executeAction(_actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__.actionTextAutoResize, \"ui\", // we need to pass down the element since it may already be deselected\n // due to the pointerdown\n activeTextElement);\n this.resetCursor();\n return true;\n };\n\n this.startTextEditing = ({\n sceneX,\n sceneY,\n insertAtParentCenter = true,\n container,\n autoEdit = true,\n initialCaretSceneCoords\n }) => {\n var _a, _b;\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__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(container, this.scene.getNonDeletedElementsMap());\n\n if (!boundTextElementToContainer) {\n shouldBindToContainer = true;\n }\n }\n\n const existingTextElement = this.getSelectedTextElement(container) || this.getTextElementAtPosition(sceneX, sceneY);\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_6__.getLineHeight)(fontFamily);\n const fontSize = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_72__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value); //zsviczian\n\n if (!existingTextElement && shouldBindToContainer && container && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n const fontString = {\n fontSize,\n fontFamily\n };\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getApproxMinLineWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)(fontString), lineHeight);\n const minHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 textCreationGridPoint = this.getTextCreationGridPoint(sceneX, sceneY);\n const newTextElementPosition = parentCenterPosition ? {\n x: parentCenterPosition.elementCenterX,\n y: parentCenterPosition.elementCenterY\n } : !existingTextElement ? {\n x: (_a = textCreationGridPoint === null || textCreationGridPoint === void 0 ? void 0 : textCreationGridPoint.x) !== null && _a !== void 0 ? _a : sceneX,\n y: textCreationGridPoint === null ? // Free text starts from a point cursor, so center the first line box on it.\n sceneY - (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLineHeightInPx)(fontSize, lineHeight) / 2 : textCreationGridPoint.y\n } : {\n x: sceneX,\n y: sceneY\n };\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: newTextElementPosition.x,\n y: newTextElementPosition.y\n }); // container has higher priority. Only add to frame if container is in the same frame.\n\n const frameId = topLayerFrame && (!shouldBindToContainer || !container || container.frameId === topLayerFrame.id) ? topLayerFrame.id : null;\n const element = existingTextElement || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newTextElement)({\n x: newTextElementPosition.x,\n y: newTextElementPosition.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 roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text: \"\",\n rawText: \"\",\n //zsviczian\n fontSize,\n fontFamily,\n textAlign: parentCenterPosition ? \"center\" : this.state.currentItemTextAlign,\n verticalAlign: parentCenterPosition ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.VERTICAL_ALIGN.MIDDLE : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n containerId: shouldBindToContainer ? container === null || container === void 0 ? void 0 : container.id : undefined,\n groupIds: (_b = container === null || container === void 0 ? void 0 : container.groupIds) !== null && _b !== void 0 ? _b : [],\n lineHeight,\n angle: container ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) ? 0 : container.angle : 0,\n frameId\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); // TODO should use insertNewElement, after we update it to handle\n // elements with containerId + frameId at the same time (containerId\n // should take precedence when it comes to z-index)\n\n this.scene.insertElementsAtIndex([element], containerIndex + 1);\n } else {\n this.insertNewElement(element);\n }\n }\n\n if (autoEdit || existingTextElement || container) {\n this.handleTextWysiwyg(element, {\n isExistingElement: !!existingTextElement,\n initialCaretSceneCoords: existingTextElement ? initialCaretSceneCoords : null\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.scheduleCapture();\n this.setState({\n croppingElementId: image.id\n });\n };\n\n this.finishImageCropping = () => {\n if (this.state.croppingElementId) {\n this.store.scheduleCapture();\n this.setState({\n croppingElementId: null\n });\n }\n };\n\n this.shouldHandleBrowserCanvasDoubleClick = type => {\n // TODO remove this once we consolidate double-click logic and handle\n // ourselves for all event types together\n if (type === \"touch\") {\n return true;\n }\n\n if (this.lastCompletedCanvasClicks.length === 0) {\n return true;\n }\n\n if (this.lastCompletedCanvasClicks.length < 2) {\n return false;\n }\n\n const [firstClick, secondClick] = this.lastCompletedCanvasClicks;\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(firstClick.x, firstClick.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(secondClick.x, secondClick.y)) <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DOUBLE_TAP_POSITION_THRESHOLD;\n };\n\n this.handleCanvasDoubleClick = event => {\n var _a, _b, _c, _d;\n\n if (this.state.editingTextElement || !this.shouldHandleBrowserCanvasDoubleClick(event.type)) {\n return;\n } // 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_70__.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_10__.actionToggleEraserTool.perform([], this.state, null, this));\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 !== this.state.preferredSelectionTool.type) {\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_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0])) {\n const selectedLinearElement = selectedElements[0];\n\n if ((event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow)(selectedLinearElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) && (!((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.isEditing) || this.state.selectedLinearElement.elementId !== selectedLinearElement.id)) {\n // Use the proper action to ensure immediate history capture\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n return;\n } else if (this.state.selectedLinearElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) {\n const hitCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(this.state.selectedLinearElement, {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const midPoint = hitCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, hitCoords, this.scene.getNonDeletedElementsMap()) : -1;\n\n if (midPoint && midPoint > -1) {\n this.store.scheduleCapture();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.deleteFixedSegment(selectedElements[0], this.scene, midPoint);\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n segmentMidpoint: {\n index: nextIndex,\n value: hitCoords,\n added: false\n }\n }),\n segmentMidPointHoveredCoords: nextCoords\n })\n });\n return;\n }\n } else if (((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing) && this.state.selectedLinearElement.elementId === selectedLinearElement.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) {\n return;\n }\n }\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0])) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n const selectedGroupIds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIds)(this.state);\n\n if (selectedGroupIds.length > 0) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n const selectedGroupId = hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIdForElement)(hitElement, this.state.selectedGroupIds);\n\n if (selectedGroupId) {\n this.store.scheduleCapture();\n this.setState(prevState => Object.assign(Object.assign({}, prevState), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_40__.resetCursor)(this.interactiveCanvas);\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !this.state.viewModeEnabled) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement)) {\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"active\"\n }\n });\n return;\n } // shouldn't edit/create text when inside line editor (often false positive)\n\n\n if (!((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing)) {\n const container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if (container) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hasBoundTextElement)(container) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isTransparent)(container.backgroundColor) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(sceneX, sceneY),\n element: container,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(container)\n })) {\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_70__.disableDoubleClickTextEditing)()) {\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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\n this.handleCanvasClick = event => {\n if (event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN) {\n this.lastCompletedCanvasClicks = [];\n return;\n }\n\n this.lastCompletedCanvasClicks = [...this.lastCompletedCanvasClicks.slice(-1), {\n x: event.clientX,\n y: event.clientY\n }];\n };\n\n this.getElementLinkAtPosition = (scenePointer, hitElementMightBeLocked) => {\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n return undefined;\n }\n\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 (hitElementMightBeLocked && element.id === hitElementMightBeLocked.id) {\n hitElementIndex = index;\n }\n\n if ((element.link || element.hasTextLink) && //zsviczian\n index >= hitElementIndex && (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__.isPointHittingLink)(element, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.editorInterface.formFactor === \"phone\")) {\n return element;\n }\n }\n };\n\n this.handleElementLinkClick = event => {\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_6__.DRAGGING_THRESHOLD) {\n return;\n }\n\n const lastPointerDownCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerDownEvent, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const lastPointerDownHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerDownCoords.x, lastPointerDownCoords.y), this.editorInterface.formFactor === \"phone\");\n const lastPointerUpCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerUpEvent, this.state);\n const lastPointerUpHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_65__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerUpCoords.x, lastPointerUpCoords.y), this.editorInterface.formFactor === \"phone\");\n\n if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_34__.hideHyperlinkToolip)();\n let url = this.hitLinkElement.link;\n\n if (url || this.hitLinkElement.hasTextLink) {\n //zsviczian\n url = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(url !== null && url !== void 0 ? url : \"\"); //zsviczian\n\n let customEvent;\n\n if (this.props.onLinkOpen) {\n customEvent = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.wrapEvent)(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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 * finds candidate frame under cursor (when dragging frame children/elements\n * inside frames)\n */\n\n\n this.getTopLayerFrameAtSceneCoords = (\n /**\n * should be already grid aligned (basically should be what the call site\n * sets the element's coords to, if applicable)\n */\n sceneCoords, opts) => {\n var _a, _b;\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const framesUnderCursor = this.scene.getNonDeletedFramesLikes().filter(frame => !frame.locked && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isCursorInFrame)(sceneCoords, frame, elementsMap) && frame.frameRole !== \"marker\");\n\n if (!framesUnderCursor.length) {\n return null;\n }\n\n const topLayerFrame = framesUnderCursor.at(-1);\n const hitElement = this.getElementsAtPosition(sceneCoords.x, sceneCoords.y, {\n includeLockedElements: true\n }).findLast(element => {\n var _a;\n\n return !((_a = opts === null || opts === void 0 ? void 0 : opts.excludeElementIds) === null || _a === void 0 ? void 0 : _a[element.id]);\n });\n\n if (hitElement) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement) && // case: we're hitting a locked frame itself (frame's outline\n // or later its bg once implemented)\n !hitElement.locked) {\n return topLayerFrame;\n }\n\n const hitElementIndex = this.scene.getElementIndex(hitElement.id);\n const topLayerFrameIndex = this.scene.getElementIndex(topLayerFrame.id);\n\n if (hitElementIndex !== -1 && topLayerFrameIndex !== -1 && hitElementIndex <= topLayerFrameIndex) {\n return topLayerFrame;\n } // to support a case of dragging a pre-existing frame child underneath\n // a non-frame element covering the cursor\n\n\n const currentFrame = (opts === null || opts === void 0 ? void 0 : opts.currentFrameId) ? (_a = framesUnderCursor.find(frame => frame.id === opts.currentFrameId)) !== null && _a !== void 0 ? _a : null : null;\n\n if (currentFrame) {\n return currentFrame;\n }\n\n return hitElement.frameId ? (_b = framesUnderCursor.find(frame => frame.id === hitElement.frameId)) !== null && _b !== void 0 ? _b : null : null;\n }\n\n return topLayerFrame;\n };\n\n this.updateFrameToHighlight = frameToHighlight => {\n if (this.state.frameToHighlight !== frameToHighlight) {\n this.setState({\n frameToHighlight\n });\n }\n };\n\n this.maybeUpdateFrameToHighlightOnPointerMove = (sceneCoords, isOverScrollBar) => {\n // currently this function is being called even during pointerdown so we\n // need to make sure we don't re-set the state when dragging and similar\n //\n // But, we still want to reset on pointermove in case the state is stale\n // so we updte even for non-eligible tool types\n if (this.state.newElement || this.state.multiElement || this.state.selectionElement || this.state.selectedElementsAreBeingDragged) {\n return;\n }\n\n this.updateFrameToHighlight(!isOverScrollBar && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEligibleFrameChildType)(this.state.activeTool.type) ? this.getTopLayerFrameAtSceneCoords(sceneCoords) : null);\n };\n\n this.insertNewElements = (elements, idx) => {\n //zsviczian added idx for highligher pens\n if (!elements.length) {\n return;\n }\n\n const chunkedElements = [];\n\n for (const element of elements) {\n const currentChunk = chunkedElements[chunkedElements.length - 1];\n\n if ((currentChunk === null || currentChunk === void 0 ? void 0 : currentChunk[0].frameId) === element.frameId) {\n currentChunk.push(element);\n } else {\n chunkedElements.push([element]);\n }\n }\n\n for (const chunk of chunkedElements) {\n const frameId = chunk[0].frameId;\n const insertionIndex = frameId ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildrenInsertionIndex)(this.scene.getElementsIncludingDeleted(), frameId) : null;\n this.scene.insertElementsAtIndex(chunk, idx !== null && idx !== void 0 ? idx : insertionIndex);\n }\n };\n\n this.insertNewElement = (element, idx) => {\n //zsviczian added idx for highligher pens\n this.insertNewElements([element], idx); //zsviczian\n\n const frame = element.frameId ? this.scene.getNonDeletedElement(element.frameId) : null;\n this.updateFrameToHighlight(frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(frame) ? frame : null);\n };\n\n this.handleCanvasPointerMove = event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n\n this.savePointer(event.clientX, event.clientY, this.state.cursorButton);\n this.lastPointerMoveEvent = event.nativeEvent;\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n this.lastPointerMoveCoords = {\n x: scenePointerX,\n y: scenePointerY\n };\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_27__.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_27__.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_30__.getNormalizedZoom)(initialScale * scaleFactor) : this.state.zoom.value;\n this.setState(state => {\n const zoomState = (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_31__.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 return null;\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_22__.isHandToolActive)(this.state)) {\n return;\n }\n\n const isPointerOverScrollBars = (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_46__.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_40__.resetCursor)(this.interactiveCanvas);\n } else if (isPenFreedraw && this.interactiveCanvas && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.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_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n this.maybeUpdateFrameToHighlightOnPointerMove({\n x: scenePointerX,\n y: scenePointerY\n }, isOverScrollBar);\n\n if (!this.state.newElement && (0,_snapping__WEBPACK_IMPORTED_MODULE_38__.isActiveToolNonLinearSnappable)(this.state.activeTool.type)) {\n const {\n originOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_38__.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_6__.updateStable)(prevState.snapLines, snapLines);\n const nextOriginOffset = prevState.originSnapOffset ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 (((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !this.state.selectedLinearElement.isDragging) {\n const editingLinearElement = this.state.newElement ? null : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMoveInEditMode(event, scenePointerX, scenePointerY, this);\n\n if (editingLinearElement && editingLinearElement !== this.state.selectedLinearElement) {\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 selectedLinearElement: editingLinearElement\n });\n });\n }\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 (!newElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state)) {\n const globalPoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(globalPoint, this.scene.getNonDeletedElements(), elementsMap, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maxBindingDistance_simple)(this.state.zoom));\n\n if (hoveredElement) {\n this.setState({\n suggestedBinding: {\n element: hoveredElement,\n midPoint: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSnapOutlineMidPoint)(globalPoint, hoveredElement, elementsMap, this.state.zoom)\n }\n });\n } else if (this.state.suggestedBinding) {\n this.setState({\n suggestedBinding: null\n });\n }\n }\n }\n\n if (this.state.multiElement && this.state.selectedLinearElement) {\n const {\n multiElement,\n selectedLinearElement\n } = this.state;\n const {\n x: rx,\n y: ry,\n points\n } = multiElement;\n const lastPoint = points[points.length - 1];\n const {\n lastCommittedPoint\n } = selectedLinearElement;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n\n if (lastPoint === lastCommittedPoint) {\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(this.state.newElement) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maxBindingDistance_simple)(this.state.zoom));\n\n if (hoveredElement) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: event.nativeEvent,\n sceneCoords: {\n x: scenePointerX,\n y: scenePointerY\n }\n });\n this.setState({\n suggestedBinding: null\n });\n\n if (!this.state.activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n }),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(multiElement, this.scene.getNonDeletedElementsMap())\n }));\n }\n } else if ( // if we haven't yet created a temp point and we're beyond commit-zone\n // threshold, add a point\n (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_6__.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 (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.initialState, \"initialState must be set\");\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n lastCommittedPoint: points[points.length - 1],\n selectedPointsIndices: [multiElement.points.length - 1],\n initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n lastClickedPoint: multiElement.points.length - 1\n })\n })\n });\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.LINE_CONFIRM_THRESHOLD) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.scene.mutateElement(multiElement, {\n points: points.slice(0, -1)\n }, {\n informMutation: false,\n isDragging: false\n });\n const newLastIdx = multiElement.points.length - 1;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, selectedLinearElement), {\n selectedPointsIndices: selectedLinearElement.selectedPointsIndices ? [...new Set(selectedLinearElement.selectedPointsIndices.map(idx => Math.min(idx, newLastIdx)))] : selectedLinearElement.selectedPointsIndices,\n lastCommittedPoint: multiElement.points[newLastIdx],\n initialState: Object.assign(Object.assign({}, selectedLinearElement.initialState), {\n lastClickedPoint: newLastIdx\n })\n })\n });\n } else {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(points, this.state.zoom.value)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } // Update arrow points\n\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow)(multiElement)) {\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY), this.scene.getNonDeletedElements(), elementsMap);\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleDelayedBindModeChange(multiElement, hoveredElement);\n }\n }\n\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.state.selectedLinearElement, \"Expected selectedLinearElement to be set to operate on a linear element\");\n const newState = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event.nativeEvent, this, scenePointerX, scenePointerY, this.state.selectedLinearElement);\n\n if (newState) {\n this.setState(newState);\n }\n }\n\n return;\n }\n\n if (this.state.activeTool.type === \"arrow\") {\n const hit = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maxBindingDistance_simple)(this.state.zoom));\n const scenePointer = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (hit && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPointInElement)(scenePointer, hit, elementsMap)) {\n this.setState({\n suggestedBinding: {\n element: hit,\n midPoint: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSnapOutlineMidPoint)(scenePointer, hit, elementsMap, this.state.zoom)\n }\n });\n }\n }\n\n const isPressingAnyButton = Boolean(event.buttons);\n const isLaserTool = this.state.activeTool.type === \"laser\";\n\n if (isPressingAnyButton || // checking against laser so that if you mouseover with a laser tool\n // over a link/embeddable, we change the cursor\n !isLaserTool && this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\" && 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 (this.isHittingTextAutoResizeHandle(selectedElements, scenePointer)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n return;\n }\n\n if (selectedElements.length === 1 && !isOverScrollBar && !((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing)) {\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) && ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) !== \"elementLinkSelector\" && !(selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) && // HACK: Disable transform handles for linear elements on mobile until a\n // better way of showing them is found\n !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && (this.editorInterface.userAgent.isMobileDevice || selectedElements[0].points.length === 2))) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.editorInterface);\n\n if (elementWithTransformHandleType && elementWithTransformHandleType.transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)(elementWithTransformHandleType));\n return;\n }\n }\n } else if (selectedElements.length > 1 && !isOverScrollBar && ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== \"elementLinkSelector\") {\n const transformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.editorInterface);\n\n if (transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)({\n transformHandleType\n }));\n return;\n }\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_22__.isEraserActive)(this.state)) {\n return;\n }\n\n const hitElementMightBeLocked = this.getElementAtPosition(scenePointerX, scenePointerY, {\n preferSelected: true,\n includeLockedElements: true\n });\n let hitElement = null;\n\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n hitElement = null;\n } else {\n hitElement = hitElementMightBeLocked;\n }\n\n if (!this.handleIframeLikeElementHover({\n hitElement,\n scenePointer,\n moveEvent: event\n })) {\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElementMightBeLocked);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_34__.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_34__.hideHyperlinkToolip)();\n\n if (isLaserTool) {\n return;\n }\n\n if (hitElement && (hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_40__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(hitElement) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.TEXT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.CROSSHAIR);\n } else if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n } else if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if ( // if using cmd/ctrl, we're not dragging\n !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && // editing text -> don't show move cursor when hovering over its bbox\n (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) !== ((_g = this.state.editingTextElement) === null || _g === void 0 ? void 0 : _g.id)) {\n if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) && !(hitElement === null || hitElement === void 0 ? void 0 : hitElement.locked)) {\n if (!hitElement || // Elbow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(hitElement) || !(hitElement.startBinding || hitElement.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || selectedElements.length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n }\n\n if (((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) === \"elementLinkSelector\" && hitElement) {\n this.setState(prevState => {\n return {\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.hoveredElementIds, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this).selectedElementIds)\n };\n });\n } else if (((_j = this.state.openDialog) === null || _j === void 0 ? void 0 : _j.name) === \"elementLinkSelector\" && !hitElement) {\n this.setState(prevState => ({\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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, _d, _e; //mfuria #329. Right-click pan support when enabled via host plugin setting\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isPanWithRightMouseEnabled)() && event.pointerType === \"mouse\" && event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.SECONDARY && !this.state.editingTextElement) {\n // prevent native context menu\n const onContextMenu = e => {\n e.preventDefault();\n };\n\n window.addEventListener('contextmenu', onContextMenu, {\n once: true\n }); // Start right-click panning\n\n this.startRightClickPanning(event);\n return;\n } //zsviczian - begin\n\n\n const isInsideEmbeddableContainer = !!((_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest) === null || _b === void 0 ? void 0 : _b.call(_a, \".excalidraw__embeddable-container\"));\n\n if (!isInsideEmbeddableContainer) {\n this.focusContainer();\n } //zsviczian - end\n\n\n const selectedElements = this.scene.getSelectedElements(this.state); // If Ctrl is not held, ensure isBindingEnabled reflects the user preference.\n\n if (!event.ctrlKey) {\n const preferenceEnabled = this.state.bindingPreference === \"enabled\";\n\n if (this.state.isBindingEnabled !== preferenceEnabled) {\n this.setState({\n isBindingEnabled: preferenceEnabled\n });\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n this.lastPointerMoveCoords = {\n x: scenePointerX,\n y: scenePointerY\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 return {\n searchMatches: state.searchMatches && {\n focusedId: null,\n matches: state.searchMatches.matches.map(searchMatch => Object.assign(Object.assign({}, searchMatch), {\n focus: false\n }))\n }\n };\n });\n this.updateEditorAtom(_SearchMenu__WEBPACK_IMPORTED_MODULE_61__.searchItemInFocusAtom, null);\n }\n\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom)) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.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 if (this.state.openPopup) {\n this.setState({\n openPopup: null\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 suggestedBinding: null,\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: ((_c = this.state.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.EVENTUALLY : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.editorInterface.isTouchScreen && [\"pen\", \"touch\"].includes(event.pointerType)) {\n this.editorInterface = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.editorInterface, {\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)) {\n return;\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_6__.POINTER_BUTTON.ERASER && this.state.activeTool.type !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.eraser) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_22__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, Object.assign(Object.assign({}, this.state.activeTool.lastActiveTool || {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.selection\n }), {\n lastActiveToolBeforeEraser: null\n }))\n });\n }\n };\n\n const unsubPointerUp = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.POINTER_BUTTON.MAIN && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.TOUCH && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.handleTextAutoResizeHandlePointerDown(selectedElements, pointerDownState.origin)) {\n return;\n }\n\n if (this.handleDraggingScrollBar(event, pointerDownState)) {\n return;\n }\n\n this.clearSelectionIfNotUsingSelection();\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 const hitSelectedElement = pointerDownState.hit.element && this.isASelectedElement(pointerDownState.hit.element);\n const shouldForceLassoReselect = event.altKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !pointerDownState.resize.handleType;\n const shouldStartLassoSelection = shouldForceLassoReselect || !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements && !pointerDownState.resize.handleType && !hitSelectedElement;\n\n if (shouldStartLassoSelection) {\n if (!this.lassoTrail.hasCurrentTrail) {\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n } // block dragging after lasso selection on PCs until the next pointer down\n // (on mobile or tablet, we want to allow user to drag immediately)\n\n\n pointerDownState.drag.blockDragging = this.editorInterface.formFactor === \"desktop\";\n } // only for mobile or tablet, if we hit an element, select it immediately like normal selection\n\n\n if (this.editorInterface.formFactor !== \"desktop\" && pointerDownState.hit.element && !hitSelectedElement) {\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [pointerDownState.hit.element.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 });\n const hitElement = pointerDownState.hit.element; // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\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 === \"freedraw\") {\n this.handleFreeDrawElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"custom\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n } else if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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\" && //zsviczian\n this.state.activeTool.type !== \"image\") {\n this.createGenericElementOnPointerDown(this.state.activeTool.type, pointerDownState);\n }\n\n (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.onPointerDown) === null || _e === void 0 ? void 0 : _e.call(_d, 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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, onKeyDown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.resetDelayedBindMode();\n }\n\n this.removePointer(event);\n this.lastPointerUpIsDoubleClick = this.isDoubleClick(this.lastPointerUpEvent, event);\n this.lastPointerUpEvent = event;\n\n if (!event.ctrlKey) {\n const preferenceEnabled = this.state.bindingPreference === \"enabled\";\n\n if (this.state.isBindingEnabled !== preferenceEnabled) {\n this.setState({\n isBindingEnabled: preferenceEnabled\n });\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: event.clientX,\n clientY: event.clientY\n }, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n this.lastPointerMoveCoords = {\n x: scenePointerX,\n y: scenePointerY\n };\n\n if (this.handleIframeLikeCenterClick()) {\n return;\n }\n\n if (this.editorInterface.isTouchScreen) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y, {\n includeLockedElements: true\n });\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n this.handleElementLinkClick(event);\n } else if (this.state.viewModeEnabled) {\n this.setState({\n activeEmbeddable: null,\n selectedElementIds: {}\n });\n }\n };\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices = event => {\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isContextMenuDisabled)()) {\n return;\n } // deal with opening context menu on touch devices\n\n\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 && !this.state.isResizing) {\n //zsviczian - avoid context menu during resizing on Mobiles\n this.handleCanvasContextMenu(event);\n }\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOUCH_CTX_MENU_TIMEOUT);\n }\n }\n };\n\n this.resetContextMenuTimer = () => {\n clearTimeout(touchTimeout);\n touchTimeout = 0;\n invalidateContextMenu = false;\n };\n /**\n * pointerup may not fire in certian cases (user tabs away...), so in order\n * to properly cleanup pointerdown state, we need to fire any hanging\n * pointerup handlers manually\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_6__.POINTER_BUTTON.WHEEL || event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN && isHoldingSpace || (0,_appState__WEBPACK_IMPORTED_MODULE_22__.isHandToolActive)(this.state) || (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isTouchInPenMode)(this.state, event) || //zsviczian\n this.state.viewModeEnabled && this.state.activeTool.type !== \"laser\"))) {\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_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n /*\n * Prevent paste event if we move while middle clicking on Linux.\n * See issue #1383.\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_6__.EVENT.PASTE, preventNextPaste);\n event.stopPropagation();\n };\n /*\n * Reenable next paste in case of disabled middle click paste for\n * any reason:\n * - right click paste\n * - empty clipboard\n */\n\n\n const enableNextPaste = () => {\n setTimeout(() => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, enableNextPaste);\n }, 100);\n };\n\n document.body.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdates)(lastPointerUp = () => {\n lastPointerUp = null;\n isPanning = false;\n\n if (!isHoldingSpace) {\n if (this.state.viewModeEnabled && this.state.activeTool.type !== \"laser\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n return true;\n };\n\n this.clearSelectionIfNotUsingSelection = () => {\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(this.state.activeTool.type)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n };\n /**\n * @returns whether the pointer event has been completely handled\n */\n\n\n this.handleSelectionOnPointerDown = (event, pointerDownState) => {\n var _a, _b, _c, _d, _e, _f, _g;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isSelectionLikeTool)(this.state.activeTool.type)) {\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 && !((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]) && !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && (this.editorInterface.userAgent.isMobileDevice || selectedElements[0].points.length === 2)) && !(this.state.selectedLinearElement && this.state.selectedLinearElement.hoverPointIndex !== -1)) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.editorInterface);\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__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.editorInterface);\n }\n\n if (pointerDownState.resize.handleType) {\n pointerDownState.resize.isResizing = true;\n pointerDownState.resize.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeOffsetXY)(pointerDownState.resize.handleType, selectedElements, elementsMap, pointerDownState.origin.x, pointerDownState.origin.y));\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && selectedElements[0].points.length === 2) {\n pointerDownState.resize.arrowDirection = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeArrowDirection)(pointerDownState.resize.handleType, selectedElements[0]);\n }\n } else {\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.selectedLinearElement;\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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\n if (ret.didAddPoint) {\n return true;\n } // Also check at current pointer position if focus point is being hovered\n // (in case we're clicking directly without a prior move event)\n\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const arrow = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (arrow && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(arrow)) {\n const {\n hitFocusPoint,\n pointerOffset\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointPointerDown)(arrow, pointerDownState, elementsMap, this.state); // If focus point is hit, update state and prevent element selection\n\n if (hitFocusPoint) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n hoveredFocusPointBinding: hitFocusPoint,\n draggedFocusPointBinding: hitFocusPoint,\n pointerOffset\n })\n });\n return false;\n }\n }\n }\n\n const allHitElements = this.getElementsAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n includeLockedElements: true\n });\n const unlockedHitElements = allHitElements.filter(e => !e.locked); // Cannot set preferSelected in getElementAtPosition as we do in pointer move; consider:\n // A & B: both unlocked, A selected, B on top, A & B overlaps in some way\n // we want to select B when clicking on the overlapping area\n\n const hitElementMightBeLocked = this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n allHitElements\n });\n\n if (!hitElementMightBeLocked || hitElementMightBeLocked.id !== this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n const isUnlockedHitElSelected = unlockedHitElements.some(el => this.state.selectedElementIds[el.id]); //zsviczian\n // Prioritize unlocked elements over locked ones\n\n if (!isUnlockedHitElSelected && unlockedHitElements.length > 0) {\n //zsviczian https://github.com/excalidraw/excalidraw/pull/9582\n // If there are unlocked elements, use the topmost one\n pointerDownState.hit.element = unlockedHitElements[unlockedHitElements.length - 1];\n } else if (hitElementMightBeLocked && hitElementMightBeLocked.locked && !isUnlockedHitElSelected //zsviczian\n ) {\n pointerDownState.hit.element = null;\n } else {\n // hitElement may already be set above, so check first\n pointerDownState.hit.element = (_b = pointerDownState.hit.element) !== null && _b !== void 0 ? _b : this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n }\n\n this.hitLinkElement = this.getElementLinkAtPosition(pointerDownState.origin, hitElementMightBeLocked);\n\n if (this.hitLinkElement) {\n return true;\n }\n\n if (this.state.croppingElementId && ((_c = pointerDownState.hit.element) === null || _c === void 0 ? void 0 : _c.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 = unlockedHitElements;\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 && (!((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) || hitElement && (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) !== ((_e = this.state.selectedLinearElement) === null || _e === void 0 ? void 0 : _e.elementId))) {\n this.clearSelection(hitElement);\n }\n\n if ((_f = this.state.selectedLinearElement) === null || _f === void 0 ? void 0 : _f.isEditing) {\n this.setState(prevState => {\n var _a;\n\n return {\n selectedLinearElement: prevState.selectedLinearElement ? Object.assign(Object.assign({}, prevState.selectedLinearElement), {\n isEditing: !!hitElement && hitElement.id === ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId)\n }) : null,\n selectedElementIds: prevState.selectedLinearElement ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [prevState.selectedLinearElement.elementId]: true\n }, this.state) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState)\n };\n }); // If we click on something\n } else if (hitElement != null) {\n // == deep selection ==\n // on CMD/CTRL, drill down to hit element regardless of groups etc.\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (event.altKey) {\n // ctrl + alt means we're lasso selecting - start lasso trail and switch to lasso tool\n // Close any open dialogs that might interfere with lasso selection\n if (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") {\n this.setOpenDialog(null);\n }\n\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n });\n return false;\n }\n\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, this.state.editingGroupId)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 initialCaretSceneCoords: {\n x: sceneX,\n y: sceneY\n }\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n\n if (!this.state.activeTool.locked) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\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_6__.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__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(element, 0);\n } else {\n this.insertNewElement(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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n this.setState({\n newElement: element,\n suggestedBinding: null\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_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(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_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_29__.t)(\"toast.unrecognizedLinkFormat\"),\n closable: true\n });\n }\n\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(element);\n return element;\n };\n\n this.newImagePlaceholder = ({\n sceneX,\n sceneY,\n addToFrameUnderCursor = true\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = addToFrameUnderCursor ? this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n }) : null;\n const placeholderSize = 100 / this.state.zoom.value;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newImageElement)({\n type: \"image\",\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 x: gridX - placeholderSize / 2,\n y: gridY - placeholderSize / 2,\n width: placeholderSize,\n height: placeholderSize\n });\n };\n\n this.handleLinearElementOnPointerDown = (event, elementType, pointerDownState) => {\n var _a, _b, _c, _d;\n\n if (event.ctrlKey) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n isBindingEnabled: this.state.bindingPreference !== \"enabled\"\n });\n });\n }\n\n if (this.state.multiElement) {\n const {\n multiElement,\n selectedLinearElement\n } = this.state;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(selectedLinearElement, \"selectedLinearElement is expected to be set\"); // finalize if completing a loop\n\n if (multiElement.type === \"line\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(multiElement.points, this.state.zoom.value)) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, selectedLinearElement), {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1],\n initialState: Object.assign(Object.assign({}, selectedLinearElement.initialState), {\n lastClickedPoint: -1\n })\n })\n });\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.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__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(multiElement) && multiElement.points.length > 1) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: event.nativeEvent,\n sceneCoords: {\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }\n });\n return;\n }\n\n const {\n x: rx,\n y: ry\n } = multiElement;\n const {\n lastCommittedPoint\n } = selectedLinearElement;\n const hoveredElementForBinding = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((_b = (_a = this.lastPointerMoveCoords) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : rx + multiElement.points[multiElement.points.length - 1][0], (_d = (_c = this.lastPointerMoveCoords) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : ry + multiElement.points[multiElement.points.length - 1][1]), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap()); // clicking inside commit zone → finalize arrow\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(multiElement) && hoveredElementForBinding || 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_6__.LINE_CONFIRM_THRESHOLD) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: event.nativeEvent,\n sceneCoords: {\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }\n });\n return;\n }\n\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState)\n }));\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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.\n If so, we want it to be null for start and \"arrow\" for end. If the linear item is not\n an arrow, we want it to be null for both. Otherwise, we want it to use the\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__WEBPACK_IMPORTED_MODULE_7__.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_6__.ARROW_TYPE.round ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.ARROW_TYPE.elbow,\n fixedSegments: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow ? [] : null\n }) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n const point = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const boundElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(point, this.scene.getNonDeletedElements(), elementsMap) : null;\n this.scene.mutateElement(element, {\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)]\n });\n this.insertNewElement(element);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n // Do the initial binding so the binding strategy has the initial state\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindBindingElement)(element, new Map([[0, {\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0),\n isDragging: false\n }]]), point[0], point[1], this.scene, this.state, {\n newArrow: true,\n altKey: event.altKey,\n initialBinding: true,\n angleLocked: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event.nativeEvent)\n });\n } // NOTE: We need the flushSync here for the\n // delayed bind mode change to see the right state\n // (specifically the `newElement`)\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => {\n let linearElementEditor = null;\n let nextSelectedElementIds = prevState.selectedElementIds;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element)) {\n linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(element, this.scene.getNonDeletedElementsMap());\n const endIdx = element.points.length - 1;\n linearElementEditor = Object.assign(Object.assign({}, linearElementEditor), {\n selectedPointsIndices: [endIdx],\n initialState: Object.assign(Object.assign({}, linearElementEditor.initialState), {\n arrowStartIsInside: event.altKey,\n lastClickedPoint: endIdx,\n origin: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)\n })\n });\n }\n\n nextSelectedElementIds = !this.state.activeTool.locked ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [element.id]: true\n }, prevState) : prevState.selectedElementIds;\n return Object.assign(Object.assign({}, prevState), {\n bindMode: \"orbit\",\n newElement: element,\n startBoundElement: boundElement,\n suggestedBinding: boundElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element) ? {\n element: boundElement,\n midPoint: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSnapOutlineMidPoint)(point, boundElement, elementsMap, this.state.zoom)\n } : null,\n selectedElementIds: nextSelectedElementIds,\n selectedLinearElement: linearElementEditor\n });\n });\n });\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleDelayedBindModeChange(element, boundElement);\n }\n }\n };\n\n this.createGenericElementOnPointerDown = (elementType, pointerDownState) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.newEmbeddableElement)(Object.assign({\n type: \"embeddable\"\n }, baseElementAttributes));\n } else {\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElement(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_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const constructorOpts = Object.assign(Object.assign(Object.assign({\n x: gridX,\n y: gridY,\n opacity: this.state.currentItemOpacity,\n locked: false\n }, type === \"frame\" && this.state.currentItemFrameRole ? {\n frameRole: this.state.currentItemFrameRole\n } : {}), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.TOOL_TYPE.magicframe ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(constructorOpts) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newFrameElement)(constructorOpts, this.scene.getNonDeletedElements()); //zsviczian\n\n this.insertNewElement(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; // Binding is double accounted on both elements and if one of them is\n // deleted, the binding should be removed\n\n this.elementsPendingErasure.forEach(id => {\n var _a;\n\n const element = this.scene.getElement(id);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n if (element.startBinding) {\n const bindable = this.scene.getElement(element.startBinding.elementId); // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(bindable, this.scene.getElementsMapIncludingDeleted(), {\n boundElements: bindable.boundElements.filter(e => e.id !== element.id)\n });\n }\n\n if (element.endBinding) {\n const bindable = this.scene.getElement(element.endBinding.elementId); // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(bindable, this.scene.getElementsMapIncludingDeleted(), {\n boundElements: bindable.boundElements.filter(e => e.id !== element.id)\n });\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindableElement)(element)) {\n (_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.forEach(boundElement => {\n var _a, _b;\n\n if (boundElement.type === \"arrow\") {\n const arrow = this.scene.getElement(boundElement.id);\n\n if (((_a = arrow === null || arrow === void 0 ? void 0 : arrow.startBinding) === null || _a === void 0 ? void 0 : _a.elementId) === element.id) {\n // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(arrow, this.scene.getElementsMapIncludingDeleted(), {\n startBinding: null\n });\n }\n\n if (((_b = arrow === null || arrow === void 0 ? void 0 : arrow.endBinding) === null || _b === void 0 ? void 0 : _b.elementId) === element.id) {\n // NOTE: We use the raw mutateElement() because we don't want history\n // entries or multiplayer updates\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.mutateElement)(arrow, this.scene.getElementsMapIncludingDeleted(), {\n endBinding: null\n });\n }\n }\n });\n }\n });\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__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(ele) && this.elementsPendingErasure.has(ele.containerId)) {\n didChange = true;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(ele, {\n isDeleted: true\n });\n }\n\n return ele;\n });\n this.elementsPendingErasure = new Set();\n\n if (didChange) {\n this.store.scheduleCapture();\n this.scene.replaceAllElements(elements);\n }\n };\n\n this.initializeImage = async (placeholderImageElement, imageFile) => {\n var _a, _b, _c; // 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_32__.isSupportedImageFile)(imageFile)) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.unsupportedFileType\"));\n }\n\n const mimeType = imageFile.type;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, \"wait\");\n\n if (mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg) {\n try {\n imageFile = (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.SVGStringToFile)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)(await imageFile.text()), imageFile.name);\n } catch (error) {\n console.warn(error);\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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_32__.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_29__.t)(\"errors.imageInsertError\"));\n }\n\n const existingFileData = this.files[fileId];\n\n if (!(existingFileData === null || existingFileData === void 0 ? void 0 : existingFileData.dataURL)) {\n const {\n maxWidthOrHeight,\n maxFileSizeBytes\n } = this.props.imageOptions;\n\n try {\n imageFile = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.resizeImageFile)(imageFile, {\n maxWidthOrHeight\n });\n } catch (error) {\n console.error(\"Error trying to resizing image file on insertion\", error);\n }\n\n if (imageFile.size > maxFileSizeBytes) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.fileTooBig\", {\n maxSize: `${Math.trunc(maxFileSizeBytes / 1024 / 1024)}MB`\n }));\n }\n }\n\n const dataURL = ((_c = this.files[fileId]) === null || _c === void 0 ? void 0 : _c.dataURL) || (await (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.getDataURL)(imageFile));\n return new Promise(async (resolve, reject) => {\n var _a, _b;\n\n try {\n let initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\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\n if (!this.imageCache.get(fileId)) {\n this.addNewImagesToImageCache();\n const {\n erroredFiles\n } = await this.updateImageCache([initializedImageElement]);\n\n if (erroredFiles.size) {\n throw new Error(\"Image cache update resulted with an error.\");\n }\n }\n\n const imageHTML = await ((_a = this.imageCache.get(fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (imageHTML && ((_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.id) !== initializedImageElement.id) {\n initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\n const naturalDimensions = this.getImageNaturalDimensions(initializedImageElement, imageHTML); // no need to create a new instance anymore, just assign the natural dimensions\n\n Object.assign(initializedImageElement, naturalDimensions);\n }\n\n resolve(initializedImageElement);\n } catch (error) {\n console.error(error);\n reject(new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.imageInsertError\")));\n }\n });\n };\n /**\n * use during async image initialization,\n * when the placeholder image could have been modified in the meantime,\n * and when you don't want to loose those modifications\n */\n\n\n this.getLatestInitializedImageElement = (imagePlaceholder, fileId) => {\n var _a;\n\n const latestImageElement = (_a = this.scene.getElement(imagePlaceholder.id)) !== null && _a !== void 0 ? _a : imagePlaceholder;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(latestImageElement, {\n fileId\n });\n };\n\n this.onImageToolbarButtonClick = async () => {\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_6__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const imageFiles = await (0,_data_filesystem__WEBPACK_IMPORTED_MODULE_33__.fileOpen)({\n description: \"Image\",\n extensions: Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.IMAGE_MIME_TYPES),\n multiple: true\n });\n this.insertImages(imageFiles, x, y);\n } catch (error) {\n if (error.name !== \"AbortError\") {\n console.error(error);\n } else {\n console.warn(error);\n }\n\n this.setState({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n })\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n }\n };\n\n this.getImageNaturalDimensions = (imageElement, imageHTML) => {\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(imageHTML.naturalHeight, maxHeight);\n const width = height * (imageHTML.naturalWidth / imageHTML.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 return {\n x,\n y,\n width,\n height,\n crop: null\n };\n };\n /** updates image cache, refreshing updated elements and/or setting status\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__WEBPACK_IMPORTED_MODULE_7__.updateImageCache)({\n imageCache: this.imageCache,\n fileIds: elements.map(element => element.fileId),\n files\n });\n\n if (erroredFiles.size) {\n this.store.scheduleAction(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER);\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && erroredFiles.has(element.fileId)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 for (const element of uncachedImageElements) {\n if (updatedFiles.has(element.fileId)) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n }\n }\n\n if (updatedFiles.size) {\n this.scene.triggerUpdate();\n }\n }\n };\n /** generally you should use `addNewImagesToImageCache()` directly if you need\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_6__.IMAGE_RENDER_TIMEOUT);\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_6__.EVENT.TOUCH_START, this.onTouchStart, {\n passive: false\n });\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd); // -----------------------------------------------------------------------\n } else {\n (_a = this.interactiveCanvas) === null || _a === void 0 ? void 0 : _a.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_START, this.onTouchStart);\n (_b = this.interactiveCanvas) === null || _b === void 0 ? void 0 : _b.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd);\n }\n };\n\n this.insertImages = async (imageFiles, sceneX, sceneY) => {\n const gridPadding = 50 / this.state.zoom.value; // Create, position, and insert placeholders\n\n const placeholders = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(imageFiles.map(() => this.newImagePlaceholder({\n sceneX,\n sceneY\n })), sceneX, sceneY, gridPadding);\n this.insertNewElements(placeholders); // Create, position, insert and select initialized (replacing placeholders)\n\n const initialized = await Promise.all(placeholders.map(async (placeholder, i) => {\n try {\n return await this.initializeImage(placeholder, await (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.normalizeFile)(imageFiles[i]));\n } catch (error) {\n this.setState({\n errorMessage: error.message || (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.imageInsertError\")\n });\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(placeholder, {\n isDeleted: true\n });\n }\n }));\n const initializedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(initialized);\n const positioned = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(initialized.filter(el => !el.isDeleted), sceneX, sceneY, gridPadding);\n const positionedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(positioned);\n const nextElements = this.scene.getElementsIncludingDeleted().map(el => {\n var _a, _b;\n\n return (_b = (_a = positionedMap.get(el.id)) !== null && _a !== void 0 ? _a : initializedMap.get(el.id)) !== null && _b !== void 0 ? _b : el;\n });\n this.updateScene({\n appState: {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.fromEntries(positioned.map(el => [el.id, true])), this.state)\n },\n elements: nextElements,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n this.setState({}, () => {\n // actionFinalize after all state values have been updated\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n };\n\n this.handleAppOnDrop = async event => {\n var _a;\n\n if (this.props.onDrop) {\n //zsviczian\n try {\n if ((await this.props.onDrop(event)) === false) {\n return;\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_23__.parseDataTransferEvent)(event); // must be retrieved first, in the same frame\n\n const fileItems = dataTransferList.getFiles();\n\n if (fileItems.length === 1) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file && (file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.png || file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg)) {\n try {\n const scene = await (0,_data__WEBPACK_IMPORTED_MODULE_24__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n return;\n } catch (error) {\n if (error.name !== \"EncodingError\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"alerts.couldNotLoadInvalidFile\"));\n } // if EncodingError, fall through to insert as regular image\n\n }\n }\n }\n\n const imageFiles = fileItems.map(data => data.file).filter(file => (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.isSupportedImageFile)(file));\n\n if (imageFiles.length > 0 && this.isToolSupported(\"image\")) {\n return this.insertImages(imageFiles, sceneX, sceneY);\n }\n\n const excalidrawLibrary_ids = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlibIds);\n const excalidrawLibrary_data = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlib);\n\n if (excalidrawLibrary_ids || excalidrawLibrary_data) {\n try {\n let libraryItems = null;\n\n if (excalidrawLibrary_ids) {\n const {\n itemIds\n } = JSON.parse(excalidrawLibrary_ids);\n const allLibraryItems = await this.library.getLatestLibrary();\n libraryItems = allLibraryItems.filter(item => itemIds.includes(item.id)); // legacy library dataTransfer format\n } else if (excalidrawLibrary_data) {\n libraryItems = (0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.parseLibraryJSON)(excalidrawLibrary_data);\n }\n\n if (libraryItems === null || libraryItems === void 0 ? void 0 : libraryItems.length) {\n libraryItems = libraryItems.map(item => Object.assign(Object.assign({}, item), {\n // #6465\n elements: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: item.elements,\n randomizeSeed: true,\n preserveFrameChildrenOrder: true\n }).duplicatedElements\n }));\n this.addElementsFromPasteOrLibrary({\n elements: (0,_data_library__WEBPACK_IMPORTED_MODULE_25__.distributeLibraryItemsOnSquareGrid)(libraryItems),\n position: event,\n files: null\n });\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n\n return;\n }\n\n if (fileItems.length > 0) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file) {\n // Attempt to parse an excalidraw/excalidrawlib file\n await this.loadFileToCanvas(file, fileHandle);\n }\n }\n\n const textItem = dataTransferList.findByType(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.text);\n\n if (textItem) {\n const text = textItem.value;\n\n if (text && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(text, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(text) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(text)) === null || _a === void 0 ? void 0 : _a.type) === \"video\")) {\n const embeddable = this.insertEmbeddableElement({\n sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(text)\n });\n\n if (embeddable) {\n this.store.scheduleCapture();\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_32__.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_32__.loadSceneOrLibraryFromBlob)(file, this.state, elements, fileHandle);\n } catch (error) {\n const imageSceneDataError = error instanceof _errors__WEBPACK_IMPORTED_MODULE_37__.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_29__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const errorMessage = imageSceneDataError ? (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"alerts.cannotRestoreFromImage\") : (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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_6__.MIME_TYPES.excalidraw) {\n // restore the fractional indices by mutating elements\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncInvalidIndices)(elements.concat(ret.data.elements)); // don't capture and only update the store snapshot for old elements,\n // otherwise we would end up with duplicated fractional indices on undo\n\n this.store.scheduleMicroAction({\n action: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER,\n elements,\n appState: undefined\n });\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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n } else if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_29__.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 (this.state.disableContextMenu) {\n //zsviczian\n return;\n } //mfuria #329. if right-click pan is enabled, we suppress opening our custom menu too.\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.isPanWithRightMouseEnabled)()) {\n return;\n }\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_6__.POINTER_BUTTON.SECONDARY) && this.state.activeTool.type !== this.state.preferredSelectionTool.type) {\n return;\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_21__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 && pointerDownState.boxSelection.hasOccurred && this.state.activeTool.type !== \"eraser\") {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.distance)(pointerDownState.origin.x, pointerCoords.x),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.origin.y, pointerCoords.y),\n shouldMaintainAspectRatio: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_38__.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\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.distance)(pointerDownState.originInGrid.x, gridX),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.originInGrid.y, gridY),\n shouldMaintainAspectRatio: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(newElement) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event),\n zoom: this.state.zoom.value,\n scene: this.scene,\n widthAspectRatio: aspectRatio,\n originOffset: this.state.originSnapOffset,\n informMutation\n });\n }\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_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe) {\n this.setState({\n elementsToHighlight: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement)) {\n const croppingAtStateStart = pointerDownState.originalElements.get(croppingElement.id);\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_a = this.imageCache.get(croppingElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (croppingAtStateStart && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingAtStateStart) && image && !(image instanceof Promise)) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_38__.snapResizingElements)([croppingElement], [croppingAtStateStart], this, event, dragOffset, transformHandleType);\n this.scene.mutateElement(croppingElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.cropElement)(croppingElement, this.scene.getNonDeletedElementsMap(), transformHandleType, image.naturalWidth, image.naturalHeight, x + snapOffset.x, y + snapOffset.y, event.shiftKey ? croppingAtStateStart.width / croppingAtStateStart.height : undefined));\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(croppingElement, this.scene);\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const frameElementsOffsetsMap = new Map();\n selectedFrames.forEach(frame => {\n const elementsInFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_38__.snapResizingElements)(selectedElements, (0,_scene__WEBPACK_IMPORTED_MODULE_30__.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__WEBPACK_IMPORTED_MODULE_7__.transformElements)(pointerDownState.originalElements, transformHandleType, selectedElements, this.scene, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event), selectedElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(element)) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event), resizeX, resizeY, pointerDownState.resize.center.x, pointerDownState.resize.center.y)) {\n const elementsToHighlight = new Set();\n selectedFrames.forEach(frame => {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), frame, this.state, this.scene.getNonDeletedElementsMap()).forEach(element => elementsToHighlight.add(element));\n });\n this.setState({\n elementsToHighlight: [...elementsToHighlight]\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_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg); // canvas contextMenu\n // -------------------------------------------------------------------------\n\n if (type === \"canvas\") {\n if (this.state.viewModeEnabled) {\n return [...options, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats, _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleLaserPointer];\n }\n\n return [_actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg, _actions__WEBPACK_IMPORTED_MODULE_8__.copyText, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSelectAll, _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__.actionUnlockAllElements, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleObjectsSnapMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleArrowBinding, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleMidpointSnapping, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats];\n } // element contextMenu\n // -------------------------------------------------------------------------\n\n\n options.push(_actions__WEBPACK_IMPORTED_MODULE_8__.copyText);\n\n if (this.state.viewModeEnabled) {\n return [_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, ...options];\n }\n\n const zIndexActions = this.editorInterface.formFactor === \"desktop\" ? [_ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendBackward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringForward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendToBack, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringToFront] : [];\n return [_ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionSelectAllElementsInFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionRemoveAllElementsFromFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionWrapSelectionInFrame, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleCropEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, ...options, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyStyles, _actions__WEBPACK_IMPORTED_MODULE_8__.actionPasteStyles, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionGroup, _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__.actionTextAutoResize, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUnbindText, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBindText, _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__.actionWrapTextInContainer, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUngroup, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionAddToLibrary, ...zIndexActions, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipHorizontal, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipVertical, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__.actionCopyElementLink, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDuplicateSelection, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleElementLock, _ContextMenu__WEBPACK_IMPORTED_MODULE_55__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDeleteSelected];\n };\n\n this.handleWheel = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d; // if not scrolling on canvas/wysiwyg, ignore\n //zsviczian - begin\n\n\n const path = (_b = (_a = event).composedPath) === null || _b === void 0 ? void 0 : _b.call(_a);\n const isOnExcalidrawCanvas = (path === null || path === void 0 ? void 0 : path.some(n => {\n var _a;\n\n return n instanceof HTMLCanvasElement && ((_a = n.classList) === null || _a === void 0 ? void 0 : _a.contains(\"excalidraw__canvas\"));\n })) || ((_d = (_c = event.target) === null || _c === void 0 ? void 0 : _c.closest) === null || _d === void 0 ? void 0 : _d.call(_c, \"canvas.excalidraw__canvas\")) != null; //zsviczian - end\n\n if (!(isOnExcalidrawCanvas || //zsviczian\n event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLIFrameElement || event.target instanceof HTMLElement && event.target.classList.contains(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CLASSES.FRAME_NAME))) {\n // prevent zooming the browser (but allow scrolling DOM)\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.getZoomStep)() * 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_31__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_30__.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_6__.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_6__.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 this.watchState = () => {};\n\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_22__.getDefaultAppState)();\n const {\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_29__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`\n } = props;\n this.state = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultAppState), {\n theme,\n exportWithDarkMode: theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK,\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.refreshEditorInterface();\n this.stylesPanelMode = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.deriveStylesPanelMode)(this.editorInterface);\n this.id = (0,nanoid__WEBPACK_IMPORTED_MODULE_73__.nanoid)();\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.initializeObsidianUtils)();\n this.library = new _data_library__WEBPACK_IMPORTED_MODULE_25__[\"default\"](this);\n this.actionManager = new _actions_manager__WEBPACK_IMPORTED_MODULE_18__.ActionManager(this.syncActionResult, () => this.state, () => this.scene.getElementsIncludingDeleted(), this);\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\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_39__.Renderer(this.scene);\n this.visibleElements = [];\n this.store = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Store(this);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_28__.History(this.store);\n this.excalidrawContainerValue = {\n container: this.excalidrawContainerRef.current,\n id: this.id\n };\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_35__.Fonts(this.scene);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_28__.History(this.store);\n this.actionManager.registerAll(_actions_register__WEBPACK_IMPORTED_MODULE_19__.actions);\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createUndoAction)(this.history));\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createRedoAction)(this.history)); // in case internal editor APIs call this early, otherwise we need\n // to construct this in componentDidMount because componentWillUnmount\n // will invalidate it (so in StrictMode, doing this in constructor alone\n // would be a problem)\n\n this.api = this.createExcalidrawAPI();\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_6__.YOUTUBE_STATES).includes(playerState)) {\n YOUTUBE_VIDEO_STATES.set(id, playerState);\n }\n }\n\n break;\n }\n }\n\n handleSkipBindMode() {\n var _a, _b, _c, _d, _e;\n\n if (((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.initialState) && !this.state.selectedLinearElement.initialState.arrowStartIsInside) {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.lastPointerMoveCoords, \"Missing last pointer move coords when changing bind skip mode for arrow start\");\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerMoveCoords.x, this.lastPointerMoveCoords.y), this.scene.getNonDeletedElements(), elementsMap);\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, elementsMap);\n\n if ((element === null || element === void 0 ? void 0 : element.startBinding) && (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) === element.startBinding.elementId) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n arrowStartIsInside: true\n })\n })\n });\n }\n }\n\n if (this.state.bindMode === \"orbit\") {\n if (this.bindModeHandler) {\n clearTimeout(this.bindModeHandler);\n this.bindModeHandler = null;\n } // PERF: It's okay since it's a single trigger from a key handler\n // or single call from pointer move handler because the bindMode check\n // will not pass the second time\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n bindMode: \"skip\"\n });\n });\n\n if (this.lastPointerMoveCoords && ((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) && ((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.selectedPointsIndices.length)) {\n const {\n x,\n y\n } = this.lastPointerMoveCoords;\n const event = (_d = this.lastPointerMoveEvent) !== null && _d !== void 0 ? _d : (_e = this.lastPointerDownEvent) === null || _e === void 0 ? void 0 : _e.nativeEvent;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(event, \"Last event must exist\");\n const deltaX = x - this.state.selectedLinearElement.pointerOffset.x;\n const deltaY = y - this.state.selectedLinearElement.pointerOffset.y;\n const newState = this.state.multiElement ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event, this, deltaX, deltaY, this.state.selectedLinearElement) : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, deltaX, deltaY, this.state.selectedLinearElement);\n\n if (newState) {\n this.setState(newState);\n }\n }\n }\n }\n\n resetDelayedBindMode() {\n if (this.bindModeHandler) {\n clearTimeout(this.bindModeHandler);\n this.bindModeHandler = null;\n }\n\n if (this.state.bindMode !== \"orbit\") {\n // We need this iteration to complete binding and change\n // back to orbit mode after that\n setTimeout(() => this.setState({\n bindMode: \"orbit\"\n }));\n }\n }\n\n handleDelayedBindModeChange(arrow, hoveredElement) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;\n\n if (arrow.isDeleted || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(arrow)) {\n return;\n }\n\n const effector = () => {\n var _a, _b, _c, _d;\n\n this.bindModeHandler = null;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.lastPointerMoveCoords, \"Expected lastPointerMoveCoords to be set\");\n\n if (!this.state.multiElement) {\n if (!this.state.selectedLinearElement || !this.state.selectedLinearElement.selectedPointsIndices || !this.state.selectedLinearElement.selectedPointsIndices.length) {\n return;\n }\n\n const startDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(0);\n const endDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(arrow.points.length - 1); // Check if the whole arrow is dragged by selecting all endpoints\n\n if (!startDragged && !endDragged || startDragged && endDragged) {\n return;\n }\n }\n\n const {\n x,\n y\n } = this.lastPointerMoveCoords;\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap());\n\n if (hoveredElement && this.state.bindMode !== \"skip\") {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId) === arrow.id, \"The selectedLinearElement is expected to not change while a bind mode timeout is ticking\"); // Once the start is set to inside binding, it remains so\n\n const arrowStartIsInside = this.state.selectedLinearElement.initialState.arrowStartIsInside || ((_b = arrow.startBinding) === null || _b === void 0 ? void 0 : _b.elementId) === hoveredElement.id; // Change the global binding mode\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(this.state.selectedLinearElement, \"this.state.selectedLinearElement must exist\");\n this.setState({\n bindMode: \"inside\",\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n initialState: Object.assign(Object.assign({}, this.state.selectedLinearElement.initialState), {\n arrowStartIsInside\n })\n })\n });\n });\n const event = (_c = this.lastPointerMoveEvent) !== null && _c !== void 0 ? _c : (_d = this.lastPointerDownEvent) === null || _d === void 0 ? void 0 : _d.nativeEvent;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(event, \"Last event must exist\");\n const deltaX = x - this.state.selectedLinearElement.pointerOffset.x;\n const deltaY = y - this.state.selectedLinearElement.pointerOffset.y;\n const newState = this.state.multiElement ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event, this, deltaX, deltaY, this.state.selectedLinearElement) : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, deltaX, deltaY, this.state.selectedLinearElement);\n\n if (newState) {\n this.setState(newState);\n }\n }\n };\n\n let isOverlapping = false;\n\n if ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.selectedPointsIndices) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const startDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(0);\n const endDragged = this.state.selectedLinearElement.selectedPointsIndices.includes(arrow.points.length - 1);\n const startElement = startDragged ? hoveredElement : arrow.startBinding && elementsMap.get(arrow.startBinding.elementId);\n const endElement = endDragged ? hoveredElement : arrow.endBinding && elementsMap.get(arrow.endBinding.elementId);\n const startBounds = startElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementBounds)(startElement, elementsMap);\n const endBounds = endElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementBounds)(endElement, elementsMap);\n isOverlapping = !!(startBounds && endBounds && startElement.id !== endElement.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.doBoundsIntersect)(startBounds, endBounds));\n }\n\n const startDragged = (_c = (_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) === null || _c === void 0 ? void 0 : _c.includes(0);\n const endDragged = (_e = (_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.selectedPointsIndices) === null || _e === void 0 ? void 0 : _e.includes(arrow.points.length - 1);\n const currentBinding = startDragged ? \"startBinding\" : endDragged ? \"endBinding\" : null;\n const otherBinding = startDragged ? \"endBinding\" : endDragged ? \"startBinding\" : null;\n const isAlreadyInsideBindingToSameElement = otherBinding && ((_f = arrow[otherBinding]) === null || _f === void 0 ? void 0 : _f.mode) === \"inside\" && ((_g = arrow[otherBinding]) === null || _g === void 0 ? void 0 : _g.elementId) === (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) || currentBinding && ((_h = arrow[currentBinding]) === null || _h === void 0 ? void 0 : _h.mode) === \"inside\" && (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) === ((_j = arrow[currentBinding]) === null || _j === void 0 ? void 0 : _j.elementId);\n\n if (currentBinding && otherBinding && ((_k = arrow[currentBinding]) === null || _k === void 0 ? void 0 : _k.mode) === \"inside\" && (hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id) !== ((_l = arrow[currentBinding]) === null || _l === void 0 ? void 0 : _l.elementId) && ((_m = arrow[otherBinding]) === null || _m === void 0 ? void 0 : _m.elementId) !== ((_o = arrow[currentBinding]) === null || _o === void 0 ? void 0 : _o.elementId)) {\n // Update binding out of place to orbit mode\n this.scene.mutateElement(arrow, {\n [currentBinding]: Object.assign(Object.assign({}, arrow[currentBinding]), {\n mode: \"orbit\"\n })\n }, {\n informMutation: false,\n isDragging: true\n });\n }\n\n if (!hoveredElement || this.previousHoveredBindableElement && hoveredElement.id !== this.previousHoveredBindableElement.id) {\n // Clear the timeout if we're not hovering a bindable\n if (this.bindModeHandler) {\n clearTimeout(this.bindModeHandler);\n this.bindModeHandler = null;\n } // Clear the inside binding mode too\n\n\n if (this.state.bindMode === \"inside\") {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n bindMode: \"orbit\"\n });\n });\n }\n\n this.previousHoveredBindableElement = null;\n } else if (!this.bindModeHandler && (!this.state.newElement || !arrow.startBinding || isOverlapping) && !isAlreadyInsideBindingToSameElement) {\n // We are hovering a bindable element\n this.bindModeHandler = setTimeout(effector, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.BIND_MODE_TIMEOUT);\n }\n\n this.previousHoveredBindableElement = hoveredElement;\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 /** @returns true if iframe-like element click handled */\n\n\n handleIframeLikeCenterClick() {\n var _a, _b, _c, _d;\n\n if (!this.lastPointerDownEvent || !this.lastPointerUpEvent || // middle-click or something other than primary\n this.lastPointerDownEvent.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN || // panning\n isHoldingSpace || // wrong tool\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.oneOf)(this.state.activeTool.type, [\"laser\", \"selection\", \"lasso\"])) {\n return false;\n }\n\n const viewportClickStart_scenePoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastPointerDownEvent.clientX,\n clientY: this.lastPointerDownEvent.clientY\n }, this.state));\n const viewportClickEnd_scenePoint = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastPointerUpEvent.clientX,\n clientY: this.lastPointerUpEvent.clientY\n }, this.state));\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)(viewportClickStart_scenePoint, viewportClickEnd_scenePoint);\n\n if (draggedDistance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DRAGGING_THRESHOLD) {\n return false;\n }\n\n const hitElement = this.getElementAtPosition(viewportClickStart_scenePoint[0], viewportClickStart_scenePoint[1]);\n const shouldActivate = hitElement && this.lastPointerUpEvent.timeStamp - this.lastPointerDownEvent.timeStamp <= 300 && gesture.pointers.size < 2 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && (this.state.viewModeEnabled || this.state.activeTool.type === \"laser\" || this.isIframeLikeElementCenter(hitElement, this.lastPointerUpEvent, viewportClickEnd_scenePoint[0], viewportClickEnd_scenePoint[1]));\n\n if (!shouldActivate) {\n return false;\n }\n\n const iframeLikeElement = hitElement;\n\n if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) === iframeLikeElement && ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"active\") {\n return true;\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: iframeLikeElement,\n state: \"active\"\n },\n selectedElementIds: {\n [iframeLikeElement.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n }, 100);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(iframeLikeElement)) {\n return true;\n }\n\n const iframe = this.getHTMLIFrameElement(iframeLikeElement);\n\n if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {\n return true;\n }\n\n if (iframe.src.includes(\"youtube\")) {\n const state = YOUTUBE_VIDEO_STATES.get(iframeLikeElement.id);\n\n if (!state) {\n YOUTUBE_VIDEO_STATES.set(iframeLikeElement.id, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.UNSTARTED);\n iframe.contentWindow.postMessage(JSON.stringify({\n event: \"listening\",\n id: iframeLikeElement.id\n }), \"*\");\n }\n\n switch (state) {\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.PLAYING:\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 return true;\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__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(el) && this.embedsValidationStatus.get(el.id) === true || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.sceneCoordsToViewportCoords)({\n sceneX: el.x,\n sceneY: el.y\n }, this.state); //zsviczian - shouldRenderAllEmbeddables\n\n const isVisible = this.shouldRenderAllEmbeddables || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.toValidURL)(el.link || \"\")); //zsviczian\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.createSrcDoc)(`\n <style>\n html, body {\n width: 100%;\n height: 100%;\n color: ${this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.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})`; // scale video embeds based on zoom (capped) so that smaller embeds\n // on canvas when zoomed are still of legible quality\n // (note: for some embed types like gdrive, the quality is poor when\n // scaling mid playback and works only when you initially start the\n // playback at the higher zoom level)\n\n const shouldScaleEmbeddableViewport = (src === null || src === void 0 ? void 0 : src.type) === \"video\";\n const embeddableViewportScale = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(shouldScaleEmbeddableViewport ? scale : 1, 0.75, MAX_EMBEDDABLE_VIEWPORT_SCALE);\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__WEBPACK_IMPORTED_MODULE_7__.getRenderOpacity)(el, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1),\n [\"--embeddable-radius\"]: `${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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) => {\n if (!this.excalidrawContainerRef.current) {\n return;\n }\n const container = this.excalidrawContainerRef.current;\n const sh = container.scrollHeight;\n const ch = container.clientHeight;\n if (sh !== ch) {\n container.style.height = `${sh}px`;\n setTimeout(() => {\n container.style.height = `100%`;\n });\n }\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_6__.POINTER_EVENTS.enabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_29__.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 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable__content\",\n style: {\n width: `${embeddableViewportScale * 100}%`,\n height: `${embeddableViewportScale * 100}%`,\n transform: `scale(${1 / embeddableViewportScale})`\n }\n }, (_o = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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\" //zsviczian\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 renderTopLeftUI,\n renderCustomStats\n } = this.props;\n const {\n elementsMap,\n visibleElements,\n canvasNonce,\n\n /**\n * element to draw on the <NewElementCanvas> for optimization purposes.\n * Can be null even if this.state.newElement defined\n * (e.g. when its zIndex isn't on top) */\n newElementCanvasElement\n } = this.renderer.getRenderableElements({\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 newElement: this.state.newElement,\n selectedElements,\n selectedElementsAreBeingDragged: this.state.selectedElementsAreBeingDragged,\n frameToHighlight: this.state.frameToHighlight\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 = (_c = (_b = (_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.customData) === null || _b === void 0 ? void 0 : _b.strokeOptions) === null || _c === void 0 ? void 0 : _c.highlighter;\n const showShapeSwitchPanel = ((_d = _editor_jotai__WEBPACK_IMPORTED_MODULE_36__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__.convertElementTypePopupAtom)) === null || _d === void 0 ? void 0 : _d.type) === \"panel\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n translate: \"no\",\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw excalidraw-container notranslate\", {\n \"excalidraw--view-mode\": this.state.viewModeEnabled || ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) === \"elementLinkSelector\",\n \"excalidraw--mobile\": this.editorInterface.formFactor === \"phone\",\n \"excalidraw--tray\": !(this.state.viewModeEnabled || this.state.zenModeEnabled) && //this.editorInterface.formFactor !== \"phone\" &&\n this.editorInterface.desktopUIMode === \"tray\" //zsviczian\n\n }),\n style: Object.assign(Object.assign({\n //zsviczian\n [\"--ui-pointerEvents\"]: shouldBlockPointerEvents ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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(ExcalidrawAPIContext.Provider, {\n value: this.api\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(EditorInterfaceContext.Provider, {\n value: this.editorInterface\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_58__[\"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_29__.getLanguage)().code,\n renderTopLeftUI: renderTopLeftUI,\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 === this.state.preferredSelectionTool.type && !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_60__.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_34__.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__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(firstSelectedElement) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_41__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_59__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"labels.convertToCode\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_66__.MagicIcon,\n checked: false,\n onChange: () => this.onMagicFrameGenerate(firstSelectedElement, \"button\")\n })), selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_41__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_59__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"labels.copySource\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_66__.copyIcon,\n checked: false,\n onChange: () => this.onIframeSrcCopy(firstSelectedElement)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_59__.ElementCanvasButton, {\n title: \"Enter fullscreen\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_66__.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.contextMenu && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ContextMenu__WEBPACK_IMPORTED_MODULE_55__.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 }), newElementCanvasElement && isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_64__[\"default\"], {\n appState: this.state,\n newElement: newElementCanvasElement,\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 theme: this.state.theme,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_63__.StaticCanvas, {\n canvas: this.canvas,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n visibleElements: visibleElements,\n canvasNonce: canvasNonce,\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_38__.isGridModeEnabled)(this),\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: this.flowChartCreator.pendingNodes,\n theme: this.state.theme,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), newElementCanvasElement && !isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_64__[\"default\"], {\n appState: this.state,\n newElement: newElementCanvasElement,\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 theme: this.state.theme,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_63__.InteractiveCanvas, {\n app: this,\n containerRef: this.excalidrawContainerRef,\n canvas: this.interactiveCanvas,\n elementsMap: elementsMap,\n visibleElements: visibleElements,\n allElementsMap: allElementsMap,\n selectedElements: selectedElements,\n canvasNonce: canvasNonce,\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 editorInterface: this.editorInterface,\n renderInteractiveSceneCallback: this.renderInteractiveSceneCallback,\n handleCanvasRef: this.handleInteractiveCanvasRef,\n onContextMenu: this.handleCanvasContextMenu,\n onClick: this.handleCanvasClick,\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_57__[\"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.state.activeLockedId && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_UnlockPopup__WEBPACK_IMPORTED_MODULE_69__[\"default\"], {\n app: this,\n activeLockedId: this.state.activeLockedId\n }), showShapeSwitchPanel && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_52__[\"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__WEBPACK_IMPORTED_MODULE_7__.getElementsOverlappingFrame)(this.scene.getNonDeletedElements(), magicFrame, this.scene.getNonDeletedElementsMap()).filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_21__.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_21__.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_21__.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_21__.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_23__.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__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && files[element.fileId]) {\n this.imageCache.delete(element.fileId);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n });\n }\n\n async componentDidMount() {\n var _a, _b, _c, _d, _e;\n\n this.unmounted = false;\n this.api = this.createExcalidrawAPI();\n this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; //zsviczian disabling this code\n\n /*\n if (false && (isTestEnv() || isDevEnv())) {\n const setState = this.setState.bind(this);\n Object.defineProperties(window.h, {\n state: {\n configurable: true,\n get: () => {\n return this.state;\n },\n },\n setState: {\n configurable: true,\n value: (...args: Parameters<typeof setState>) => {\n return this.setState(...args);\n },\n },\n app: {\n configurable: true,\n value: this,\n },\n history: {\n configurable: true,\n value: this.history,\n },\n store: {\n configurable: true,\n value: this.store,\n },\n fonts: {\n configurable: true,\n value: this.fonts,\n },\n });\n }*/\n\n this.store.onDurableIncrementEmitter.on(increment => {\n this.history.record(increment.delta);\n }); // per. optimmisation, only subscribe if there is the `onIncrement` prop registered, to avoid unnecessary computation\n\n if (this.props.onIncrement) {\n this.store.onStoreIncrementEmitter.on(increment => {\n var _a, _b;\n\n (_b = (_a = this.props).onIncrement) === null || _b === void 0 ? void 0 : _b.call(_a, increment);\n });\n }\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 (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.supportsResizeObserver && this.excalidrawContainerRef.current) {\n this.resizeObserver = new ResizeObserver(() => {\n this.refreshEditorInterface();\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_6__.isBrave)() && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMeasureTextSupported)()) {\n this.setState({\n errorMessage: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_54__[\"default\"], null)\n });\n }\n\n const mountPayload = {\n excalidrawAPI: this.api,\n container: this.excalidrawContainerRef.current\n };\n this.editorLifecycleEvents.emit(\"editor:mount\", mountPayload);\n (_c = (_b = this.props).onMount) === null || _c === void 0 ? void 0 : _c.call(_b, mountPayload);\n (_e = (_d = this.props).onExcalidrawAPI) === null || _e === void 0 ? void 0 : _e.call(_d, this.api);\n }\n\n componentWillUnmount() {\n var _a, _b, _c, _d, _e, _f; // we're recreating the api object reference so that the\n // <ExcalidrawAPIContext.Provider/> picks up on it\n\n\n this.api = Object.assign(Object.assign({}, this.api), {\n isDestroyed: true\n });\n\n for (const key of Object.keys(this.api)) {\n if ((key.startsWith(\"get\") || key === \"onStateChange\" || key === \"onEvent\") && typeof this.api[key] === \"function\") {\n this.api[key] = () => {\n throw new Error(\"ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.\");\n };\n }\n }\n\n this.editorLifecycleEvents.emit(\"editor:unmount\");\n (_b = (_a = this.props).onUnmount) === null || _b === void 0 ? void 0 : _b.call(_a);\n (_d = (_c = this.props).onExcalidrawAPI) === null || _d === void 0 ? void 0 : _d.call(_c, null);\n (_e = window.launchQueue) === null || _e === void 0 ? void 0 : _e.setConsumer(() => {});\n this.renderer.destroy();\n this.scene.destroy();\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_35__.Fonts(this.scene);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_39__.Renderer(this.scene);\n this.files = {};\n this.imageCache.clear();\n (_f = this.resizeObserver) === null || _f === void 0 ? void 0 : _f.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 this.store.onDurableIncrementEmitter.clear();\n this.appStateObserver.clear();\n this.editorLifecycleEvents.clear();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.destroy();\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.destroy();\n clearTimeout(touchTimeout);\n _scene__WEBPACK_IMPORTED_MODULE_30__.isSomeElementSelected.clearCache();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements.clearCache();\n touchTimeout = 0;\n document.documentElement.style.overscrollBehaviorX = \"\";\n document.body.removeChild((0,_Tooltip__WEBPACK_IMPORTED_MODULE_71__.getTooltipDiv)()); //clearRenderCache(); //zsviczian\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.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.excalidrawContainerValue = {\n container: null,\n id: \"unknown\"\n }; //zsviczian\n //@ts-ignore\n // this.laserTrails.terminate(); //zsviczian\n // this.eraserTrail.terminate(); //zsviczian\n\n /*\n Object.keys(this).forEach((key) => {\n //@ts-ignore\n delete this[key];\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_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, this.onKeyDown, false));\n }\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.MESSAGE, this.onWindowMessage, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, this.removePointer, {\n passive: false\n }), // #3553\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.COPY, this.onCopy, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, this.onKeyUp, {\n passive: true\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, \"focus\", () => this.triggerRender(true), {\n passive: true\n }), //zsviczian\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.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_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_START, this.onGestureStart, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_CHANGE, this.onGestureChange, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_END, this.onGestureEnd, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.FULLSCREENCHANGE, this.onFullscreenChange, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, this.pasteFromClipboard, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.CUT, this.onCut, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.RESIZE, this.onResize, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.UNLOAD, this.onUnload, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, this.onBlur, false),\n /*addEventListener( //zsviczian (duplicate)\n this.excalidrawContainerRef.current,\n EVENT.WHEEL,\n this.handleWheel,\n { passive: false },\n ),*/\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DRAG_OVER, this.disableEvent, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DROP, this.disableEvent, false));\n\n if (this.props.detectScroll) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getNearestScrollableContainer)(this.excalidrawContainerRef.current), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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, _l, _m, _o, _p; // must be updated *before* state change listeners are triggered below\n\n\n if (!this._initialized && !this.state.isLoading) {\n this._initialized = true;\n this.editorLifecycleEvents.emit(\"editor:initialize\", this.api);\n (_b = (_a = this.props).onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, this.api);\n }\n\n this.appStateObserver.flush(prevState);\n this.updateEmbeddables();\n const elements = this.scene.getElementsIncludingDeleted();\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n const shouldExportWithDarkMode = ((_c = this.sessionExportThemeOverride) !== null && _c !== void 0 ? _c : this.state.theme) === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK;\n\n if (this.state.exportWithDarkMode !== shouldExportWithDarkMode) {\n this.setState({\n exportWithDarkMode: shouldExportWithDarkMode\n });\n }\n\n if (!this.state.showWelcomeScreen && !elements.length) {\n this.setState({\n showWelcomeScreen: true\n });\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 (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.onScrollChange) === null || _e === void 0 ? void 0 : _e.call(_d, 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_22__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_40__.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_22__.isEraserActive)(prevState) && !(0,_appState__WEBPACK_IMPORTED_MODULE_22__.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 ((((_f = prevState.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\" || ((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") && ((_h = prevState.openDialog) === null || _h === void 0 ? void 0 : _h.name) !== ((_j = this.state.openDialog) === null || _j === void 0 ? void 0 : _j.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 (_k = this.excalidrawContainerRef.current) === null || _k === void 0 ? void 0 : _k.classList.toggle(\"theme--dark\", this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK);\n\n if (((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.isEditing) && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // defer so that the scheduleCapture flag isn't reset via current update\n setTimeout(() => {\n var _a; // 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\n\n ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.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 ((_m = this.state.editingTextElement) === null || _m === void 0 ? void 0 : _m.isDeleted) {\n this.setState({\n editingTextElement: null\n });\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 (_p = (_o = this.props).onChange) === null || _p === void 0 ? void 0 : _p.call(_o, elements, this.state, this.files);\n this.onChangeEmitter.trigger(elements, this.state, this.files);\n }\n }\n\n static resetTapTwice() {\n didTapTwice = false;\n firstTapPosition = null;\n } // TODO: Cover with tests\n\n\n async insertClipboardContent(data, dataTransferFiles, isPlainPaste) {\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state); // ------------------- Error -------------------\n\n if (data.errorMessage) {\n this.setState({\n errorMessage: data.errorMessage\n });\n return;\n } // ------------------- Mixed content with no files -------------------\n\n\n if (dataTransferFiles.length === 0 && !isPlainPaste && data.mixedContent) {\n await this.addElementsFromMixedContentPaste(data.mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n });\n return;\n } // ------------------- Spreadsheet -------------------\n\n\n if (!isPlainPaste && data.text) {\n const result = (0,_charts__WEBPACK_IMPORTED_MODULE_51__.tryParseSpreadsheet)(data.text);\n\n if (result.ok) {\n this.setState({\n openDialog: {\n name: \"charts\",\n data: result.data,\n rawText: data.text\n }\n });\n return;\n }\n } // ------------------- Images or SVG code -------------------\n\n\n const imageFiles = dataTransferFiles.map(data => data.file);\n\n if (imageFiles.length === 0 && data.text && !isPlainPaste) {\n const trimmedText = data.text.trim();\n\n if (trimmedText.startsWith(\"<svg\") && trimmedText.endsWith(\"</svg>\")) {\n // ignore SVG validation/normalization which will be done during image\n // initialization\n imageFiles.push((0,_data_blob__WEBPACK_IMPORTED_MODULE_32__.SVGStringToFile)(trimmedText));\n }\n }\n\n if (imageFiles.length > 0) {\n if (this.isToolSupported(\"image\")) {\n await this.insertImages(imageFiles, sceneX, sceneY);\n } else {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.imageToolNotSupported\")\n });\n }\n\n return;\n } // ------------------- Elements -------------------\n\n\n if (data.elements) {\n const elements = data.programmaticAPI ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: this.editorInterface.formFactor === \"desktop\" ? \"cursor\" : \"center\",\n retainSeed: isPlainPaste,\n preserveFrameChildrenOrder: true\n });\n return;\n } // ------------------- Only textual stuff remaining -------------------\n\n\n if (!data.text) {\n return;\n } // ------------------- Successful Mermaid -------------------\n\n\n if (!isPlainPaste && (0,_mermaid__WEBPACK_IMPORTED_MODULE_47__.isMaybeMermaidDefinition)(data.text)) {\n const api = await Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! @excalidraw/mermaid-to-excalidraw */ \"../../node_modules/@excalidraw/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,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.convertToExcalidrawElements)(skeletonElements, {\n regenerateIds: true\n });\n this.addElementsFromPasteOrLibrary({\n elements,\n files,\n position: this.editorInterface.formFactor === \"desktop\" ? \"cursor\" : \"center\"\n });\n return;\n } catch (err) {\n console.warn(`parsing pasted text as mermaid definition failed: ${err.message}`);\n }\n } // ------------------- Pure embeddable URLs -------------------\n\n\n const nonEmptyLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeEOL)(data.text).split(/\\n+/).map(s => s.trim()).filter(Boolean);\n const embbeddableUrls = nonEmptyLines.map(str => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeParseEmbedSrc)(str)).filter(string => {\n var _a;\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(string, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(string) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(string)) === null || _a === void 0 ? void 0 : _a.type) === \"video\");\n });\n\n if (!isPlainPaste && embbeddableUrls.length > 0 && 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_6__.normalizeLink)(url)\n });\n\n if (embeddable) {\n embeddables.push(embeddable);\n }\n }\n\n if (embeddables.length) {\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: Object.fromEntries(embeddables.map(embeddable => [embeddable.id, true]))\n });\n }\n\n return;\n } // ------------------- Text -------------------\n\n\n this.addTextFromPaste(data.text, isPlainPaste);\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_32__.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_29__.t)(\"errors.failedToFetchImage\");\n } else if (error.cause === \"UNSUPPORTED\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"errors.unsupportedFileType\");\n }\n\n return {\n errorMessage\n };\n }\n }));\n const imageFiles = responses.filter(response => !!response.file).map(response => response.file);\n await this.insertImages(imageFiles, sceneX, sceneY);\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_6__.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_72__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value),\n //zsviczian\n fontFamily: this.state.currentItemFontFamily,\n textAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_TEXT_ALIGN,\n verticalAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n locked: false\n };\n const fontString = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)({\n fontSize: textElementProps.fontSize,\n fontFamily: textElementProps.fontFamily\n });\n const lineHeight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getLineHeight)(textElementProps.fontFamily);\n const [x1,, x2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.measureText)(originalText, fontString, lineHeight);\n const isTextUnwrapped = metrics.width > maxTextWidth;\n const text = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.wrapText)(originalText, fontString, maxTextWidth) : originalText;\n metrics = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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.insertNewElements(textElements);\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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.editorInterface.formFactor !== \"phone\") {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.t)(\"toast.pasteAsSingleElement\", {\n shortcut: (0,_shortcut__WEBPACK_IMPORTED_MODULE_50__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")\n }),\n duration: 5000\n });\n PLAIN_PASTE_TOAST_SHOWN = true;\n }\n }\n\n handleTextWysiwyg(element, {\n isExistingElement = false,\n initialCaretSceneCoords = null\n }) {\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n const updateElement = (nextOriginalText, isDeleted, rawText, //zsviczian\n link, //zsviczian\n hasTextLink) => {\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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: nextOriginalText,\n rawText: rawText !== null && rawText !== void 0 ? rawText : nextOriginalText,\n //zsviczian\n link,\n hasTextLink: hasTextLink !== null && hasTextLink !== void 0 ? hasTextLink : _element.hasTextLink,\n isDeleted: isDeleted !== null && isDeleted !== void 0 ? isDeleted : _element.isDeleted\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n //changing the value of element so this gets edited by textWysiwyg\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: text,\n rawText: text,\n isDeleted: false\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, text)));\n return element;\n }\n\n return _element;\n })]);\n }\n }\n\n (0,_wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_45__.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_6__.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_43__.withBatchedUpdates)(nextOriginalText => {\n updateElement(nextOriginalText, false);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isNonDeletedElement)(element)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene);\n }\n }),\n onSubmit: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdates)(({\n viaKeyboard,\n nextOriginalText\n }) => {\n var _a, _b;\n\n const isDeleted = !nextOriginalText.trim(); //zsviczian insert start\n\n const rawText = nextOriginalText; //should this be originalText??\n\n let link = undefined;\n let hasTextLink = false;\n\n if (this.props.onBeforeTextSubmit) {\n const _element = this.scene.getElementsIncludingDeleted().find(el => el.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(el));\n\n if (_element) {\n const dismensionsData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 hasTextLink = !!nextLink;\n link = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.syncElementLinkWithText)() ? nextLink : (_b = element.link) !== null && _b !== void 0 ? _b : undefined;\n }\n } //zsviczian insert end\n\n\n updateElement(nextOriginalText, isDeleted, rawText, link, hasTextLink); //zsviczian (added rawText, link, text)\n // keyboard-submit keeps focus on the edited object. For bound text, keep\n // the container selected even if the text becomes empty and is deleted.\n\n const elementIdToSelect = viaKeyboard ? element.containerId || (!isDeleted ? element.id : null) : null;\n\n if (elementIdToSelect) {\n // 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 (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [elementIdToSelect]: true\n }), prevState)\n }));\n });\n }\n\n if (isDeleted) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.fixBindingsAfterDeletion)(this.scene.getNonDeletedElements(), [element]);\n }\n\n if (!isDeleted || isExistingElement) {\n this.store.scheduleCapture();\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_40__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.focusContainer();\n }),\n element,\n excalidrawContainer: this.excalidrawContainerRef.current,\n app: this,\n initialCaretSceneCoords,\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.editorInterface.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n getSelectedTextElement(container) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length !== 1) {\n return null;\n }\n\n const selectedElement = selectedElements[0];\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n return selectedElement;\n }\n\n if (!container) {\n return null;\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(selectedElement, this.scene.getNonDeletedElementsMap());\n }\n\n getSelectedTextEditingContainerAtPosition(hitElement, sceneCoords) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length !== 1 || !hitElement || hitElement.id !== selectedElements[0].id) {\n return null;\n }\n\n const selectedElement = selectedElements[0];\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n return null;\n }\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isValidTextContainer)(selectedElement)) {\n return undefined;\n }\n\n const textElement = this.getSelectedTextElement(selectedElement);\n const hitTextElement = this.getTextElementAtPosition(sceneCoords.x, sceneCoords.y);\n\n if (!textElement || (hitTextElement === null || hitTextElement === void 0 ? void 0 : hitTextElement.id) !== textElement.id) {\n return undefined;\n }\n\n return selectedElement;\n }\n\n getTextElementAtPosition(x, y) {\n const element = this.getElementAtPosition(x, y, {\n includeBoundTextElement: true\n });\n\n if (element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) && !element.isDeleted) {\n return element;\n }\n\n return null;\n } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementAtPosition(x, y, opts) {\n let allHitElements = [];\n\n if (opts && \"allHitElements\" in opts) {\n allHitElements = (opts === null || opts === void 0 ? void 0 : opts.allHitElements) || [];\n } else {\n allHitElements = this.getElementsAtPosition(x, y, {\n includeBoundTextElement: opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement,\n includeLockedElements: opts === null || opts === void 0 ? void 0 : opts.includeLockedElements\n });\n }\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__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elementWithHighestZIndex,\n // when overlapping, we would like to be more precise\n // this also avoids the need to update past tests\n threshold: this.getElementHitThreshold(elementWithHighestZIndex) / 2,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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 } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementsAtPosition(x, y, opts) {\n const iframeLikes = [];\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const elements = ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) && (opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) ? this.scene.getNonDeletedElements() : this.scene.getNonDeletedElements().filter(element => ((opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) || !element.locked) && ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) || !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(element, elementsMap);\n return containingFrame && this.state.frameRendering.enabled && this.state.frameRendering.clip ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el)) {\n iframeLikes.push(el);\n return false;\n }\n\n return true;\n }).concat(iframeLikes);\n return elements;\n }\n\n getElementHitThreshold(element) {\n return Math.max(element.strokeWidth / 2 + 0.1, // NOTE: Here be dragons. Do not go under the 0.63 multiplier unless you're\n // willing to test extensively. The hit testing starts to become unreliable\n // due to FP imprecision under 0.63 in high zoom levels.\n 0.85 * (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.hasBoundingBox)([element], this.state, this.editorInterface)) {\n // if hitting the bounding box, return early\n // but if not, we should check for other cases as well (e.g. frame name)\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBox)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap(), this.getElementHitThreshold(element))) {\n return true;\n }\n } // take bound text element into consideration for hit collision as well\n\n\n const hitBoundTextOfElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundText)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap());\n\n if (hitBoundTextOfElement) {\n return true;\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element,\n threshold: this.getElementHitThreshold(element),\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementAbsoluteCoords)(elements[index], this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(elements[index]) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elements[index],\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(elements[index])\n })) {\n hitElement = elements[index];\n break;\n } else if (x1 < x && x < x2 && y1 < y && y < y2) {\n // to allow binding to containers within frames,\n // ignore frames in hit testing\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(elements[index])) {\n continue;\n }\n\n hitElement = elements[index];\n break;\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextBindableContainer)(hitElement, false) ? hitElement : null;\n }\n\n handleHoverSelectedLinearElement(linearElementEditor, scenePointerX, scenePointerY) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY),\n element,\n elementsMap,\n threshold: this.getElementHitThreshold(element)\n })) {\n hoverPointIndex = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointIndexUnderCursor(element, elementsMap, this.state.zoom, scenePointerX, scenePointerY);\n segmentMidPointHoveredCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, {\n x: scenePointerX,\n y: scenePointerY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const isHoveringAPointHandle = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) ? hoverPointIndex === 0 || hoverPointIndex === element.points.length - 1 : hoverPointIndex >= 0;\n\n if (isHoveringAPointHandle || segmentMidPointHoveredCoords) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Elbow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Elbow arrow can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\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__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords, segmentMidPointHoveredCoords)) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords\n })\n });\n } // Check for focus point hover\n\n\n let hoveredFocusPointBinding = null;\n const arrow = element;\n\n if (arrow.startBinding || arrow.endBinding) {\n hoveredFocusPointBinding = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointHover)(element, scenePointerX, scenePointerY, this.scene, this.state);\n }\n\n if (this.state.selectedLinearElement.hoveredFocusPointBinding !== hoveredFocusPointBinding) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isDragging: false,\n hoveredFocusPointBinding\n })\n });\n } // Set cursor to pointer when hovering over a focus point\n\n\n if (hoveredFocusPointBinding) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n } //mfuria #329. start right-click panning\n\n\n startRightClickPanning(event) {\n // Set up right-click panning similar to hand tool\n isPanning = true;\n this.focusContainer();\n\n if (!this.state.editingTextElement) {\n event.preventDefault();\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\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_43__.withBatchedUpdates)(() => {\n isPanning = false;\n\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursorForShape)(this.interactiveCanvas, this.state);\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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\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 if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_70__.shouldDisableZoom)(this.state)) {\n //zsviczian\n gesture.initialDistance = null;\n } else {\n gesture.lastCenter = (0,_gesture__WEBPACK_IMPORTED_MODULE_27__.getCenter)(gesture.pointers);\n gesture.initialScale = this.state.zoom.value;\n gesture.initialDistance = (0,_gesture__WEBPACK_IMPORTED_MODULE_27__.getDistance)(Array.from(gesture.pointers.values()));\n }\n }\n }\n\n initialPointerDownState(event) {\n const origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const selectedElements = this.scene.getSelectedElements(this.state);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const isElbowArrowOnly = selectedElements.findIndex(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow) === 0;\n return {\n origin,\n withCmdOrCtrl: event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD],\n originInGrid: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(origin.x, origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || isElbowArrowOnly ? null : this.getEffectiveGridSize())),\n scrollbars: (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_46__.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__WEBPACK_IMPORTED_MODULE_7__.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 blockDragging: false\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_43__.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_43__.withBatchedUpdates)(() => {\n lastPointerUp = null;\n isDraggingScrollBar = false;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.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_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n onPointerMove.flush();\n });\n lastPointerUp = onPointerUp;\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 = Math.max(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value, 1);\n const boundsPadding = _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_TRANSFORM_HANDLE_SPACING * 2 / this.state.zoom.value;\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n return point.x > x1 - boundsPadding - threshold && point.x < x2 + boundsPadding + threshold && point.y > y1 - boundsPadding - threshold && point.y < y2 + boundsPadding + threshold;\n }\n\n getCurrentItemRoundness(elementType) {\n return this.state.currentItemRoundness === \"round\" ? {\n type: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isUsingAdaptiveRadius)(elementType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null;\n }\n\n maybeCacheReferenceSnapPoints(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_38__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.getReferenceSnapPoints())) {\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setReferenceSnapPoints((0,_snapping__WEBPACK_IMPORTED_MODULE_38__.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_38__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.getVisibleGaps())) {\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setVisibleGaps((0,_snapping__WEBPACK_IMPORTED_MODULE_38__.getVisibleGaps)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n onKeyDownFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_43__.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_43__.withBatchedUpdates)(event => {\n // Prevents focus from escaping excalidraw tab\n event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_43__.withBatchedUpdatesThrottled)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z; //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_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.elbowed && this.state.selectedLinearElement.initialState.segmentMidpoint.index) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n let index = this.state.selectedLinearElement.initialState.segmentMidpoint.index;\n\n if (index < 0) {\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : -1;\n }\n\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.moveFixedSegment(this.state.selectedLinearElement, index, gridX, gridY, this.scene);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isDragging: true,\n segmentMidPointHoveredCoords: ret.segmentMidPointHoveredCoords,\n initialState: ret.initialState\n })\n });\n return;\n }\n\n const lastPointerCoords = (_b = this.previousPointerMoveCoords) !== null && _b !== void 0 ? _b : pointerDownState.origin;\n this.previousPointerMoveCoords = 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_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_22__.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_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\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.selectedLinearElement; // Handle focus point dragging if needed\n\n if (linearElementEditor.draggedFocusPointBinding) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointDrag)(linearElementEditor, elementsMap, pointerCoords, this.scene, this.state, this.getEffectiveGridSize(), event.altKey);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n isDragging: false,\n selectedPointsIndices: [],\n initialState: Object.assign(Object.assign({}, linearElementEditor.initialState), {\n lastClickedPoint: -1\n })\n })\n });\n return;\n }\n\n if (_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.shouldAddMidpoint(this.state.selectedLinearElement, pointerCoords, this.state, elementsMap)) {\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.addMidpoint(this.state.selectedLinearElement, pointerCoords, this, !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 initialState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n });\n return;\n } else if (linearElementEditor.initialState.segmentMidpoint.value !== null && !linearElementEditor.initialState.segmentMidpoint.added) {\n return;\n } else if (linearElementEditor.initialState.lastClickedPoint > -1) {\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (element === null || element === void 0 ? void 0 : element.isDeleted) {\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(element)) {\n const hoveredElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), this.scene.getNonDeletedElements(), elementsMap);\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleDelayedBindModeChange(element, hoveredElement);\n }\n }\n\n if (event.altKey && !((_d = (_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.initialState) === null || _d === void 0 ? void 0 : _d.arrowStartIsInside) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.handleSkipBindMode();\n } // Ignore drag requests if the arrow modification already happened\n\n\n if (linearElementEditor.initialState.lastClickedPoint === -1) {\n return;\n }\n\n const newState = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, pointerCoords.x, pointerCoords.y, linearElementEditor);\n\n if (newState) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n pointerDownState.drag.hasOccurred = true; // NOTE: Optimize setState calls because it\n // affects history and performance\n\n if (newState.suggestedBinding !== this.state.suggestedBinding || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isShallowEqual)((_f = (_e = newState.selectedLinearElement) === null || _e === void 0 ? void 0 : _e.selectedPointsIndices) !== null && _f !== void 0 ? _f : [], (_h = (_g = this.state.selectedLinearElement) === null || _g === void 0 ? void 0 : _g.selectedPointsIndices) !== null && _h !== void 0 ? _h : []) || ((_j = newState.selectedLinearElement) === null || _j === void 0 ? void 0 : _j.hoverPointIndex) !== ((_k = this.state.selectedLinearElement) === null || _k === void 0 ? void 0 : _k.hoverPointIndex) || ((_l = newState.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.customLineAngle) !== ((_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.customLineAngle) || this.state.selectedLinearElement.isDragging !== ((_o = newState.selectedLinearElement) === null || _o === void 0 ? void 0 : _o.isDragging) || ((_q = (_p = this.state.selectedLinearElement) === null || _p === void 0 ? void 0 : _p.initialState) === null || _q === void 0 ? void 0 : _q.altFocusPoint) !== ((_s = (_r = newState.selectedLinearElement) === null || _r === void 0 ? void 0 : _r.initialState) === null || _s === void 0 ? void 0 : _s.altFocusPoint)) {\n this.setState(newState);\n }\n\n return;\n }\n }\n }\n\n const hasHitASelectedElement = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n const isSelectingPointsInLineEditor = ((_t = this.state.selectedLinearElement) === null || _t === void 0 ? void 0 : _t.isEditing) && event.shiftKey && this.state.selectedLinearElement.elementId === ((_u = pointerDownState.hit.element) === null || _u === void 0 ? void 0 : _u.id);\n\n if ((hasHitASelectedElement || pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && !isSelectingPointsInLineEditor && !pointerDownState.drag.blockDragging) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length > 0 && selectedElements.every(element => element.locked)) {\n return;\n }\n\n const selectedElementsHasAFrame = selectedElements.some(e => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(e));\n const frameToHighlight = selectedElementsHasAFrame ? null : this.getTopLayerFrameAtSceneCoords(pointerCoords, {\n currentFrameId: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonFrameId)(selectedElements),\n excludeElementIds: this.state.selectedElementIds\n }); // Only update the state if there is a difference\n\n this.updateFrameToHighlight(frameToHighlight); // Marking that click was used for dragging to check\n // if elements should be deselected on pointerup\n\n pointerDownState.drag.hasOccurred = true; // prevent immediate dragging during lasso selection to avoid element displacement\n // only allow dragging if we're not in the middle of lasso selection\n // (on mobile, allow dragging if we hit an element)\n\n if (this.state.activeTool.type === \"lasso\" && this.lassoTrail.hasCurrentTrail && !(this.editorInterface.formFactor !== \"desktop\" && pointerDownState.hit.element) && !this.state.activeTool.fromSelection) {\n return;\n } // Clear lasso trail when starting to drag selected elements with lasso tool\n // Only clear if we're actually dragging (not during lasso selection)\n\n\n if (this.state.activeTool.type === \"lasso\" && selectedElements.length > 0 && pointerDownState.drag.hasOccurred && !this.state.activeTool.fromSelection) {\n this.lassoTrail.endPath();\n } // 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\n if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl && !this.state.editingTextElement && ((_v = this.state.activeEmbeddable) === null || _v === void 0 ? void 0 : _v.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__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement) && croppingElement.crop !== null && pointerDownState.hit.element === croppingElement) {\n const crop = croppingElement.crop;\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_w = this.imageCache.get(croppingElement.fileId)) === null || _w === void 0 ? void 0 : _w.image);\n\n if (image && !(image instanceof Promise)) {\n const uncroppedSize = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getUncroppedWidthAndHeight)(croppingElement);\n const instantDragOffset = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)(pointerCoords.x - lastPointerCoords.x, pointerCoords.y - lastPointerCoords.y); // to reduce cursor:image drift, we need to take into account\n // the canvas image element scaling so we can accurately\n // track the pixels on movement\n\n instantDragOffset[0] *= image.naturalWidth / uncroppedSize.width;\n instantDragOffset[1] *= image.naturalHeight / uncroppedSize.height;\n const [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_38__.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__WEBPACK_IMPORTED_MODULE_7__.dragSelectedElements)(pointerDownState, selectedElements, dragOffset, this.scene, snapOffset, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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 }); // We duplicate the selected element if alt is pressed on pointer move\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__WEBPACK_IMPORTED_MODULE_7__.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_6__.randomInteger)()\n };\n }\n });\n duplicatedElements.forEach(element => {\n pointerDownState.originalElements.set(element.id, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n x: origEl.x,\n y: origEl.y\n });\n }\n }\n\n return el;\n });\n const mappedNewSceneElements = (_y = (_x = this.props).onDuplicate) === null || _y === void 0 ? void 0 : _y.call(_x, mappedClonedElements, elements);\n const elementsWithIndices = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(mappedNewSceneElements || mappedClonedElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_6__.viewportCoordsToSceneCoords)(event, this.state); // switch selected elements to the duplicated ones\n\n this.setState(prevState => Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectionStateForElements)(duplicatedElements, this.scene.getNonDeletedElements(), prevState)));\n this.scene.replaceAllElements(elementsWithIndices);\n selectedElements.forEach(element => {\n var _a;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindableElement)(element) && ((_a = element.boundElements) === null || _a === void 0 ? void 0 : _a.some(other => other.type === \"arrow\"))) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene);\n }\n });\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 return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement) && !newElement.isDeleted) {\n pointerDownState.drag.hasOccurred = true;\n const points = newElement.points;\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.invariant)(points.length > 1, \"Do not create linear elements with less than 2 points\");\n let linearElementEditor = this.state.selectedLinearElement;\n\n if (!linearElementEditor || linearElementEditor.elementId !== newElement.id) {\n linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap());\n }\n\n const lastClickedPointOutOfBounds = linearElementEditor && (linearElementEditor.initialState.lastClickedPoint < 0 || linearElementEditor.initialState.lastClickedPoint >= points.length);\n\n if (lastClickedPointOutOfBounds) {\n console.warn(\"Last clicked point is out of bounds. Attempting to fix it.\");\n linearElementEditor = Object.assign(Object.assign({}, linearElementEditor), {\n selectedPointsIndices: [points.length - 1],\n initialState: Object.assign(Object.assign({}, linearElementEditor.initialState), {\n prevSelectedPointsIndices: null,\n lastClickedPoint: points.length - 1\n }),\n hoverPointIndex: points.length - 1\n });\n }\n\n this.setState(Object.assign({\n newElement\n }, _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, gridX, gridY, linearElementEditor)));\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 ((_z = this.state.selectedLinearElement) === null || _z === void 0 ? void 0 : _z.isEditing) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_30__.isSomeElementSelected)(elements, this.state)) {\n if (pointerDownState.withCmdOrCtrl && pointerDownState.hit.element) {\n this.setState(prevState => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_30__.getElementsWithinSelection)(elements, this.state.selectionElement, this.scene.getNonDeletedElementsMap(), false, this.state.boxSelectionMode) : [];\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(elementsWithinSelection[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(elementsWithinSelection[0], this.scene.getNonDeletedElementsMap()) : null,\n showHyperlinkPopup: elementsWithinSelection.length === 1 && (elementsWithinSelection[0].link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_43__.withBatchedUpdates)(childEvent => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n this.removePointer(childEvent);\n pointerDownState.drag.blockDragging = false;\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_6__.updateStable)(prevState.snapLines, []),\n originSnapOffset: null\n })); // just in case, tool changes mid drag, always clean up\n\n this.lassoTrail.endPath();\n this.previousPointerMoveCoords = null;\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setReferenceSnapPoints(null);\n _snapping__WEBPACK_IMPORTED_MODULE_38__.SnapCache.setVisibleGaps(null);\n this.savePointer(childEvent.clientX, childEvent.clientY, \"up\"); // if current elements are still selected\n // and the pointer is just over a locked element\n // do not allow activeLockedId to be set\n\n const hitElements = pointerDownState.hit.allHitElements;\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: childEvent.clientX,\n clientY: childEvent.clientY\n }, this.state);\n\n if (this.state.activeTool.type === \"selection\" && !pointerDownState.boxSelection.hasOccurred && !pointerDownState.resize.isResizing && !hitElements.some(el => this.state.selectedElementIds[el.id])) {\n const hitLockedElement = this.getElementAtPosition(sceneCoords.x, sceneCoords.y, {\n includeLockedElements: true\n });\n this.store.scheduleCapture();\n\n if (hitLockedElement === null || hitLockedElement === void 0 ? void 0 : hitLockedElement.locked) {\n this.setState({\n activeLockedId: hitLockedElement.groupIds.length > 0 ? hitLockedElement.groupIds.at(-1) || \"\" : hitLockedElement.id\n });\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFeatureFlag)(\"COMPLEX_BINDINGS\")) {\n this.resetDelayedBindMode();\n }\n\n this.setState({\n selectedElementsAreBeingDragged: false,\n bindMode: \"orbit\"\n });\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 (((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) && !this.state.newElement && this.state.selectedLinearElement.draggedFocusPointBinding === null) {\n if (!pointerDownState.boxSelection.hasOccurred && ((_f = (_e = pointerDownState.hit) === null || _e === void 0 ? void 0 : _e.element) === null || _f === void 0 ? void 0 : _f.id) !== this.state.selectedLinearElement.elementId && this.state.selectedLinearElement.draggedFocusPointBinding === null) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const editingLinearElement = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerUp(childEvent, this.state.selectedLinearElement, this.state, this.scene);\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n\n if (editingLinearElement !== this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: editingLinearElement,\n suggestedBinding: null\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__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if (element) {\n this.scene.mutateElement(element, {});\n }\n }\n\n if (this.state.selectedLinearElement.draggedFocusPointBinding) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.handleFocusPointPointerUp)(this.state.selectedLinearElement, this.scene);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n draggedFocusPointBinding: null\n })\n });\n } else if (((_h = (_g = pointerDownState.hit) === null || _g === void 0 ? void 0 : _g.element) === null || _h === void 0 ? void 0 : _h.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 if (this.state.selectedLinearElement.isDragging) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isDragging: false\n })\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n\n if (this.state.newElement && this.state.multiElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(this.state.newElement) && this.state.selectedLinearElement) {\n const {\n multiElement\n } = this.state;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n })\n });\n }\n }\n\n this.missingPointerEventCleanupEmitter.clear();\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, pointerDownState.eventListeners.onMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, pointerDownState.eventListeners.onUp);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, pointerDownState.eventListeners.onKeyDown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, pointerDownState.eventListeners.onKeyUp);\n (_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.onPointerUp) === null || _k === void 0 ? void 0 : _k.call(_j, 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_6__.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 });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n if (newElement.points.length > 1 && newElement.points[1][0] !== 0 && newElement.points[1][1] !== 0) {\n this.store.scheduleCapture();\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const dragDistance = (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)) * this.state.zoom.value;\n\n if ((!pointerDownState.drag.hasOccurred || dragDistance < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MINIMUM_ARROW_SIZE) && newElement && !multiElement) {\n if (this.editorInterface.isTouchScreen && newElement.points.length > 1) {\n //zsviczian\n const FIXED_DELTA_X = Math.min(this.state.width * 0.7 / this.state.zoom.value, 100);\n this.scene.mutateElement(newElement, {\n x: newElement.x - FIXED_DELTA_X / 2,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(FIXED_DELTA_X, 0)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n this.scene.mutateElement(newElement, {\n points: [newElement.points[0], (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n multiElement: newElement,\n newElement\n });\n }\n } else if (pointerDownState.drag.hasOccurred && !multiElement) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n\n this.setState({\n suggestedBinding: null\n });\n\n if (!activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n }),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap())\n }));\n } else {\n this.setState({\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__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement)) {\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getMinTextElementWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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__WEBPACK_IMPORTED_MODULE_7__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n });\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(newElement)) {\n const elementsInsideFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInNewFrame)(this.scene.getElementsIncludingDeleted(), newElement, this.scene.getNonDeletedElementsMap());\n this.scene.replaceAllElements((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(this.scene.getElementsMapIncludingDeleted(), elementsInsideFrame, newElement));\n }\n\n if (newElement) {\n this.scene.mutateElement(newElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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_6__.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__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(linearElement, elementsMap);\n\n if (frame && linearElement) {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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 selectedElements = this.scene.getSelectedElements(this.state);\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(sceneCoords, {\n currentFrameId: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonFrameId)(selectedElements),\n excludeElementIds: this.state.selectedElementIds\n });\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__WEBPACK_IMPORTED_MODULE_7__.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 => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n\n if (this.state.editingGroupId) {\n updateGroupIdsAfterEditingGroup(elementsToAdd);\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, elementsToAdd, topLayerFrame);\n } else if (!topLayerFrame) {\n if (this.state.editingGroupId) {\n const elementsToRemove = selectedElements.filter(element => element.frameId && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n updateGroupIdsAfterEditingGroup(elementsToRemove);\n }\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(nextElements, this.state, this);\n this.scene.replaceAllElements(nextElements);\n }\n }\n\n if (resizingElement) {\n this.store.scheduleCapture();\n }\n\n if (resizingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(this.scene.getElementsIncludingDeleted(), this.state, this);\n const selectedFrames = this.scene.getSelectedElements(this.state).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element));\n\n for (const frame of selectedFrames) {\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.replaceAllElementsInFrame)(nextElements, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getElementsIncludingDeleted(), frame, this.state, elementsMap), frame);\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 (((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.elementId) !== (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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_22__.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_6__.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 !((_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.isEditing) || !pointerDownState.boxSelection.hasOccurred) && // hitElement can be set when alt + ctrl to toggle lasso and we will\n // just respect the selected elements from lasso instead\n this.state.activeTool.type !== \"lasso\") {\n // when inside line editor, shift selects points instead\n if (childEvent.shiftKey && !((_o = this.state.selectedLinearElement) === null || _o === void 0 ? void 0 : _o.isEditing)) {\n if (this.state.selectedElementIds[hitElement.id]) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, _prevState)\n };\n }); // if not dragging a linear element point (outside editor)\n } else if (!((_p = this.state.selectedLinearElement) === null || _p === void 0 ? void 0 : _p.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_30__.getSelectedElements)(this.scene.getNonDeletedElements(), {\n selectedElementIds: newSelectedElementIds\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newSelectedElements[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n selectedLinearElement: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBoxOnly)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y),\n element: hitElement,\n elementsMap,\n threshold: this.getElementHitThreshold(hitElement),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement) ? this.frameNameBoundsCache.get(hitElement) : null\n }, elementsMap) || !hitElement && pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements)) {\n if ((_q = this.state.selectedLinearElement) === null || _q === void 0 ? void 0 : _q.isEditing) {\n // Exit editing mode but keep the element selected\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n } else {\n // Deselect selected elements\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // reset cursor\n\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_40__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n return;\n }\n\n const selectedTextEditingContainer = this.getSelectedTextEditingContainerAtPosition(hitElement, sceneCoords);\n\n if (activeTool.type === this.state.preferredSelectionTool.type && !this.state.editingTextElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && !childEvent.shiftKey && !childEvent[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !childEvent.altKey && childEvent.pointerType !== \"touch\" && hitElement && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(hitElement) && this.state.selectedElementIds[hitElement.id] && this.scene.getSelectedElements(this.state).length === 1 || selectedTextEditingContainer)) {\n this.startTextEditing({\n sceneX: sceneCoords.x,\n sceneY: sceneCoords.y,\n container: selectedTextEditingContainer,\n initialCaretSceneCoords: this.lastPointerUpIsDoubleClick ? undefined : sceneCoords\n });\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && newElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n showHyperlinkPopup: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(newElement) && !newElement.link ? \"editor\" : prevState.showHyperlinkPopup\n }));\n }\n\n if (activeTool.type !== \"selection\" || (0,_scene__WEBPACK_IMPORTED_MODULE_30__.isSomeElementSelected)(this.scene.getNonDeletedElements(), this.state) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isShallowEqual)(this.state.previousSelectedElementIds, this.state.selectedElementIds)) {\n this.store.scheduleCapture();\n }\n\n if (pointerDownState.drag.hasOccurred && !this.state.selectedLinearElement || 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__WEBPACK_IMPORTED_MODULE_7__.isArrowElement);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindBindingElements)(linearElements, this.scene, this.state);\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_40__.resetCursor)(this.interactiveCanvas);\n this.setState({\n newElement: null,\n suggestedBinding: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.state.preferredSelectionTool.type\n })\n });\n } else {\n this.setState({\n newElement: null,\n suggestedBinding: null\n });\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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.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__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, prevState.editingGroupId) ? prevState.editingGroupId : null\n }));\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null,\n previousSelectedElementIds: this.state.selectedElementIds,\n selectedLinearElement: null\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__WEBPACK_IMPORTED_MODULE_7__.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_6__.TEXT_TO_CENTER_SNAP_THRESHOLD;\n\n if (isSnappedToCenter) {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.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_29__.languages.find(lang => lang.code === this.props.langCode) || _i18n__WEBPACK_IMPORTED_MODULE_29__.defaultLang;\n await (0,_i18n__WEBPACK_IMPORTED_MODULE_29__.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\ndeclare global {\n interface Window {\n h: {\n scene: Scene;\n elements: readonly ExcalidrawElement[];\n state: AppState;\n setState: React.Component<any, AppState>[\"setState\"];\n watchState: (prev: any, next: any) => void | undefined;\n app: InstanceType<typeof App>;\n history: History;\n store: Store;\n };\n }\n}\n\nexport const createTestHook = () => {\n if (isTestEnv() || isDevEnv()) {\n window.h = window.h || ({} as Window[\"h\"]);\n\n Object.defineProperties(window.h, {\n elements: {\n configurable: true,\n get() {\n return this.app?.scene.getElementsIncludingDeleted();\n },\n set(elements: ExcalidrawElement[]) {\n return this.app?.scene.replaceAllElements(\n syncInvalidIndices(elements),\n );\n },\n },\n scene: {\n configurable: true,\n get() {\n return this.app?.scene;\n },\n },\n });\n }\n};\n\ncreateTestHook();*/\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/App.tsx?");
15846
15846
 
15847
15847
  /***/ }),
15848
15848
 
@@ -18856,7 +18856,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
18856
18856
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
18857
18857
 
18858
18858
  "use strict";
18859
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Button: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Button),\n/* harmony export */ CaptureUpdateAction: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.CaptureUpdateAction),\n/* harmony export */ CommandPalette: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.CommandPalette),\n/* harmony export */ DEFAULT_LASER_COLOR: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.DEFAULT_LASER_COLOR),\n/* harmony export */ DefaultSidebar: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.DefaultSidebar),\n/* harmony export */ DiagramToCodePlugin: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.DiagramToCodePlugin),\n/* harmony export */ Ellipsify: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Ellipsify),\n/* harmony export */ Excalidraw: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Excalidraw),\n/* harmony export */ ExcalidrawAPIContext: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.ExcalidrawAPIContext),\n/* harmony export */ ExcalidrawAPIProvider: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.ExcalidrawAPIProvider),\n/* harmony export */ FONT_FAMILY: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.FONT_FAMILY),\n/* harmony export */ Fonts: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Fonts),\n/* harmony export */ Footer: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Footer),\n/* harmony export */ LiveCollaborationTrigger: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.LiveCollaborationTrigger),\n/* harmony export */ MIME_TYPES: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.MIME_TYPES),\n/* harmony export */ MainMenu: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.MainMenu),\n/* harmony export */ ROUNDNESS: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.ROUNDNESS),\n/* harmony export */ Sidebar: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Sidebar),\n/* harmony export */ Stats: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Stats),\n/* harmony export */ THEME: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.THEME),\n/* harmony export */ TTDDialog: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.TTDDialog),\n/* harmony export */ TTDDialogTrigger: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.TTDDialogTrigger),\n/* harmony export */ TTDStreamFetch: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.TTDStreamFetch),\n/* harmony export */ UserIdleState: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.UserIdleState),\n/* harmony export */ WelcomeScreen: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.WelcomeScreen),\n/* harmony export */ bumpVersion: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.bumpVersion),\n/* harmony export */ convertToExcalidrawElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.convertToExcalidrawElements),\n/* harmony export */ defaultLang: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.defaultLang),\n/* harmony export */ destroyObsidianUtils: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.destroyObsidianUtils),\n/* harmony export */ elementPartiallyOverlapsWithOrContainsBBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.elementPartiallyOverlapsWithOrContainsBBox),\n/* harmony export */ elementsOverlappingBBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.elementsOverlappingBBox),\n/* harmony export */ exportToBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToBlob),\n/* harmony export */ exportToCanvas: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToCanvas),\n/* harmony export */ exportToClipboard: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToClipboard),\n/* harmony export */ exportToSvg: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToSvg),\n/* harmony export */ getBoundTextMaxWidth: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxWidth),\n/* harmony export */ getCSSFontDefinition: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getCSSFontDefinition),\n/* harmony export */ getCommonBoundingBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getCommonBoundingBox),\n/* harmony export */ getCommonBounds: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getCommonBounds),\n/* harmony export */ getContainerElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getContainerElement),\n/* harmony export */ getDataURL: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getDataURL),\n/* harmony export */ getDefaultColorPalette: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getDefaultColorPalette),\n/* harmony export */ getEmbedLink: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getEmbedLink),\n/* harmony export */ getFontFamilies: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontFamilies),\n/* harmony export */ getFontFamilyString: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontFamilyString),\n/* harmony export */ getFontMetrics: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontMetrics),\n/* harmony export */ getFontString: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontString),\n/* harmony export */ getFormFactor: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFormFactor),\n/* harmony export */ getLibraryItemsHash: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getLibraryItemsHash),\n/* harmony export */ getLineHeight: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getLineHeight),\n/* harmony export */ getMaximumGroups: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getMaximumGroups),\n/* harmony export */ getNonDeletedElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getNonDeletedElements),\n/* harmony export */ getSceneVersion: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getSceneVersion),\n/* harmony export */ getSharedMermaidInstance: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getSharedMermaidInstance),\n/* harmony export */ getTextFromElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getTextFromElements),\n/* harmony export */ getVisibleSceneBounds: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getVisibleSceneBounds),\n/* harmony export */ hashElementsVersion: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.hashElementsVersion),\n/* harmony export */ hashString: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.hashString),\n/* harmony export */ intersectElementWithLine: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLine),\n/* harmony export */ isElementInsideBBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isElementInsideBBox),\n/* harmony export */ isElementLink: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isElementLink),\n/* harmony export */ isInvisiblySmallElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isInvisiblySmallElement),\n/* harmony export */ isLinearElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isLinearElement),\n/* harmony export */ isSpreadsheetValidForChartType: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isSpreadsheetValidForChartType),\n/* harmony export */ languages: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.languages),\n/* harmony export */ loadFromBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadFromBlob),\n/* harmony export */ loadLibraryFromBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadLibraryFromBlob),\n/* harmony export */ loadMermaid: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadMermaid),\n/* harmony export */ loadSceneFonts: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadSceneFonts),\n/* harmony export */ loadSceneOrLibraryFromBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadSceneOrLibraryFromBlob),\n/* harmony export */ measureText: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.measureText),\n/* harmony export */ mergeLibraryItems: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.mergeLibraryItems),\n/* harmony export */ mermaidToExcalidraw: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.mermaidToExcalidraw),\n/* harmony export */ mutateElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.mutateElement),\n/* harmony export */ newElementWith: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.newElementWith),\n/* harmony export */ normalizeLink: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.normalizeLink),\n/* harmony export */ parseLibraryTokensFromUrl: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.parseLibraryTokensFromUrl),\n/* harmony export */ reconcileElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.reconcileElements),\n/* harmony export */ refreshTextDimensions: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.refreshTextDimensions),\n/* harmony export */ registerFontsInCSS: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.registerFontsInCSS),\n/* harmony export */ registerLocalFont: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.registerLocalFont),\n/* harmony export */ renderSpreadsheet: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.renderSpreadsheet),\n/* harmony export */ restoreAppState: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreAppState),\n/* harmony export */ restoreElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreElement),\n/* harmony export */ restoreElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreElements),\n/* harmony export */ restoreLibraryItems: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreLibraryItems),\n/* harmony export */ safelyParseJSON: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.safelyParseJSON),\n/* harmony export */ sceneCoordsToViewportCoords: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.sceneCoordsToViewportCoords),\n/* harmony export */ serializeAsJSON: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.serializeAsJSON),\n/* harmony export */ serializeLibraryAsJSON: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.serializeLibraryAsJSON),\n/* harmony export */ setCustomTextMetricsProvider: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.setCustomTextMetricsProvider),\n/* harmony export */ syncInvalidIndices: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.syncInvalidIndices),\n/* harmony export */ syncMovedIndices: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.syncMovedIndices),\n/* harmony export */ throttleRAF: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.throttleRAF),\n/* harmony export */ tryParseSpreadsheet: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.tryParseSpreadsheet),\n/* harmony export */ useEditorInterface: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useEditorInterface),\n/* harmony export */ useExcalidrawAPI: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useExcalidrawAPI),\n/* harmony export */ useExcalidrawStateValue: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useExcalidrawStateValue),\n/* harmony export */ useHandleLibrary: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useHandleLibrary),\n/* harmony export */ useI18n: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useI18n),\n/* harmony export */ useOnExcalidrawStateChange: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useOnExcalidrawStateChange),\n/* harmony export */ useStylesPanelMode: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useStylesPanelMode),\n/* harmony export */ viewportCoordsToSceneCoords: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.viewportCoordsToSceneCoords),\n/* harmony export */ wrapText: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.wrapText),\n/* harmony export */ zoomToFitBounds: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.zoomToFitBounds)\n/* harmony export */ });\n/* harmony import */ var _publicPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./publicPath */ \"./publicPath.js\");\n/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./polyfill */ \"./polyfill.ts\");\n/* harmony import */ var _fonts_fonts_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fonts/fonts.css */ \"./fonts/fonts.css\");\n/* harmony import */ var _css_obsidianStylingOverrides_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css/obsidianStylingOverrides.css */ \"./css/obsidianStylingOverrides.css\");\n/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./index */ \"./index.tsx\");\n\n\n\n\n(0,_polyfill__WEBPACK_IMPORTED_MODULE_1__[\"default\"])();\n\n\n//# sourceURL=webpack://ExcalidrawLib/./entry.js?");
18859
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Button: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Button),\n/* harmony export */ CaptureUpdateAction: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.CaptureUpdateAction),\n/* harmony export */ CommandPalette: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.CommandPalette),\n/* harmony export */ DEFAULT_LASER_COLOR: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.DEFAULT_LASER_COLOR),\n/* harmony export */ DefaultSidebar: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.DefaultSidebar),\n/* harmony export */ DiagramToCodePlugin: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.DiagramToCodePlugin),\n/* harmony export */ Ellipsify: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Ellipsify),\n/* harmony export */ Excalidraw: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Excalidraw),\n/* harmony export */ ExcalidrawAPIContext: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.ExcalidrawAPIContext),\n/* harmony export */ ExcalidrawAPIProvider: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.ExcalidrawAPIProvider),\n/* harmony export */ FONT_FAMILY: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.FONT_FAMILY),\n/* harmony export */ Fonts: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Fonts),\n/* harmony export */ Footer: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Footer),\n/* harmony export */ LiveCollaborationTrigger: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.LiveCollaborationTrigger),\n/* harmony export */ MIME_TYPES: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.MIME_TYPES),\n/* harmony export */ MainMenu: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.MainMenu),\n/* harmony export */ ROUNDNESS: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.ROUNDNESS),\n/* harmony export */ Sidebar: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Sidebar),\n/* harmony export */ Stats: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.Stats),\n/* harmony export */ THEME: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.THEME),\n/* harmony export */ TTDDialog: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.TTDDialog),\n/* harmony export */ TTDDialogTrigger: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.TTDDialogTrigger),\n/* harmony export */ TTDStreamFetch: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.TTDStreamFetch),\n/* harmony export */ UserIdleState: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.UserIdleState),\n/* harmony export */ WelcomeScreen: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.WelcomeScreen),\n/* harmony export */ applyDarkModeFilter: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.applyDarkModeFilter),\n/* harmony export */ bumpVersion: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.bumpVersion),\n/* harmony export */ convertToExcalidrawElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.convertToExcalidrawElements),\n/* harmony export */ defaultLang: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.defaultLang),\n/* harmony export */ destroyObsidianUtils: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.destroyObsidianUtils),\n/* harmony export */ elementPartiallyOverlapsWithOrContainsBBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.elementPartiallyOverlapsWithOrContainsBBox),\n/* harmony export */ elementsOverlappingBBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.elementsOverlappingBBox),\n/* harmony export */ exportToBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToBlob),\n/* harmony export */ exportToCanvas: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToCanvas),\n/* harmony export */ exportToClipboard: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToClipboard),\n/* harmony export */ exportToSvg: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.exportToSvg),\n/* harmony export */ getBoundTextMaxWidth: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getBoundTextMaxWidth),\n/* harmony export */ getCSSFontDefinition: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getCSSFontDefinition),\n/* harmony export */ getCommonBoundingBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getCommonBoundingBox),\n/* harmony export */ getCommonBounds: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getCommonBounds),\n/* harmony export */ getContainerElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getContainerElement),\n/* harmony export */ getDataURL: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getDataURL),\n/* harmony export */ getDefaultColorPalette: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getDefaultColorPalette),\n/* harmony export */ getEmbedLink: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getEmbedLink),\n/* harmony export */ getFontFamilies: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontFamilies),\n/* harmony export */ getFontFamilyString: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontFamilyString),\n/* harmony export */ getFontMetrics: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontMetrics),\n/* harmony export */ getFontString: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFontString),\n/* harmony export */ getFormFactor: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getFormFactor),\n/* harmony export */ getLibraryItemsHash: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getLibraryItemsHash),\n/* harmony export */ getLineHeight: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getLineHeight),\n/* harmony export */ getMaximumGroups: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getMaximumGroups),\n/* harmony export */ getNonDeletedElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getNonDeletedElements),\n/* harmony export */ getSceneVersion: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getSceneVersion),\n/* harmony export */ getSharedMermaidInstance: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getSharedMermaidInstance),\n/* harmony export */ getTextFromElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getTextFromElements),\n/* harmony export */ getVisibleSceneBounds: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.getVisibleSceneBounds),\n/* harmony export */ hashElementsVersion: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.hashElementsVersion),\n/* harmony export */ hashString: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.hashString),\n/* harmony export */ intersectElementWithLine: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.intersectElementWithLine),\n/* harmony export */ isElementInsideBBox: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isElementInsideBBox),\n/* harmony export */ isElementLink: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isElementLink),\n/* harmony export */ isInvisiblySmallElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isInvisiblySmallElement),\n/* harmony export */ isLinearElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isLinearElement),\n/* harmony export */ isSpreadsheetValidForChartType: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.isSpreadsheetValidForChartType),\n/* harmony export */ languages: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.languages),\n/* harmony export */ loadFromBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadFromBlob),\n/* harmony export */ loadLibraryFromBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadLibraryFromBlob),\n/* harmony export */ loadMermaid: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadMermaid),\n/* harmony export */ loadSceneFonts: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadSceneFonts),\n/* harmony export */ loadSceneOrLibraryFromBlob: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.loadSceneOrLibraryFromBlob),\n/* harmony export */ measureText: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.measureText),\n/* harmony export */ mergeLibraryItems: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.mergeLibraryItems),\n/* harmony export */ mermaidToExcalidraw: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.mermaidToExcalidraw),\n/* harmony export */ mutateElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.mutateElement),\n/* harmony export */ newElementWith: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.newElementWith),\n/* harmony export */ normalizeLink: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.normalizeLink),\n/* harmony export */ parseLibraryTokensFromUrl: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.parseLibraryTokensFromUrl),\n/* harmony export */ reconcileElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.reconcileElements),\n/* harmony export */ refreshTextDimensions: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.refreshTextDimensions),\n/* harmony export */ registerFontsInCSS: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.registerFontsInCSS),\n/* harmony export */ registerLocalFont: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.registerLocalFont),\n/* harmony export */ renderSpreadsheet: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.renderSpreadsheet),\n/* harmony export */ restoreAppState: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreAppState),\n/* harmony export */ restoreElement: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreElement),\n/* harmony export */ restoreElements: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreElements),\n/* harmony export */ restoreLibraryItems: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.restoreLibraryItems),\n/* harmony export */ safelyParseJSON: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.safelyParseJSON),\n/* harmony export */ sceneCoordsToViewportCoords: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.sceneCoordsToViewportCoords),\n/* harmony export */ serializeAsJSON: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.serializeAsJSON),\n/* harmony export */ serializeLibraryAsJSON: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.serializeLibraryAsJSON),\n/* harmony export */ setCustomTextMetricsProvider: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.setCustomTextMetricsProvider),\n/* harmony export */ syncInvalidIndices: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.syncInvalidIndices),\n/* harmony export */ syncMovedIndices: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.syncMovedIndices),\n/* harmony export */ throttleRAF: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.throttleRAF),\n/* harmony export */ tryParseSpreadsheet: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.tryParseSpreadsheet),\n/* harmony export */ useEditorInterface: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useEditorInterface),\n/* harmony export */ useExcalidrawAPI: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useExcalidrawAPI),\n/* harmony export */ useExcalidrawStateValue: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useExcalidrawStateValue),\n/* harmony export */ useHandleLibrary: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useHandleLibrary),\n/* harmony export */ useI18n: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useI18n),\n/* harmony export */ useOnExcalidrawStateChange: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useOnExcalidrawStateChange),\n/* harmony export */ useStylesPanelMode: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.useStylesPanelMode),\n/* harmony export */ viewportCoordsToSceneCoords: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.viewportCoordsToSceneCoords),\n/* harmony export */ wrapText: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.wrapText),\n/* harmony export */ zoomToFitBounds: () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_4__.zoomToFitBounds)\n/* harmony export */ });\n/* harmony import */ var _publicPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./publicPath */ \"./publicPath.js\");\n/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./polyfill */ \"./polyfill.ts\");\n/* harmony import */ var _fonts_fonts_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fonts/fonts.css */ \"./fonts/fonts.css\");\n/* harmony import */ var _css_obsidianStylingOverrides_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css/obsidianStylingOverrides.css */ \"./css/obsidianStylingOverrides.css\");\n/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./index */ \"./index.tsx\");\n\n\n\n\n(0,_polyfill__WEBPACK_IMPORTED_MODULE_1__[\"default\"])();\n\n\n//# sourceURL=webpack://ExcalidrawLib/./entry.js?");
18860
18860
 
18861
18861
  /***/ }),
18862
18862
 
@@ -18977,7 +18977,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
18977
18977
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
18978
18978
 
18979
18979
  "use strict";
18980
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawFontFace: () => (/* binding */ ExcalidrawFontFace)\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 _subset_subset_main__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../subset/subset-main */ \"./subset/subset-main.ts\");\n/* harmony import */ var _data_encode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/encode */ \"./data/encode.ts\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n\n\n\n\nclass ExcalidrawFontFace {\n constructor(family, uri, descriptors) {\n this.urls = ExcalidrawFontFace.createUrls(uri);\n const sources = this.urls.map(url => `url(${url}) ${ExcalidrawFontFace.getFormat(url)}`).join(\", \");\n this.fontFace = new FontFace(family, sources, Object.assign({\n display: \"swap\",\n style: \"normal\",\n weight: \"400\"\n }, descriptors));\n }\n /**\n * Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.\n *\n * Retrieves `undefined` otherwise.\n */\n\n\n toCSS(characters) {\n // quick exit in case the characters are not within this font face's unicode range\n if (!this.getUnicodeRangeRegex().test(characters)) {\n return;\n } //zsviczian - only woffs are chopped into glyphs other fonts are returned as is\n\n\n if (typeof this.urls[0] === \"string\" && !this.urls[0].startsWith(\"data:font/woff2\")) {\n return Promise.resolve(`@font-face { font-family: ${this.fontFace.family}; src: url(${this.urls[0]}); }`);\n }\n\n const codepoints = Array.from(characters).map(char => char.codePointAt(0));\n return this.getContent(codepoints).then(content => `@font-face { font-family: ${this.fontFace.family}; src: url(${content}); }`);\n }\n /**\n * Tries to fetch woff2 content, based on the registered urls (from first to last, treated as fallbacks).\n *\n * @returns base64 with subsetted glyphs based on the passed codepoint, last defined url otherwise\n */\n\n\n async getContent(codePoints) {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n try {\n const arrayBuffer = await this.fetchFont(url);\n const base64 = await (0,_subset_subset_main__WEBPACK_IMPORTED_MODULE_1__.subsetWoff2GlyphsByCodepoints)(arrayBuffer, codePoints);\n return base64;\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font family \"${this.fontFace.family}\"`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n fetchFont(url) {\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.promiseTry)(async () => {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_3__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n return result;\n }\n\n const response = await fetch(url, {\n // always prefer cache (even stale), otherwise it always triggers an unnecessary validation request\n // which we don't need as we are controlling freshness of the fonts with the stable hash suffix in the url\n // https://developer.mozilla.org/en-US/docs/Web/API/Request/cache\n cache: \"force-cache\",\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (!response.ok) {\n const urlString = url instanceof URL ? url.toString() : \"dataurl\";\n throw new Error(`Failed to fetch \"${urlString}\": ${response.statusText}`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n });\n }\n\n getUnicodeRangeRegex() {\n // using \\u{h} or \\u{hhhhh} to match any number of hex digits,\n // otherwise we would get an \"Invalid Unicode escape\" error\n // e.g. U+0-1007F -> \\u{0}-\\u{1007F}\n const unicodeRangeRegex = this.fontFace.unicodeRange.split(/,\\s*/).map(range => {\n const [start, end] = range.replace(\"U+\", \"\").split(\"-\");\n\n if (end) {\n return `\\\\u{${start}}-\\\\u{${end}}`;\n }\n\n return `\\\\u{${start}}`;\n }).join(\"\");\n return new RegExp(`[${unicodeRangeRegex}]`, \"u\");\n }\n\n static createUrls(uri) {\n if (uri.startsWith(\"data\")) {\n // don't create the URL instance, as parsing the huge dataurl string is expensive\n return [uri];\n }\n\n if (uri.startsWith(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.LOCAL_FONT_PROTOCOL)) {\n // no url for local fonts\n return [];\n }\n\n if (uri.startsWith(\"http\")) {\n // one url for http imports or data url\n return [new URL(uri)];\n } // absolute assets paths, which are found in tests and excalidraw-app build, won't work with base url, so we are stripping initial slash away\n\n\n const assetUrl = uri.replace(/^\\/+/, \"\");\n const urls = [];\n\n if (typeof window.EXCALIDRAW_ASSET_PATH === \"string\") {\n const normalizedBaseUrl = this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n } else if (Array.isArray(window.EXCALIDRAW_ASSET_PATH)) {\n window.EXCALIDRAW_ASSET_PATH.forEach(path => {\n const normalizedBaseUrl = this.normalizeBaseUrl(path);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n });\n } // fallback url for bundled fonts\n\n\n urls.push(new URL(assetUrl, ExcalidrawFontFace.ASSETS_FALLBACK_URL));\n return urls;\n }\n\n static getFormat(url) {\n if (!(url instanceof URL)) {\n // format is irrelevant for data url\n return \"\";\n }\n\n try {\n const parts = new URL(url).pathname.split(\".\");\n\n if (parts.length === 1) {\n return \"\";\n }\n\n return `format('${parts.pop()}')`;\n } catch (error) {\n return \"\";\n }\n }\n\n static normalizeBaseUrl(baseUrl) {\n var _a;\n\n let result = baseUrl; // in case user passed a root-relative url (~absolute path),\n // like \"/\" or \"/some/path\", or relative (starts with \"./\"),\n // prepend it with `location.origin`\n\n if (/^\\.?\\//.test(result)) {\n result = new URL(result.replace(/^\\.?\\/+/, \"\"), (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.origin).toString();\n } // ensure there is a trailing slash, otherwise url won't be correctly concatenated\n\n\n result = `${result.replace(/\\/+$/, \"\")}/`;\n return result;\n }\n /**\n * zsviczian https://github.com/zsviczian/excalidraw/commit/b4cfaaa4b4f46ca01f94e27fb7bf651a9da99daa\n */\n\n\n async getContentLegacy() {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n if (typeof url === \"string\" && url.startsWith(\"data:\")) {\n // it's dataurl, the font is inlined as base64, no need to fetch\n return url;\n }\n\n try {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_3__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n return `data:font/woff2;base64,${(0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.stringToBase64)((0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.toByteString)(result), true)}`;\n }\n\n const response = await fetch(url, {\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (response.ok) {\n const mimeType = response.headers.get(\"Content-Type\");\n const buffer = await response.arrayBuffer();\n return `data:${mimeType};base64,${(0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.stringToBase64)((0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.toByteString)(buffer), true)}`;\n } // response not ok, try to continue\n\n\n errorMessages.push(`\"${url.toString()}\" returned status \"${response.status}\"`);\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font \"${this.fontFace.family}\" from urls \"${this.urls.toString()}`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n}\nExcalidrawFontFace.ASSETS_FALLBACK_URL = `https://esm.sh/${({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.0-94\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_NAME ? `${({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.0-94\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_NAME}@${({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.0-94\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_VERSION}` // is provided during package build\n: \"@excalidraw/excalidraw\" // fallback to the latest package version (i.e. for app)\n}/dist/prod/`;\n\n//# sourceURL=webpack://ExcalidrawLib/./fonts/ExcalidrawFontFace.ts?");
18980
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawFontFace: () => (/* binding */ ExcalidrawFontFace)\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 _subset_subset_main__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../subset/subset-main */ \"./subset/subset-main.ts\");\n/* harmony import */ var _data_encode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/encode */ \"./data/encode.ts\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n\n\n\n\nclass ExcalidrawFontFace {\n constructor(family, uri, descriptors) {\n this.urls = ExcalidrawFontFace.createUrls(uri);\n const sources = this.urls.map(url => `url(${url}) ${ExcalidrawFontFace.getFormat(url)}`).join(\", \");\n this.fontFace = new FontFace(family, sources, Object.assign({\n display: \"swap\",\n style: \"normal\",\n weight: \"400\"\n }, descriptors));\n }\n /**\n * Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.\n *\n * Retrieves `undefined` otherwise.\n */\n\n\n toCSS(characters) {\n // quick exit in case the characters are not within this font face's unicode range\n if (!this.getUnicodeRangeRegex().test(characters)) {\n return;\n } //zsviczian - only woffs are chopped into glyphs other fonts are returned as is\n\n\n if (typeof this.urls[0] === \"string\" && !this.urls[0].startsWith(\"data:font/woff2\")) {\n return Promise.resolve(`@font-face { font-family: ${this.fontFace.family}; src: url(${this.urls[0]}); }`);\n }\n\n const codepoints = Array.from(characters).map(char => char.codePointAt(0));\n return this.getContent(codepoints).then(content => `@font-face { font-family: ${this.fontFace.family}; src: url(${content}); }`);\n }\n /**\n * Tries to fetch woff2 content, based on the registered urls (from first to last, treated as fallbacks).\n *\n * @returns base64 with subsetted glyphs based on the passed codepoint, last defined url otherwise\n */\n\n\n async getContent(codePoints) {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n try {\n const arrayBuffer = await this.fetchFont(url);\n const base64 = await (0,_subset_subset_main__WEBPACK_IMPORTED_MODULE_1__.subsetWoff2GlyphsByCodepoints)(arrayBuffer, codePoints);\n return base64;\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font family \"${this.fontFace.family}\"`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n fetchFont(url) {\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.promiseTry)(async () => {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_3__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n return result;\n }\n\n const response = await fetch(url, {\n // always prefer cache (even stale), otherwise it always triggers an unnecessary validation request\n // which we don't need as we are controlling freshness of the fonts with the stable hash suffix in the url\n // https://developer.mozilla.org/en-US/docs/Web/API/Request/cache\n cache: \"force-cache\",\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (!response.ok) {\n const urlString = url instanceof URL ? url.toString() : \"dataurl\";\n throw new Error(`Failed to fetch \"${urlString}\": ${response.statusText}`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n });\n }\n\n getUnicodeRangeRegex() {\n // using \\u{h} or \\u{hhhhh} to match any number of hex digits,\n // otherwise we would get an \"Invalid Unicode escape\" error\n // e.g. U+0-1007F -> \\u{0}-\\u{1007F}\n const unicodeRangeRegex = this.fontFace.unicodeRange.split(/,\\s*/).map(range => {\n const [start, end] = range.replace(\"U+\", \"\").split(\"-\");\n\n if (end) {\n return `\\\\u{${start}}-\\\\u{${end}}`;\n }\n\n return `\\\\u{${start}}`;\n }).join(\"\");\n return new RegExp(`[${unicodeRangeRegex}]`, \"u\");\n }\n\n static createUrls(uri) {\n if (uri.startsWith(\"data\")) {\n // don't create the URL instance, as parsing the huge dataurl string is expensive\n return [uri];\n }\n\n if (uri.startsWith(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.LOCAL_FONT_PROTOCOL)) {\n // no url for local fonts\n return [];\n }\n\n if (uri.startsWith(\"http\")) {\n // one url for http imports or data url\n return [new URL(uri)];\n } // absolute assets paths, which are found in tests and excalidraw-app build, won't work with base url, so we are stripping initial slash away\n\n\n const assetUrl = uri.replace(/^\\/+/, \"\");\n const urls = [];\n\n if (typeof window.EXCALIDRAW_ASSET_PATH === \"string\") {\n const normalizedBaseUrl = this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n } else if (Array.isArray(window.EXCALIDRAW_ASSET_PATH)) {\n window.EXCALIDRAW_ASSET_PATH.forEach(path => {\n const normalizedBaseUrl = this.normalizeBaseUrl(path);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n });\n } // fallback url for bundled fonts\n\n\n urls.push(new URL(assetUrl, ExcalidrawFontFace.ASSETS_FALLBACK_URL));\n return urls;\n }\n\n static getFormat(url) {\n if (!(url instanceof URL)) {\n // format is irrelevant for data url\n return \"\";\n }\n\n try {\n const parts = new URL(url).pathname.split(\".\");\n\n if (parts.length === 1) {\n return \"\";\n }\n\n return `format('${parts.pop()}')`;\n } catch (error) {\n return \"\";\n }\n }\n\n static normalizeBaseUrl(baseUrl) {\n var _a;\n\n let result = baseUrl; // in case user passed a root-relative url (~absolute path),\n // like \"/\" or \"/some/path\", or relative (starts with \"./\"),\n // prepend it with `location.origin`\n\n if (/^\\.?\\//.test(result)) {\n result = new URL(result.replace(/^\\.?\\/+/, \"\"), (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.origin).toString();\n } // ensure there is a trailing slash, otherwise url won't be correctly concatenated\n\n\n result = `${result.replace(/\\/+$/, \"\")}/`;\n return result;\n }\n /**\n * zsviczian https://github.com/zsviczian/excalidraw/commit/b4cfaaa4b4f46ca01f94e27fb7bf651a9da99daa\n */\n\n\n async getContentLegacy() {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n if (typeof url === \"string\" && url.startsWith(\"data:\")) {\n // it's dataurl, the font is inlined as base64, no need to fetch\n return url;\n }\n\n try {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_3__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n return `data:font/woff2;base64,${(0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.stringToBase64)((0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.toByteString)(result), true)}`;\n }\n\n const response = await fetch(url, {\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (response.ok) {\n const mimeType = response.headers.get(\"Content-Type\");\n const buffer = await response.arrayBuffer();\n return `data:${mimeType};base64,${(0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.stringToBase64)((0,_data_encode__WEBPACK_IMPORTED_MODULE_2__.toByteString)(buffer), true)}`;\n } // response not ok, try to continue\n\n\n errorMessages.push(`\"${url.toString()}\" returned status \"${response.status}\"`);\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font \"${this.fontFace.family}\" from urls \"${this.urls.toString()}`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n}\nExcalidrawFontFace.ASSETS_FALLBACK_URL = `https://esm.sh/${({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.95\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_NAME ? `${({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.95\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_NAME}@${({\"MODE\":\"development\",\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"http://localhost:3000\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3016\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3001\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_APP_ENABLE_PWA\":\"false\",\"VITE_APP_PLUS_EXPORT_PUBLIC_KEY\":\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\\nHQIDAQAB\",\"VITE_APP_DISABLE_PREVENT_UNLOAD\":\"\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.18.95\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_VERSION}` // is provided during package build\n: \"@excalidraw/excalidraw\" // fallback to the latest package version (i.e. for app)\n}/dist/prod/`;\n\n//# sourceURL=webpack://ExcalidrawLib/./fonts/ExcalidrawFontFace.ts?");
18981
18981
 
18982
18982
  /***/ }),
18983
18983
 
@@ -21738,7 +21738,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
21738
21738
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
21739
21739
 
21740
21740
  "use strict";
21741
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Button: () => (/* reexport safe */ _components_Button__WEBPACK_IMPORTED_MODULE_32__.Button),\n/* harmony export */ CaptureUpdateAction: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.CaptureUpdateAction),\n/* harmony export */ CommandPalette: () => (/* reexport safe */ _components_CommandPalette_CommandPalette__WEBPACK_IMPORTED_MODULE_43__.CommandPalette),\n/* harmony export */ DEFAULT_LASER_COLOR: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_LASER_COLOR),\n/* harmony export */ DefaultSidebar: () => (/* reexport safe */ _components_DefaultSidebar__WEBPACK_IMPORTED_MODULE_35__.DefaultSidebar),\n/* harmony export */ DiagramToCodePlugin: () => (/* reexport safe */ _components_DiagramToCodePlugin_DiagramToCodePlugin__WEBPACK_IMPORTED_MODULE_41__.DiagramToCodePlugin),\n/* harmony export */ Ellipsify: () => (/* reexport safe */ _components_Ellipsify__WEBPACK_IMPORTED_MODULE_33__.Ellipsify),\n/* harmony export */ Excalidraw: () => (/* binding */ Excalidraw),\n/* harmony export */ ExcalidrawAPIContext: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPIContext),\n/* harmony export */ ExcalidrawAPIProvider: () => (/* binding */ ExcalidrawAPIProvider),\n/* harmony export */ FONT_FAMILY: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY),\n/* harmony export */ Fonts: () => (/* reexport safe */ _fonts_Fonts__WEBPACK_IMPORTED_MODULE_42__.Fonts),\n/* harmony export */ Footer: () => (/* reexport safe */ _components_footer_FooterCenter__WEBPACK_IMPORTED_MODULE_4__[\"default\"]),\n/* harmony export */ LiveCollaborationTrigger: () => (/* reexport safe */ _components_live_collaboration_LiveCollaborationTrigger__WEBPACK_IMPORTED_MODULE_5__[\"default\"]),\n/* harmony export */ MIME_TYPES: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.MIME_TYPES),\n/* harmony export */ MainMenu: () => (/* reexport safe */ _components_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_6__[\"default\"]),\n/* harmony export */ ROUNDNESS: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.ROUNDNESS),\n/* harmony export */ Sidebar: () => (/* reexport safe */ _components_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_31__.Sidebar),\n/* harmony export */ Stats: () => (/* reexport safe */ _components_Stats__WEBPACK_IMPORTED_MODULE_34__.Stats),\n/* harmony export */ THEME: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME),\n/* harmony export */ TTDDialog: () => (/* reexport safe */ _components_TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_36__.TTDDialog),\n/* harmony export */ TTDDialogTrigger: () => (/* reexport safe */ _components_TTDDialog_TTDDialogTrigger__WEBPACK_IMPORTED_MODULE_37__.TTDDialogTrigger),\n/* harmony export */ TTDStreamFetch: () => (/* reexport safe */ _components_TTDDialog_utils_TTDStreamFetch__WEBPACK_IMPORTED_MODULE_38__.TTDStreamFetch),\n/* harmony export */ UserIdleState: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.UserIdleState),\n/* harmony export */ WelcomeScreen: () => (/* reexport safe */ _components_welcome_screen_WelcomeScreen__WEBPACK_IMPORTED_MODULE_7__[\"default\"]),\n/* harmony export */ bumpVersion: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.bumpVersion),\n/* harmony export */ convertToExcalidrawElements: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.convertToExcalidrawElements),\n/* harmony export */ defaultLang: () => (/* reexport safe */ _i18n__WEBPACK_IMPORTED_MODULE_8__.defaultLang),\n/* harmony export */ destroyObsidianUtils: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.destroyObsidianUtils),\n/* harmony export */ elementPartiallyOverlapsWithOrContainsBBox: () => (/* reexport safe */ _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__.elementPartiallyOverlapsWithOrContainsBBox),\n/* harmony export */ elementsOverlappingBBox: () => (/* reexport safe */ _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__.elementsOverlappingBBox),\n/* harmony export */ exportToBlob: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToBlob),\n/* harmony export */ exportToCanvas: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToCanvas),\n/* harmony export */ exportToClipboard: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToClipboard),\n/* harmony export */ exportToSvg: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToSvg),\n/* harmony export */ getBoundTextMaxWidth: () => (/* reexport safe */ _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_23__.getBoundTextMaxWidth),\n/* harmony export */ getCSSFontDefinition: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getCSSFontDefinition),\n/* harmony export */ getCommonBoundingBox: () => (/* reexport safe */ _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_19__.getCommonBoundingBox),\n/* harmony export */ getCommonBounds: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getCommonBounds),\n/* harmony export */ getContainerElement: () => (/* reexport safe */ _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_23__.getContainerElement),\n/* harmony export */ getDataURL: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.getDataURL),\n/* harmony export */ getDefaultColorPalette: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getDefaultColorPalette),\n/* harmony export */ getEmbedLink: () => (/* reexport safe */ _excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_30__.getEmbedLink),\n/* harmony export */ getFontFamilies: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getFontFamilies),\n/* harmony export */ getFontFamilyString: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFontFamilyString),\n/* harmony export */ getFontMetrics: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getFontMetrics),\n/* harmony export */ getFontString: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFontString),\n/* harmony export */ getFormFactor: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFormFactor),\n/* harmony export */ getLibraryItemsHash: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.getLibraryItemsHash),\n/* harmony export */ getLineHeight: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getLineHeight),\n/* harmony export */ getMaximumGroups: () => (/* reexport safe */ _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_20__.getMaximumGroups),\n/* harmony export */ getNonDeletedElements: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getNonDeletedElements),\n/* harmony export */ getSceneVersion: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getSceneVersion),\n/* harmony export */ getSharedMermaidInstance: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getSharedMermaidInstance),\n/* harmony export */ getTextFromElements: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getTextFromElements),\n/* harmony export */ getVisibleSceneBounds: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getVisibleSceneBounds),\n/* harmony export */ hashElementsVersion: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.hashElementsVersion),\n/* harmony export */ hashString: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.hashString),\n/* harmony export */ intersectElementWithLine: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.intersectElementWithLine),\n/* harmony export */ isElementInsideBBox: () => (/* reexport safe */ _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__.isElementInsideBBox),\n/* harmony export */ isElementLink: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.isElementLink),\n/* harmony export */ isInvisiblySmallElement: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.isInvisiblySmallElement),\n/* harmony export */ isLinearElement: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.isLinearElement),\n/* harmony export */ isSpreadsheetValidForChartType: () => (/* reexport safe */ _charts__WEBPACK_IMPORTED_MODULE_44__.isSpreadsheetValidForChartType),\n/* harmony export */ languages: () => (/* reexport safe */ _i18n__WEBPACK_IMPORTED_MODULE_8__.languages),\n/* harmony export */ loadFromBlob: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.loadFromBlob),\n/* harmony export */ loadLibraryFromBlob: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.loadLibraryFromBlob),\n/* harmony export */ loadMermaid: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.loadMermaid),\n/* harmony export */ loadSceneFonts: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.loadSceneFonts),\n/* harmony export */ loadSceneOrLibraryFromBlob: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.loadSceneOrLibraryFromBlob),\n/* harmony export */ measureText: () => (/* reexport safe */ _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_21__.measureText),\n/* harmony export */ mergeLibraryItems: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.mergeLibraryItems),\n/* harmony export */ mermaidToExcalidraw: () => (/* reexport safe */ _components_TTDDialog_MermaidToExcalidrawLib__WEBPACK_IMPORTED_MODULE_24__.mermaidToExcalidraw),\n/* harmony export */ mutateElement: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.mutateElement),\n/* harmony export */ newElementWith: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.newElementWith),\n/* harmony export */ normalizeLink: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.normalizeLink),\n/* harmony export */ parseLibraryTokensFromUrl: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.parseLibraryTokensFromUrl),\n/* harmony export */ reconcileElements: () => (/* reexport safe */ _data_reconcile__WEBPACK_IMPORTED_MODULE_17__.reconcileElements),\n/* harmony export */ refreshTextDimensions: () => (/* reexport safe */ _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_26__.refreshTextDimensions),\n/* harmony export */ registerFontsInCSS: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.registerFontsInCSS),\n/* harmony export */ registerLocalFont: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.registerLocalFont),\n/* harmony export */ renderSpreadsheet: () => (/* reexport safe */ _charts__WEBPACK_IMPORTED_MODULE_44__.renderSpreadsheet),\n/* harmony export */ restoreAppState: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreAppState),\n/* harmony export */ restoreElement: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreElement),\n/* harmony export */ restoreElements: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreElements),\n/* harmony export */ restoreLibraryItems: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreLibraryItems),\n/* harmony export */ safelyParseJSON: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.safelyParseJSON),\n/* harmony export */ sceneCoordsToViewportCoords: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.sceneCoordsToViewportCoords),\n/* harmony export */ serializeAsJSON: () => (/* reexport safe */ _data_json__WEBPACK_IMPORTED_MODULE_27__.serializeAsJSON),\n/* harmony export */ serializeLibraryAsJSON: () => (/* reexport safe */ _data_json__WEBPACK_IMPORTED_MODULE_27__.serializeLibraryAsJSON),\n/* harmony export */ setCustomTextMetricsProvider: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.setCustomTextMetricsProvider),\n/* harmony export */ syncInvalidIndices: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.syncInvalidIndices),\n/* harmony export */ syncMovedIndices: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.syncMovedIndices),\n/* harmony export */ throttleRAF: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.throttleRAF),\n/* harmony export */ tryParseSpreadsheet: () => (/* reexport safe */ _charts__WEBPACK_IMPORTED_MODULE_44__.tryParseSpreadsheet),\n/* harmony export */ useEditorInterface: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.useEditorInterface),\n/* harmony export */ useExcalidrawAPI: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.useExcalidrawAPI),\n/* harmony export */ useExcalidrawStateValue: () => (/* binding */ useExcalidrawStateValue),\n/* harmony export */ useHandleLibrary: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.useHandleLibrary),\n/* harmony export */ useI18n: () => (/* reexport safe */ _i18n__WEBPACK_IMPORTED_MODULE_8__.useI18n),\n/* harmony export */ useOnExcalidrawStateChange: () => (/* reexport safe */ _hooks_useAppStateValue__WEBPACK_IMPORTED_MODULE_9__.useOnAppStateChange),\n/* harmony export */ useStylesPanelMode: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.useStylesPanelMode),\n/* harmony export */ viewportCoordsToSceneCoords: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.viewportCoordsToSceneCoords),\n/* harmony export */ wrapText: () => (/* reexport safe */ _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_22__.wrapText),\n/* harmony export */ zoomToFitBounds: () => (/* reexport safe */ _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_39__.zoomToFitBounds)\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 _components_App__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/App */ \"./components/App.tsx\");\n/* harmony import */ var _components_InitializeApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/InitializeApp */ \"./components/InitializeApp.tsx\");\n/* harmony import */ var _components_footer_FooterCenter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/footer/FooterCenter */ \"./components/footer/FooterCenter.tsx\");\n/* harmony import */ var _components_live_collaboration_LiveCollaborationTrigger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/live-collaboration/LiveCollaborationTrigger */ \"./components/live-collaboration/LiveCollaborationTrigger.tsx\");\n/* harmony import */ var _components_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/main-menu/MainMenu */ \"./components/main-menu/MainMenu.tsx\");\n/* harmony import */ var _components_welcome_screen_WelcomeScreen__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/welcome-screen/WelcomeScreen */ \"./components/welcome-screen/WelcomeScreen.tsx\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./i18n */ \"./i18n.ts\");\n/* harmony import */ var _hooks_useAppStateValue__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./hooks/useAppStateValue */ \"./hooks/useAppStateValue.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./polyfill */ \"./polyfill.ts\");\n/* harmony import */ var _css_app_scss__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./css/app.scss */ \"./css/app.scss\");\n/* harmony import */ var _css_styles_scss__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./css/styles.scss */ \"./css/styles.scss\");\n/* harmony import */ var _fonts_fonts_css__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./fonts/fonts.css */ \"./fonts/fonts.css\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _data_reconcile__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./data/reconcile */ \"./data/reconcile.ts\");\n/* harmony import */ var _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @excalidraw/utils/export */ \"../utils/src/export.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @excalidraw/element/groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _components_TTDDialog_MermaidToExcalidrawLib__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./components/TTDDialog/MermaidToExcalidrawLib */ \"./components/TTDDialog/MermaidToExcalidrawLib.ts\");\n/* harmony import */ var _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../excalidraw/obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _data_json__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./data/json */ \"./data/json.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./data/library */ \"./data/library.ts\");\n/* harmony import */ var _excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! @excalidraw/element/embeddable */ \"../element/src/embeddable.ts\");\n/* harmony import */ var _components_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./components/Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _components_Button__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./components/Button */ \"./components/Button.tsx\");\n/* harmony import */ var _components_Ellipsify__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./components/Ellipsify */ \"./components/Ellipsify.tsx\");\n/* harmony import */ var _components_Stats__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./components/Stats */ \"./components/Stats/index.tsx\");\n/* harmony import */ var _components_DefaultSidebar__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./components/DefaultSidebar */ \"./components/DefaultSidebar.tsx\");\n/* harmony import */ var _components_TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./components/TTDDialog/TTDDialog */ \"./components/TTDDialog/TTDDialog.tsx\");\n/* harmony import */ var _components_TTDDialog_TTDDialogTrigger__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./components/TTDDialog/TTDDialogTrigger */ \"./components/TTDDialog/TTDDialogTrigger.tsx\");\n/* harmony import */ var _components_TTDDialog_utils_TTDStreamFetch__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./components/TTDDialog/utils/TTDStreamFetch */ \"./components/TTDDialog/utils/TTDStreamFetch.ts\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! @excalidraw/utils/withinBounds */ \"../utils/src/withinBounds.ts\");\n/* harmony import */ var _components_DiagramToCodePlugin_DiagramToCodePlugin__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./components/DiagramToCodePlugin/DiagramToCodePlugin */ \"./components/DiagramToCodePlugin/DiagramToCodePlugin.tsx\");\n/* harmony import */ var _fonts_Fonts__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./fonts/Fonts */ \"./fonts/Fonts.ts\");\n/* harmony import */ var _components_CommandPalette_CommandPalette__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./components/CommandPalette/CommandPalette */ \"./components/CommandPalette/CommandPalette.tsx\");\n/* harmony import */ var _charts__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./charts */ \"./charts/index.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\n\n\n\n\n\n\n\n\n\n\n\n(0,_polyfill__WEBPACK_IMPORTED_MODULE_11__[\"default\"])();\n/**\n * Stateless provider that allows `useExcalidrawAPI()` (and hooks built\n * on it, such as `useAppStateValue()` and `useOnAppStateChange()`) to work\n * outside the <Excalidraw> component tree.\n */\n\nconst ExcalidrawAPIProvider = ({\n children\n}) => {\n const [api, setApi] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPIContext.Provider, {\n value: api\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPISetContext.Provider, {\n value: setApi\n }, children));\n};\n\nconst ExcalidrawBase = props => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n const {\n onExport,\n onChange,\n onIncrement,\n initialData,\n onExcalidrawAPI,\n onMount,\n onUnmount,\n onInitialize,\n isCollaborating = false,\n onPointerUpdate,\n renderTopLeftUI,\n renderTopRightUI,\n langCode = _i18n__WEBPACK_IMPORTED_MODULE_8__.defaultLang.code,\n viewModeEnabled,\n zenModeEnabled,\n gridModeEnabled,\n initState,\n //zsviczian\n libraryReturnUrl,\n theme,\n name,\n renderCustomStats,\n onPaste,\n onDrop,\n //zsviczian\n detectScroll = true,\n handleKeyboardGlobally = false,\n onLibraryChange,\n autoFocus = false,\n onBeforeTextEdit,\n //zsviczian\n onBeforeTextSubmit,\n //zsviczian\n generateIdForFile,\n onThemeChange,\n //zsviczian\n onLinkOpen,\n onLinkHover,\n //zsviczian\n onViewModeChange,\n //zsviczian\n generateLinkForSelection,\n onPointerDown,\n onPointerUp,\n onScrollChange,\n onDuplicate,\n children,\n validateEmbeddable,\n renderEmbeddable,\n renderWebview,\n //zsviczian\n renderEmbeddableMenu,\n //zsviczian\n renderMermaid,\n //zsviczian\n onContextMenu,\n //zsviczian\n aiEnabled,\n showDeprecatedFonts,\n insertLinkAction,\n //zsviczian\n renderScrollbars,\n imageOptions\n } = props;\n const canvasActions = (_a = props.UIOptions) === null || _a === void 0 ? void 0 : _a.canvasActions; // FIXME normalize/set defaults in parent component so that the memo resolver\n // compares the same values\n\n const UIOptions = Object.assign(Object.assign({}, props.UIOptions), {\n canvasActions: Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_UI_OPTIONS.canvasActions), canvasActions),\n tools: {\n image: (_d = (_c = (_b = props.UIOptions) === null || _b === void 0 ? void 0 : _b.tools) === null || _c === void 0 ? void 0 : _c.image) !== null && _d !== void 0 ? _d : true\n }\n });\n\n if (canvasActions === null || canvasActions === void 0 ? void 0 : canvasActions.export) {\n UIOptions.canvasActions.export.saveFileToDisk = (_f = (_e = canvasActions.export) === null || _e === void 0 ? void 0 : _e.saveFileToDisk) !== null && _f !== void 0 ? _f : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_UI_OPTIONS.canvasActions.export.saveFileToDisk;\n }\n\n if (UIOptions.canvasActions.toggleTheme === null && typeof theme === \"undefined\") {\n UIOptions.canvasActions.toggleTheme = true;\n }\n\n const normalizedImageOptions = {\n maxFileSizeBytes: (_g = imageOptions === null || imageOptions === void 0 ? void 0 : imageOptions.maxFileSizeBytes) !== null && _g !== void 0 ? _g : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxFileSizeBytes,\n maxWidthOrHeight: (_h = imageOptions === null || imageOptions === void 0 ? void 0 : imageOptions.maxWidthOrHeight) !== null && _h !== void 0 ? _h : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxWidthOrHeight\n };\n const setExcalidrawAPI = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPISetContext);\n const onExcalidrawAPIRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(onExcalidrawAPI);\n onExcalidrawAPIRef.current = onExcalidrawAPI;\n const handleExcalidrawAPI = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(api => {\n var _a;\n\n setExcalidrawAPI === null || setExcalidrawAPI === void 0 ? void 0 : setExcalidrawAPI(api);\n (_a = onExcalidrawAPIRef.current) === null || _a === void 0 ? void 0 : _a.call(onExcalidrawAPIRef, api);\n }, [setExcalidrawAPI]);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n const importPolyfill = async () => {\n //@ts-ignore\n await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! canvas-roundrect-polyfill */ \"../../node_modules/canvas-roundrect-polyfill/roundRect.js\", 23));\n };\n\n importPolyfill(); // Block pinch-zooming on iOS outside of the content area\n\n const handleTouchMove = event => {\n // @ts-ignore\n if (typeof event.scale === \"number\" && event.scale !== 1) {\n event.preventDefault();\n }\n };\n\n document.addEventListener(\"touchmove\", handleTouchMove, {\n passive: false\n });\n return () => {\n document.removeEventListener(\"touchmove\", handleTouchMove);\n };\n }, []);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_editor_jotai__WEBPACK_IMPORTED_MODULE_10__.EditorJotaiProvider, {\n store: _editor_jotai__WEBPACK_IMPORTED_MODULE_10__.editorJotaiStore\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_InitializeApp__WEBPACK_IMPORTED_MODULE_3__.InitializeApp, {\n langCode: langCode,\n theme: theme\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_App__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n onExport: onExport,\n onChange: onChange,\n onIncrement: onIncrement,\n initialData: initialData,\n onExcalidrawAPI: handleExcalidrawAPI,\n onMount: onMount,\n onUnmount: onUnmount,\n onInitialize: onInitialize,\n isCollaborating: isCollaborating,\n onPointerUpdate: onPointerUpdate,\n renderTopLeftUI: renderTopLeftUI,\n renderTopRightUI: renderTopRightUI,\n langCode: langCode,\n viewModeEnabled: viewModeEnabled,\n zenModeEnabled: zenModeEnabled,\n gridModeEnabled: gridModeEnabled,\n initState: initState,\n libraryReturnUrl: libraryReturnUrl,\n theme: theme,\n name: name,\n renderCustomStats: renderCustomStats,\n UIOptions: UIOptions,\n onPaste: onPaste,\n onDrop: onDrop,\n detectScroll: detectScroll,\n handleKeyboardGlobally: handleKeyboardGlobally,\n onLibraryChange: onLibraryChange,\n autoFocus: autoFocus,\n onBeforeTextEdit: onBeforeTextEdit,\n onBeforeTextSubmit: onBeforeTextSubmit,\n generateIdForFile: generateIdForFile,\n onThemeChange: onThemeChange,\n onLinkOpen: onLinkOpen,\n onLinkHover: onLinkHover,\n onViewModeChange: onViewModeChange,\n generateLinkForSelection: generateLinkForSelection,\n onPointerDown: onPointerDown,\n onPointerUp: onPointerUp,\n onScrollChange: onScrollChange,\n onDuplicate: onDuplicate,\n validateEmbeddable: validateEmbeddable,\n renderEmbeddable: renderEmbeddable,\n renderWebview: renderWebview,\n renderEmbeddableMenu: renderEmbeddableMenu,\n renderMermaid: renderMermaid,\n onContextMenu: onContextMenu,\n aiEnabled: aiEnabled !== false,\n showDeprecatedFonts: showDeprecatedFonts,\n insertLinkAction: insertLinkAction,\n renderScrollbars: renderScrollbars,\n imageOptions: normalizedImageOptions\n }, children)));\n};\n\nconst areEqual = (prevProps, nextProps) => {\n var _a, _b, _c, _d; // short-circuit early\n\n\n if (prevProps.children !== nextProps.children) {\n return false;\n }\n\n const {\n initialData: prevInitialData,\n UIOptions: prevUIOptions = {},\n imageOptions: prevImageOptions\n } = prevProps,\n prev = __rest(prevProps, [\"initialData\", \"UIOptions\", \"imageOptions\"]);\n\n const {\n initialData: nextInitialData,\n UIOptions: nextUIOptions = {},\n imageOptions: nextImageOptions\n } = nextProps,\n next = __rest(nextProps, [\"initialData\", \"UIOptions\", \"imageOptions\"]); // comparing UIOptions\n\n\n const prevUIOptionsKeys = Object.keys(prevUIOptions);\n const nextUIOptionsKeys = Object.keys(nextUIOptions);\n\n if (prevUIOptionsKeys.length !== nextUIOptionsKeys.length) {\n return false;\n }\n\n const isUIOptionsSame = prevUIOptionsKeys.every(key => {\n if (key === \"getFormFactor\") {\n return true;\n }\n\n if (key === \"canvasActions\") {\n const canvasOptionKeys = Object.keys(prevUIOptions.canvasActions);\n return canvasOptionKeys.every(key => {\n var _a, _b, _c, _d;\n\n if (key === \"export\" && ((_a = prevUIOptions === null || prevUIOptions === void 0 ? void 0 : prevUIOptions.canvasActions) === null || _a === void 0 ? void 0 : _a.export) && ((_b = nextUIOptions === null || nextUIOptions === void 0 ? void 0 : nextUIOptions.canvasActions) === null || _b === void 0 ? void 0 : _b.export)) {\n return prevUIOptions.canvasActions.export.saveFileToDisk === nextUIOptions.canvasActions.export.saveFileToDisk;\n }\n\n return ((_c = prevUIOptions === null || prevUIOptions === void 0 ? void 0 : prevUIOptions.canvasActions) === null || _c === void 0 ? void 0 : _c[key]) === ((_d = nextUIOptions === null || nextUIOptions === void 0 ? void 0 : nextUIOptions.canvasActions) === null || _d === void 0 ? void 0 : _d[key]);\n });\n }\n\n return prevUIOptions[key] === nextUIOptions[key];\n });\n const isImageOptionsSame = ((_a = prevImageOptions === null || prevImageOptions === void 0 ? void 0 : prevImageOptions.maxWidthOrHeight) !== null && _a !== void 0 ? _a : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxWidthOrHeight) === ((_b = nextImageOptions === null || nextImageOptions === void 0 ? void 0 : nextImageOptions.maxWidthOrHeight) !== null && _b !== void 0 ? _b : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxWidthOrHeight) && ((_c = prevImageOptions === null || prevImageOptions === void 0 ? void 0 : prevImageOptions.maxFileSizeBytes) !== null && _c !== void 0 ? _c : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxFileSizeBytes) === ((_d = nextImageOptions === null || nextImageOptions === void 0 ? void 0 : nextImageOptions.maxFileSizeBytes) !== null && _d !== void 0 ? _d : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxFileSizeBytes);\n return isUIOptionsSame && isImageOptionsSame && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isShallowEqual)(prev, next);\n};\n\nconst Excalidraw = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().memo(ExcalidrawBase, areEqual);\nExcalidraw.displayName = \"Excalidraw\";\n\n\n\n\n\n\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n\n\n\n\n\n\n\n\n //zsviczian - not sure if I use it any more\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction useExcalidrawStateValue(selector) {\n return (0,_hooks_useAppStateValue__WEBPACK_IMPORTED_MODULE_9__.useAppStateValue)(selector, false);\n} // -----------------------------------------------------------------------------\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/./index.tsx?");
21741
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Button: () => (/* reexport safe */ _components_Button__WEBPACK_IMPORTED_MODULE_32__.Button),\n/* harmony export */ CaptureUpdateAction: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.CaptureUpdateAction),\n/* harmony export */ CommandPalette: () => (/* reexport safe */ _components_CommandPalette_CommandPalette__WEBPACK_IMPORTED_MODULE_43__.CommandPalette),\n/* harmony export */ DEFAULT_LASER_COLOR: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_LASER_COLOR),\n/* harmony export */ DefaultSidebar: () => (/* reexport safe */ _components_DefaultSidebar__WEBPACK_IMPORTED_MODULE_35__.DefaultSidebar),\n/* harmony export */ DiagramToCodePlugin: () => (/* reexport safe */ _components_DiagramToCodePlugin_DiagramToCodePlugin__WEBPACK_IMPORTED_MODULE_41__.DiagramToCodePlugin),\n/* harmony export */ Ellipsify: () => (/* reexport safe */ _components_Ellipsify__WEBPACK_IMPORTED_MODULE_33__.Ellipsify),\n/* harmony export */ Excalidraw: () => (/* binding */ Excalidraw),\n/* harmony export */ ExcalidrawAPIContext: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPIContext),\n/* harmony export */ ExcalidrawAPIProvider: () => (/* binding */ ExcalidrawAPIProvider),\n/* harmony export */ FONT_FAMILY: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY),\n/* harmony export */ Fonts: () => (/* reexport safe */ _fonts_Fonts__WEBPACK_IMPORTED_MODULE_42__.Fonts),\n/* harmony export */ Footer: () => (/* reexport safe */ _components_footer_FooterCenter__WEBPACK_IMPORTED_MODULE_4__[\"default\"]),\n/* harmony export */ LiveCollaborationTrigger: () => (/* reexport safe */ _components_live_collaboration_LiveCollaborationTrigger__WEBPACK_IMPORTED_MODULE_5__[\"default\"]),\n/* harmony export */ MIME_TYPES: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.MIME_TYPES),\n/* harmony export */ MainMenu: () => (/* reexport safe */ _components_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_6__[\"default\"]),\n/* harmony export */ ROUNDNESS: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.ROUNDNESS),\n/* harmony export */ Sidebar: () => (/* reexport safe */ _components_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_31__.Sidebar),\n/* harmony export */ Stats: () => (/* reexport safe */ _components_Stats__WEBPACK_IMPORTED_MODULE_34__.Stats),\n/* harmony export */ THEME: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME),\n/* harmony export */ TTDDialog: () => (/* reexport safe */ _components_TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_36__.TTDDialog),\n/* harmony export */ TTDDialogTrigger: () => (/* reexport safe */ _components_TTDDialog_TTDDialogTrigger__WEBPACK_IMPORTED_MODULE_37__.TTDDialogTrigger),\n/* harmony export */ TTDStreamFetch: () => (/* reexport safe */ _components_TTDDialog_utils_TTDStreamFetch__WEBPACK_IMPORTED_MODULE_38__.TTDStreamFetch),\n/* harmony export */ UserIdleState: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.UserIdleState),\n/* harmony export */ WelcomeScreen: () => (/* reexport safe */ _components_welcome_screen_WelcomeScreen__WEBPACK_IMPORTED_MODULE_7__[\"default\"]),\n/* harmony export */ applyDarkModeFilter: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.applyDarkModeFilter),\n/* harmony export */ bumpVersion: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.bumpVersion),\n/* harmony export */ convertToExcalidrawElements: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.convertToExcalidrawElements),\n/* harmony export */ defaultLang: () => (/* reexport safe */ _i18n__WEBPACK_IMPORTED_MODULE_8__.defaultLang),\n/* harmony export */ destroyObsidianUtils: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.destroyObsidianUtils),\n/* harmony export */ elementPartiallyOverlapsWithOrContainsBBox: () => (/* reexport safe */ _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__.elementPartiallyOverlapsWithOrContainsBBox),\n/* harmony export */ elementsOverlappingBBox: () => (/* reexport safe */ _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__.elementsOverlappingBBox),\n/* harmony export */ exportToBlob: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToBlob),\n/* harmony export */ exportToCanvas: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToCanvas),\n/* harmony export */ exportToClipboard: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToClipboard),\n/* harmony export */ exportToSvg: () => (/* reexport safe */ _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__.exportToSvg),\n/* harmony export */ getBoundTextMaxWidth: () => (/* reexport safe */ _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_23__.getBoundTextMaxWidth),\n/* harmony export */ getCSSFontDefinition: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getCSSFontDefinition),\n/* harmony export */ getCommonBoundingBox: () => (/* reexport safe */ _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_19__.getCommonBoundingBox),\n/* harmony export */ getCommonBounds: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getCommonBounds),\n/* harmony export */ getContainerElement: () => (/* reexport safe */ _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_23__.getContainerElement),\n/* harmony export */ getDataURL: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.getDataURL),\n/* harmony export */ getDefaultColorPalette: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getDefaultColorPalette),\n/* harmony export */ getEmbedLink: () => (/* reexport safe */ _excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_30__.getEmbedLink),\n/* harmony export */ getFontFamilies: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getFontFamilies),\n/* harmony export */ getFontFamilyString: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFontFamilyString),\n/* harmony export */ getFontMetrics: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getFontMetrics),\n/* harmony export */ getFontString: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFontString),\n/* harmony export */ getFormFactor: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFormFactor),\n/* harmony export */ getLibraryItemsHash: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.getLibraryItemsHash),\n/* harmony export */ getLineHeight: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getLineHeight),\n/* harmony export */ getMaximumGroups: () => (/* reexport safe */ _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_20__.getMaximumGroups),\n/* harmony export */ getNonDeletedElements: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getNonDeletedElements),\n/* harmony export */ getSceneVersion: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getSceneVersion),\n/* harmony export */ getSharedMermaidInstance: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.getSharedMermaidInstance),\n/* harmony export */ getTextFromElements: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getTextFromElements),\n/* harmony export */ getVisibleSceneBounds: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.getVisibleSceneBounds),\n/* harmony export */ hashElementsVersion: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.hashElementsVersion),\n/* harmony export */ hashString: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.hashString),\n/* harmony export */ intersectElementWithLine: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.intersectElementWithLine),\n/* harmony export */ isElementInsideBBox: () => (/* reexport safe */ _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__.isElementInsideBBox),\n/* harmony export */ isElementLink: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.isElementLink),\n/* harmony export */ isInvisiblySmallElement: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.isInvisiblySmallElement),\n/* harmony export */ isLinearElement: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.isLinearElement),\n/* harmony export */ isSpreadsheetValidForChartType: () => (/* reexport safe */ _charts__WEBPACK_IMPORTED_MODULE_44__.isSpreadsheetValidForChartType),\n/* harmony export */ languages: () => (/* reexport safe */ _i18n__WEBPACK_IMPORTED_MODULE_8__.languages),\n/* harmony export */ loadFromBlob: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.loadFromBlob),\n/* harmony export */ loadLibraryFromBlob: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.loadLibraryFromBlob),\n/* harmony export */ loadMermaid: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.loadMermaid),\n/* harmony export */ loadSceneFonts: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.loadSceneFonts),\n/* harmony export */ loadSceneOrLibraryFromBlob: () => (/* reexport safe */ _data_blob__WEBPACK_IMPORTED_MODULE_28__.loadSceneOrLibraryFromBlob),\n/* harmony export */ measureText: () => (/* reexport safe */ _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_21__.measureText),\n/* harmony export */ mergeLibraryItems: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.mergeLibraryItems),\n/* harmony export */ mermaidToExcalidraw: () => (/* reexport safe */ _components_TTDDialog_MermaidToExcalidrawLib__WEBPACK_IMPORTED_MODULE_24__.mermaidToExcalidraw),\n/* harmony export */ mutateElement: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.mutateElement),\n/* harmony export */ newElementWith: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.newElementWith),\n/* harmony export */ normalizeLink: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.normalizeLink),\n/* harmony export */ parseLibraryTokensFromUrl: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.parseLibraryTokensFromUrl),\n/* harmony export */ reconcileElements: () => (/* reexport safe */ _data_reconcile__WEBPACK_IMPORTED_MODULE_17__.reconcileElements),\n/* harmony export */ refreshTextDimensions: () => (/* reexport safe */ _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_26__.refreshTextDimensions),\n/* harmony export */ registerFontsInCSS: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.registerFontsInCSS),\n/* harmony export */ registerLocalFont: () => (/* reexport safe */ _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__.registerLocalFont),\n/* harmony export */ renderSpreadsheet: () => (/* reexport safe */ _charts__WEBPACK_IMPORTED_MODULE_44__.renderSpreadsheet),\n/* harmony export */ restoreAppState: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreAppState),\n/* harmony export */ restoreElement: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreElement),\n/* harmony export */ restoreElements: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreElements),\n/* harmony export */ restoreLibraryItems: () => (/* reexport safe */ _data_restore__WEBPACK_IMPORTED_MODULE_16__.restoreLibraryItems),\n/* harmony export */ safelyParseJSON: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.safelyParseJSON),\n/* harmony export */ sceneCoordsToViewportCoords: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.sceneCoordsToViewportCoords),\n/* harmony export */ serializeAsJSON: () => (/* reexport safe */ _data_json__WEBPACK_IMPORTED_MODULE_27__.serializeAsJSON),\n/* harmony export */ serializeLibraryAsJSON: () => (/* reexport safe */ _data_json__WEBPACK_IMPORTED_MODULE_27__.serializeLibraryAsJSON),\n/* harmony export */ setCustomTextMetricsProvider: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.setCustomTextMetricsProvider),\n/* harmony export */ syncInvalidIndices: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.syncInvalidIndices),\n/* harmony export */ syncMovedIndices: () => (/* reexport safe */ _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__.syncMovedIndices),\n/* harmony export */ throttleRAF: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.throttleRAF),\n/* harmony export */ tryParseSpreadsheet: () => (/* reexport safe */ _charts__WEBPACK_IMPORTED_MODULE_44__.tryParseSpreadsheet),\n/* harmony export */ useEditorInterface: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.useEditorInterface),\n/* harmony export */ useExcalidrawAPI: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.useExcalidrawAPI),\n/* harmony export */ useExcalidrawStateValue: () => (/* binding */ useExcalidrawStateValue),\n/* harmony export */ useHandleLibrary: () => (/* reexport safe */ _data_library__WEBPACK_IMPORTED_MODULE_29__.useHandleLibrary),\n/* harmony export */ useI18n: () => (/* reexport safe */ _i18n__WEBPACK_IMPORTED_MODULE_8__.useI18n),\n/* harmony export */ useOnExcalidrawStateChange: () => (/* reexport safe */ _hooks_useAppStateValue__WEBPACK_IMPORTED_MODULE_9__.useOnAppStateChange),\n/* harmony export */ useStylesPanelMode: () => (/* reexport safe */ _components_App__WEBPACK_IMPORTED_MODULE_2__.useStylesPanelMode),\n/* harmony export */ viewportCoordsToSceneCoords: () => (/* reexport safe */ _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.viewportCoordsToSceneCoords),\n/* harmony export */ wrapText: () => (/* reexport safe */ _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_22__.wrapText),\n/* harmony export */ zoomToFitBounds: () => (/* reexport safe */ _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_39__.zoomToFitBounds)\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 _components_App__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/App */ \"./components/App.tsx\");\n/* harmony import */ var _components_InitializeApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/InitializeApp */ \"./components/InitializeApp.tsx\");\n/* harmony import */ var _components_footer_FooterCenter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/footer/FooterCenter */ \"./components/footer/FooterCenter.tsx\");\n/* harmony import */ var _components_live_collaboration_LiveCollaborationTrigger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/live-collaboration/LiveCollaborationTrigger */ \"./components/live-collaboration/LiveCollaborationTrigger.tsx\");\n/* harmony import */ var _components_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/main-menu/MainMenu */ \"./components/main-menu/MainMenu.tsx\");\n/* harmony import */ var _components_welcome_screen_WelcomeScreen__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/welcome-screen/WelcomeScreen */ \"./components/welcome-screen/WelcomeScreen.tsx\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./i18n */ \"./i18n.ts\");\n/* harmony import */ var _hooks_useAppStateValue__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./hooks/useAppStateValue */ \"./hooks/useAppStateValue.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./polyfill */ \"./polyfill.ts\");\n/* harmony import */ var _css_app_scss__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./css/app.scss */ \"./css/app.scss\");\n/* harmony import */ var _css_styles_scss__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./css/styles.scss */ \"./css/styles.scss\");\n/* harmony import */ var _fonts_fonts_css__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./fonts/fonts.css */ \"./fonts/fonts.css\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _data_reconcile__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./data/reconcile */ \"./data/reconcile.ts\");\n/* harmony import */ var _excalidraw_utils_export__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @excalidraw/utils/export */ \"../utils/src/export.ts\");\n/* harmony import */ var _excalidraw_element_bounds__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @excalidraw/element/bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _excalidraw_element_groups__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @excalidraw/element/groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _excalidraw_element_textMeasurements__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @excalidraw/element/textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _excalidraw_element_textWrapping__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @excalidraw/element/textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _excalidraw_element_textElement__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @excalidraw/element/textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _components_TTDDialog_MermaidToExcalidrawLib__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./components/TTDDialog/MermaidToExcalidrawLib */ \"./components/TTDDialog/MermaidToExcalidrawLib.ts\");\n/* harmony import */ var _excalidraw_obsidianUtils__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../excalidraw/obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _excalidraw_element_newElement__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @excalidraw/element/newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _data_json__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./data/json */ \"./data/json.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./data/library */ \"./data/library.ts\");\n/* harmony import */ var _excalidraw_element_embeddable__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! @excalidraw/element/embeddable */ \"../element/src/embeddable.ts\");\n/* harmony import */ var _components_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./components/Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _components_Button__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./components/Button */ \"./components/Button.tsx\");\n/* harmony import */ var _components_Ellipsify__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./components/Ellipsify */ \"./components/Ellipsify.tsx\");\n/* harmony import */ var _components_Stats__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./components/Stats */ \"./components/Stats/index.tsx\");\n/* harmony import */ var _components_DefaultSidebar__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./components/DefaultSidebar */ \"./components/DefaultSidebar.tsx\");\n/* harmony import */ var _components_TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./components/TTDDialog/TTDDialog */ \"./components/TTDDialog/TTDDialog.tsx\");\n/* harmony import */ var _components_TTDDialog_TTDDialogTrigger__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./components/TTDDialog/TTDDialogTrigger */ \"./components/TTDDialog/TTDDialogTrigger.tsx\");\n/* harmony import */ var _components_TTDDialog_utils_TTDStreamFetch__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./components/TTDDialog/utils/TTDStreamFetch */ \"./components/TTDDialog/utils/TTDStreamFetch.ts\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _excalidraw_utils_withinBounds__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! @excalidraw/utils/withinBounds */ \"../utils/src/withinBounds.ts\");\n/* harmony import */ var _components_DiagramToCodePlugin_DiagramToCodePlugin__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./components/DiagramToCodePlugin/DiagramToCodePlugin */ \"./components/DiagramToCodePlugin/DiagramToCodePlugin.tsx\");\n/* harmony import */ var _fonts_Fonts__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./fonts/Fonts */ \"./fonts/Fonts.ts\");\n/* harmony import */ var _components_CommandPalette_CommandPalette__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./components/CommandPalette/CommandPalette */ \"./components/CommandPalette/CommandPalette.tsx\");\n/* harmony import */ var _charts__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./charts */ \"./charts/index.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\n\n\n\n\n\n\n\n\n\n\n\n(0,_polyfill__WEBPACK_IMPORTED_MODULE_11__[\"default\"])();\n/**\n * Stateless provider that allows `useExcalidrawAPI()` (and hooks built\n * on it, such as `useAppStateValue()` and `useOnAppStateChange()`) to work\n * outside the <Excalidraw> component tree.\n */\n\nconst ExcalidrawAPIProvider = ({\n children\n}) => {\n const [api, setApi] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPIContext.Provider, {\n value: api\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPISetContext.Provider, {\n value: setApi\n }, children));\n};\n\nconst ExcalidrawBase = props => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n const {\n onExport,\n onChange,\n onIncrement,\n initialData,\n onExcalidrawAPI,\n onMount,\n onUnmount,\n onInitialize,\n isCollaborating = false,\n onPointerUpdate,\n renderTopLeftUI,\n renderTopRightUI,\n langCode = _i18n__WEBPACK_IMPORTED_MODULE_8__.defaultLang.code,\n viewModeEnabled,\n zenModeEnabled,\n gridModeEnabled,\n initState,\n //zsviczian\n libraryReturnUrl,\n theme,\n name,\n renderCustomStats,\n onPaste,\n onDrop,\n //zsviczian\n detectScroll = true,\n handleKeyboardGlobally = false,\n onLibraryChange,\n autoFocus = false,\n onBeforeTextEdit,\n //zsviczian\n onBeforeTextSubmit,\n //zsviczian\n generateIdForFile,\n onThemeChange,\n //zsviczian\n onLinkOpen,\n onLinkHover,\n //zsviczian\n onViewModeChange,\n //zsviczian\n generateLinkForSelection,\n onPointerDown,\n onPointerUp,\n onScrollChange,\n onDuplicate,\n children,\n validateEmbeddable,\n renderEmbeddable,\n renderWebview,\n //zsviczian\n renderEmbeddableMenu,\n //zsviczian\n renderMermaid,\n //zsviczian\n onContextMenu,\n //zsviczian\n aiEnabled,\n showDeprecatedFonts,\n insertLinkAction,\n //zsviczian\n renderScrollbars,\n imageOptions\n } = props;\n const canvasActions = (_a = props.UIOptions) === null || _a === void 0 ? void 0 : _a.canvasActions; // FIXME normalize/set defaults in parent component so that the memo resolver\n // compares the same values\n\n const UIOptions = Object.assign(Object.assign({}, props.UIOptions), {\n canvasActions: Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_UI_OPTIONS.canvasActions), canvasActions),\n tools: {\n image: (_d = (_c = (_b = props.UIOptions) === null || _b === void 0 ? void 0 : _b.tools) === null || _c === void 0 ? void 0 : _c.image) !== null && _d !== void 0 ? _d : true\n }\n });\n\n if (canvasActions === null || canvasActions === void 0 ? void 0 : canvasActions.export) {\n UIOptions.canvasActions.export.saveFileToDisk = (_f = (_e = canvasActions.export) === null || _e === void 0 ? void 0 : _e.saveFileToDisk) !== null && _f !== void 0 ? _f : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_UI_OPTIONS.canvasActions.export.saveFileToDisk;\n }\n\n if (UIOptions.canvasActions.toggleTheme === null && typeof theme === \"undefined\") {\n UIOptions.canvasActions.toggleTheme = true;\n }\n\n const normalizedImageOptions = {\n maxFileSizeBytes: (_g = imageOptions === null || imageOptions === void 0 ? void 0 : imageOptions.maxFileSizeBytes) !== null && _g !== void 0 ? _g : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxFileSizeBytes,\n maxWidthOrHeight: (_h = imageOptions === null || imageOptions === void 0 ? void 0 : imageOptions.maxWidthOrHeight) !== null && _h !== void 0 ? _h : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxWidthOrHeight\n };\n const setExcalidrawAPI = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_components_App__WEBPACK_IMPORTED_MODULE_2__.ExcalidrawAPISetContext);\n const onExcalidrawAPIRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(onExcalidrawAPI);\n onExcalidrawAPIRef.current = onExcalidrawAPI;\n const handleExcalidrawAPI = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(api => {\n var _a;\n\n setExcalidrawAPI === null || setExcalidrawAPI === void 0 ? void 0 : setExcalidrawAPI(api);\n (_a = onExcalidrawAPIRef.current) === null || _a === void 0 ? void 0 : _a.call(onExcalidrawAPIRef, api);\n }, [setExcalidrawAPI]);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n const importPolyfill = async () => {\n //@ts-ignore\n await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! canvas-roundrect-polyfill */ \"../../node_modules/canvas-roundrect-polyfill/roundRect.js\", 23));\n };\n\n importPolyfill(); // Block pinch-zooming on iOS outside of the content area\n\n const handleTouchMove = event => {\n // @ts-ignore\n if (typeof event.scale === \"number\" && event.scale !== 1) {\n event.preventDefault();\n }\n };\n\n document.addEventListener(\"touchmove\", handleTouchMove, {\n passive: false\n });\n return () => {\n document.removeEventListener(\"touchmove\", handleTouchMove);\n };\n }, []);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_editor_jotai__WEBPACK_IMPORTED_MODULE_10__.EditorJotaiProvider, {\n store: _editor_jotai__WEBPACK_IMPORTED_MODULE_10__.editorJotaiStore\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_InitializeApp__WEBPACK_IMPORTED_MODULE_3__.InitializeApp, {\n langCode: langCode,\n theme: theme\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_App__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n onExport: onExport,\n onChange: onChange,\n onIncrement: onIncrement,\n initialData: initialData,\n onExcalidrawAPI: handleExcalidrawAPI,\n onMount: onMount,\n onUnmount: onUnmount,\n onInitialize: onInitialize,\n isCollaborating: isCollaborating,\n onPointerUpdate: onPointerUpdate,\n renderTopLeftUI: renderTopLeftUI,\n renderTopRightUI: renderTopRightUI,\n langCode: langCode,\n viewModeEnabled: viewModeEnabled,\n zenModeEnabled: zenModeEnabled,\n gridModeEnabled: gridModeEnabled,\n initState: initState,\n libraryReturnUrl: libraryReturnUrl,\n theme: theme,\n name: name,\n renderCustomStats: renderCustomStats,\n UIOptions: UIOptions,\n onPaste: onPaste,\n onDrop: onDrop,\n detectScroll: detectScroll,\n handleKeyboardGlobally: handleKeyboardGlobally,\n onLibraryChange: onLibraryChange,\n autoFocus: autoFocus,\n onBeforeTextEdit: onBeforeTextEdit,\n onBeforeTextSubmit: onBeforeTextSubmit,\n generateIdForFile: generateIdForFile,\n onThemeChange: onThemeChange,\n onLinkOpen: onLinkOpen,\n onLinkHover: onLinkHover,\n onViewModeChange: onViewModeChange,\n generateLinkForSelection: generateLinkForSelection,\n onPointerDown: onPointerDown,\n onPointerUp: onPointerUp,\n onScrollChange: onScrollChange,\n onDuplicate: onDuplicate,\n validateEmbeddable: validateEmbeddable,\n renderEmbeddable: renderEmbeddable,\n renderWebview: renderWebview,\n renderEmbeddableMenu: renderEmbeddableMenu,\n renderMermaid: renderMermaid,\n onContextMenu: onContextMenu,\n aiEnabled: aiEnabled !== false,\n showDeprecatedFonts: showDeprecatedFonts,\n insertLinkAction: insertLinkAction,\n renderScrollbars: renderScrollbars,\n imageOptions: normalizedImageOptions\n }, children)));\n};\n\nconst areEqual = (prevProps, nextProps) => {\n var _a, _b, _c, _d; // short-circuit early\n\n\n if (prevProps.children !== nextProps.children) {\n return false;\n }\n\n const {\n initialData: prevInitialData,\n UIOptions: prevUIOptions = {},\n imageOptions: prevImageOptions\n } = prevProps,\n prev = __rest(prevProps, [\"initialData\", \"UIOptions\", \"imageOptions\"]);\n\n const {\n initialData: nextInitialData,\n UIOptions: nextUIOptions = {},\n imageOptions: nextImageOptions\n } = nextProps,\n next = __rest(nextProps, [\"initialData\", \"UIOptions\", \"imageOptions\"]); // comparing UIOptions\n\n\n const prevUIOptionsKeys = Object.keys(prevUIOptions);\n const nextUIOptionsKeys = Object.keys(nextUIOptions);\n\n if (prevUIOptionsKeys.length !== nextUIOptionsKeys.length) {\n return false;\n }\n\n const isUIOptionsSame = prevUIOptionsKeys.every(key => {\n if (key === \"getFormFactor\") {\n return true;\n }\n\n if (key === \"canvasActions\") {\n const canvasOptionKeys = Object.keys(prevUIOptions.canvasActions);\n return canvasOptionKeys.every(key => {\n var _a, _b, _c, _d;\n\n if (key === \"export\" && ((_a = prevUIOptions === null || prevUIOptions === void 0 ? void 0 : prevUIOptions.canvasActions) === null || _a === void 0 ? void 0 : _a.export) && ((_b = nextUIOptions === null || nextUIOptions === void 0 ? void 0 : nextUIOptions.canvasActions) === null || _b === void 0 ? void 0 : _b.export)) {\n return prevUIOptions.canvasActions.export.saveFileToDisk === nextUIOptions.canvasActions.export.saveFileToDisk;\n }\n\n return ((_c = prevUIOptions === null || prevUIOptions === void 0 ? void 0 : prevUIOptions.canvasActions) === null || _c === void 0 ? void 0 : _c[key]) === ((_d = nextUIOptions === null || nextUIOptions === void 0 ? void 0 : nextUIOptions.canvasActions) === null || _d === void 0 ? void 0 : _d[key]);\n });\n }\n\n return prevUIOptions[key] === nextUIOptions[key];\n });\n const isImageOptionsSame = ((_a = prevImageOptions === null || prevImageOptions === void 0 ? void 0 : prevImageOptions.maxWidthOrHeight) !== null && _a !== void 0 ? _a : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxWidthOrHeight) === ((_b = nextImageOptions === null || nextImageOptions === void 0 ? void 0 : nextImageOptions.maxWidthOrHeight) !== null && _b !== void 0 ? _b : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxWidthOrHeight) && ((_c = prevImageOptions === null || prevImageOptions === void 0 ? void 0 : prevImageOptions.maxFileSizeBytes) !== null && _c !== void 0 ? _c : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxFileSizeBytes) === ((_d = nextImageOptions === null || nextImageOptions === void 0 ? void 0 : nextImageOptions.maxFileSizeBytes) !== null && _d !== void 0 ? _d : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_IMAGE_OPTIONS.maxFileSizeBytes);\n return isUIOptionsSame && isImageOptionsSame && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isShallowEqual)(prev, next);\n};\n\nconst Excalidraw = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().memo(ExcalidrawBase, areEqual);\nExcalidraw.displayName = \"Excalidraw\";\n\n\n\n\n\n\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n //zsviczian\n\n\n\n\n\n\n\n\n\n //zsviczian - not sure if I use it any more\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction useExcalidrawStateValue(selector) {\n return (0,_hooks_useAppStateValue__WEBPACK_IMPORTED_MODULE_9__.useAppStateValue)(selector, false);\n} // -----------------------------------------------------------------------------\n\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/./index.tsx?");
21742
21742
 
21743
21743
  /***/ }),
21744
21744
 
@@ -22441,7 +22441,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22441
22441
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
22442
22442
 
22443
22443
  "use strict";
22444
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ customAlphabet: () => (/* binding */ customAlphabet),\n/* harmony export */ customRandom: () => (/* binding */ customRandom),\n/* harmony export */ nanoid: () => (/* binding */ nanoid),\n/* harmony export */ random: () => (/* binding */ random),\n/* harmony export */ urlAlphabet: () => (/* reexport safe */ _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__.urlAlphabet)\n/* harmony export */ });\n/* harmony import */ var _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./url-alphabet/index.js */ \"./node_modules/nanoid/url-alphabet/index.js\");\n\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nlet nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/./node_modules/nanoid/index.browser.js?");
22444
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ customAlphabet: () => (/* binding */ customAlphabet),\n/* harmony export */ customRandom: () => (/* binding */ customRandom),\n/* harmony export */ nanoid: () => (/* binding */ nanoid),\n/* harmony export */ random: () => (/* binding */ random),\n/* harmony export */ urlAlphabet: () => (/* reexport safe */ _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__.urlAlphabet)\n/* harmony export */ });\n/* harmony import */ var _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./url-alphabet/index.js */ \"./node_modules/nanoid/url-alphabet/index.js\");\n/* @ts-self-types=\"./index.d.ts\" */\n\n\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let j = size\n while (j--) {\n id += alphabet[bytes[j] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n if (bytes[j] < safeByteCutoff) {\n id += alphabet[bytes[j] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nlet nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__.urlAlphabet[bytes[size] & 63]\n }\n return id\n}\n\n\n//# sourceURL=webpack://ExcalidrawLib/./node_modules/nanoid/index.browser.js?");
22445
22445
 
22446
22446
  /***/ }),
22447
22447
 
@@ -22452,7 +22452,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22452
22452
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
22453
22453
 
22454
22454
  "use strict";
22455
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ urlAlphabet: () => (/* binding */ urlAlphabet)\n/* harmony export */ });\nlet urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/./node_modules/nanoid/url-alphabet/index.js?");
22455
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ urlAlphabet: () => (/* binding */ urlAlphabet)\n/* harmony export */ });\nlet urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n\n\n//# sourceURL=webpack://ExcalidrawLib/./node_modules/nanoid/url-alphabet/index.js?");
22456
22456
 
22457
22457
  /***/ }),
22458
22458
 
@@ -22496,7 +22496,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22496
22496
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
22497
22497
 
22498
22498
  "use strict";
22499
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _excalidraw_common_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common/constants */ \"../common/src/constants.ts\");\n\n\nif (\"development\" !== _excalidraw_common_constants__WEBPACK_IMPORTED_MODULE_0__.ENV.TEST) {\n /* eslint-disable */\n\n /* global __webpack_public_path__:writable */\n __webpack_require__.p = window.EXCALIDRAW_ASSET_PATH || `https://unpkg.com/${\"@zsviczian/excalidraw\"}@${\"0.18.0-94\"}/dist/`;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/./publicPath.js?");
22499
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _excalidraw_common_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common/constants */ \"../common/src/constants.ts\");\n\n\nif (\"development\" !== _excalidraw_common_constants__WEBPACK_IMPORTED_MODULE_0__.ENV.TEST) {\n /* eslint-disable */\n\n /* global __webpack_public_path__:writable */\n __webpack_require__.p = window.EXCALIDRAW_ASSET_PATH || `https://unpkg.com/${\"@zsviczian/excalidraw\"}@${\"0.18.95\"}/dist/`;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/./publicPath.js?");
22500
22500
 
22501
22501
  /***/ }),
22502
22502
 
@@ -22529,7 +22529,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22529
22529
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
22530
22530
 
22531
22531
  "use strict";
22532
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bootstrapCanvas: () => (/* binding */ bootstrapCanvas),\n/* harmony export */ fillCircle: () => (/* binding */ fillCircle),\n/* harmony export */ getNormalizedCanvasDimensions: () => (/* binding */ getNormalizedCanvasDimensions),\n/* harmony export */ strokeRectWithRotation_simple: () => (/* binding */ strokeRectWithRotation_simple)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n\nconst fillCircle = (context, cx, cy, radius, stroke, fill = true) => {\n context.beginPath();\n context.arc(cx, cy, radius, 0, Math.PI * 2);\n\n if (fill) {\n context.fill();\n }\n\n if (stroke) {\n context.stroke();\n }\n};\nconst getNormalizedCanvasDimensions = (canvas, scale) => {\n // When doing calculations based on canvas width we should used normalized one\n return [canvas.width / scale, canvas.height / scale];\n};\nconst bootstrapCanvas = ({\n canvas,\n scale,\n normalizedWidth,\n normalizedHeight,\n theme,\n isExporting,\n viewBackgroundColor\n}) => {\n const context = canvas.getContext(\"2d\");\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.scale(scale, scale); // Paint background\n\n if (typeof viewBackgroundColor === \"string\") {\n const hasTransparence = viewBackgroundColor === \"transparent\" || viewBackgroundColor.length === 5 || // #RGBA\n viewBackgroundColor.length === 9 || // #RRGGBBA\n /(hsla|rgba)\\(/.test(viewBackgroundColor);\n\n if (hasTransparence) {\n context.clearRect(0, 0, normalizedWidth, normalizedHeight);\n }\n\n context.save();\n context.fillStyle = theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(viewBackgroundColor) : viewBackgroundColor;\n context.fillRect(0, 0, normalizedWidth, normalizedHeight);\n context.restore();\n } else {\n context.clearRect(0, 0, normalizedWidth, normalizedHeight);\n }\n\n return context;\n};\nconst strokeRectWithRotation_simple = (context, x, y, width, height, cx, cy, angle, fill = false,\n/** should account for zoom */\nradius = 0) => {\n context.save();\n context.translate(cx, cy);\n context.rotate(angle);\n\n if (fill) {\n context.fillRect(x - cx, y - cy, width, height);\n }\n\n if (radius && context.roundRect) {\n context.beginPath();\n context.roundRect(x - cx, y - cy, width, height, radius);\n context.stroke();\n context.closePath();\n } else {\n context.strokeRect(x - cx, y - cy, width, height);\n }\n\n context.restore();\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/helpers.ts?");
22532
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bootstrapCanvas: () => (/* binding */ bootstrapCanvas),\n/* harmony export */ fillCircle: () => (/* binding */ fillCircle),\n/* harmony export */ getNormalizedCanvasDimensions: () => (/* binding */ getNormalizedCanvasDimensions),\n/* harmony export */ strokeRectWithRotation_simple: () => (/* binding */ strokeRectWithRotation_simple)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n\nconst fillCircle = (context, cx, cy, radius, stroke, fill = true) => {\n context.beginPath();\n context.arc(cx, cy, radius, 0, Math.PI * 2);\n\n if (fill) {\n context.fill();\n }\n\n if (stroke) {\n context.stroke();\n }\n};\nconst getNormalizedCanvasDimensions = (canvas, scale) => {\n // When doing calculations based on canvas width we should used normalized one\n return [canvas.width / scale, canvas.height / scale];\n};\nconst bootstrapCanvas = ({\n canvas,\n scale,\n normalizedWidth,\n normalizedHeight,\n theme,\n isExporting,\n viewBackgroundColor\n}) => {\n const context = canvas.getContext(\"2d\");\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.scale(scale, scale); // Paint background\n\n if (typeof viewBackgroundColor === \"string\") {\n const hasTransparence = viewBackgroundColor === \"transparent\" || viewBackgroundColor.length === 5 || // #RGBA\n viewBackgroundColor.length === 9 || // #RRGGBBA\n /(hsla|rgba)\\(/.test(viewBackgroundColor);\n\n if (hasTransparence) {\n context.clearRect(0, 0, normalizedWidth, normalizedHeight);\n }\n\n context.save();\n context.fillStyle = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(viewBackgroundColor, theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK);\n context.fillRect(0, 0, normalizedWidth, normalizedHeight);\n context.restore();\n } else {\n context.clearRect(0, 0, normalizedWidth, normalizedHeight);\n }\n\n return context;\n};\nconst strokeRectWithRotation_simple = (context, x, y, width, height, cx, cy, angle, fill = false,\n/** should account for zoom */\nradius = 0) => {\n context.save();\n context.translate(cx, cy);\n context.rotate(angle);\n\n if (fill) {\n context.fillRect(x - cx, y - cy, width, height);\n }\n\n if (radius && context.roundRect) {\n context.beginPath();\n context.roundRect(x - cx, y - cy, width, height, radius);\n context.stroke();\n context.closePath();\n } else {\n context.strokeRect(x - cx, y - cy, width, height);\n }\n\n context.restore();\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/helpers.ts?");
22533
22533
 
22534
22534
  /***/ }),
22535
22535
 
@@ -22595,7 +22595,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22595
22595
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
22596
22596
 
22597
22597
  "use strict";
22598
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ renderSceneToSvg: () => (/* binding */ renderSceneToSvg)\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__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _element_src_freedrawPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../element/src/freedrawPath */ \"../element/src/freedrawPath.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst roughSVGDrawWithPrecision = (rsvg, drawable, precision) => {\n if (typeof precision === \"undefined\") {\n return rsvg.draw(drawable);\n }\n\n const pshape = {\n sets: drawable.sets,\n shape: drawable.shape,\n options: Object.assign(Object.assign({}, drawable.options), {\n fixedDecimalPlaceDigits: precision\n })\n };\n return rsvg.draw(pshape);\n};\n\nconst maybeWrapNodesInFrameClipPath = (element, root, nodes, frameRendering, elementsMap) => {\n if (!frameRendering.enabled || !frameRendering.clip) {\n return null;\n }\n\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getContainingFrame)(element, elementsMap);\n\n if (frame) {\n const g = root.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n g.setAttributeNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"clip-path\", `url(#${frame.id})`);\n nodes.forEach(node => g.appendChild(node));\n return g;\n }\n\n return null;\n};\n\nconst renderElementToSvg = (element, elementsMap, rsvg, svgRoot, files, offsetX, offsetY, renderConfig) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;\n\n const offset = {\n x: offsetX,\n y: offsetY\n };\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getElementAbsoluteCoords)(element, elementsMap);\n let cx = (x2 - x1) / 2 - (element.x - x1);\n let cy = (y2 - y1) / 2 - (element.y - y1);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isTextElement)(element)) {\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getContainerElement)(element, elementsMap);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isArrowElement)(container)) {\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getElementAbsoluteCoords)(container, elementsMap);\n const boundTextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.LinearElementEditor.getBoundTextElementPosition(container, element, elementsMap);\n cx = (x2 - x1) / 2 - (boundTextCoords.x - x1);\n cy = (y2 - y1) / 2 - (boundTextCoords.y - y1);\n offsetX = offsetX + boundTextCoords.x - element.x;\n offsetY = offsetY + boundTextCoords.y - element.y;\n }\n }\n\n const degree = 180 * element.angle / Math.PI; // element to append node to, most of the time svgRoot\n\n let root = svgRoot; // if the element has a link, create an anchor tag and make that the new root\n\n if (element.link) {\n const anchorTag = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"a\");\n anchorTag.setAttribute(\"href\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.normalizeLink)(element.link));\n root.appendChild(anchorTag);\n root = anchorTag;\n }\n\n const addToRoot = (node, element) => {\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n node.setAttribute(\"data-id\", element.id);\n }\n\n root.appendChild(node);\n };\n\n const opacity = ((_b = (_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getContainingFrame)(element, elementsMap)) === null || _a === void 0 ? void 0 : _a.opacity) !== null && _b !== void 0 ? _b : 100) * element.opacity / 10000;\n\n switch (element.type) {\n case \"selection\":\n {\n // Since this is used only during editing experience, which is canvas based,\n // this should not happen\n throw new Error(\"Selection rendering is not supported for SVG\");\n }\n\n case \"rectangle\":\n case \"diamond\":\n case \"ellipse\":\n {\n const shape = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig);\n const node = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"stroke-linecap\", \"round\");\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering, elementsMap);\n addToRoot(g || node, element);\n break;\n }\n\n case \"iframe\":\n case \"embeddable\":\n {\n // render placeholder rectangle\n const shape = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig);\n const node = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n const opacity = element.opacity / 100;\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"stroke-linecap\", \"round\");\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n addToRoot(node, element);\n const label = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.createPlaceholderEmbeddableLabel)(element);\n renderElementToSvg(label, elementsMap, rsvg, root, files, label.x + offset.x - element.x, label.y + offset.y - element.y, renderConfig);\n const scaleX = ((_c = element.scale) === null || _c === void 0 ? void 0 : _c[0]) || 1; //zsviczian\n\n const scaleY = ((_d = element.scale) === null || _d === void 0 ? void 0 : _d[1]) || 1; //zsviczian\n // render embeddable element + iframe\n\n const embeddableNode = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n embeddableNode.setAttribute(\"stroke-linecap\", \"round\");\n embeddableNode.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy}) scale(${scaleX}, ${scaleY})`);\n\n while (embeddableNode.firstChild) {\n embeddableNode.removeChild(embeddableNode.firstChild);\n }\n\n const radius = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getCornerRadius)(Math.min(element.width, element.height), element);\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.toValidURL)(element.link || \"\")); // if rendering embeddables explicitly disabled or\n // embedding documents via srcdoc (which doesn't seem to work for SVGs)\n // replace with a link instead\n\n if (renderConfig.renderEmbeddables === false || (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"document\") {\n const anchorTag = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"a\");\n anchorTag.setAttribute(\"href\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.normalizeLink)(element.link || \"\"));\n anchorTag.setAttribute(\"target\", \"_blank\");\n anchorTag.setAttribute(\"rel\", \"noopener noreferrer\");\n anchorTag.style.borderRadius = `${radius}px`;\n embeddableNode.appendChild(anchorTag);\n } else {\n const foreignObject = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"foreignObject\");\n foreignObject.style.width = `${element.width / scaleX}px`; //zsviczian\n\n foreignObject.style.height = `${element.height / scaleY}px`; //zsviczian\n\n foreignObject.style.border = \"none\";\n const div = foreignObject.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"div\");\n div.setAttribute(\"xmlns\", \"http://www.w3.org/1999/xhtml\");\n div.style.width = \"100%\";\n div.style.height = \"100%\";\n const iframe = div.ownerDocument.createElement(\"iframe\");\n iframe.src = (_e = embedLink === null || embedLink === void 0 ? void 0 : embedLink.link) !== null && _e !== void 0 ? _e : \"\";\n iframe.style.width = \"100%\";\n iframe.style.height = \"100%\";\n iframe.style.border = \"none\";\n iframe.style.borderRadius = `${radius}px`;\n iframe.style.top = \"0\";\n iframe.style.left = \"0\";\n iframe.allowFullscreen = true;\n div.appendChild(iframe);\n foreignObject.appendChild(div);\n embeddableNode.appendChild(foreignObject);\n }\n\n addToRoot(embeddableNode, element);\n break;\n }\n\n case \"line\":\n case \"arrow\":\n {\n const boundText = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(element, elementsMap);\n const maskPath = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"mask\");\n\n if (boundText) {\n maskPath.setAttribute(\"id\", `mask-${element.id}`);\n const maskRectVisible = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n offsetX = offsetX || 0;\n offsetY = offsetY || 0;\n maskRectVisible.setAttribute(\"x\", \"0\");\n maskRectVisible.setAttribute(\"y\", \"0\");\n maskRectVisible.setAttribute(\"fill\", \"#fff\");\n maskRectVisible.setAttribute(\"width\", `${element.width + 100 + offsetX}`);\n maskRectVisible.setAttribute(\"height\", `${element.height + 100 + offsetY}`);\n maskPath.appendChild(maskRectVisible);\n const maskRectInvisible = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n const boundTextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.LinearElementEditor.getBoundTextElementPosition(element, boundText, elementsMap);\n const maskX = offsetX + boundTextCoords.x - element.x;\n const maskY = offsetY + boundTextCoords.y - element.y;\n maskRectInvisible.setAttribute(\"x\", maskX.toString());\n maskRectInvisible.setAttribute(\"y\", maskY.toString());\n maskRectInvisible.setAttribute(\"fill\", \"#000\");\n maskRectInvisible.setAttribute(\"width\", `${boundText.width}`);\n maskRectInvisible.setAttribute(\"height\", `${boundText.height}`);\n maskRectInvisible.setAttribute(\"opacity\", \"1\");\n maskPath.appendChild(maskRectInvisible);\n }\n\n const group = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n\n if (boundText) {\n group.setAttribute(\"mask\", `url(#mask-${element.id})`);\n }\n\n group.setAttribute(\"stroke-linecap\", \"round\");\n const shapes = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig);\n shapes.forEach(shape => {\n const node = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n\n if (element.type === \"line\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isPathALoop)(element.points) && element.backgroundColor !== \"transparent\") {\n node.setAttribute(\"fill-rule\", \"evenodd\");\n }\n\n group.appendChild(node);\n });\n const g = maybeWrapNodesInFrameClipPath(element, root, [group, maskPath], renderConfig.frameRendering, elementsMap);\n\n if (g) {\n addToRoot(g, element);\n root.appendChild(g);\n } else {\n addToRoot(group, element);\n root.append(maskPath);\n }\n\n break;\n }\n\n case \"freedraw\":\n {\n const wrapper = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n const shapes = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig); // always ordered as [background, stroke]\n\n for (const shape of shapes) {\n if (typeof shape === \"string\") {\n // stroke (SVGPathString)\n //zsviczian - custom stroke options start\n const {\n pathD,\n fillColorThemed\n } = (() => {\n var _a, _b, _c, _d, _e;\n\n const pathD = (0,_element_src_freedrawPath__WEBPACK_IMPORTED_MODULE_2__.getFreeDrawSvgPath)(element);\n const hasOutline = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.strokeOptions) === null || _b === void 0 ? void 0 : _b.hasOutline;\n const outlineWidth = (_e = (_d = (_c = element.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.outlineWidth) !== null && _e !== void 0 ? _e : 1;\n const fillColor = hasOutline ? element.backgroundColor : element.strokeColor;\n const fillColorThemed = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(fillColor) : fillColor;\n\n if (hasOutline) {\n const outline = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"path\");\n outline.setAttribute(\"fill\", \"none\");\n outline.setAttribute(\"stroke\", renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor);\n outline.setAttribute(\"stroke-width\", `${element.strokeWidth * outlineWidth}`);\n outline.setAttribute(\"d\", pathD);\n wrapper.appendChild(outline);\n }\n\n return {\n pathD,\n fillColorThemed\n };\n })(); //zsviczian - custom stroke options end\n\n\n const path = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"path\");\n /*\n path.setAttribute(\n \"fill\",\n renderConfig.theme === THEME.DARK\n ? applyDarkModeFilter(element.strokeColor)\n : element.strokeColor,\n );\n path.setAttribute(\"d\", shape);\n */\n //zsviczian\n\n path.setAttribute(\"fill\", fillColorThemed); //zsviczian\n\n path.setAttribute(\"d\", pathD); //zsviczian\n\n wrapper.appendChild(path);\n } else {\n // background (Drawable)\n const bgNode = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT); // if children wrapped in <g>, unwrap it\n\n if (bgNode.nodeName === \"g\") {\n while (bgNode.firstChild) {\n wrapper.appendChild(bgNode.firstChild);\n }\n } else {\n wrapper.appendChild(bgNode);\n }\n }\n }\n\n if (opacity !== 1) {\n wrapper.setAttribute(\"stroke-opacity\", `${opacity}`);\n wrapper.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n wrapper.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n wrapper.setAttribute(\"stroke\", \"none\");\n const g = maybeWrapNodesInFrameClipPath(element, root, [wrapper], renderConfig.frameRendering, elementsMap);\n addToRoot(g || wrapper, element);\n break;\n }\n\n case \"image\":\n {\n const width = Math.round(element.width);\n const height = Math.round(element.height);\n const fileData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isInitializedImageElement)(element) && files[element.fileId];\n\n if (fileData) {\n const {\n reuseImages = true\n } = renderConfig;\n let suffix = fileData.mimeType === \"image/svg+xml\" && ((_f = element.customData) === null || _f === void 0 ? void 0 : _f.doNotInvertSVGInDarkMode) ? \"-no-invert-svg\" : ((_g = element.customData) === null || _g === void 0 ? void 0 : _g.invertBitmapInDarkmode) ? \"-invert-bitmap\" : \"\"; //zsviczian\n\n let symbolId = `image-${fileData.id}${suffix}`; //zsviczian\n\n let uncroppedWidth = element.width;\n let uncroppedHeight = element.height;\n\n if (element.crop) {\n ({\n width: uncroppedWidth,\n height: uncroppedHeight\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getUncroppedWidthAndHeight)(element));\n symbolId = `image-crop-${fileData.id}-${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.hashString)(`${uncroppedWidth}x${uncroppedHeight}${suffix}`)}`;\n }\n\n if (!reuseImages) {\n symbolId = `image-${element.id}${suffix}`; //zsviczian\n }\n\n let symbol = svgRoot.querySelector(`#${symbolId}`);\n\n if (!symbol) {\n symbol = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"symbol\");\n symbol.id = symbolId;\n const image = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"image\");\n image.setAttribute(\"href\", fileData.dataURL);\n image.setAttribute(\"preserveAspectRatio\", \"none\");\n\n if (element.crop || !reuseImages) {\n image.setAttribute(\"width\", `${uncroppedWidth}`);\n image.setAttribute(\"height\", `${uncroppedHeight}`);\n } else {\n image.setAttribute(\"width\", \"100%\");\n image.setAttribute(\"height\", \"100%\");\n }\n\n symbol.appendChild(image);\n (root.querySelector(\"defs\") || root).prepend(symbol);\n }\n\n const use = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"use\");\n use.setAttribute(\"href\", `#${symbolId}`);\n let normalizedCropX = 0;\n let normalizedCropY = 0;\n\n if (element.crop) {\n const {\n width: uncroppedWidth,\n height: uncroppedHeight\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getUncroppedWidthAndHeight)(element);\n normalizedCropX = element.crop.x / (element.crop.naturalWidth / uncroppedWidth);\n normalizedCropY = element.crop.y / (element.crop.naturalHeight / uncroppedHeight);\n }\n\n const adjustedCenterX = cx + normalizedCropX;\n const adjustedCenterY = cy + normalizedCropY;\n use.setAttribute(\"width\", `${width + normalizedCropX}`);\n use.setAttribute(\"height\", `${height + normalizedCropY}`);\n use.setAttribute(\"opacity\", `${opacity}`); // We first apply `scale` transforms (horizontal/vertical mirroring)\n // on the <use> element, then apply translation and rotation\n // on the <g> element which wraps the <use>.\n // Doing this separately is a quick hack to to work around compositing\n // the transformations correctly (the transform-origin was not being\n // applied correctly).\n\n if (element.scale[0] !== 1 || element.scale[1] !== 1) {\n use.setAttribute(\"transform\", `translate(${adjustedCenterX} ${adjustedCenterY}) scale(${element.scale[0]} ${element.scale[1]}) translate(${-adjustedCenterX} ${-adjustedCenterY})`);\n }\n\n const g = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n\n if (renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK && (fileData.mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.svg && !((_h = element.customData) === null || _h === void 0 ? void 0 : _h.doNotInvertSVGInDarkMode) || !!((_j = element.customData) === null || _j === void 0 ? void 0 : _j.pdfPageViewProps) && ((_l = (_k = element.customData) === null || _k === void 0 ? void 0 : _k.invertBitmapInDarkmode) !== null && _l !== void 0 ? _l : true) || !!((_m = element.customData) === null || _m === void 0 ? void 0 : _m.invertBitmapInDarkmode)) //zsviczian\n ) {\n g.setAttribute(\"filter\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.DARK_THEME_FILTER);\n }\n\n if (element.crop) {\n const mask = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"mask\");\n mask.setAttribute(\"id\", `mask-image-crop-${element.id}`);\n mask.setAttribute(\"fill\", \"#fff\");\n const maskRect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n maskRect.setAttribute(\"x\", `${normalizedCropX}`);\n maskRect.setAttribute(\"y\", `${normalizedCropY}`);\n maskRect.setAttribute(\"width\", `${width}`);\n maskRect.setAttribute(\"height\", `${height}`);\n mask.appendChild(maskRect);\n root.appendChild(mask);\n g.setAttribute(\"mask\", `url(#${mask.id})`);\n }\n\n g.appendChild(use);\n g.setAttribute(\"transform\", `translate(${offsetX - normalizedCropX} ${offsetY - normalizedCropY}) rotate(${degree} ${adjustedCenterX} ${adjustedCenterY})`);\n\n if (element.roundness) {\n const clipPath = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"clipPath\");\n clipPath.id = `image-clipPath-${element.id}`;\n clipPath.setAttribute(\"clipPathUnits\", \"userSpaceOnUse\");\n const clipRect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n const radius = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getCornerRadius)(Math.min(element.width, element.height), element);\n const clipOffsetX = element.crop ? normalizedCropX : 0;\n const clipOffsetY = element.crop ? normalizedCropY : 0;\n clipRect.setAttribute(\"x\", `${clipOffsetX}`);\n clipRect.setAttribute(\"y\", `${clipOffsetY}`);\n clipRect.setAttribute(\"width\", `${element.width}`);\n clipRect.setAttribute(\"height\", `${element.height}`);\n clipRect.setAttribute(\"rx\", `${radius}`);\n clipRect.setAttribute(\"ry\", `${radius}`);\n clipPath.appendChild(clipRect);\n addToRoot(clipPath, element);\n g.setAttributeNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"clip-path\", `url(#${clipPath.id})`);\n }\n\n const clipG = maybeWrapNodesInFrameClipPath(element, root, [g], renderConfig.frameRendering, elementsMap);\n addToRoot(clipG || g, element);\n }\n\n break;\n }\n // frames are not rendered and only acts as a container\n\n case \"frame\":\n case \"magicframe\":\n {\n if (renderConfig.frameRendering.enabled && renderConfig.frameRendering.outline && !(!renderConfig.frameRendering.markerEnabled && element.frameRole === \"marker\") //zsviczian\n ) {\n const rect = document.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n rect.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n rect.setAttribute(\"width\", `${element.width}px`);\n rect.setAttribute(\"height\", `${element.height}px`); // Rounded corners\n\n rect.setAttribute(\"rx\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.radius.toString());\n rect.setAttribute(\"ry\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.radius.toString());\n rect.setAttribute(\"fill\", \"none\");\n rect.setAttribute(\"stroke\", (() => {\n var _a, _b, _c, _d, _e;\n\n const color = (_e = (_c = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.frameColor) === null || _b === void 0 ? void 0 : _b.stroke) !== null && _c !== void 0 ? _c : (_d = renderConfig.frameColor) === null || _d === void 0 ? void 0 : _d.stroke) !== null && _e !== void 0 ? _e : _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.strokeColor; //zsviczian\n\n return renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(color) : color;\n })());\n rect.setAttribute(\"stroke-width\", (_s = (_q = (_p = (_o = element.customData) === null || _o === void 0 ? void 0 : _o.frameColor) === null || _p === void 0 ? void 0 : _p.fill) !== null && _q !== void 0 ? _q : (_r = renderConfig.frameColor) === null || _r === void 0 ? void 0 : _r.fill) !== null && _s !== void 0 ? _s : _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.strokeWidth.toString());\n addToRoot(rect, element);\n }\n\n break;\n }\n\n default:\n {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isTextElement)(element)) {\n const node = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n const lines = element.text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const lineHeightPx = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getLineHeightInPx)(element.fontSize, element.lineHeight);\n const horizontalOffset = element.textAlign === \"center\" ? element.width / 2 : element.textAlign === \"right\" ? element.width : 0;\n const verticalOffset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getVerticalOffset)(element.fontFamily, element.fontSize, lineHeightPx);\n const direction = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isRTL)(element.text) ? \"rtl\" : \"ltr\";\n const textAnchor = element.textAlign === \"center\" ? \"middle\" : element.textAlign === \"right\" || direction === \"rtl\" ? \"end\" : \"start\";\n\n for (let i = 0; i < lines.length; i++) {\n const text = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"text\");\n text.textContent = lines[i];\n text.setAttribute(\"x\", `${horizontalOffset}`);\n text.setAttribute(\"y\", `${i * lineHeightPx + verticalOffset}`);\n text.setAttribute(\"font-family\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontFamilyString)(element));\n text.setAttribute(\"font-size\", `${element.fontSize}px`);\n text.setAttribute(\"fill\", renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor);\n text.setAttribute(\"text-anchor\", textAnchor);\n text.setAttribute(\"style\", \"white-space: pre;\");\n text.setAttribute(\"direction\", direction);\n text.setAttribute(\"dominant-baseline\", \"alphabetic\");\n node.appendChild(text);\n }\n\n const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering, elementsMap);\n addToRoot(g || node, element);\n } else {\n // @ts-ignore\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n }\n};\n\nconst renderSceneToSvg = (elements, elementsMap, rsvg, svgRoot, files, renderConfig) => {\n if (!svgRoot) {\n return;\n } // render elements\n\n\n elements.filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n if (!element.isDeleted) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isTextElement)(element) && element.containerId && elementsMap.has(element.containerId)) {\n // will be rendered with the container\n return;\n }\n\n try {\n renderElementToSvg(element, elementsMap, rsvg, svgRoot, files, element.x + renderConfig.offsetX, element.y + renderConfig.offsetY, renderConfig);\n const boundTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(element, elementsMap);\n\n if (boundTextElement) {\n renderElementToSvg(boundTextElement, elementsMap, rsvg, svgRoot, files, boundTextElement.x + renderConfig.offsetX, boundTextElement.y + renderConfig.offsetY, renderConfig);\n }\n } catch (error) {\n console.error(error);\n }\n }\n }); // render embeddables on top\n\n elements.filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n if (!element.isDeleted) {\n try {\n renderElementToSvg(element, elementsMap, rsvg, svgRoot, files, element.x + renderConfig.offsetX, element.y + renderConfig.offsetY, renderConfig);\n } catch (error) {\n console.error(error);\n }\n }\n });\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/staticSvgScene.ts?");
22598
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ renderSceneToSvg: () => (/* binding */ renderSceneToSvg)\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__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _element_src_freedrawPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../element/src/freedrawPath */ \"../element/src/freedrawPath.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst roughSVGDrawWithPrecision = (rsvg, drawable, precision) => {\n if (typeof precision === \"undefined\") {\n return rsvg.draw(drawable);\n }\n\n const pshape = {\n sets: drawable.sets,\n shape: drawable.shape,\n options: Object.assign(Object.assign({}, drawable.options), {\n fixedDecimalPlaceDigits: precision\n })\n };\n return rsvg.draw(pshape);\n};\n\nconst maybeWrapNodesInFrameClipPath = (element, root, nodes, frameRendering, elementsMap) => {\n if (!frameRendering.enabled || !frameRendering.clip) {\n return null;\n }\n\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getContainingFrame)(element, elementsMap);\n\n if (frame) {\n const g = root.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n g.setAttributeNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"clip-path\", `url(#${frame.id})`);\n nodes.forEach(node => g.appendChild(node));\n return g;\n }\n\n return null;\n};\n\nconst renderElementToSvg = (element, elementsMap, rsvg, svgRoot, files, offsetX, offsetY, renderConfig) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;\n\n const offset = {\n x: offsetX,\n y: offsetY\n };\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getElementAbsoluteCoords)(element, elementsMap);\n let cx = (x2 - x1) / 2 - (element.x - x1);\n let cy = (y2 - y1) / 2 - (element.y - y1);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isTextElement)(element)) {\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getContainerElement)(element, elementsMap);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isArrowElement)(container)) {\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getElementAbsoluteCoords)(container, elementsMap);\n const boundTextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.LinearElementEditor.getBoundTextElementPosition(container, element, elementsMap);\n cx = (x2 - x1) / 2 - (boundTextCoords.x - x1);\n cy = (y2 - y1) / 2 - (boundTextCoords.y - y1);\n offsetX = offsetX + boundTextCoords.x - element.x;\n offsetY = offsetY + boundTextCoords.y - element.y;\n }\n }\n\n const degree = 180 * element.angle / Math.PI; // element to append node to, most of the time svgRoot\n\n let root = svgRoot; // if the element has a link, create an anchor tag and make that the new root\n\n if (element.link) {\n const anchorTag = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"a\");\n anchorTag.setAttribute(\"href\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.normalizeLink)(element.link));\n root.appendChild(anchorTag);\n root = anchorTag;\n }\n\n const addToRoot = (node, element) => {\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isTestEnv)()) {\n node.setAttribute(\"data-id\", element.id);\n }\n\n root.appendChild(node);\n };\n\n const opacity = ((_b = (_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getContainingFrame)(element, elementsMap)) === null || _a === void 0 ? void 0 : _a.opacity) !== null && _b !== void 0 ? _b : 100) * element.opacity / 10000;\n\n switch (element.type) {\n case \"selection\":\n {\n // Since this is used only during editing experience, which is canvas based,\n // this should not happen\n throw new Error(\"Selection rendering is not supported for SVG\");\n }\n\n case \"rectangle\":\n case \"diamond\":\n case \"ellipse\":\n {\n const shape = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig);\n const node = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"stroke-linecap\", \"round\");\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering, elementsMap);\n addToRoot(g || node, element);\n break;\n }\n\n case \"iframe\":\n case \"embeddable\":\n {\n // render placeholder rectangle\n const shape = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig);\n const node = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n const opacity = element.opacity / 100;\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"stroke-linecap\", \"round\");\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n addToRoot(node, element);\n const label = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.createPlaceholderEmbeddableLabel)(element);\n renderElementToSvg(label, elementsMap, rsvg, root, files, label.x + offset.x - element.x, label.y + offset.y - element.y, renderConfig);\n const scaleX = ((_c = element.scale) === null || _c === void 0 ? void 0 : _c[0]) || 1; //zsviczian\n\n const scaleY = ((_d = element.scale) === null || _d === void 0 ? void 0 : _d[1]) || 1; //zsviczian\n // render embeddable element + iframe\n\n const embeddableNode = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n embeddableNode.setAttribute(\"stroke-linecap\", \"round\");\n embeddableNode.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy}) scale(${scaleX}, ${scaleY})`);\n\n while (embeddableNode.firstChild) {\n embeddableNode.removeChild(embeddableNode.firstChild);\n }\n\n const radius = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getCornerRadius)(Math.min(element.width, element.height), element);\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.toValidURL)(element.link || \"\")); // if rendering embeddables explicitly disabled or\n // embedding documents via srcdoc (which doesn't seem to work for SVGs)\n // replace with a link instead\n\n if (renderConfig.renderEmbeddables === false || (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"document\") {\n const anchorTag = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"a\");\n anchorTag.setAttribute(\"href\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.normalizeLink)(element.link || \"\"));\n anchorTag.setAttribute(\"target\", \"_blank\");\n anchorTag.setAttribute(\"rel\", \"noopener noreferrer\");\n anchorTag.style.borderRadius = `${radius}px`;\n embeddableNode.appendChild(anchorTag);\n } else {\n const foreignObject = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"foreignObject\");\n foreignObject.style.width = `${element.width / scaleX}px`; //zsviczian\n\n foreignObject.style.height = `${element.height / scaleY}px`; //zsviczian\n\n foreignObject.style.border = \"none\";\n const div = foreignObject.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"div\");\n div.setAttribute(\"xmlns\", \"http://www.w3.org/1999/xhtml\");\n div.style.width = \"100%\";\n div.style.height = \"100%\";\n const iframe = div.ownerDocument.createElement(\"iframe\");\n iframe.src = (_e = embedLink === null || embedLink === void 0 ? void 0 : embedLink.link) !== null && _e !== void 0 ? _e : \"\";\n iframe.style.width = \"100%\";\n iframe.style.height = \"100%\";\n iframe.style.border = \"none\";\n iframe.style.borderRadius = `${radius}px`;\n iframe.style.top = \"0\";\n iframe.style.left = \"0\";\n iframe.allowFullscreen = true;\n div.appendChild(iframe);\n foreignObject.appendChild(div);\n embeddableNode.appendChild(foreignObject);\n }\n\n addToRoot(embeddableNode, element);\n break;\n }\n\n case \"line\":\n case \"arrow\":\n {\n const boundText = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(element, elementsMap);\n const maskPath = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"mask\");\n\n if (boundText) {\n maskPath.setAttribute(\"id\", `mask-${element.id}`);\n const maskRectVisible = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n offsetX = offsetX || 0;\n offsetY = offsetY || 0;\n maskRectVisible.setAttribute(\"x\", \"0\");\n maskRectVisible.setAttribute(\"y\", \"0\");\n maskRectVisible.setAttribute(\"fill\", \"#fff\");\n maskRectVisible.setAttribute(\"width\", `${element.width + 100 + offsetX}`);\n maskRectVisible.setAttribute(\"height\", `${element.height + 100 + offsetY}`);\n maskPath.appendChild(maskRectVisible);\n const maskRectInvisible = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n const boundTextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.LinearElementEditor.getBoundTextElementPosition(element, boundText, elementsMap);\n const maskX = offsetX + boundTextCoords.x - element.x;\n const maskY = offsetY + boundTextCoords.y - element.y;\n maskRectInvisible.setAttribute(\"x\", maskX.toString());\n maskRectInvisible.setAttribute(\"y\", maskY.toString());\n maskRectInvisible.setAttribute(\"fill\", \"#000\");\n maskRectInvisible.setAttribute(\"width\", `${boundText.width}`);\n maskRectInvisible.setAttribute(\"height\", `${boundText.height}`);\n maskRectInvisible.setAttribute(\"opacity\", \"1\");\n maskPath.appendChild(maskRectInvisible);\n }\n\n const group = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n\n if (boundText) {\n group.setAttribute(\"mask\", `url(#mask-${element.id})`);\n }\n\n group.setAttribute(\"stroke-linecap\", \"round\");\n const shapes = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig);\n shapes.forEach(shape => {\n const node = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT);\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n\n if (element.type === \"line\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isPathALoop)(element.points) && element.backgroundColor !== \"transparent\") {\n node.setAttribute(\"fill-rule\", \"evenodd\");\n }\n\n group.appendChild(node);\n });\n const g = maybeWrapNodesInFrameClipPath(element, root, [group, maskPath], renderConfig.frameRendering, elementsMap);\n\n if (g) {\n addToRoot(g, element);\n root.appendChild(g);\n } else {\n addToRoot(group, element);\n root.append(maskPath);\n }\n\n break;\n }\n\n case \"freedraw\":\n {\n const wrapper = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n const shapes = _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.ShapeCache.generateElementShape(element, renderConfig); // always ordered as [background, stroke]\n\n for (const shape of shapes) {\n if (typeof shape === \"string\") {\n // stroke (SVGPathString)\n //zsviczian - custom stroke options start\n const {\n pathD,\n fillColorThemed\n } = (() => {\n var _a, _b, _c, _d, _e;\n\n const pathD = (0,_element_src_freedrawPath__WEBPACK_IMPORTED_MODULE_2__.getFreeDrawSvgPath)(element);\n const hasOutline = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.strokeOptions) === null || _b === void 0 ? void 0 : _b.hasOutline;\n const outlineWidth = (_e = (_d = (_c = element.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.outlineWidth) !== null && _e !== void 0 ? _e : 1;\n const fillColor = hasOutline ? element.backgroundColor : element.strokeColor;\n const fillColorThemed = renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(fillColor) : fillColor;\n\n if (hasOutline) {\n const outline = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"path\");\n outline.setAttribute(\"fill\", \"none\");\n outline.setAttribute(\"stroke\", renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(element.strokeColor) : element.strokeColor);\n outline.setAttribute(\"stroke-width\", `${element.strokeWidth * outlineWidth}`);\n outline.setAttribute(\"d\", pathD);\n wrapper.appendChild(outline);\n }\n\n return {\n pathD,\n fillColorThemed\n };\n })(); //zsviczian - custom stroke options end\n\n\n const path = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"path\");\n /*\n path.setAttribute(\n \"fill\",\n applyDarkModeFilter(\n element.strokeColor,\n renderConfig.theme === THEME.DARK,\n ),\n );\n path.setAttribute(\"d\", shape);\n */\n //zsviczian\n\n path.setAttribute(\"fill\", fillColorThemed); //zsviczian\n\n path.setAttribute(\"d\", pathD); //zsviczian\n\n wrapper.appendChild(path);\n } else {\n // background (Drawable)\n const bgNode = roughSVGDrawWithPrecision(rsvg, shape, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MAX_DECIMALS_FOR_SVG_EXPORT); // if children wrapped in <g>, unwrap it\n\n if (bgNode.nodeName === \"g\") {\n while (bgNode.firstChild) {\n wrapper.appendChild(bgNode.firstChild);\n }\n } else {\n wrapper.appendChild(bgNode);\n }\n }\n }\n\n if (opacity !== 1) {\n wrapper.setAttribute(\"stroke-opacity\", `${opacity}`);\n wrapper.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n wrapper.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n wrapper.setAttribute(\"stroke\", \"none\");\n const g = maybeWrapNodesInFrameClipPath(element, root, [wrapper], renderConfig.frameRendering, elementsMap);\n addToRoot(g || wrapper, element);\n break;\n }\n\n case \"image\":\n {\n const width = Math.round(element.width);\n const height = Math.round(element.height);\n const fileData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isInitializedImageElement)(element) && files[element.fileId];\n\n if (fileData) {\n const {\n reuseImages = true\n } = renderConfig;\n let suffix = fileData.mimeType === \"image/svg+xml\" && ((_f = element.customData) === null || _f === void 0 ? void 0 : _f.doNotInvertSVGInDarkMode) ? \"-no-invert-svg\" : ((_g = element.customData) === null || _g === void 0 ? void 0 : _g.invertBitmapInDarkmode) ? \"-invert-bitmap\" : \"\"; //zsviczian\n\n let symbolId = `image-${fileData.id}${suffix}`; //zsviczian\n\n let uncroppedWidth = element.width;\n let uncroppedHeight = element.height;\n\n if (element.crop) {\n ({\n width: uncroppedWidth,\n height: uncroppedHeight\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getUncroppedWidthAndHeight)(element));\n symbolId = `image-crop-${fileData.id}-${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.hashString)(`${uncroppedWidth}x${uncroppedHeight}${suffix}`)}`;\n }\n\n if (!reuseImages) {\n symbolId = `image-${element.id}${suffix}`; //zsviczian\n }\n\n let symbol = svgRoot.querySelector(`#${symbolId}`);\n\n if (!symbol) {\n symbol = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"symbol\");\n symbol.id = symbolId;\n const image = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"image\");\n image.setAttribute(\"href\", fileData.dataURL);\n image.setAttribute(\"preserveAspectRatio\", \"none\");\n\n if (element.crop || !reuseImages) {\n image.setAttribute(\"width\", `${uncroppedWidth}`);\n image.setAttribute(\"height\", `${uncroppedHeight}`);\n } else {\n image.setAttribute(\"width\", \"100%\");\n image.setAttribute(\"height\", \"100%\");\n }\n\n symbol.appendChild(image);\n (root.querySelector(\"defs\") || root).prepend(symbol);\n }\n\n const use = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"use\");\n use.setAttribute(\"href\", `#${symbolId}`);\n let normalizedCropX = 0;\n let normalizedCropY = 0;\n\n if (element.crop) {\n const {\n width: uncroppedWidth,\n height: uncroppedHeight\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getUncroppedWidthAndHeight)(element);\n normalizedCropX = element.crop.x / (element.crop.naturalWidth / uncroppedWidth);\n normalizedCropY = element.crop.y / (element.crop.naturalHeight / uncroppedHeight);\n }\n\n const adjustedCenterX = cx + normalizedCropX;\n const adjustedCenterY = cy + normalizedCropY;\n use.setAttribute(\"width\", `${width + normalizedCropX}`);\n use.setAttribute(\"height\", `${height + normalizedCropY}`);\n use.setAttribute(\"opacity\", `${opacity}`); // We first apply `scale` transforms (horizontal/vertical mirroring)\n // on the <use> element, then apply translation and rotation\n // on the <g> element which wraps the <use>.\n // Doing this separately is a quick hack to to work around compositing\n // the transformations correctly (the transform-origin was not being\n // applied correctly).\n\n if (element.scale[0] !== 1 || element.scale[1] !== 1) {\n use.setAttribute(\"transform\", `translate(${adjustedCenterX} ${adjustedCenterY}) scale(${element.scale[0]} ${element.scale[1]}) translate(${-adjustedCenterX} ${-adjustedCenterY})`);\n }\n\n const g = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n\n if (renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK && (fileData.mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.svg && !((_h = element.customData) === null || _h === void 0 ? void 0 : _h.doNotInvertSVGInDarkMode) || !!((_j = element.customData) === null || _j === void 0 ? void 0 : _j.pdfPageViewProps) && ((_l = (_k = element.customData) === null || _k === void 0 ? void 0 : _k.invertBitmapInDarkmode) !== null && _l !== void 0 ? _l : true) || !!((_m = element.customData) === null || _m === void 0 ? void 0 : _m.invertBitmapInDarkmode)) //zsviczian\n ) {\n g.setAttribute(\"filter\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.DARK_THEME_FILTER);\n }\n\n if (element.crop) {\n const mask = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"mask\");\n mask.setAttribute(\"id\", `mask-image-crop-${element.id}`);\n mask.setAttribute(\"fill\", \"#fff\");\n const maskRect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n maskRect.setAttribute(\"x\", `${normalizedCropX}`);\n maskRect.setAttribute(\"y\", `${normalizedCropY}`);\n maskRect.setAttribute(\"width\", `${width}`);\n maskRect.setAttribute(\"height\", `${height}`);\n mask.appendChild(maskRect);\n root.appendChild(mask);\n g.setAttribute(\"mask\", `url(#${mask.id})`);\n }\n\n g.appendChild(use);\n g.setAttribute(\"transform\", `translate(${offsetX - normalizedCropX} ${offsetY - normalizedCropY}) rotate(${degree} ${adjustedCenterX} ${adjustedCenterY})`);\n\n if (element.roundness) {\n const clipPath = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"clipPath\");\n clipPath.id = `image-clipPath-${element.id}`;\n clipPath.setAttribute(\"clipPathUnits\", \"userSpaceOnUse\");\n const clipRect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n const radius = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getCornerRadius)(Math.min(element.width, element.height), element);\n const clipOffsetX = element.crop ? normalizedCropX : 0;\n const clipOffsetY = element.crop ? normalizedCropY : 0;\n clipRect.setAttribute(\"x\", `${clipOffsetX}`);\n clipRect.setAttribute(\"y\", `${clipOffsetY}`);\n clipRect.setAttribute(\"width\", `${element.width}`);\n clipRect.setAttribute(\"height\", `${element.height}`);\n clipRect.setAttribute(\"rx\", `${radius}`);\n clipRect.setAttribute(\"ry\", `${radius}`);\n clipPath.appendChild(clipRect);\n addToRoot(clipPath, element);\n g.setAttributeNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"clip-path\", `url(#${clipPath.id})`);\n }\n\n const clipG = maybeWrapNodesInFrameClipPath(element, root, [g], renderConfig.frameRendering, elementsMap);\n addToRoot(clipG || g, element);\n }\n\n break;\n }\n // frames are not rendered and only acts as a container\n\n case \"frame\":\n case \"magicframe\":\n {\n if (renderConfig.frameRendering.enabled && renderConfig.frameRendering.outline && !(!renderConfig.frameRendering.markerEnabled && element.frameRole === \"marker\") //zsviczian\n ) {\n const rect = document.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"rect\");\n rect.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n rect.setAttribute(\"width\", `${element.width}px`);\n rect.setAttribute(\"height\", `${element.height}px`); // Rounded corners\n\n rect.setAttribute(\"rx\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.radius.toString());\n rect.setAttribute(\"ry\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.radius.toString());\n rect.setAttribute(\"fill\", \"none\");\n rect.setAttribute(\"stroke\", (() => {\n var _a, _b, _c, _d, _e;\n\n const color = (_e = (_c = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.frameColor) === null || _b === void 0 ? void 0 : _b.stroke) !== null && _c !== void 0 ? _c : (_d = renderConfig.frameColor) === null || _d === void 0 ? void 0 : _d.stroke) !== null && _e !== void 0 ? _e : _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.strokeColor; //zsviczian\n\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(color, //zsviczian\n renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK);\n })());\n rect.setAttribute(\"stroke-width\", (_s = (_q = (_p = (_o = element.customData) === null || _o === void 0 ? void 0 : _o.frameColor) === null || _p === void 0 ? void 0 : _p.fill) !== null && _q !== void 0 ? _q : (_r = renderConfig.frameColor) === null || _r === void 0 ? void 0 : _r.fill) !== null && _s !== void 0 ? _s : _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.strokeWidth.toString());\n addToRoot(rect, element);\n }\n\n break;\n }\n\n default:\n {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isTextElement)(element)) {\n const node = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"g\");\n\n if (opacity !== 1) {\n node.setAttribute(\"stroke-opacity\", `${opacity}`);\n node.setAttribute(\"fill-opacity\", `${opacity}`);\n }\n\n node.setAttribute(\"transform\", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);\n const lines = element.text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const lineHeightPx = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getLineHeightInPx)(element.fontSize, element.lineHeight);\n const horizontalOffset = element.textAlign === \"center\" ? element.width / 2 : element.textAlign === \"right\" ? element.width : 0;\n const verticalOffset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getVerticalOffset)(element.fontFamily, element.fontSize, lineHeightPx);\n const direction = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isRTL)(element.text) ? \"rtl\" : \"ltr\";\n const textAnchor = element.textAlign === \"center\" ? \"middle\" : element.textAlign === \"right\" || direction === \"rtl\" ? \"end\" : \"start\";\n\n for (let i = 0; i < lines.length; i++) {\n const text = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.SVG_NS, \"text\");\n text.textContent = lines[i];\n text.setAttribute(\"x\", `${horizontalOffset}`);\n text.setAttribute(\"y\", `${i * lineHeightPx + verticalOffset}`);\n text.setAttribute(\"font-family\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.getFontFamilyString)(element));\n text.setAttribute(\"font-size\", `${element.fontSize}px`);\n text.setAttribute(\"fill\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(element.strokeColor, renderConfig.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK));\n text.setAttribute(\"text-anchor\", textAnchor);\n text.setAttribute(\"style\", \"white-space: pre;\");\n text.setAttribute(\"direction\", direction);\n text.setAttribute(\"dominant-baseline\", \"alphabetic\");\n node.appendChild(text);\n }\n\n const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering, elementsMap);\n addToRoot(g || node, element);\n } else {\n // @ts-ignore\n throw new Error(`Unimplemented type ${element.type}`);\n }\n }\n }\n};\n\nconst renderSceneToSvg = (elements, elementsMap, rsvg, svgRoot, files, renderConfig) => {\n if (!svgRoot) {\n return;\n } // render elements\n\n\n elements.filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n if (!element.isDeleted) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isTextElement)(element) && element.containerId && elementsMap.has(element.containerId)) {\n // will be rendered with the container\n return;\n }\n\n try {\n renderElementToSvg(element, elementsMap, rsvg, svgRoot, files, element.x + renderConfig.offsetX, element.y + renderConfig.offsetY, renderConfig);\n const boundTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(element, elementsMap);\n\n if (boundTextElement) {\n renderElementToSvg(boundTextElement, elementsMap, rsvg, svgRoot, files, boundTextElement.x + renderConfig.offsetX, boundTextElement.y + renderConfig.offsetY, renderConfig);\n }\n } catch (error) {\n console.error(error);\n }\n }\n }); // render embeddables on top\n\n elements.filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n if (!element.isDeleted) {\n try {\n renderElementToSvg(element, elementsMap, rsvg, svgRoot, files, element.x + renderConfig.offsetX, element.y + renderConfig.offsetY, renderConfig);\n } catch (error) {\n console.error(error);\n }\n }\n });\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/staticSvgScene.ts?");
22599
22599
 
22600
22600
  /***/ }),
22601
22601
 
@@ -22617,7 +22617,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22617
22617
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
22618
22618
 
22619
22619
  "use strict";
22620
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeSvgBase64Payload: () => (/* binding */ decodeSvgBase64Payload),\n/* harmony export */ encodeSvgBase64Payload: () => (/* binding */ encodeSvgBase64Payload),\n/* harmony export */ exportToCanvas: () => (/* binding */ exportToCanvas),\n/* harmony export */ exportToSvg: () => (/* binding */ exportToSvg),\n/* harmony export */ getExportSize: () => (/* binding */ getExportSize)\n/* harmony export */ });\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\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 _appState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _data_encode__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../data/encode */ \"./data/encode.ts\");\n/* harmony import */ var _data_json__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../data/json */ \"./data/json.ts\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _renderer_staticScene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../renderer/staticScene */ \"./renderer/staticScene.ts\");\n/* harmony import */ var _renderer_staticSvgScene__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../renderer/staticSvgScene */ \"./renderer/staticSvgScene.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst truncateText = (element, maxWidth) => {\n if (element.width <= maxWidth) {\n return element;\n }\n\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n ctx.font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFontString)({\n fontFamily: element.fontFamily,\n fontSize: element.fontSize\n });\n let text = element.text;\n const metrics = ctx.measureText(text);\n\n if (metrics.width > maxWidth) {\n // we iterate from the right, removing characters one by one instead\n // of bulding the string up. This assumes that it's more likely\n // your frame names will overflow by not that many characters\n // (if ever), so it sohuld be faster this way.\n for (let i = text.length; i > 0; i--) {\n const newText = `${text.slice(0, i)}...`;\n\n if (ctx.measureText(newText).width <= maxWidth) {\n text = newText;\n break;\n }\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.newElementWith)(element, {\n text,\n width: maxWidth\n });\n};\n/**\n * When exporting frames, we need to render frame labels which are currently\n * being rendered in DOM when editing. Adding the labels as regular text\n * elements seems like a simple hack. In the future we'll want to move to\n * proper canvas rendering, even within editor (instead of DOM).\n */\n\n\nconst addFrameLabelsAsTextElements = (elements, opts) => {\n var _a, _b, _c;\n\n const nextElements = [];\n\n for (const element of elements) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(element)) {\n let textElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.newTextElement)({\n x: element.x,\n y: element.y - _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameOffsetY,\n fontFamily: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY.Helvetica,\n fontSize: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameFontSize,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameLineHeight,\n strokeColor: (_c = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.frameColor) === null || _b === void 0 ? void 0 : _b.nameColor) !== null && _c !== void 0 ? _c : opts.exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameColorLightTheme,\n text: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getFrameLikeTitle)(element),\n rawText: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getFrameLikeTitle)(element) //zsviczian\n\n });\n textElement.y -= textElement.height;\n textElement = truncateText(textElement, element.width);\n nextElements.push(textElement);\n }\n\n nextElements.push(element);\n }\n\n return nextElements;\n};\n\nconst getFrameRenderingConfig = (exportingFrame, frameRendering) => {\n frameRendering = frameRendering || (0,_appState__WEBPACK_IMPORTED_MODULE_3__.getDefaultAppState)().frameRendering;\n return {\n enabled: exportingFrame ? true : frameRendering.enabled,\n outline: exportingFrame ? false : frameRendering.outline,\n name: exportingFrame ? false : frameRendering.name,\n clip: exportingFrame ? true : frameRendering.clip,\n markerName: false,\n //zsviczian\n markerEnabled: false //zsviczian\n\n };\n};\n\nconst prepareElementsForRender = ({\n elements,\n exportingFrame,\n frameRendering,\n exportWithDarkMode\n}) => {\n let nextElements;\n\n if (exportingFrame) {\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getElementsOverlappingFrame)(elements, exportingFrame, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(elements));\n } else if (frameRendering.enabled && frameRendering.name) {\n nextElements = addFrameLabelsAsTextElements(elements, {\n exportWithDarkMode\n });\n } else {\n nextElements = elements;\n }\n\n return nextElements;\n};\n\nconst exportToCanvas = async (elements, appState, files, {\n exportBackground,\n exportPadding = _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_EXPORT_PADDING,\n viewBackgroundColor,\n exportingFrame\n}, createCanvas = (width, height) => {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width * appState.exportScale;\n canvas.height = height * appState.exportScale;\n return {\n canvas,\n scale: appState.exportScale\n };\n}, loadFonts = async () => {\n await _fonts__WEBPACK_IMPORTED_MODULE_6__.Fonts.loadElementsFonts(elements);\n}) => {\n var _a; // load font faces before continuing, by default leverages browsers' [FontFace API](https://developer.mozilla.org/en-US/docs/Web/API/FontFace)\n\n\n await loadFonts();\n const frameRendering = getFrameRenderingConfig(exportingFrame !== null && exportingFrame !== void 0 ? exportingFrame : null, (_a = appState.frameRendering) !== null && _a !== void 0 ? _a : null); // for canvas export, don't clip if exporting a specific frame as it would\n // clip the corners of the content\n\n if (exportingFrame) {\n frameRendering.clip = false;\n }\n\n const filteredElements = elements.filter(el => !(el.type === \"frame\" && el.frameRole === \"marker\")); //zsviczian\n\n const elementsForRender = prepareElementsForRender({\n elements: filteredElements,\n //zsviczian\n exportingFrame,\n exportWithDarkMode: appState.exportWithDarkMode,\n frameRendering\n });\n\n if (exportingFrame) {\n exportPadding = 0;\n }\n\n const [minX, minY, width, height] = getCanvasSize(exportingFrame ? [exportingFrame] : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getRootElements)(elementsForRender), exportPadding);\n const {\n canvas,\n scale = 1\n } = createCanvas(width, height);\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_3__.getDefaultAppState)();\n const {\n imageCache\n } = await (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateImageCache)({\n imageCache: new Map(),\n fileIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getInitializedImageElements)(elementsForRender).map(element => element.fileId),\n files\n });\n (0,_renderer_staticScene__WEBPACK_IMPORTED_MODULE_7__.renderStaticScene)({\n canvas,\n rc: roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].canvas(canvas),\n elementsMap: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toBrandedType)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(elementsForRender)),\n allElementsMap: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toBrandedType)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.syncInvalidIndices)(elements))),\n visibleElements: elementsForRender,\n scale,\n appState: Object.assign(Object.assign({}, appState), {\n frameRendering,\n viewBackgroundColor: exportBackground ? viewBackgroundColor : null,\n scrollX: -minX + exportPadding,\n scrollY: -minY + exportPadding,\n zoom: defaultAppState.zoom,\n shouldCacheIgnoreZoom: false,\n theme: appState.exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT\n }),\n renderConfig: {\n canvasBackgroundColor: viewBackgroundColor,\n imageCache,\n renderGrid: false,\n isExporting: true,\n // empty disables embeddable rendering\n embedsValidationStatus: new Map(),\n elementsPendingErasure: new Set(),\n pendingFlowchartNodes: null,\n theme: appState.exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT\n }\n });\n return canvas;\n};\n\nconst createHTMLComment = text => {\n // surrounding with spaces to maintain prettified consistency with previous\n // iterations\n // <!-- comment -->\n return document.createComment(` ${text} `);\n};\n\nconst exportToSvg = async (elements, appState, files, opts) => {\n var _a, _b, _c, _d;\n\n const frameRendering = getFrameRenderingConfig((_a = opts === null || opts === void 0 ? void 0 : opts.exportingFrame) !== null && _a !== void 0 ? _a : null, (_b = appState.frameRendering) !== null && _b !== void 0 ? _b : null);\n let {\n exportPadding = _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_EXPORT_PADDING,\n exportWithDarkMode = false,\n viewBackgroundColor,\n exportScale = 1,\n exportEmbedScene\n } = appState;\n const {\n exportingFrame = null\n } = opts || {};\n const filteredElements = elements.filter(el => !(el.type === \"frame\" && el.frameRole === \"marker\")); //zsviczian\n\n const elementsForRender = prepareElementsForRender({\n elements: filteredElements,\n //zsviczian\n exportingFrame,\n exportWithDarkMode,\n frameRendering\n });\n\n if (exportingFrame) {\n exportPadding = 0;\n }\n\n const [minX, minY, width, height] = getCanvasSize(exportingFrame ? [exportingFrame] : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getRootElements)(elementsForRender), exportPadding);\n const offsetX = -minX + exportPadding;\n const offsetY = -minY + exportPadding; // ---------------------------------------------------------------------------\n // initialize SVG root element\n // ---------------------------------------------------------------------------\n\n const svgRoot = document.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"svg\");\n svgRoot.setAttribute(\"version\", \"1.1\");\n svgRoot.setAttribute(\"xmlns\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS);\n svgRoot.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n svgRoot.setAttribute(\"width\", `${width * exportScale}`);\n svgRoot.setAttribute(\"height\", `${height * exportScale}`);\n const defsElement = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"defs\");\n const metadataElement = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"metadata\");\n svgRoot.appendChild(createHTMLComment(\"svg-source:excalidraw\"));\n svgRoot.appendChild(metadataElement);\n svgRoot.appendChild(defsElement); // ---------------------------------------------------------------------------\n // scene embed\n // ---------------------------------------------------------------------------\n // we need to serialize the \"original\" elements before we put them through\n // the tempScene hack which duplicates and regenerates ids\n\n if (exportEmbedScene) {\n try {\n encodeSvgBase64Payload({\n metadataElement,\n // when embedding scene, we want to embed the origionally supplied\n // elements which don't contain the temp frame labels.\n // But it also requires that the exportToSvg is being supplied with\n // only the elements that we're exporting, and no extra.\n payload: (0,_data_json__WEBPACK_IMPORTED_MODULE_5__.serializeAsJSON)(filteredElements, appState, files || {}, \"local\") //zsviczian\n\n });\n } catch (error) {\n console.error(error);\n }\n } // ---------------------------------------------------------------------------\n // frame clip paths\n // ---------------------------------------------------------------------------\n\n\n const frameElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getFrameLikeElements)(filteredElements); //zsviczian\n\n if (frameElements.length) {\n const elementsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(filteredElements); //zsviczian\n\n for (const frame of frameElements) {\n const clipPath = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"clipPath\");\n clipPath.setAttribute(\"id\", frame.id);\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getElementAbsoluteCoords)(frame, elementsMap);\n const cx = (x2 - x1) / 2 - (frame.x - x1);\n const cy = (y2 - y1) / 2 - (frame.y - y1);\n const rect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"rect\");\n rect.setAttribute(\"transform\", `translate(${frame.x + offsetX} ${frame.y + offsetY}) rotate(${frame.angle} ${cx} ${cy})`);\n rect.setAttribute(\"width\", `${frame.width}`);\n rect.setAttribute(\"height\", `${frame.height}`);\n\n if (!exportingFrame) {\n rect.setAttribute(\"rx\", `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.radius}`);\n rect.setAttribute(\"ry\", `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.radius}`);\n }\n\n clipPath.appendChild(rect);\n defsElement.appendChild(clipPath);\n }\n } // ---------------------------------------------------------------------------\n // inline font faces\n // ---------------------------------------------------------------------------\n\n\n const fontFaces = !(opts === null || opts === void 0 ? void 0 : opts.skipInliningFonts) ? await _fonts__WEBPACK_IMPORTED_MODULE_6__.Fonts.generateFontFaceDeclarations(elements) : [];\n const delimiter = \"\\n \"; // 6 spaces\n\n const style = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"style\");\n style.classList.add(\"style-fonts\");\n style.appendChild(document.createTextNode(`${delimiter}${fontFaces.join(delimiter)}`));\n defsElement.appendChild(style); // ---------------------------------------------------------------------------\n // background\n // ---------------------------------------------------------------------------\n // render background rect\n\n if (appState.exportBackground && viewBackgroundColor) {\n const rect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"rect\");\n rect.setAttribute(\"x\", \"0\");\n rect.setAttribute(\"y\", \"0\");\n rect.setAttribute(\"width\", `${width}`);\n rect.setAttribute(\"height\", `${height}`);\n rect.setAttribute(\"fill\", exportWithDarkMode ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.applyDarkModeFilter)(viewBackgroundColor) : viewBackgroundColor);\n svgRoot.appendChild(rect);\n } // ---------------------------------------------------------------------------\n // render elements\n // ---------------------------------------------------------------------------\n\n\n const rsvg = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].svg(svgRoot);\n const renderEmbeddables = (_c = opts === null || opts === void 0 ? void 0 : opts.renderEmbeddables) !== null && _c !== void 0 ? _c : false;\n (0,_renderer_staticSvgScene__WEBPACK_IMPORTED_MODULE_8__.renderSceneToSvg)(elementsForRender, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toBrandedType)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(elementsForRender)), rsvg, svgRoot, files || {}, {\n offsetX,\n offsetY,\n isExporting: true,\n exportWithDarkMode,\n renderEmbeddables,\n frameRendering,\n frameColor: appState.frameColor,\n //zsviczian\n canvasBackgroundColor: viewBackgroundColor,\n embedsValidationStatus: renderEmbeddables ? new Map(elementsForRender.filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(element)).map(element => [element.id, true])) : new Map(),\n reuseImages: (_d = opts === null || opts === void 0 ? void 0 : opts.reuseImages) !== null && _d !== void 0 ? _d : true,\n theme: exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT\n }); // ---------------------------------------------------------------------------\n\n return svgRoot;\n};\nconst encodeSvgBase64Payload = ({\n payload,\n metadataElement\n}) => {\n const base64 = (0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.stringToBase64)(JSON.stringify((0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.encode)({\n text: payload\n })), true\n /* is already byte string */\n );\n metadataElement.appendChild(createHTMLComment(`payload-type:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.MIME_TYPES.excalidraw}`));\n metadataElement.appendChild(createHTMLComment(\"payload-version:2\"));\n metadataElement.appendChild(createHTMLComment(\"payload-start\"));\n metadataElement.appendChild(document.createTextNode(base64));\n metadataElement.appendChild(createHTMLComment(\"payload-end\"));\n};\nconst decodeSvgBase64Payload = ({\n svg\n}) => {\n if (svg.includes(`payload-type:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.MIME_TYPES.excalidraw}`)) {\n const match = svg.match(/<!-- payload-start -->\\s*(.+?)\\s*<!-- payload-end -->/);\n\n if (!match) {\n throw new Error(\"INVALID\");\n }\n\n const versionMatch = svg.match(/<!-- payload-version:(\\d+) -->/);\n const version = (versionMatch === null || versionMatch === void 0 ? void 0 : versionMatch[1]) || \"1\";\n const isByteString = version !== \"1\";\n\n try {\n const json = (0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.base64ToString)(match[1], isByteString);\n const encodedData = JSON.parse(json);\n\n if (!(\"encoded\" in encodedData)) {\n // legacy, un-encoded scene JSON\n if (\"type\" in encodedData && encodedData.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EXPORT_DATA_TYPES.excalidraw) {\n return json;\n }\n\n throw new Error(\"FAILED\");\n }\n\n return (0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.decode)(encodedData);\n } catch (error) {\n console.error(error);\n throw new Error(\"FAILED\");\n }\n }\n\n throw new Error(\"INVALID\");\n}; // calculate smallest area to fit the contents in\n\nconst getCanvasSize = (elements, exportPadding) => {\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(elements);\n const width = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.distance)(minX, maxX) + exportPadding * 2;\n const height = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.distance)(minY, maxY) + exportPadding * 2;\n return [minX, minY, width, height];\n};\n\nconst getExportSize = (elements, exportPadding, scale) => {\n const [,, width, height] = getCanvasSize(elements, exportPadding).map(dimension => Math.trunc(dimension * scale));\n return [width, height];\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./scene/export.ts?");
22620
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeSvgBase64Payload: () => (/* binding */ decodeSvgBase64Payload),\n/* harmony export */ encodeSvgBase64Payload: () => (/* binding */ encodeSvgBase64Payload),\n/* harmony export */ exportToCanvas: () => (/* binding */ exportToCanvas),\n/* harmony export */ exportToSvg: () => (/* binding */ exportToSvg),\n/* harmony export */ getExportSize: () => (/* binding */ getExportSize)\n/* harmony export */ });\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\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 _appState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _data_encode__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../data/encode */ \"./data/encode.ts\");\n/* harmony import */ var _data_json__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../data/json */ \"./data/json.ts\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _renderer_staticScene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../renderer/staticScene */ \"./renderer/staticScene.ts\");\n/* harmony import */ var _renderer_staticSvgScene__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../renderer/staticSvgScene */ \"./renderer/staticSvgScene.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst truncateText = (element, maxWidth) => {\n if (element.width <= maxWidth) {\n return element;\n }\n\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n ctx.font = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getFontString)({\n fontFamily: element.fontFamily,\n fontSize: element.fontSize\n });\n let text = element.text;\n const metrics = ctx.measureText(text);\n\n if (metrics.width > maxWidth) {\n // we iterate from the right, removing characters one by one instead\n // of bulding the string up. This assumes that it's more likely\n // your frame names will overflow by not that many characters\n // (if ever), so it sohuld be faster this way.\n for (let i = text.length; i > 0; i--) {\n const newText = `${text.slice(0, i)}...`;\n\n if (ctx.measureText(newText).width <= maxWidth) {\n text = newText;\n break;\n }\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.newElementWith)(element, {\n text,\n width: maxWidth\n });\n};\n/**\n * When exporting frames, we need to render frame labels which are currently\n * being rendered in DOM when editing. Adding the labels as regular text\n * elements seems like a simple hack. In the future we'll want to move to\n * proper canvas rendering, even within editor (instead of DOM).\n */\n\n\nconst addFrameLabelsAsTextElements = (elements, opts) => {\n var _a, _b, _c;\n\n const nextElements = [];\n\n for (const element of elements) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(element)) {\n let textElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.newTextElement)({\n x: element.x,\n y: element.y - _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameOffsetY,\n fontFamily: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY.Helvetica,\n fontSize: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameFontSize,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameLineHeight,\n strokeColor: (_c = (_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.frameColor) === null || _b === void 0 ? void 0 : _b.nameColor) !== null && _c !== void 0 ? _c : opts.exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.nameColorLightTheme,\n text: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getFrameLikeTitle)(element),\n rawText: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getFrameLikeTitle)(element) //zsviczian\n\n });\n textElement.y -= textElement.height;\n textElement = truncateText(textElement, element.width);\n nextElements.push(textElement);\n }\n\n nextElements.push(element);\n }\n\n return nextElements;\n};\n\nconst getFrameRenderingConfig = (exportingFrame, frameRendering) => {\n frameRendering = frameRendering || (0,_appState__WEBPACK_IMPORTED_MODULE_3__.getDefaultAppState)().frameRendering;\n return {\n enabled: exportingFrame ? true : frameRendering.enabled,\n outline: exportingFrame ? false : frameRendering.outline,\n name: exportingFrame ? false : frameRendering.name,\n clip: exportingFrame ? true : frameRendering.clip,\n markerName: false,\n //zsviczian\n markerEnabled: false //zsviczian\n\n };\n};\n\nconst prepareElementsForRender = ({\n elements,\n exportingFrame,\n frameRendering,\n exportWithDarkMode\n}) => {\n let nextElements;\n\n if (exportingFrame) {\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getElementsOverlappingFrame)(elements, exportingFrame, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(elements));\n } else if (frameRendering.enabled && frameRendering.name) {\n nextElements = addFrameLabelsAsTextElements(elements, {\n exportWithDarkMode\n });\n } else {\n nextElements = elements;\n }\n\n return nextElements;\n};\n\nconst exportToCanvas = async (elements, appState, files, {\n exportBackground,\n exportPadding = _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_EXPORT_PADDING,\n viewBackgroundColor,\n exportingFrame\n}, createCanvas = (width, height) => {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width * appState.exportScale;\n canvas.height = height * appState.exportScale;\n return {\n canvas,\n scale: appState.exportScale\n };\n}, loadFonts = async () => {\n await _fonts__WEBPACK_IMPORTED_MODULE_6__.Fonts.loadElementsFonts(elements);\n}) => {\n var _a; // load font faces before continuing, by default leverages browsers' [FontFace API](https://developer.mozilla.org/en-US/docs/Web/API/FontFace)\n\n\n await loadFonts();\n const frameRendering = getFrameRenderingConfig(exportingFrame !== null && exportingFrame !== void 0 ? exportingFrame : null, (_a = appState.frameRendering) !== null && _a !== void 0 ? _a : null); // for canvas export, don't clip if exporting a specific frame as it would\n // clip the corners of the content\n\n if (exportingFrame) {\n frameRendering.clip = false;\n }\n\n const filteredElements = elements.filter(el => !(el.type === \"frame\" && el.frameRole === \"marker\")); //zsviczian\n\n const elementsForRender = prepareElementsForRender({\n elements: filteredElements,\n //zsviczian\n exportingFrame,\n exportWithDarkMode: appState.exportWithDarkMode,\n frameRendering\n });\n\n if (exportingFrame) {\n exportPadding = 0;\n }\n\n const [minX, minY, width, height] = getCanvasSize(exportingFrame ? [exportingFrame] : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getRootElements)(elementsForRender), exportPadding);\n const {\n canvas,\n scale = 1\n } = createCanvas(width, height);\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_3__.getDefaultAppState)();\n const {\n imageCache\n } = await (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateImageCache)({\n imageCache: new Map(),\n fileIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getInitializedImageElements)(elementsForRender).map(element => element.fileId),\n files\n });\n (0,_renderer_staticScene__WEBPACK_IMPORTED_MODULE_7__.renderStaticScene)({\n canvas,\n rc: roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].canvas(canvas),\n elementsMap: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toBrandedType)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(elementsForRender)),\n allElementsMap: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toBrandedType)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.syncInvalidIndices)(elements))),\n visibleElements: elementsForRender,\n scale,\n appState: Object.assign(Object.assign({}, appState), {\n frameRendering,\n viewBackgroundColor: exportBackground ? viewBackgroundColor : null,\n scrollX: -minX + exportPadding,\n scrollY: -minY + exportPadding,\n zoom: defaultAppState.zoom,\n shouldCacheIgnoreZoom: false,\n theme: appState.exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT\n }),\n renderConfig: {\n canvasBackgroundColor: viewBackgroundColor,\n imageCache,\n renderGrid: false,\n isExporting: true,\n // empty disables embeddable rendering\n embedsValidationStatus: new Map(),\n elementsPendingErasure: new Set(),\n pendingFlowchartNodes: null,\n theme: appState.exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT\n }\n });\n return canvas;\n};\n\nconst createHTMLComment = text => {\n // surrounding with spaces to maintain prettified consistency with previous\n // iterations\n // <!-- comment -->\n return document.createComment(` ${text} `);\n};\n\nconst exportToSvg = async (elements, appState, files, opts) => {\n var _a, _b, _c, _d;\n\n const frameRendering = getFrameRenderingConfig((_a = opts === null || opts === void 0 ? void 0 : opts.exportingFrame) !== null && _a !== void 0 ? _a : null, (_b = appState.frameRendering) !== null && _b !== void 0 ? _b : null);\n let {\n exportPadding = _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_EXPORT_PADDING,\n exportWithDarkMode = false,\n viewBackgroundColor,\n exportScale = 1,\n exportEmbedScene\n } = appState;\n const {\n exportingFrame = null\n } = opts || {};\n const filteredElements = elements.filter(el => !(el.type === \"frame\" && el.frameRole === \"marker\")); //zsviczian\n\n const elementsForRender = prepareElementsForRender({\n elements: filteredElements,\n //zsviczian\n exportingFrame,\n exportWithDarkMode,\n frameRendering\n });\n\n if (exportingFrame) {\n exportPadding = 0;\n }\n\n const [minX, minY, width, height] = getCanvasSize(exportingFrame ? [exportingFrame] : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getRootElements)(elementsForRender), exportPadding);\n const offsetX = -minX + exportPadding;\n const offsetY = -minY + exportPadding; // ---------------------------------------------------------------------------\n // initialize SVG root element\n // ---------------------------------------------------------------------------\n\n const svgRoot = document.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"svg\");\n svgRoot.setAttribute(\"version\", \"1.1\");\n svgRoot.setAttribute(\"xmlns\", _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS);\n svgRoot.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n svgRoot.setAttribute(\"width\", `${width * exportScale}`);\n svgRoot.setAttribute(\"height\", `${height * exportScale}`);\n const defsElement = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"defs\");\n const metadataElement = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"metadata\");\n svgRoot.appendChild(createHTMLComment(\"svg-source:excalidraw\"));\n svgRoot.appendChild(metadataElement);\n svgRoot.appendChild(defsElement); // ---------------------------------------------------------------------------\n // scene embed\n // ---------------------------------------------------------------------------\n // we need to serialize the \"original\" elements before we put them through\n // the tempScene hack which duplicates and regenerates ids\n\n if (exportEmbedScene) {\n try {\n encodeSvgBase64Payload({\n metadataElement,\n // when embedding scene, we want to embed the origionally supplied\n // elements which don't contain the temp frame labels.\n // But it also requires that the exportToSvg is being supplied with\n // only the elements that we're exporting, and no extra.\n payload: (0,_data_json__WEBPACK_IMPORTED_MODULE_5__.serializeAsJSON)(filteredElements, appState, files || {}, \"local\") //zsviczian\n\n });\n } catch (error) {\n console.error(error);\n }\n } // ---------------------------------------------------------------------------\n // frame clip paths\n // ---------------------------------------------------------------------------\n\n\n const frameElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getFrameLikeElements)(filteredElements); //zsviczian\n\n if (frameElements.length) {\n const elementsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(filteredElements); //zsviczian\n\n for (const frame of frameElements) {\n const clipPath = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"clipPath\");\n clipPath.setAttribute(\"id\", frame.id);\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getElementAbsoluteCoords)(frame, elementsMap);\n const cx = (x2 - x1) / 2 - (frame.x - x1);\n const cy = (y2 - y1) / 2 - (frame.y - y1);\n const rect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"rect\");\n rect.setAttribute(\"transform\", `translate(${frame.x + offsetX} ${frame.y + offsetY}) rotate(${frame.angle} ${cx} ${cy})`);\n rect.setAttribute(\"width\", `${frame.width}`);\n rect.setAttribute(\"height\", `${frame.height}`);\n\n if (!exportingFrame) {\n rect.setAttribute(\"rx\", `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.radius}`);\n rect.setAttribute(\"ry\", `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.FRAME_STYLE.radius}`);\n }\n\n clipPath.appendChild(rect);\n defsElement.appendChild(clipPath);\n }\n } // ---------------------------------------------------------------------------\n // inline font faces\n // ---------------------------------------------------------------------------\n\n\n const fontFaces = !(opts === null || opts === void 0 ? void 0 : opts.skipInliningFonts) ? await _fonts__WEBPACK_IMPORTED_MODULE_6__.Fonts.generateFontFaceDeclarations(elements) : [];\n const delimiter = \"\\n \"; // 6 spaces\n\n const style = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"style\");\n style.classList.add(\"style-fonts\");\n style.appendChild(document.createTextNode(`${delimiter}${fontFaces.join(delimiter)}`));\n defsElement.appendChild(style); // ---------------------------------------------------------------------------\n // background\n // ---------------------------------------------------------------------------\n // render background rect\n\n if (appState.exportBackground && viewBackgroundColor) {\n const rect = svgRoot.ownerDocument.createElementNS(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.SVG_NS, \"rect\");\n rect.setAttribute(\"x\", \"0\");\n rect.setAttribute(\"y\", \"0\");\n rect.setAttribute(\"width\", `${width}`);\n rect.setAttribute(\"height\", `${height}`);\n rect.setAttribute(\"fill\", (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.applyDarkModeFilter)(viewBackgroundColor, exportWithDarkMode));\n svgRoot.appendChild(rect);\n } // ---------------------------------------------------------------------------\n // render elements\n // ---------------------------------------------------------------------------\n\n\n const rsvg = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_0__[\"default\"].svg(svgRoot);\n const renderEmbeddables = (_c = opts === null || opts === void 0 ? void 0 : opts.renderEmbeddables) !== null && _c !== void 0 ? _c : false;\n (0,_renderer_staticSvgScene__WEBPACK_IMPORTED_MODULE_8__.renderSceneToSvg)(elementsForRender, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toBrandedType)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(elementsForRender)), rsvg, svgRoot, files || {}, {\n offsetX,\n offsetY,\n isExporting: true,\n exportWithDarkMode,\n renderEmbeddables,\n frameRendering,\n frameColor: appState.frameColor,\n //zsviczian\n canvasBackgroundColor: viewBackgroundColor,\n embedsValidationStatus: renderEmbeddables ? new Map(elementsForRender.filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(element)).map(element => [element.id, true])) : new Map(),\n reuseImages: (_d = opts === null || opts === void 0 ? void 0 : opts.reuseImages) !== null && _d !== void 0 ? _d : true,\n theme: exportWithDarkMode ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT\n }); // ---------------------------------------------------------------------------\n\n return svgRoot;\n};\nconst encodeSvgBase64Payload = ({\n payload,\n metadataElement\n}) => {\n const base64 = (0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.stringToBase64)(JSON.stringify((0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.encode)({\n text: payload\n })), true\n /* is already byte string */\n );\n metadataElement.appendChild(createHTMLComment(`payload-type:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.MIME_TYPES.excalidraw}`));\n metadataElement.appendChild(createHTMLComment(\"payload-version:2\"));\n metadataElement.appendChild(createHTMLComment(\"payload-start\"));\n metadataElement.appendChild(document.createTextNode(base64));\n metadataElement.appendChild(createHTMLComment(\"payload-end\"));\n};\nconst decodeSvgBase64Payload = ({\n svg\n}) => {\n if (svg.includes(`payload-type:${_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.MIME_TYPES.excalidraw}`)) {\n const match = svg.match(/<!-- payload-start -->\\s*(.+?)\\s*<!-- payload-end -->/);\n\n if (!match) {\n throw new Error(\"INVALID\");\n }\n\n const versionMatch = svg.match(/<!-- payload-version:(\\d+) -->/);\n const version = (versionMatch === null || versionMatch === void 0 ? void 0 : versionMatch[1]) || \"1\";\n const isByteString = version !== \"1\";\n\n try {\n const json = (0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.base64ToString)(match[1], isByteString);\n const encodedData = JSON.parse(json);\n\n if (!(\"encoded\" in encodedData)) {\n // legacy, un-encoded scene JSON\n if (\"type\" in encodedData && encodedData.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EXPORT_DATA_TYPES.excalidraw) {\n return json;\n }\n\n throw new Error(\"FAILED\");\n }\n\n return (0,_data_encode__WEBPACK_IMPORTED_MODULE_4__.decode)(encodedData);\n } catch (error) {\n console.error(error);\n throw new Error(\"FAILED\");\n }\n }\n\n throw new Error(\"INVALID\");\n}; // calculate smallest area to fit the contents in\n\nconst getCanvasSize = (elements, exportPadding) => {\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(elements);\n const width = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.distance)(minX, maxX) + exportPadding * 2;\n const height = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.distance)(minY, maxY) + exportPadding * 2;\n return [minX, minY, width, height];\n};\n\nconst getExportSize = (elements, exportPadding, scale) => {\n const [,, width, height] = getCanvasSize(elements, exportPadding).map(dimension => Math.trunc(dimension * scale));\n return [width, height];\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./scene/export.ts?");
22621
22621
 
22622
22622
  /***/ }),
22623
22623
 
@@ -22836,7 +22836,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22836
22836
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
22837
22837
 
22838
22838
  "use strict";
22839
- 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_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/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 _actions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n\n\n\n\n\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 getLineDirection = (text, offset) => {\n const hardLineStart = text.lastIndexOf(\"\\n\", Math.max(0, offset - 1)) + 1;\n const hardLineEnd = text.indexOf(\"\\n\", offset);\n const hardLineText = text.slice(hardLineStart, hardLineEnd === -1 ? text.length : hardLineEnd);\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isRTL)(hardLineText) ? \"rtl\" : \"ltr\";\n};\n\nconst getCaretBoundaryOffsets = text => {\n const offsets = [0];\n let offset = 0;\n\n for (const char of Array.from(text)) {\n offset += char.length;\n offsets.push(offset);\n }\n\n return offsets;\n};\n\nconst getLineCaretOffsetFromNativeLayout = ({\n text,\n font,\n lineHeightPx,\n direction,\n targetX\n}) => {\n if (!text || !document.body || typeof document.createRange !== \"function\") {\n return null;\n }\n\n const offsets = getCaretBoundaryOffsets(text);\n const mirror = document.createElement(\"div\");\n const textNode = document.createTextNode(text);\n const range = document.createRange();\n const positions = [];\n mirror.dir = direction;\n Object.assign(mirror.style, {\n position: \"fixed\",\n top: \"0\",\n left: \"0\",\n margin: 0,\n padding: 0,\n border: 0,\n opacity: \"0\",\n pointerEvents: \"none\",\n whiteSpace: \"pre\",\n font,\n lineHeight: `${lineHeightPx}px`\n });\n mirror.append(textNode);\n document.body.append(mirror);\n\n try {\n for (const offset of offsets) {\n range.setStart(textNode, offset);\n range.setEnd(textNode, offset);\n const caretRect = range.getBoundingClientRect();\n\n if (!Number.isFinite(caretRect.left)) {\n return null;\n }\n\n positions.push(caretRect.left);\n }\n } catch (_a) {\n return null;\n } finally {\n mirror.remove();\n }\n\n const leftEdge = Math.min(...positions);\n let closestOffset = offsets[0];\n let closestDistance = Infinity;\n\n for (let index = 0; index < offsets.length; index++) {\n const distance = Math.abs(positions[index] - leftEdge - targetX);\n\n if (distance < closestDistance) {\n closestDistance = distance;\n closestOffset = offsets[index];\n }\n }\n\n return closestOffset;\n};\n\nconst textWysiwyg = ({\n id,\n onChange,\n onSubmit,\n getViewportCoords,\n element,\n canvas,\n excalidrawContainer,\n app,\n autoSelect = true,\n initialCaretSceneCoords = null\n}) => {\n let currentTextLayout = null;\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 let LAST_THEME = app.state.theme;\n\n const updateWysiwygStyle = () => {\n LAST_THEME = app.state.theme;\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__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(updatedTextElement)) {\n let coordX = updatedTextElement.x;\n let coordY = updatedTextElement.y;\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container)) {\n const boundTextCoords = _excalidraw_element__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__WEBPACK_IMPORTED_MODULE_2__.updateOriginalContainerCache)(container.id, container.height);\n } else {\n originalContainerData = _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.originalContainerCache[container.id];\n\n if (!originalContainerData) {\n originalContainerData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateOriginalContainerCache)(container.id, container.height);\n }\n }\n\n maxWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getBoundTextMaxWidth)(container, updatedTextElement);\n maxHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getBoundTextMaxHeight)(container, updatedTextElement); // autogrow container height if text exceeds\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container) && height > maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateBoundElements)(container, app.scene);\n return;\n } else if ( // autoshrink container height until original container height\n // is reached when text is removed\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container) && container.height > originalContainerData.height && height < maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateBoundElements)(container, app.scene);\n } else {\n const {\n x,\n y\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.computeBoundTextPosition)(container, updatedTextElement, elementsMap);\n coordX = x;\n coordY = y;\n }\n }\n\n const [viewportX, viewportY] = getViewportCoords(coordX, coordY);\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);\n const angle = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getTextElementAngle)(updatedTextElement, container); // 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 //zsviczian Obsidian app zoom !== 100% issue, floor due to screen shift\n height: `${height}px`,\n left: `${viewportX}px`,\n top: `${viewportY}px`,\n transform: getTransform(width, height, angle, appState, maxWidth, editorMaxHeight),\n textAlign,\n verticalAlign,\n color: appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(updatedTextElement.strokeColor) : updatedTextElement.strokeColor,\n opacity: updatedTextElement.opacity / 100,\n maxHeight: `${editorMaxHeight}px`,\n caretColor: updatedTextElement.strokeColor === \"transparent\" //zsviczian\n ? \"var(--excalidraw-caret-color)\" : appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(updatedTextElement.strokeColor) : updatedTextElement.strokeColor //zsviczian Set caret color\n\n });\n currentTextLayout = {\n angle: angle,\n font,\n height: updatedTextElement.height,\n lineHeightPx: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getLineHeightInPx)(updatedTextElement.fontSize, updatedTextElement.lineHeight),\n textAlign,\n width: updatedTextElement.width,\n x: coordX,\n y: coordY\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 (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_7__.attachInlineLinkSuggester)(editable, undefined, excalidrawContainer); //zsviczian\n\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__WEBPACK_IMPORTED_MODULE_2__.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 const getCaretIndexFromInitialSceneCoords = () => {\n if (!initialCaretSceneCoords || !currentTextLayout) {\n return null;\n }\n\n const layout = currentTextLayout;\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(layout.x + layout.width / 2, layout.y + layout.height / 2);\n const [unrotatedX, unrotatedY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(initialCaretSceneCoords.x, initialCaretSceneCoords.y), center, -layout.angle);\n const localX = unrotatedX - layout.x;\n const localY = unrotatedY - layout.y;\n const lines = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getWrappedTextLines)(editable.value, layout.font, whiteSpace === \"pre-wrap\" ? layout.width : Infinity);\n const lineIndex = Math.max(0, Math.min(lines.length - 1, Math.floor(localY / layout.lineHeightPx)));\n const line = lines[lineIndex];\n const direction = getLineDirection(editable.value, line.start);\n const lineWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getLineWidth)(line.text, layout.font);\n const lineStartX = layout.textAlign === \"center\" ? (layout.width - lineWidth) / 2 : layout.textAlign === \"right\" ? layout.width - lineWidth : 0;\n const relativeX = localX - lineStartX;\n\n if (!line.text) {\n return line.start;\n }\n\n const lineCaretOffset = getLineCaretOffsetFromNativeLayout({\n text: line.text,\n font: layout.font,\n lineHeightPx: layout.lineHeightPx,\n direction,\n targetX: relativeX\n });\n return line.start + (lineCaretOffset || 0);\n };\n\n let pendingInitialSelection = (() => {\n const caretIndex = getCaretIndexFromInitialSceneCoords();\n\n if (caretIndex === null) {\n return null;\n }\n\n return {\n start: caretIndex,\n end: caretIndex\n };\n })();\n\n if (onChange) {\n editable.onpaste = async event => {\n // we need to synchronously get the MIME types so we can preventDefault()\n // in the same tick (FF requires that)\n const mimeTypes = (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseDataTransferEventMimeTypes)(event);\n let dataList = null; // when copy/pasting excalidraw elements, only paste the text content\n //\n // Note that these custom MIME types only work within the same family\n // of browsers, so won't work e.g. between chrome and firefox. We could\n // parse the text/plain for existence of excalidraw instead, but this\n // is an edge case\n\n if (mimeTypes.has(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.excalidrawClipboard) || mimeTypes.has(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.excalidraw)) {\n // must be called in the same tick\n event.preventDefault();\n dataList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseDataTransferEvent)(event);\n\n try {\n const parsed = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseClipboard)(dataList);\n\n if (parsed.elements) {\n const text = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getTextFromElements)(parsed.elements);\n\n if (text) {\n const {\n selectionStart,\n selectionEnd,\n value\n } = editable;\n editable.value = value.slice(0, selectionStart) + text + value.slice(selectionEnd);\n const newPos = selectionStart + text.length;\n editable.selectionStart = editable.selectionEnd = newPos;\n editable.dispatchEvent(new Event(\"input\"));\n }\n } // if excalidraw elements don't contain any text elements,\n // don't paste anything\n\n\n return;\n } catch (_a) {\n console.warn(\"failed to parse excalidraw clipboard data\");\n }\n }\n\n dataList = dataList || (await (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseDataTransferEvent)(event));\n const textItem = dataList.findByType(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.text);\n\n if (!textItem) {\n return;\n }\n\n const text = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.normalizeText)(textItem.value);\n\n if (!text) {\n return;\n }\n\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.getBoundTextElement)(container, app.scene.getNonDeletedElementsMap());\n const wrappedText = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.wrapText)(`${editable.value}${text}`, font, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getBoundTextMaxWidth)(container, boundTextElement));\n const width = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.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_6__.actionZoomIn.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionZoomIn);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionZoomOut.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionZoomOut);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionResetZoom.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionResetZoom);\n updateWysiwygStyle();\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.actionDecreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.actionDecreaseFontSize);\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.actionIncreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.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_3__.actionSaveToActiveFile.keyTest(event)) {\n event.preventDefault();\n handleSubmit();\n app.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_3__.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 /**\n * @returns indices of start positions of selected lines, in reverse order\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__WEBPACK_IMPORTED_MODULE_2__.getContainerElement)(updateElement, app.scene.getNonDeletedElementsMap());\n\n if (container) {\n if (editable.value.trim()) {\n const boundTextElementId = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container)) {\n // updating an arrow label may change bounds, prevent stale cache:\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(ele))\n });\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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 unsubOnChange();\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 const isPropertiesContent = (target instanceof HTMLElement || target instanceof SVGElement) && !!target.closest(\".properties-content\");\n const inShapeActionsMenu = (target instanceof HTMLElement || target instanceof SVGElement) && (!!target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MENU}`) || !!target.closest(\".compact-shape-actions-island\"));\n setTimeout(() => {\n // If we interacted within shape actions menu or its popovers/triggers,\n // keep submit disabled and don't steal focus back to textarea.\n if (inShapeActionsMenu || isPropertiesTrigger || isPropertiesContent) {\n return;\n } // Otherwise, re-enable submit on blur and refocus the editor.\n\n\n editable.onblur = handleSubmit;\n editable.focus();\n\n if (pendingInitialSelection) {\n editable.setSelectionRange(pendingInitialSelection.start, pendingInitialSelection.end);\n pendingInitialSelection = null;\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.SHAPE_ACTIONS_TRAY_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 const isPropertiesContent = (target instanceof HTMLElement || target instanceof SVGElement) && !!target.closest(\".properties-content\");\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}`) || event.target.closest(\".compact-shape-actions-island\")) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isWritableElement)(event.target) || isPropertiesTrigger || isPropertiesContent) {\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 }; // FIXME after we start emitting updates from Store for appState.theme\n\n\n const unsubOnChange = app.onChangeEmitter.on(elements => {\n if (app.state.theme !== LAST_THEME) {\n updateWysiwygStyle();\n }\n }); // handle updates of textElement properties of editing element\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 && !pendingInitialSelection) {\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?");
22839
+ 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_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/math */ \"../math/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 _actions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n\n\n\n\n\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 getLineDirection = (text, offset) => {\n const hardLineStart = text.lastIndexOf(\"\\n\", Math.max(0, offset - 1)) + 1;\n const hardLineEnd = text.indexOf(\"\\n\", offset);\n const hardLineText = text.slice(hardLineStart, hardLineEnd === -1 ? text.length : hardLineEnd);\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isRTL)(hardLineText) ? \"rtl\" : \"ltr\";\n};\n\nconst getCaretBoundaryOffsets = text => {\n const offsets = [0];\n let offset = 0;\n\n for (const char of Array.from(text)) {\n offset += char.length;\n offsets.push(offset);\n }\n\n return offsets;\n};\n\nconst getLineCaretOffsetFromNativeLayout = ({\n text,\n font,\n lineHeightPx,\n direction,\n targetX\n}) => {\n if (!text || !document.body || typeof document.createRange !== \"function\") {\n return null;\n }\n\n const offsets = getCaretBoundaryOffsets(text);\n const mirror = document.createElement(\"div\");\n const textNode = document.createTextNode(text);\n const range = document.createRange();\n const positions = [];\n mirror.dir = direction;\n Object.assign(mirror.style, {\n position: \"fixed\",\n top: \"0\",\n left: \"0\",\n margin: 0,\n padding: 0,\n border: 0,\n opacity: \"0\",\n pointerEvents: \"none\",\n whiteSpace: \"pre\",\n font,\n lineHeight: `${lineHeightPx}px`\n });\n mirror.append(textNode);\n document.body.append(mirror);\n\n try {\n for (const offset of offsets) {\n range.setStart(textNode, offset);\n range.setEnd(textNode, offset);\n const caretRect = range.getBoundingClientRect();\n\n if (!Number.isFinite(caretRect.left)) {\n return null;\n }\n\n positions.push(caretRect.left);\n }\n } catch (_a) {\n return null;\n } finally {\n mirror.remove();\n }\n\n const leftEdge = Math.min(...positions);\n let closestOffset = offsets[0];\n let closestDistance = Infinity;\n\n for (let index = 0; index < offsets.length; index++) {\n const distance = Math.abs(positions[index] - leftEdge - targetX);\n\n if (distance < closestDistance) {\n closestDistance = distance;\n closestOffset = offsets[index];\n }\n }\n\n return closestOffset;\n};\n\nconst textWysiwyg = ({\n id,\n onChange,\n onSubmit,\n getViewportCoords,\n element,\n canvas,\n excalidrawContainer,\n app,\n autoSelect = true,\n initialCaretSceneCoords = null\n}) => {\n let currentTextLayout = null;\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 let LAST_THEME = app.state.theme;\n\n const updateWysiwygStyle = () => {\n LAST_THEME = app.state.theme;\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__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(updatedTextElement)) {\n let coordX = updatedTextElement.x;\n let coordY = updatedTextElement.y;\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container)) {\n const boundTextCoords = _excalidraw_element__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__WEBPACK_IMPORTED_MODULE_2__.updateOriginalContainerCache)(container.id, container.height);\n } else {\n originalContainerData = _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.originalContainerCache[container.id];\n\n if (!originalContainerData) {\n originalContainerData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateOriginalContainerCache)(container.id, container.height);\n }\n }\n\n maxWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getBoundTextMaxWidth)(container, updatedTextElement);\n maxHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getBoundTextMaxHeight)(container, updatedTextElement); // autogrow container height if text exceeds\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container) && height > maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateBoundElements)(container, app.scene);\n return;\n } else if ( // autoshrink container height until original container height\n // is reached when text is removed\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container) && container.height > originalContainerData.height && height < maxHeight) {\n const targetContainerHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.computeContainerDimensionForBoundText)(height, container.type);\n app.scene.mutateElement(container, {\n height: targetContainerHeight\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.updateBoundElements)(container, app.scene);\n } else {\n const {\n x,\n y\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.computeBoundTextPosition)(container, updatedTextElement, elementsMap);\n coordX = x;\n coordY = y;\n }\n }\n\n const [viewportX, viewportY] = getViewportCoords(coordX, coordY);\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);\n const angle = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getTextElementAngle)(updatedTextElement, container); // 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 //zsviczian Obsidian app zoom !== 100% issue, floor due to screen shift\n height: `${height}px`,\n left: `${viewportX}px`,\n top: `${viewportY}px`,\n transform: getTransform(width, height, angle, appState, maxWidth, editorMaxHeight),\n textAlign,\n verticalAlign,\n color: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(updatedTextElement.strokeColor, appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK),\n opacity: updatedTextElement.opacity / 100,\n maxHeight: `${editorMaxHeight}px`,\n caretColor: updatedTextElement.strokeColor === \"transparent\" //zsviczian\n ? \"var(--excalidraw-caret-color)\" : appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.THEME.DARK ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.applyDarkModeFilter)(updatedTextElement.strokeColor) : updatedTextElement.strokeColor //zsviczian Set caret color\n\n });\n currentTextLayout = {\n angle: angle,\n font,\n height: updatedTextElement.height,\n lineHeightPx: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getLineHeightInPx)(updatedTextElement.fontSize, updatedTextElement.lineHeight),\n textAlign,\n width: updatedTextElement.width,\n x: coordX,\n y: coordY\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 (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_7__.attachInlineLinkSuggester)(editable, undefined, excalidrawContainer); //zsviczian\n\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__WEBPACK_IMPORTED_MODULE_2__.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 const getCaretIndexFromInitialSceneCoords = () => {\n if (!initialCaretSceneCoords || !currentTextLayout) {\n return null;\n }\n\n const layout = currentTextLayout;\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(layout.x + layout.width / 2, layout.y + layout.height / 2);\n const [unrotatedX, unrotatedY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_1__.pointFrom)(initialCaretSceneCoords.x, initialCaretSceneCoords.y), center, -layout.angle);\n const localX = unrotatedX - layout.x;\n const localY = unrotatedY - layout.y;\n const lines = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getWrappedTextLines)(editable.value, layout.font, whiteSpace === \"pre-wrap\" ? layout.width : Infinity);\n const lineIndex = Math.max(0, Math.min(lines.length - 1, Math.floor(localY / layout.lineHeightPx)));\n const line = lines[lineIndex];\n const direction = getLineDirection(editable.value, line.start);\n const lineWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getLineWidth)(line.text, layout.font);\n const lineStartX = layout.textAlign === \"center\" ? (layout.width - lineWidth) / 2 : layout.textAlign === \"right\" ? layout.width - lineWidth : 0;\n const relativeX = localX - lineStartX;\n\n if (!line.text) {\n return line.start;\n }\n\n const lineCaretOffset = getLineCaretOffsetFromNativeLayout({\n text: line.text,\n font: layout.font,\n lineHeightPx: layout.lineHeightPx,\n direction,\n targetX: relativeX\n });\n return line.start + (lineCaretOffset || 0);\n };\n\n let pendingInitialSelection = (() => {\n const caretIndex = getCaretIndexFromInitialSceneCoords();\n\n if (caretIndex === null) {\n return null;\n }\n\n return {\n start: caretIndex,\n end: caretIndex\n };\n })();\n\n if (onChange) {\n editable.onpaste = async event => {\n // we need to synchronously get the MIME types so we can preventDefault()\n // in the same tick (FF requires that)\n const mimeTypes = (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseDataTransferEventMimeTypes)(event);\n let dataList = null; // when copy/pasting excalidraw elements, only paste the text content\n //\n // Note that these custom MIME types only work within the same family\n // of browsers, so won't work e.g. between chrome and firefox. We could\n // parse the text/plain for existence of excalidraw instead, but this\n // is an edge case\n\n if (mimeTypes.has(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.excalidrawClipboard) || mimeTypes.has(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.excalidraw)) {\n // must be called in the same tick\n event.preventDefault();\n dataList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseDataTransferEvent)(event);\n\n try {\n const parsed = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseClipboard)(dataList);\n\n if (parsed.elements) {\n const text = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getTextFromElements)(parsed.elements);\n\n if (text) {\n const {\n selectionStart,\n selectionEnd,\n value\n } = editable;\n editable.value = value.slice(0, selectionStart) + text + value.slice(selectionEnd);\n const newPos = selectionStart + text.length;\n editable.selectionStart = editable.selectionEnd = newPos;\n editable.dispatchEvent(new Event(\"input\"));\n }\n } // if excalidraw elements don't contain any text elements,\n // don't paste anything\n\n\n return;\n } catch (_a) {\n console.warn(\"failed to parse excalidraw clipboard data\");\n }\n }\n\n dataList = dataList || (await (0,_clipboard__WEBPACK_IMPORTED_MODULE_4__.parseDataTransferEvent)(event));\n const textItem = dataList.findByType(_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.MIME_TYPES.text);\n\n if (!textItem) {\n return;\n }\n\n const text = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.normalizeText)(textItem.value);\n\n if (!text) {\n return;\n }\n\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.getBoundTextElement)(container, app.scene.getNonDeletedElementsMap());\n const wrappedText = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.wrapText)(`${editable.value}${text}`, font, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getBoundTextMaxWidth)(container, boundTextElement));\n const width = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.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_6__.actionZoomIn.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionZoomIn);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionZoomOut.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionZoomOut);\n updateWysiwygStyle();\n } else if (!event.shiftKey && _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionResetZoom.keyTest(event)) {\n event.preventDefault();\n app.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_6__.actionResetZoom);\n updateWysiwygStyle();\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.actionDecreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.actionDecreaseFontSize);\n } else if (_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.actionIncreaseFontSize.keyTest(event)) {\n app.actionManager.executeAction(_actions_actionProperties__WEBPACK_IMPORTED_MODULE_5__.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_3__.actionSaveToActiveFile.keyTest(event)) {\n event.preventDefault();\n handleSubmit();\n app.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_3__.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 /**\n * @returns indices of start positions of selected lines, in reverse order\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__WEBPACK_IMPORTED_MODULE_2__.getContainerElement)(updateElement, app.scene.getNonDeletedElementsMap());\n\n if (container) {\n if (editable.value.trim()) {\n const boundTextElementId = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.isArrowElement)(container)) {\n // updating an arrow label may change bounds, prevent stale cache:\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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__WEBPACK_IMPORTED_MODULE_2__.isTextElement)(ele))\n });\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.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 unsubOnChange();\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 const isPropertiesContent = (target instanceof HTMLElement || target instanceof SVGElement) && !!target.closest(\".properties-content\");\n const inShapeActionsMenu = (target instanceof HTMLElement || target instanceof SVGElement) && (!!target.closest(`.${_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.CLASSES.SHAPE_ACTIONS_MENU}`) || !!target.closest(\".compact-shape-actions-island\"));\n setTimeout(() => {\n // If we interacted within shape actions menu or its popovers/triggers,\n // keep submit disabled and don't steal focus back to textarea.\n if (inShapeActionsMenu || isPropertiesTrigger || isPropertiesContent) {\n return;\n } // Otherwise, re-enable submit on blur and refocus the editor.\n\n\n editable.onblur = handleSubmit;\n editable.focus();\n\n if (pendingInitialSelection) {\n editable.setSelectionRange(pendingInitialSelection.start, pendingInitialSelection.end);\n pendingInitialSelection = null;\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.SHAPE_ACTIONS_TRAY_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 const isPropertiesContent = (target instanceof HTMLElement || target instanceof SVGElement) && !!target.closest(\".properties-content\");\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}`) || event.target.closest(\".compact-shape-actions-island\")) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.isWritableElement)(event.target) || isPropertiesTrigger || isPropertiesContent) {\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 }; // FIXME after we start emitting updates from Store for appState.theme\n\n\n const unsubOnChange = app.onChangeEmitter.on(elements => {\n if (app.state.theme !== LAST_THEME) {\n updateWysiwygStyle();\n }\n }); // handle updates of textElement properties of editing element\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 && !pendingInitialSelection) {\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?");
22840
22840
 
22841
22841
  /***/ }),
22842
22842