@zsviczian/excalidraw 0.18.0-26 → 0.18.0-27

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.
@@ -8330,7 +8330,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
8330
8330
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8331
8331
 
8332
8332
  "use strict";
8333
- 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\nlet FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;\nif (typeof process !== 'undefined') {\n\t({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = ({\"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:3015\",\"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\":\"3000\",\"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-25\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}) || 0);\n\tisTTY = process.stdout && process.stdout.isTTY;\n}\n\nconst $ = {\n\tenabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && (\n\t\tFORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY\n\t),\n\n\t// modifiers\n\treset: init(0, 0),\n\tbold: init(1, 22),\n\tdim: init(2, 22),\n\titalic: init(3, 23),\n\tunderline: init(4, 24),\n\tinverse: init(7, 27),\n\thidden: init(8, 28),\n\tstrikethrough: init(9, 29),\n\n\t// colors\n\tblack: init(30, 39),\n\tred: init(31, 39),\n\tgreen: init(32, 39),\n\tyellow: init(33, 39),\n\tblue: init(34, 39),\n\tmagenta: init(35, 39),\n\tcyan: init(36, 39),\n\twhite: init(37, 39),\n\tgray: init(90, 39),\n\tgrey: init(90, 39),\n\n\t// background colors\n\tbgBlack: init(40, 49),\n\tbgRed: init(41, 49),\n\tbgGreen: init(42, 49),\n\tbgYellow: init(43, 49),\n\tbgBlue: init(44, 49),\n\tbgMagenta: init(45, 49),\n\tbgCyan: init(46, 49),\n\tbgWhite: init(47, 49)\n};\n\nfunction run(arr, str) {\n\tlet i=0, tmp, beg='', end='';\n\tfor (; i < arr.length; i++) {\n\t\ttmp = arr[i];\n\t\tbeg += tmp.open;\n\t\tend += tmp.close;\n\t\tif (!!~str.indexOf(tmp.close)) {\n\t\t\tstr = str.replace(tmp.rgx, tmp.close + tmp.open);\n\t\t}\n\t}\n\treturn beg + str + end;\n}\n\nfunction chain(has, keys) {\n\tlet ctx = { has, keys };\n\n\tctx.reset = $.reset.bind(ctx);\n\tctx.bold = $.bold.bind(ctx);\n\tctx.dim = $.dim.bind(ctx);\n\tctx.italic = $.italic.bind(ctx);\n\tctx.underline = $.underline.bind(ctx);\n\tctx.inverse = $.inverse.bind(ctx);\n\tctx.hidden = $.hidden.bind(ctx);\n\tctx.strikethrough = $.strikethrough.bind(ctx);\n\n\tctx.black = $.black.bind(ctx);\n\tctx.red = $.red.bind(ctx);\n\tctx.green = $.green.bind(ctx);\n\tctx.yellow = $.yellow.bind(ctx);\n\tctx.blue = $.blue.bind(ctx);\n\tctx.magenta = $.magenta.bind(ctx);\n\tctx.cyan = $.cyan.bind(ctx);\n\tctx.white = $.white.bind(ctx);\n\tctx.gray = $.gray.bind(ctx);\n\tctx.grey = $.grey.bind(ctx);\n\n\tctx.bgBlack = $.bgBlack.bind(ctx);\n\tctx.bgRed = $.bgRed.bind(ctx);\n\tctx.bgGreen = $.bgGreen.bind(ctx);\n\tctx.bgYellow = $.bgYellow.bind(ctx);\n\tctx.bgBlue = $.bgBlue.bind(ctx);\n\tctx.bgMagenta = $.bgMagenta.bind(ctx);\n\tctx.bgCyan = $.bgCyan.bind(ctx);\n\tctx.bgWhite = $.bgWhite.bind(ctx);\n\n\treturn ctx;\n}\n\nfunction init(open, close) {\n\tlet blk = {\n\t\topen: `\\x1b[${open}m`,\n\t\tclose: `\\x1b[${close}m`,\n\t\trgx: new RegExp(`\\\\x1b\\\\[${close}m`, 'g')\n\t};\n\treturn function (txt) {\n\t\tif (this !== void 0 && this.has !== void 0) {\n\t\t\t!!~this.has.indexOf(open) || (this.has.push(open),this.keys.push(blk));\n\t\t\treturn txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';\n\t\t}\n\t\treturn txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';\n\t};\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ($);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/kleur/index.mjs?");
8333
+ 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\nlet FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;\nif (typeof process !== 'undefined') {\n\t({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = ({\"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:3015\",\"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\":\"3000\",\"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-26\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}) || 0);\n\tisTTY = process.stdout && process.stdout.isTTY;\n}\n\nconst $ = {\n\tenabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && (\n\t\tFORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY\n\t),\n\n\t// modifiers\n\treset: init(0, 0),\n\tbold: init(1, 22),\n\tdim: init(2, 22),\n\titalic: init(3, 23),\n\tunderline: init(4, 24),\n\tinverse: init(7, 27),\n\thidden: init(8, 28),\n\tstrikethrough: init(9, 29),\n\n\t// colors\n\tblack: init(30, 39),\n\tred: init(31, 39),\n\tgreen: init(32, 39),\n\tyellow: init(33, 39),\n\tblue: init(34, 39),\n\tmagenta: init(35, 39),\n\tcyan: init(36, 39),\n\twhite: init(37, 39),\n\tgray: init(90, 39),\n\tgrey: init(90, 39),\n\n\t// background colors\n\tbgBlack: init(40, 49),\n\tbgRed: init(41, 49),\n\tbgGreen: init(42, 49),\n\tbgYellow: init(43, 49),\n\tbgBlue: init(44, 49),\n\tbgMagenta: init(45, 49),\n\tbgCyan: init(46, 49),\n\tbgWhite: init(47, 49)\n};\n\nfunction run(arr, str) {\n\tlet i=0, tmp, beg='', end='';\n\tfor (; i < arr.length; i++) {\n\t\ttmp = arr[i];\n\t\tbeg += tmp.open;\n\t\tend += tmp.close;\n\t\tif (!!~str.indexOf(tmp.close)) {\n\t\t\tstr = str.replace(tmp.rgx, tmp.close + tmp.open);\n\t\t}\n\t}\n\treturn beg + str + end;\n}\n\nfunction chain(has, keys) {\n\tlet ctx = { has, keys };\n\n\tctx.reset = $.reset.bind(ctx);\n\tctx.bold = $.bold.bind(ctx);\n\tctx.dim = $.dim.bind(ctx);\n\tctx.italic = $.italic.bind(ctx);\n\tctx.underline = $.underline.bind(ctx);\n\tctx.inverse = $.inverse.bind(ctx);\n\tctx.hidden = $.hidden.bind(ctx);\n\tctx.strikethrough = $.strikethrough.bind(ctx);\n\n\tctx.black = $.black.bind(ctx);\n\tctx.red = $.red.bind(ctx);\n\tctx.green = $.green.bind(ctx);\n\tctx.yellow = $.yellow.bind(ctx);\n\tctx.blue = $.blue.bind(ctx);\n\tctx.magenta = $.magenta.bind(ctx);\n\tctx.cyan = $.cyan.bind(ctx);\n\tctx.white = $.white.bind(ctx);\n\tctx.gray = $.gray.bind(ctx);\n\tctx.grey = $.grey.bind(ctx);\n\n\tctx.bgBlack = $.bgBlack.bind(ctx);\n\tctx.bgRed = $.bgRed.bind(ctx);\n\tctx.bgGreen = $.bgGreen.bind(ctx);\n\tctx.bgYellow = $.bgYellow.bind(ctx);\n\tctx.bgBlue = $.bgBlue.bind(ctx);\n\tctx.bgMagenta = $.bgMagenta.bind(ctx);\n\tctx.bgCyan = $.bgCyan.bind(ctx);\n\tctx.bgWhite = $.bgWhite.bind(ctx);\n\n\treturn ctx;\n}\n\nfunction init(open, close) {\n\tlet blk = {\n\t\topen: `\\x1b[${open}m`,\n\t\tclose: `\\x1b[${close}m`,\n\t\trgx: new RegExp(`\\\\x1b\\\\[${close}m`, 'g')\n\t};\n\treturn function (txt) {\n\t\tif (this !== void 0 && this.has !== void 0) {\n\t\t\t!!~this.has.indexOf(open) || (this.has.push(open),this.keys.push(blk));\n\t\t\treturn txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';\n\t\t}\n\t\treturn txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';\n\t};\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ($);\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/kleur/index.mjs?");
8334
8334
 
8335
8335
  /***/ }),
8336
8336
 
@@ -12022,7 +12022,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
12022
12022
  \**********************************************************************/
12023
12023
  /***/ ((module, exports, __webpack_require__) => {
12024
12024
 
12025
- eval("/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = ({\"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:3015\",\"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\":\"3000\",\"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-25\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = __webpack_require__(/*! ./common */ \"../../node_modules/micromark/node_modules/debug/src/common.js\")(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/micromark/node_modules/debug/src/browser.js?");
12025
+ eval("/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = ({\"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:3015\",\"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\":\"3000\",\"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-26\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = __webpack_require__(/*! ./common */ \"../../node_modules/micromark/node_modules/debug/src/common.js\")(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/micromark/node_modules/debug/src/browser.js?");
12026
12026
 
12027
12027
  /***/ }),
12028
12028
 
@@ -13036,7 +13036,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
13036
13036
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
13037
13037
 
13038
13038
  "use strict";
13039
- 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 */ 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 */ getShortcutKey: () => (/* binding */ getShortcutKey),\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 */ isBindingFallthroughEnabled: () => (/* binding */ isBindingFallthroughEnabled),\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 */ isServerEnv: () => (/* binding */ isServerEnv),\n/* harmony export */ isShallowEqual: () => (/* binding */ isShallowEqual),\n/* harmony export */ isTestEnv: () => (/* binding */ isTestEnv),\n/* harmony export */ isToolIcon: () => (/* binding */ isToolIcon),\n/* harmony export */ isTransparent: () => (/* binding */ isTransparent),\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 */ normalizeEOL: () => (/* binding */ normalizeEOL),\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 */ 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 _colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colors */ \"../common/src/colors.ts\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants */ \"../common/src/constants.ts\");\n\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\");\nconst getFontFamilyString = ({\n fontFamily\n}) => {\n for (const [fontFamilyString, id] of Object.entries(_constants__WEBPACK_IMPORTED_MODULE_2__.FONT_FAMILY)) {\n if (id === fontFamily) {\n return `${fontFamilyString}${(0,_constants__WEBPACK_IMPORTED_MODULE_2__.getFontFamilyFallbacks)(id).map(x => `, ${x}`).join(\"\")}`;\n }\n }\n\n return _constants__WEBPACK_IMPORTED_MODULE_2__.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};\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\n\nconst throttleRAF = (fn, opts) => {\n let timerId = null;\n let lastArgs = null;\n let lastArgsTrailing = null;\n\n const scheduleFunc = args => {\n timerId = window.requestAnimationFrame(() => {\n timerId = null;\n fn(...args);\n lastArgs = null;\n\n if (lastArgsTrailing) {\n lastArgs = lastArgsTrailing;\n lastArgsTrailing = null;\n scheduleFunc(lastArgs);\n }\n });\n };\n\n const ret = (...args) => {\n if (isTestEnv()) {\n fn(...args);\n return;\n }\n\n lastArgs = args;\n\n if (timerId === null) {\n scheduleFunc(lastArgs);\n } else if (opts === null || opts === void 0 ? void 0 : opts.trailing) {\n lastArgsTrailing = args;\n }\n };\n\n ret.flush = () => {\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n\n if (lastArgs) {\n fn(...(lastArgsTrailing || lastArgs));\n lastArgs = lastArgsTrailing = null;\n }\n };\n\n ret.cancel = () => {\n lastArgs = lastArgsTrailing = null;\n\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n };\n\n return ret;\n};\n/**\r\n * Exponential ease-out method\r\n *\r\n * @param {number} k - The value to be tweened.\r\n * @returns {number} The tweened value.\r\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/**\r\n * Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.\r\n * Executes the `onStep` callback on each step with the interpolated values.\r\n * Returns a function that can be called to cancel the animation.\r\n *\r\n * @example\r\n * // Example usage:\r\n * const fromValues = { x: 0, y: 0 };\r\n * const toValues = { x: 100, y: 200 };\r\n * const onStep = ({x, y}) => {\r\n * setState(x, y)\r\n * };\r\n * const onCancel = () => {\r\n * console.log(\"Animation canceled\");\r\n * };\r\n *\r\n * const cancelAnimation = easeToValuesRAF({\r\n * fromValues,\r\n * toValues,\r\n * onStep,\r\n * onCancel,\r\n * });\r\n *\r\n * // To cancel the animation:\r\n * cancelAnimation();\r\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 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 getShortcutKey = shortcut => {\n shortcut = shortcut.replace(/\\bAlt\\b/i, \"Alt\").replace(/\\bShift\\b/i, \"Shift\").replace(/\\b(Enter|Return)\\b/i, \"Enter\");\n\n if (_constants__WEBPACK_IMPORTED_MODULE_2__.isDarwin) {\n return shortcut.replace(/\\bCtrlOrCmd\\b/gi, \"Cmd\").replace(/\\bAlt\\b/i, \"Option\");\n }\n\n return shortcut.replace(/\\bCtrlOrCmd\\b/gi, \"Ctrl\");\n};\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/**\r\n * Checks whether first directional character is RTL. Meaning whether it starts\r\n * with RTL characters, or indeterminate (numbers etc.) characters followed by\r\n * RTL.\r\n * See https://github.com/excalidraw/excalidraw/pull/1722#discussion_r436340171\r\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 isTransparent = color => {\n const isRGBTransparent = color.length === 5 && color.substr(4, 1) === \"0\";\n const isRRGGBBTransparent = color.length === 9 && color.substr(7, 2) === \"00\";\n return isRGBTransparent || isRRGGBBTransparent || color === _colors__WEBPACK_IMPORTED_MODULE_1__.COLOR_PALETTE.transparent;\n};\nconst isBindingFallthroughEnabled = el => el.fillStyle !== \"solid\" || isTransparent(el.backgroundColor);\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_2__.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/**\r\n * Transforms array of objects containing `id` attribute,\r\n * or array of ids (strings), into a Map, keyd by `id`.\r\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/**\r\n * Transform array into an object, use only when array order is irrelevant.\r\n */\n\nconst arrayToObject = (array, groupBy) => array.reduce((acc, value, idx) => {\n acc[groupBy ? groupBy(value) : idx] = value;\n return acc;\n}, {});\n/**\r\n * Creates a circular doubly linked list by adding `prev` and `next` props to the existing array nodes.\r\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/**\r\n * Converts a readonly array or map into an iterable.\r\n * Useful for avoiding entry allocations when iterating object / map on each iteration.\r\n */\n\nconst toIterable = values => {\n return Array.isArray(values) ? values : values.values();\n};\n/**\r\n * Converts a readonly array or map into an array.\r\n */\n\nconst toArray = values => {\n return Array.isArray(values) ? values : Array.from(toIterable(values));\n};\nconst isTestEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_2__.ENV.TEST;\nconst isDevEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_2__.ENV.DEVELOPMENT;\nconst isProdEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_2__.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:3015\",\"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\":\"3000\",\"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-25\",\"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/**\r\n * Returns whether object/array is shallow equal.\r\n * Considers empty object/arrays as equal (whether top-level or second-level).\r\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/**\r\n * supply `null` as message if non-never value is valid, you just need to\r\n * typecheck against it\r\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/**\r\n * Memoizes on values of `opts` object (strict equality).\r\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/**\r\n * allows for falsy values so you don't have to type check when adding\r\n * event listeners to optional elements\r\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};\n/**\r\n * Makes type into a branded type, ensuring that value is assignable to\r\n * the base ubranded type. Optionally you can explicitly supply current value\r\n * type to combine both (useful for composite branded types. Make sure you\r\n * compose branded types which are not composite themselves.)\r\n */\n\nconst 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/**\r\n * use when you need to render unsafe string as HTML attribute, but MAKE SURE\r\n * the attribute is double-quoted when constructing the HTML string\r\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};\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/utils.ts?");
13039
+ 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 */ 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 */ getShortcutKey: () => (/* binding */ getShortcutKey),\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 */ isBindingFallthroughEnabled: () => (/* binding */ isBindingFallthroughEnabled),\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 */ isServerEnv: () => (/* binding */ isServerEnv),\n/* harmony export */ isShallowEqual: () => (/* binding */ isShallowEqual),\n/* harmony export */ isTestEnv: () => (/* binding */ isTestEnv),\n/* harmony export */ isToolIcon: () => (/* binding */ isToolIcon),\n/* harmony export */ isTransparent: () => (/* binding */ isTransparent),\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 */ normalizeEOL: () => (/* binding */ normalizeEOL),\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 */ 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 _colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colors */ \"../common/src/colors.ts\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants */ \"../common/src/constants.ts\");\n\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\");\nconst getFontFamilyString = ({\n fontFamily\n}) => {\n for (const [fontFamilyString, id] of Object.entries(_constants__WEBPACK_IMPORTED_MODULE_2__.FONT_FAMILY)) {\n if (id === fontFamily) {\n return `${fontFamilyString}${(0,_constants__WEBPACK_IMPORTED_MODULE_2__.getFontFamilyFallbacks)(id).map(x => `, ${x}`).join(\"\")}`;\n }\n }\n\n return _constants__WEBPACK_IMPORTED_MODULE_2__.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};\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\n\nconst throttleRAF = (fn, opts) => {\n let timerId = null;\n let lastArgs = null;\n let lastArgsTrailing = null;\n\n const scheduleFunc = args => {\n timerId = window.requestAnimationFrame(() => {\n timerId = null;\n fn(...args);\n lastArgs = null;\n\n if (lastArgsTrailing) {\n lastArgs = lastArgsTrailing;\n lastArgsTrailing = null;\n scheduleFunc(lastArgs);\n }\n });\n };\n\n const ret = (...args) => {\n if (isTestEnv()) {\n fn(...args);\n return;\n }\n\n lastArgs = args;\n\n if (timerId === null) {\n scheduleFunc(lastArgs);\n } else if (opts === null || opts === void 0 ? void 0 : opts.trailing) {\n lastArgsTrailing = args;\n }\n };\n\n ret.flush = () => {\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n\n if (lastArgs) {\n fn(...(lastArgsTrailing || lastArgs));\n lastArgs = lastArgsTrailing = null;\n }\n };\n\n ret.cancel = () => {\n lastArgs = lastArgsTrailing = null;\n\n if (timerId !== null) {\n cancelAnimationFrame(timerId);\n timerId = null;\n }\n };\n\n return ret;\n};\n/**\r\n * Exponential ease-out method\r\n *\r\n * @param {number} k - The value to be tweened.\r\n * @returns {number} The tweened value.\r\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/**\r\n * Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.\r\n * Executes the `onStep` callback on each step with the interpolated values.\r\n * Returns a function that can be called to cancel the animation.\r\n *\r\n * @example\r\n * // Example usage:\r\n * const fromValues = { x: 0, y: 0 };\r\n * const toValues = { x: 100, y: 200 };\r\n * const onStep = ({x, y}) => {\r\n * setState(x, y)\r\n * };\r\n * const onCancel = () => {\r\n * console.log(\"Animation canceled\");\r\n * };\r\n *\r\n * const cancelAnimation = easeToValuesRAF({\r\n * fromValues,\r\n * toValues,\r\n * onStep,\r\n * onCancel,\r\n * });\r\n *\r\n * // To cancel the animation:\r\n * cancelAnimation();\r\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 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 getShortcutKey = shortcut => {\n shortcut = shortcut.replace(/\\bAlt\\b/i, \"Alt\").replace(/\\bShift\\b/i, \"Shift\").replace(/\\b(Enter|Return)\\b/i, \"Enter\");\n\n if (_constants__WEBPACK_IMPORTED_MODULE_2__.isDarwin) {\n return shortcut.replace(/\\bCtrlOrCmd\\b/gi, \"Cmd\").replace(/\\bAlt\\b/i, \"Option\");\n }\n\n return shortcut.replace(/\\bCtrlOrCmd\\b/gi, \"Ctrl\");\n};\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/**\r\n * Checks whether first directional character is RTL. Meaning whether it starts\r\n * with RTL characters, or indeterminate (numbers etc.) characters followed by\r\n * RTL.\r\n * See https://github.com/excalidraw/excalidraw/pull/1722#discussion_r436340171\r\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 isTransparent = color => {\n const isRGBTransparent = color.length === 5 && color.substr(4, 1) === \"0\";\n const isRRGGBBTransparent = color.length === 9 && color.substr(7, 2) === \"00\";\n return isRGBTransparent || isRRGGBBTransparent || color === _colors__WEBPACK_IMPORTED_MODULE_1__.COLOR_PALETTE.transparent;\n};\nconst isBindingFallthroughEnabled = el => el.fillStyle !== \"solid\" || isTransparent(el.backgroundColor);\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_2__.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/**\r\n * Transforms array of objects containing `id` attribute,\r\n * or array of ids (strings), into a Map, keyd by `id`.\r\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/**\r\n * Transform array into an object, use only when array order is irrelevant.\r\n */\n\nconst arrayToObject = (array, groupBy) => array.reduce((acc, value, idx) => {\n acc[groupBy ? groupBy(value) : idx] = value;\n return acc;\n}, {});\n/**\r\n * Creates a circular doubly linked list by adding `prev` and `next` props to the existing array nodes.\r\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/**\r\n * Converts a readonly array or map into an iterable.\r\n * Useful for avoiding entry allocations when iterating object / map on each iteration.\r\n */\n\nconst toIterable = values => {\n return Array.isArray(values) ? values : values.values();\n};\n/**\r\n * Converts a readonly array or map into an array.\r\n */\n\nconst toArray = values => {\n return Array.isArray(values) ? values : Array.from(toIterable(values));\n};\nconst isTestEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_2__.ENV.TEST;\nconst isDevEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_2__.ENV.DEVELOPMENT;\nconst isProdEnv = () => \"development\" === _constants__WEBPACK_IMPORTED_MODULE_2__.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:3015\",\"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\":\"3000\",\"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-26\",\"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/**\r\n * Returns whether object/array is shallow equal.\r\n * Considers empty object/arrays as equal (whether top-level or second-level).\r\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/**\r\n * supply `null` as message if non-never value is valid, you just need to\r\n * typecheck against it\r\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/**\r\n * Memoizes on values of `opts` object (strict equality).\r\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/**\r\n * allows for falsy values so you don't have to type check when adding\r\n * event listeners to optional elements\r\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};\n/**\r\n * Makes type into a branded type, ensuring that value is assignable to\r\n * the base ubranded type. Optionally you can explicitly supply current value\r\n * type to combine both (useful for composite branded types. Make sure you\r\n * compose branded types which are not composite themselves.)\r\n */\n\nconst 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/**\r\n * use when you need to render unsafe string as HTML attribute, but MAKE SURE\r\n * the attribute is double-quoted when constructing the HTML string\r\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};\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/utils.ts?");
13040
13040
 
13041
13041
  /***/ }),
13042
13042
 
@@ -14158,7 +14158,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
14158
14158
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14159
14159
 
14160
14160
  "use strict";
14161
- 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:3015\",\"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\":\"3000\",\"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-25\",\"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?");
14161
+ 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:3015\",\"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\":\"3000\",\"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-26\",\"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?");
14162
14162
 
14163
14163
  /***/ }),
14164
14164
 
@@ -16358,7 +16358,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
16358
16358
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
16359
16359
 
16360
16360
  "use strict";
16361
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _renderer_staticScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../renderer/staticScene */ \"./renderer/staticScene.ts\");\n\n\n\n\n\nconst StaticCanvas = props => {\n const wrapperRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);\n const isComponentMounted = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n const wrapper = wrapperRef.current;\n\n if (!wrapper) {\n return;\n }\n\n const canvas = props.canvas;\n\n if (!isComponentMounted.current) {\n isComponentMounted.current = true;\n wrapper.replaceChildren(canvas);\n canvas.classList.add(\"excalidraw__canvas\", \"static\");\n }\n\n const widthString = `${props.appState.width}px`;\n const heightString = `${props.appState.height}px`;\n\n if (canvas.style.width !== widthString) {\n canvas.style.width = widthString;\n }\n\n if (canvas.style.height !== heightString) {\n canvas.style.height = heightString;\n }\n\n const scaledWidth = props.appState.width * props.scale;\n const scaledHeight = props.appState.height * props.scale; // setting width/height resets the canvas even if dimensions not changed,\n // which would cause flicker when we skip frame (due to throttling)\n\n if (canvas.width !== scaledWidth) {\n canvas.width = scaledWidth;\n }\n\n if (canvas.height !== scaledHeight) {\n canvas.height = scaledHeight;\n }\n\n (0,_renderer_staticScene__WEBPACK_IMPORTED_MODULE_3__.renderStaticScene)({\n canvas,\n rc: props.rc,\n scale: props.scale,\n elementsMap: props.elementsMap,\n allElementsMap: props.allElementsMap,\n visibleElements: props.visibleElements,\n appState: props.appState,\n renderConfig: props.renderConfig\n }, (0,_reactUtils__WEBPACK_IMPORTED_MODULE_2__.isRenderThrottlingEnabled)());\n });\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"excalidraw__canvas-wrapper\",\n ref: wrapperRef\n });\n};\n\nconst getRelevantAppStateProps = appState => {\n const relevantAppStateProps = {\n zoom: appState.zoom,\n scrollX: appState.scrollX,\n scrollY: appState.scrollY,\n width: appState.width,\n height: appState.height,\n viewModeEnabled: appState.viewModeEnabled,\n openDialog: appState.openDialog,\n hoveredElementIds: appState.hoveredElementIds,\n offsetLeft: appState.offsetLeft,\n offsetTop: appState.offsetTop,\n theme: appState.theme,\n shouldCacheIgnoreZoom: appState.shouldCacheIgnoreZoom,\n viewBackgroundColor: appState.viewBackgroundColor,\n exportScale: appState.exportScale,\n selectedElementsAreBeingDragged: appState.selectedElementsAreBeingDragged,\n gridSize: appState.gridSize,\n gridStep: appState.gridStep,\n frameRendering: appState.frameRendering,\n selectedElementIds: appState.selectedElementIds,\n frameToHighlight: appState.frameToHighlight,\n editingGroupId: appState.editingGroupId,\n currentHoveredFontFamily: appState.currentHoveredFontFamily,\n croppingElementId: appState.croppingElementId,\n linkOpacity: appState.linkOpacity,\n gridColor: appState.gridColor,\n gridDirection: appState.gridDirection,\n frameColor: appState.frameColor //zsviczian\n\n };\n return relevantAppStateProps;\n};\n\nconst areEqual = (prevProps, nextProps) => {\n if (prevProps.sceneNonce !== nextProps.sceneNonce || prevProps.scale !== nextProps.scale || // we need to memoize on elementsMap because they may have renewed\n // even if sceneNonce didn't change (e.g. we filter elements out based\n // on appState)\n prevProps.elementsMap !== nextProps.elementsMap || prevProps.visibleElements !== nextProps.visibleElements) {\n return false;\n }\n\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isShallowEqual)( // asserting AppState because we're being passed the whole AppState\n // but resolve to only the StaticCanvas-relevant props\n getRelevantAppStateProps(prevProps.appState), getRelevantAppStateProps(nextProps.appState)) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isShallowEqual)(prevProps.renderConfig, nextProps.renderConfig);\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().memo(StaticCanvas, areEqual));\n\n//# sourceURL=webpack://ExcalidrawLib/./components/canvases/StaticCanvas.tsx?");
16361
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _renderer_staticScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../renderer/staticScene */ \"./renderer/staticScene.ts\");\n\n\n\n\n\nconst StaticCanvas = props => {\n const wrapperRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);\n const isComponentMounted = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n props.canvas.style.width = `${props.appState.width}px`;\n props.canvas.style.height = `${props.appState.height}px`;\n props.canvas.width = props.appState.width * props.scale;\n props.canvas.height = props.appState.height * props.scale;\n }, [props.appState.height, props.appState.width, props.canvas, props.scale]);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n const wrapper = wrapperRef.current;\n\n if (!wrapper) {\n return;\n }\n\n const canvas = props.canvas;\n\n if (!isComponentMounted.current) {\n isComponentMounted.current = true;\n wrapper.replaceChildren(canvas);\n canvas.classList.add(\"excalidraw__canvas\", \"static\");\n }\n\n (0,_renderer_staticScene__WEBPACK_IMPORTED_MODULE_3__.renderStaticScene)({\n canvas,\n rc: props.rc,\n scale: props.scale,\n elementsMap: props.elementsMap,\n allElementsMap: props.allElementsMap,\n visibleElements: props.visibleElements,\n appState: props.appState,\n renderConfig: props.renderConfig\n }, (0,_reactUtils__WEBPACK_IMPORTED_MODULE_2__.isRenderThrottlingEnabled)());\n });\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"excalidraw__canvas-wrapper\",\n ref: wrapperRef\n });\n};\n\nconst getRelevantAppStateProps = appState => {\n const relevantAppStateProps = {\n zoom: appState.zoom,\n scrollX: appState.scrollX,\n scrollY: appState.scrollY,\n width: appState.width,\n height: appState.height,\n viewModeEnabled: appState.viewModeEnabled,\n openDialog: appState.openDialog,\n hoveredElementIds: appState.hoveredElementIds,\n offsetLeft: appState.offsetLeft,\n offsetTop: appState.offsetTop,\n theme: appState.theme,\n shouldCacheIgnoreZoom: appState.shouldCacheIgnoreZoom,\n viewBackgroundColor: appState.viewBackgroundColor,\n exportScale: appState.exportScale,\n selectedElementsAreBeingDragged: appState.selectedElementsAreBeingDragged,\n gridSize: appState.gridSize,\n gridStep: appState.gridStep,\n frameRendering: appState.frameRendering,\n selectedElementIds: appState.selectedElementIds,\n frameToHighlight: appState.frameToHighlight,\n editingGroupId: appState.editingGroupId,\n currentHoveredFontFamily: appState.currentHoveredFontFamily,\n croppingElementId: appState.croppingElementId,\n linkOpacity: appState.linkOpacity,\n gridColor: appState.gridColor,\n gridDirection: appState.gridDirection,\n frameColor: appState.frameColor //zsviczian\n\n };\n return relevantAppStateProps;\n};\n\nconst areEqual = (prevProps, nextProps) => {\n if (prevProps.sceneNonce !== nextProps.sceneNonce || prevProps.scale !== nextProps.scale || // we need to memoize on elementsMap because they may have renewed\n // even if sceneNonce didn't change (e.g. we filter elements out based\n // on appState)\n prevProps.elementsMap !== nextProps.elementsMap || prevProps.visibleElements !== nextProps.visibleElements) {\n return false;\n }\n\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isShallowEqual)( // asserting AppState because we're being passed the whole AppState\n // but resolve to only the StaticCanvas-relevant props\n getRelevantAppStateProps(prevProps.appState), getRelevantAppStateProps(nextProps.appState)) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.isShallowEqual)(prevProps.renderConfig, nextProps.renderConfig);\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().memo(StaticCanvas, areEqual));\n\n//# sourceURL=webpack://ExcalidrawLib/./components/canvases/StaticCanvas.tsx?");
16362
16362
 
16363
16363
  /***/ }),
16364
16364
 
@@ -17062,7 +17062,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
17062
17062
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
17063
17063
 
17064
17064
  "use strict";
17065
- 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 /**\r\n * Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.\r\n *\r\n * Retrieves `undefined` otherwise.\r\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 /**\r\n * Tries to fetch woff2 content, based on the registered urls (from first to last, treated as fallbacks).\r\n *\r\n * @returns base64 with subsetted glyphs based on the passed codepoint, last defined url otherwise\r\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 /**\r\n * zsviczian https://github.com/zsviczian/excalidraw/commit/b4cfaaa4b4f46ca01f94e27fb7bf651a9da99daa\r\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:3015\",\"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\":\"3000\",\"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-25\",\"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:3015\",\"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\":\"3000\",\"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-25\",\"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:3015\",\"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\":\"3000\",\"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-25\",\"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?");
17065
+ 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 /**\r\n * Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.\r\n *\r\n * Retrieves `undefined` otherwise.\r\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 /**\r\n * Tries to fetch woff2 content, based on the registered urls (from first to last, treated as fallbacks).\r\n *\r\n * @returns base64 with subsetted glyphs based on the passed codepoint, last defined url otherwise\r\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 /**\r\n * zsviczian https://github.com/zsviczian/excalidraw/commit/b4cfaaa4b4f46ca01f94e27fb7bf651a9da99daa\r\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:3015\",\"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\":\"3000\",\"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-26\",\"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:3015\",\"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\":\"3000\",\"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-26\",\"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:3015\",\"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\":\"3000\",\"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-26\",\"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?");
17066
17066
 
17067
17067
  /***/ }),
17068
17068
 
@@ -20526,7 +20526,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
20526
20526
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
20527
20527
 
20528
20528
  "use strict";
20529
- 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-25\"}/dist/`;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/./publicPath.js?");
20529
+ 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-26\"}/dist/`;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/./publicPath.js?");
20530
20530
 
20531
20531
  /***/ }),
20532
20532
 
@@ -20570,7 +20570,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
20570
20570
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
20571
20571
 
20572
20572
  "use strict";
20573
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ renderNewElementScene: () => (/* binding */ renderNewElementScene),\n/* harmony export */ renderNewElementSceneThrottled: () => (/* binding */ renderNewElementSceneThrottled)\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 _helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helpers */ \"./renderer/helpers.ts\");\n\n\n\n\nconst _renderNewElementScene = ({\n canvas,\n rc,\n newElement,\n elementsMap,\n allElementsMap,\n scale,\n appState,\n renderConfig\n}) => {\n if (canvas) {\n const [normalizedWidth, normalizedHeight] = (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.getNormalizedCanvasDimensions)(canvas, scale);\n const {\n isHighlighterPenDrawing = false\n } = renderConfig; //zsviczian\n\n const context = (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.bootstrapCanvas)({\n canvas,\n scale,\n normalizedWidth,\n normalizedHeight,\n viewBackgroundColor: isHighlighterPenDrawing ? appState.viewBackgroundColor : \"transparent\" //zsviczian\n\n }); // Apply zoom\n\n context.save();\n context.scale(appState.zoom.value, appState.zoom.value);\n\n if (newElement && newElement.type !== \"selection\") {\n // e.g. when creating arrows and we're still below the arrow drag distance\n // threshold\n // (for now we skip render only with elements while we're creating to be\n // safe)\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isInvisiblySmallElement)(newElement)) {\n return;\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(newElement, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n } else {\n context.clearRect(0, 0, normalizedWidth, normalizedHeight);\n }\n }\n};\n\nconst renderNewElementSceneThrottled = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.throttleRAF)(config => {\n _renderNewElementScene(config);\n}, {\n trailing: true\n});\nconst renderNewElementScene = (renderConfig, throttle) => {\n if (throttle) {\n renderNewElementSceneThrottled(renderConfig);\n return;\n }\n\n _renderNewElementScene(renderConfig);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/renderNewElementScene.ts?");
20573
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ renderNewElementScene: () => (/* binding */ renderNewElementScene),\n/* harmony export */ renderNewElementSceneThrottled: () => (/* binding */ renderNewElementSceneThrottled)\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 _helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helpers */ \"./renderer/helpers.ts\");\n/* harmony import */ var _staticScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./staticScene */ \"./renderer/staticScene.ts\");\n\n\n\n\n\nconst _renderNewElementScene = ({\n canvas,\n rc,\n newElement,\n elementsMap,\n allElementsMap,\n scale,\n appState,\n renderConfig\n}) => {\n var _a;\n\n if (canvas) {\n const [normalizedWidth, normalizedHeight] = (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.getNormalizedCanvasDimensions)(canvas, scale);\n const {\n isHighlighterPenDrawing = false\n } = renderConfig; //zsviczian\n\n const context = (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.bootstrapCanvas)({\n canvas,\n scale,\n normalizedWidth,\n normalizedHeight,\n viewBackgroundColor: isHighlighterPenDrawing ? appState.viewBackgroundColor : \"transparent\" //zsviczian\n\n });\n context.save(); // Apply zoom\n\n context.scale(appState.zoom.value, appState.zoom.value);\n\n if (newElement && newElement.type !== \"selection\") {\n // e.g. when creating arrows and we're still below the arrow drag distance\n // threshold\n // (for now we skip render only with elements while we're creating to be\n // safe)\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isInvisiblySmallElement)(newElement)) {\n return;\n }\n\n const frameId = newElement.frameId || ((_a = appState.frameToHighlight) === null || _a === void 0 ? void 0 : _a.id);\n\n if (frameId && appState.frameRendering.enabled && appState.frameRendering.clip) {\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getTargetFrame)(newElement, elementsMap, appState);\n\n if (frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.shouldApplyFrameClip)(newElement, frame, appState, elementsMap)) {\n (0,_staticScene__WEBPACK_IMPORTED_MODULE_3__.frameClip)(frame, context, renderConfig, appState);\n }\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(newElement, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n } else {\n context.clearRect(0, 0, normalizedWidth, normalizedHeight);\n }\n\n context.restore();\n }\n};\n\nconst renderNewElementSceneThrottled = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.throttleRAF)(config => {\n _renderNewElementScene(config);\n}, {\n trailing: true\n});\nconst renderNewElementScene = (renderConfig, throttle) => {\n if (throttle) {\n renderNewElementSceneThrottled(renderConfig);\n return;\n }\n\n _renderNewElementScene(renderConfig);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/renderNewElementScene.ts?");
20574
20574
 
20575
20575
  /***/ }),
20576
20576
 
@@ -20603,7 +20603,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
20603
20603
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
20604
20604
 
20605
20605
  "use strict";
20606
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ renderStaticScene: () => (/* binding */ renderStaticScene),\n/* harmony export */ renderStaticSceneThrottled: () => (/* binding */ renderStaticSceneThrottled)\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 _components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helpers */ \"./renderer/helpers.ts\");\n\n\n\n\n\n\n\n\n\n\n/*const gridLineColor = {\r\n Bold: \"#dddddd\",\r\n Regular: \"#e5e5e5\",\r\n} as const;*/\n//zsviczian\n\nconst strokeGrid = (context,\n/** grid cell pixel size */\ngridSize,\n/** setting to 1 will disble bold lines */\ngridStep, scrollX, scrollY, zoom, width, height, gridLineColor, //zsviczian\ngridDirection = {\n horizontal: true,\n vertical: true\n}) => {\n const offsetX = scrollX % gridSize - gridSize;\n const offsetY = scrollY % gridSize - gridSize;\n const actualGridSize = gridSize * zoom.value;\n const spaceWidth = 1 / zoom.value;\n context.save(); // Offset rendering by 0.5 to ensure that 1px wide lines are crisp.\n // We only do this when zoomed to 100% because otherwise the offset is\n // fractional, and also visibly offsets the elements.\n // We also do this per-axis, as each axis may already be offset by 0.5.\n\n if (zoom.value === 1) {\n context.translate(offsetX % 1 ? 0 : 0.5, offsetY % 1 ? 0 : 0.5);\n } // vertical lines\n\n\n if (gridDirection.vertical) {\n //zsviczian\n for (let x = offsetX; x < offsetX + width + gridSize * 2; x += gridSize) {\n const isBold = gridStep > 1 && Math.round(x - scrollX) % (gridStep * gridSize) === 0; // don't render regular lines when zoomed out and they're barely visible\n\n if (!isBold && actualGridSize < 10) {\n continue;\n }\n\n const lineWidth = Math.min(1 / zoom.value, isBold ? 4 : 1);\n context.lineWidth = lineWidth;\n const lineDash = [lineWidth * 3, spaceWidth + (lineWidth + spaceWidth)];\n context.beginPath();\n context.setLineDash(isBold ? [] : lineDash);\n context.strokeStyle = isBold ? gridLineColor.Bold : gridLineColor.Regular;\n context.moveTo(x, offsetY - gridSize);\n context.lineTo(x, Math.ceil(offsetY + height + gridSize * 2));\n context.stroke();\n }\n }\n\n if (gridDirection.horizontal) {\n //zsviczian\n for (let y = offsetY; y < offsetY + height + gridSize * 2; y += gridSize) {\n const isBold = gridStep > 1 && Math.round(y - scrollY) % (gridStep * gridSize) === 0;\n\n if (!isBold && actualGridSize < 10) {\n continue;\n }\n\n const lineWidth = Math.min(1 / zoom.value, isBold ? 4 : 1);\n context.lineWidth = lineWidth;\n const lineDash = [lineWidth * 3, spaceWidth + (lineWidth + spaceWidth)];\n context.beginPath();\n context.setLineDash(isBold ? [] : lineDash);\n context.strokeStyle = isBold ? gridLineColor.Bold : gridLineColor.Regular;\n context.moveTo(offsetX - gridSize, y);\n context.lineTo(Math.ceil(offsetX + width + gridSize * 2), y);\n context.stroke();\n }\n }\n\n context.restore();\n};\n\nconst frameClip = (frame, context, renderConfig, appState) => {\n context.translate(frame.x + appState.scrollX, frame.y + appState.scrollY);\n context.beginPath();\n\n if (context.roundRect) {\n context.roundRect(0, 0, frame.width, frame.height, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.radius / appState.zoom.value);\n } else {\n context.rect(0, 0, frame.width, frame.height);\n }\n\n context.clip();\n context.translate(-(frame.x + appState.scrollX), -(frame.y + appState.scrollY));\n};\n\nconst linkIconCanvasCache = {\n regularLink: null,\n elementLink: null\n};\n\nconst renderLinkIcon = (element, context, appState, elementsMap) => {\n if (element.link && !appState.selectedElementIds[element.id]) {\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getElementAbsoluteCoords)(element, elementsMap);\n const [x, y, width, height] = (0,_components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__.getLinkHandleFromCoords)([x1, y1, x2, y2], element.angle, appState);\n const centerX = x + width / 2;\n const centerY = y + height / 2;\n context.save();\n context.translate(appState.scrollX + centerX, appState.scrollY + centerY);\n context.rotate(element.angle);\n const canvasKey = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isElementLink)(element.link) ? \"elementLink\" : \"regularLink\";\n let linkCanvas = linkIconCanvasCache[canvasKey];\n\n if (!linkCanvas || linkCanvas.zoom !== appState.zoom.value || linkCanvas.linkOpacity !== appState.linkOpacity //zsviczian\n ) {\n linkCanvas = Object.assign(document.createElement(\"canvas\"), {\n zoom: appState.zoom.value,\n linkOpacity: appState.linkOpacity //zsviczian\n\n });\n linkCanvas.width = width * window.devicePixelRatio * appState.zoom.value;\n linkCanvas.height = height * window.devicePixelRatio * appState.zoom.value;\n linkIconCanvasCache[canvasKey] = linkCanvas;\n const linkCanvasCacheContext = linkCanvas.getContext(\"2d\");\n linkCanvasCacheContext.scale(window.devicePixelRatio * appState.zoom.value, window.devicePixelRatio * appState.zoom.value);\n /*linkCanvasCacheContext.fillStyle = appState.viewBackgroundColor || \"#fff\";\r\n linkCanvasCacheContext.fillRect(0, 0, width, height);*/\n //zsviczian\n\n if (canvasKey === \"elementLink\") {\n linkCanvasCacheContext.drawImage(_components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_LINK_IMG, 0, 0, width, height);\n } else {\n linkCanvasCacheContext.globalAlpha = appState.linkOpacity; //zsviczian\n\n linkCanvasCacheContext.drawImage(_components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__.EXTERNAL_LINK_IMG, 0, 0, width, height);\n }\n\n linkCanvasCacheContext.restore();\n }\n\n context.drawImage(linkCanvas, x - centerX, y - centerY, width, height);\n context.restore();\n }\n};\n\nconst _renderStaticScene = ({\n canvas,\n rc,\n elementsMap,\n allElementsMap,\n visibleElements,\n scale,\n appState,\n renderConfig\n}) => {\n var _a;\n\n if (canvas === null) {\n return;\n }\n\n const {\n renderGrid = true,\n isExporting,\n isHighlighterPenDrawing = false\n } = renderConfig; //zsviczian\n\n const [normalizedWidth, normalizedHeight] = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getNormalizedCanvasDimensions)(canvas, scale);\n const context = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.bootstrapCanvas)({\n canvas,\n scale,\n normalizedWidth,\n normalizedHeight,\n theme: appState.theme,\n isExporting,\n viewBackgroundColor: isHighlighterPenDrawing ? \"transparent\" : appState.viewBackgroundColor //zsviczian\n\n }); // Apply zoom\n\n context.scale(appState.zoom.value, appState.zoom.value); // Grid\n\n if (renderGrid) {\n strokeGrid(context, appState.gridSize, appState.gridStep, appState.scrollX, appState.scrollY, appState.zoom, normalizedWidth / appState.zoom.value, normalizedHeight / appState.zoom.value, appState.gridColor, //zsviczian\n appState.gridDirection);\n }\n\n const groupsToBeAddedToFrame = new Set();\n visibleElements.forEach(element => {\n if (element.groupIds.length > 0 && appState.frameToHighlight && appState.selectedElementIds[element.id] && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.elementOverlapsWithFrame)(element, appState.frameToHighlight, elementsMap) || element.groupIds.find(groupId => groupsToBeAddedToFrame.has(groupId)))) {\n element.groupIds.forEach(groupId => groupsToBeAddedToFrame.add(groupId));\n }\n });\n const inFrameGroupsMap = new Map(); // Paint visible elements\n\n visibleElements.filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n var _a;\n\n try {\n const frameId = element.frameId || ((_a = appState.frameToHighlight) === null || _a === void 0 ? void 0 : _a.id);\n\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 context.save();\n\n if (frameId && appState.frameRendering.enabled && appState.frameRendering.clip) {\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getTargetFrame)(element, elementsMap, appState);\n\n if (frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.shouldApplyFrameClip)(element, frame, appState, elementsMap, inFrameGroupsMap)) {\n frameClip(frame, context, renderConfig, appState);\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n } else {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n }\n\n const boundTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(element, elementsMap);\n\n if (boundTextElement) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(boundTextElement, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n }\n\n context.restore();\n\n if (!isExporting) {\n renderLinkIcon(element, context, appState, elementsMap);\n }\n } catch (error) {\n console.error(error, element.id, element.x, element.y, element.width, element.height);\n }\n }); // render embeddables on top\n\n visibleElements.filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n var _a;\n\n try {\n const render = () => {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(element) && (isExporting || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isEmbeddableElement)(element) && renderConfig.embedsValidationStatus.get(element.id) !== true) && element.width && element.height) {\n const label = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.createPlaceholderEmbeddableLabel)(element);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(label, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n }\n\n if (!isExporting) {\n renderLinkIcon(element, context, appState, elementsMap);\n }\n }; // - when exporting the whole canvas, we DO NOT apply clipping\n // - when we are exporting a particular frame, apply clipping\n // if the containing frame is not selected, apply clipping\n\n\n const frameId = element.frameId || ((_a = appState.frameToHighlight) === null || _a === void 0 ? void 0 : _a.id);\n\n if (frameId && appState.frameRendering.enabled && appState.frameRendering.clip) {\n context.save();\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getTargetFrame)(element, elementsMap, appState);\n\n if (frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.shouldApplyFrameClip)(element, frame, appState, elementsMap, inFrameGroupsMap)) {\n frameClip(frame, context, renderConfig, appState);\n }\n\n render();\n context.restore();\n } else {\n render();\n }\n } catch (error) {\n console.error(error);\n }\n }); // render pending nodes for flowcharts\n\n (_a = renderConfig.pendingFlowchartNodes) === null || _a === void 0 ? void 0 : _a.forEach(element => {\n try {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n } catch (error) {\n console.error(error);\n }\n });\n};\n/** throttled to animation framerate */\n\n\nconst renderStaticSceneThrottled = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.throttleRAF)(config => {\n _renderStaticScene(config);\n}, {\n trailing: true\n});\n/**\r\n * Static scene is the non-ui canvas where we render elements.\r\n */\n\nconst renderStaticScene = (renderConfig, throttle) => {\n if (throttle) {\n renderStaticSceneThrottled(renderConfig);\n return;\n }\n\n _renderStaticScene(renderConfig);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/staticScene.ts?");
20606
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ frameClip: () => (/* binding */ frameClip),\n/* harmony export */ renderStaticScene: () => (/* binding */ renderStaticScene),\n/* harmony export */ renderStaticSceneThrottled: () => (/* binding */ renderStaticSceneThrottled)\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 _components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helpers */ \"./renderer/helpers.ts\");\n\n\n\n\n\n\n\n\n\n\n/*const gridLineColor = {\r\n Bold: \"#dddddd\",\r\n Regular: \"#e5e5e5\",\r\n} as const;*/\n//zsviczian\n\nconst strokeGrid = (context,\n/** grid cell pixel size */\ngridSize,\n/** setting to 1 will disble bold lines */\ngridStep, scrollX, scrollY, zoom, width, height, gridLineColor, //zsviczian\ngridDirection = {\n horizontal: true,\n vertical: true\n}) => {\n const offsetX = scrollX % gridSize - gridSize;\n const offsetY = scrollY % gridSize - gridSize;\n const actualGridSize = gridSize * zoom.value;\n const spaceWidth = 1 / zoom.value;\n context.save(); // Offset rendering by 0.5 to ensure that 1px wide lines are crisp.\n // We only do this when zoomed to 100% because otherwise the offset is\n // fractional, and also visibly offsets the elements.\n // We also do this per-axis, as each axis may already be offset by 0.5.\n\n if (zoom.value === 1) {\n context.translate(offsetX % 1 ? 0 : 0.5, offsetY % 1 ? 0 : 0.5);\n } // vertical lines\n\n\n if (gridDirection.vertical) {\n //zsviczian\n for (let x = offsetX; x < offsetX + width + gridSize * 2; x += gridSize) {\n const isBold = gridStep > 1 && Math.round(x - scrollX) % (gridStep * gridSize) === 0; // don't render regular lines when zoomed out and they're barely visible\n\n if (!isBold && actualGridSize < 10) {\n continue;\n }\n\n const lineWidth = Math.min(1 / zoom.value, isBold ? 4 : 1);\n context.lineWidth = lineWidth;\n const lineDash = [lineWidth * 3, spaceWidth + (lineWidth + spaceWidth)];\n context.beginPath();\n context.setLineDash(isBold ? [] : lineDash);\n context.strokeStyle = isBold ? gridLineColor.Bold : gridLineColor.Regular;\n context.moveTo(x, offsetY - gridSize);\n context.lineTo(x, Math.ceil(offsetY + height + gridSize * 2));\n context.stroke();\n }\n }\n\n if (gridDirection.horizontal) {\n //zsviczian\n for (let y = offsetY; y < offsetY + height + gridSize * 2; y += gridSize) {\n const isBold = gridStep > 1 && Math.round(y - scrollY) % (gridStep * gridSize) === 0;\n\n if (!isBold && actualGridSize < 10) {\n continue;\n }\n\n const lineWidth = Math.min(1 / zoom.value, isBold ? 4 : 1);\n context.lineWidth = lineWidth;\n const lineDash = [lineWidth * 3, spaceWidth + (lineWidth + spaceWidth)];\n context.beginPath();\n context.setLineDash(isBold ? [] : lineDash);\n context.strokeStyle = isBold ? gridLineColor.Bold : gridLineColor.Regular;\n context.moveTo(offsetX - gridSize, y);\n context.lineTo(Math.ceil(offsetX + width + gridSize * 2), y);\n context.stroke();\n }\n }\n\n context.restore();\n};\n\nconst frameClip = (frame, context, renderConfig, appState) => {\n context.translate(frame.x + appState.scrollX, frame.y + appState.scrollY);\n context.beginPath();\n\n if (context.roundRect) {\n context.roundRect(0, 0, frame.width, frame.height, _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.FRAME_STYLE.radius / appState.zoom.value);\n } else {\n context.rect(0, 0, frame.width, frame.height);\n }\n\n context.clip();\n context.translate(-(frame.x + appState.scrollX), -(frame.y + appState.scrollY));\n};\nconst linkIconCanvasCache = {\n regularLink: null,\n elementLink: null\n};\n\nconst renderLinkIcon = (element, context, appState, elementsMap) => {\n if (element.link && !appState.selectedElementIds[element.id]) {\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getElementAbsoluteCoords)(element, elementsMap);\n const [x, y, width, height] = (0,_components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__.getLinkHandleFromCoords)([x1, y1, x2, y2], element.angle, appState);\n const centerX = x + width / 2;\n const centerY = y + height / 2;\n context.save();\n context.translate(appState.scrollX + centerX, appState.scrollY + centerY);\n context.rotate(element.angle);\n const canvasKey = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isElementLink)(element.link) ? \"elementLink\" : \"regularLink\";\n let linkCanvas = linkIconCanvasCache[canvasKey];\n\n if (!linkCanvas || linkCanvas.zoom !== appState.zoom.value || linkCanvas.linkOpacity !== appState.linkOpacity //zsviczian\n ) {\n linkCanvas = Object.assign(document.createElement(\"canvas\"), {\n zoom: appState.zoom.value,\n linkOpacity: appState.linkOpacity //zsviczian\n\n });\n linkCanvas.width = width * window.devicePixelRatio * appState.zoom.value;\n linkCanvas.height = height * window.devicePixelRatio * appState.zoom.value;\n linkIconCanvasCache[canvasKey] = linkCanvas;\n const linkCanvasCacheContext = linkCanvas.getContext(\"2d\");\n linkCanvasCacheContext.scale(window.devicePixelRatio * appState.zoom.value, window.devicePixelRatio * appState.zoom.value);\n /*linkCanvasCacheContext.fillStyle = appState.viewBackgroundColor || \"#fff\";\r\n linkCanvasCacheContext.fillRect(0, 0, width, height);*/\n //zsviczian\n\n if (canvasKey === \"elementLink\") {\n linkCanvasCacheContext.drawImage(_components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_LINK_IMG, 0, 0, width, height);\n } else {\n linkCanvasCacheContext.globalAlpha = appState.linkOpacity; //zsviczian\n\n linkCanvasCacheContext.drawImage(_components_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_2__.EXTERNAL_LINK_IMG, 0, 0, width, height);\n }\n\n linkCanvasCacheContext.restore();\n }\n\n context.drawImage(linkCanvas, x - centerX, y - centerY, width, height);\n context.restore();\n }\n};\n\nconst _renderStaticScene = ({\n canvas,\n rc,\n elementsMap,\n allElementsMap,\n visibleElements,\n scale,\n appState,\n renderConfig\n}) => {\n var _a;\n\n if (canvas === null) {\n return;\n }\n\n const {\n renderGrid = true,\n isExporting,\n isHighlighterPenDrawing = false\n } = renderConfig; //zsviczian\n\n const [normalizedWidth, normalizedHeight] = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getNormalizedCanvasDimensions)(canvas, scale);\n const context = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.bootstrapCanvas)({\n canvas,\n scale,\n normalizedWidth,\n normalizedHeight,\n theme: appState.theme,\n isExporting,\n viewBackgroundColor: isHighlighterPenDrawing ? \"transparent\" : appState.viewBackgroundColor //zsviczian\n\n }); // Apply zoom\n\n context.scale(appState.zoom.value, appState.zoom.value); // Grid\n\n if (renderGrid) {\n strokeGrid(context, appState.gridSize, appState.gridStep, appState.scrollX, appState.scrollY, appState.zoom, normalizedWidth / appState.zoom.value, normalizedHeight / appState.zoom.value, appState.gridColor, //zsviczian\n appState.gridDirection);\n }\n\n const groupsToBeAddedToFrame = new Set();\n visibleElements.forEach(element => {\n if (element.groupIds.length > 0 && appState.frameToHighlight && appState.selectedElementIds[element.id] && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.elementOverlapsWithFrame)(element, appState.frameToHighlight, elementsMap) || element.groupIds.find(groupId => groupsToBeAddedToFrame.has(groupId)))) {\n element.groupIds.forEach(groupId => groupsToBeAddedToFrame.add(groupId));\n }\n });\n const inFrameGroupsMap = new Map(); // Paint visible elements\n\n visibleElements.filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n var _a;\n\n try {\n const frameId = element.frameId || ((_a = appState.frameToHighlight) === null || _a === void 0 ? void 0 : _a.id);\n\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 context.save();\n\n if (frameId && appState.frameRendering.enabled && appState.frameRendering.clip) {\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getTargetFrame)(element, elementsMap, appState);\n\n if (frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.shouldApplyFrameClip)(element, frame, appState, elementsMap, inFrameGroupsMap)) {\n frameClip(frame, context, renderConfig, appState);\n }\n\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n } else {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n }\n\n const boundTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getBoundTextElement)(element, elementsMap);\n\n if (boundTextElement) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(boundTextElement, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n }\n\n context.restore();\n\n if (!isExporting) {\n renderLinkIcon(element, context, appState, elementsMap);\n }\n } catch (error) {\n console.error(error, element.id, element.x, element.y, element.width, element.height);\n }\n }); // render embeddables on top\n\n visibleElements.filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(el)).forEach(element => {\n var _a;\n\n try {\n const render = () => {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isIframeLikeElement)(element) && (isExporting || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.isEmbeddableElement)(element) && renderConfig.embedsValidationStatus.get(element.id) !== true) && element.width && element.height) {\n const label = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.createPlaceholderEmbeddableLabel)(element);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(label, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n }\n\n if (!isExporting) {\n renderLinkIcon(element, context, appState, elementsMap);\n }\n }; // - when exporting the whole canvas, we DO NOT apply clipping\n // - when we are exporting a particular frame, apply clipping\n // if the containing frame is not selected, apply clipping\n\n\n const frameId = element.frameId || ((_a = appState.frameToHighlight) === null || _a === void 0 ? void 0 : _a.id);\n\n if (frameId && appState.frameRendering.enabled && appState.frameRendering.clip) {\n context.save();\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getTargetFrame)(element, elementsMap, appState);\n\n if (frame && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.shouldApplyFrameClip)(element, frame, appState, elementsMap, inFrameGroupsMap)) {\n frameClip(frame, context, renderConfig, appState);\n }\n\n render();\n context.restore();\n } else {\n render();\n }\n } catch (error) {\n console.error(error);\n }\n }); // render pending nodes for flowcharts\n\n (_a = renderConfig.pendingFlowchartNodes) === null || _a === void 0 ? void 0 : _a.forEach(element => {\n try {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.renderElement)(element, elementsMap, allElementsMap, rc, context, renderConfig, appState);\n } catch (error) {\n console.error(error);\n }\n });\n};\n/** throttled to animation framerate */\n\n\nconst renderStaticSceneThrottled = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.throttleRAF)(config => {\n _renderStaticScene(config);\n}, {\n trailing: true\n});\n/**\r\n * Static scene is the non-ui canvas where we render elements.\r\n */\n\nconst renderStaticScene = (renderConfig, throttle) => {\n if (throttle) {\n renderStaticSceneThrottled(renderConfig);\n return;\n }\n\n _renderStaticScene(renderConfig);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./renderer/staticScene.ts?");
20607
20607
 
20608
20608
  /***/ }),
20609
20609
 
@@ -20702,7 +20702,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
20702
20702
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
20703
20703
 
20704
20704
  "use strict";
20705
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SnapCache: () => (/* binding */ SnapCache),\n/* harmony export */ areRoughlyEqual: () => (/* binding */ areRoughlyEqual),\n/* harmony export */ getElementsCorners: () => (/* binding */ getElementsCorners),\n/* harmony export */ getReferenceSnapPoints: () => (/* binding */ getReferenceSnapPoints),\n/* harmony export */ getSnapDistance: () => (/* binding */ getSnapDistance),\n/* harmony export */ getSnapLinesAtPointer: () => (/* binding */ getSnapLinesAtPointer),\n/* harmony export */ getVisibleGaps: () => (/* binding */ getVisibleGaps),\n/* harmony export */ isActiveToolNonLinearSnappable: () => (/* binding */ isActiveToolNonLinearSnappable),\n/* harmony export */ isGridModeEnabled: () => (/* binding */ isGridModeEnabled),\n/* harmony export */ isSnappingEnabled: () => (/* binding */ isSnappingEnabled),\n/* harmony export */ snapDraggedElements: () => (/* binding */ snapDraggedElements),\n/* harmony export */ snapNewElement: () => (/* binding */ snapNewElement),\n/* harmony export */ snapResizingElements: () => (/* binding */ snapResizingElements)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n\n\n\n\n\n\nconst SNAP_DISTANCE = 8; // do not comput more gaps per axis than this limit\n// TODO increase or remove once we optimize\n\nconst VISIBLE_GAPS_LIMIT_PER_AXIS = 99999; // snap distance with zoom value taken into consideration\n\nconst getSnapDistance = zoomValue => {\n return SNAP_DISTANCE / zoomValue;\n}; // -----------------------------------------------------------------------------\n\nclass SnapCache {}\nSnapCache.referenceSnapPoints = null;\nSnapCache.visibleGaps = null;\n\nSnapCache.setReferenceSnapPoints = snapPoints => {\n SnapCache.referenceSnapPoints = snapPoints;\n};\n\nSnapCache.getReferenceSnapPoints = () => {\n return SnapCache.referenceSnapPoints;\n};\n\nSnapCache.setVisibleGaps = gaps => {\n SnapCache.visibleGaps = gaps;\n};\n\nSnapCache.getVisibleGaps = () => {\n return SnapCache.visibleGaps;\n};\n\nSnapCache.destroy = () => {\n SnapCache.referenceSnapPoints = null;\n SnapCache.visibleGaps = null;\n}; // -----------------------------------------------------------------------------\n\n\nconst isGridModeEnabled = app => {\n var _a;\n\n return (_a = app.props.gridModeEnabled) !== null && _a !== void 0 ? _a : app.state.gridModeEnabled;\n};\nconst isSnappingEnabled = ({\n event,\n app,\n selectedElements\n}) => {\n if (event) {\n return app.state.activeTool.type !== \"lasso\" && (app.state.objectsSnapModeEnabled && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || !app.state.objectsSnapModeEnabled && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] && !isGridModeEnabled(app));\n } // do not suggest snaps for an arrow to give way to binding\n\n\n if (selectedElements.length === 1 && selectedElements[0].type === \"arrow\") {\n return false;\n }\n\n return app.state.objectsSnapModeEnabled;\n};\nconst areRoughlyEqual = (a, b, precision = 0.01) => {\n return Math.abs(a - b) <= precision;\n};\nconst getElementsCorners = (elements, elementsMap, {\n omitCenter,\n boundingBoxCorners,\n dragOffset\n} = {\n omitCenter: false,\n boundingBoxCorners: false\n}) => {\n let result = [];\n\n if (elements.length === 1) {\n const element = elements[0];\n let [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getElementAbsoluteCoords)(element, elementsMap);\n\n if (dragOffset) {\n x1 += dragOffset.x;\n x2 += dragOffset.x;\n cx += dragOffset.x;\n y1 += dragOffset.y;\n y2 += dragOffset.y;\n cy += dragOffset.y;\n }\n\n const halfWidth = (x2 - x1) / 2;\n const halfHeight = (y2 - y1) / 2;\n\n if ((element.type === \"diamond\" || element.type === \"ellipse\") && !boundingBoxCorners) {\n const leftMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y1 + halfHeight), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const topMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1 + halfWidth, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const rightMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y1 + halfHeight), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const bottomMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1 + halfWidth, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy);\n result = omitCenter ? [leftMid, topMid, rightMid, bottomMid] : [leftMid, topMid, rightMid, bottomMid, center];\n } else {\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const bottomRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy);\n result = omitCenter ? [topLeft, topRight, bottomLeft, bottomRight] : [topLeft, topRight, bottomLeft, bottomRight, center];\n }\n } else if (elements.length > 1) {\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getDraggedElementsBounds)(elements, dragOffset !== null && dragOffset !== void 0 ? dragOffset : {\n x: 0,\n y: 0\n });\n const width = maxX - minX;\n const height = maxY - minY;\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY);\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY);\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY);\n const bottomRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX + width / 2, minY + height / 2);\n result = omitCenter ? [topLeft, topRight, bottomLeft, bottomRight] : [topLeft, topRight, bottomLeft, bottomRight, center];\n }\n\n return result.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1])));\n};\n\nconst getReferenceElements = (elements, selectedElements, appState, elementsMap) => {\n const selectedFrames = selectedElements.filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement)(element)).map(frame => frame.id);\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getVisibleAndNonSelectedElements)(elements, selectedElements, appState, elementsMap).filter(element => !(element.frameId && selectedFrames.includes(element.frameId)));\n};\n\nconst getVisibleGaps = (elements, selectedElements, appState, elementsMap) => {\n const referenceElements = getReferenceElements(elements, selectedElements, appState, elementsMap);\n const referenceBounds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getMaximumGroups)(referenceElements, elementsMap).filter(elementsGroup => !(elementsGroup.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isBoundToContainer)(elementsGroup[0]))).map(group => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(group).map(bound => round(bound)));\n const horizontallySorted = referenceBounds.sort((a, b) => a[0] - b[0]);\n const horizontalGaps = [];\n let c = 0;\n\n horizontal: for (let i = 0; i < horizontallySorted.length; i++) {\n const startBounds = horizontallySorted[i];\n\n for (let j = i + 1; j < horizontallySorted.length; j++) {\n if (++c > VISIBLE_GAPS_LIMIT_PER_AXIS) {\n break horizontal;\n }\n\n const endBounds = horizontallySorted[j];\n const [, startMinY, startMaxX, startMaxY] = startBounds;\n const [endMinX, endMinY,, endMaxY] = endBounds;\n\n if (startMaxX < endMinX && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinY, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinY, endMaxY))) {\n horizontalGaps.push({\n startBounds,\n endBounds,\n startSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, startMinY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, startMaxY)],\n endSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, endMinY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, endMaxY)],\n length: endMinX - startMaxX,\n overlap: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinY, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinY, endMaxY))\n });\n }\n }\n }\n\n const verticallySorted = referenceBounds.sort((a, b) => a[1] - b[1]);\n const verticalGaps = [];\n c = 0;\n\n vertical: for (let i = 0; i < verticallySorted.length; i++) {\n const startBounds = verticallySorted[i];\n\n for (let j = i + 1; j < verticallySorted.length; j++) {\n if (++c > VISIBLE_GAPS_LIMIT_PER_AXIS) {\n break vertical;\n }\n\n const endBounds = verticallySorted[j];\n const [startMinX,, startMaxX, startMaxY] = startBounds;\n const [endMinX, endMinY, endMaxX] = endBounds;\n\n if (startMaxY < endMinY && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinX, startMaxX), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinX, endMaxX))) {\n verticalGaps.push({\n startBounds,\n endBounds,\n startSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMinX, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, startMaxY)],\n endSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, endMinY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMaxX, endMinY)],\n length: endMinY - startMaxY,\n overlap: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinX, startMaxX), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinX, endMaxX))\n });\n }\n }\n }\n\n return {\n horizontalGaps,\n verticalGaps\n };\n};\n\nconst getGapSnaps = (selectedElements, dragOffset, app, event, nearestSnapsX, nearestSnapsY, minOffset) => {\n if (!isSnappingEnabled({\n app,\n event,\n selectedElements\n })) {\n return [];\n }\n\n if (selectedElements.length === 0) {\n return [];\n }\n\n const visibleGaps = SnapCache.getVisibleGaps();\n\n if (visibleGaps) {\n const {\n horizontalGaps,\n verticalGaps\n } = visibleGaps;\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getDraggedElementsBounds)(selectedElements, dragOffset).map(bound => round(bound));\n const centerX = (minX + maxX) / 2;\n const centerY = (minY + maxY) / 2;\n\n for (const gap of horizontalGaps) {\n if (!(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minY, maxY), gap.overlap)) {\n continue;\n } // center gap\n\n\n const gapMidX = gap.startSide[0][0] + gap.length / 2;\n const centerOffset = round(gapMidX - centerX);\n const gapIsLargerThanSelection = gap.length > maxX - minX;\n\n if (gapIsLargerThanSelection && Math.abs(centerOffset) <= minOffset.x) {\n if (Math.abs(centerOffset) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n minOffset.x = Math.abs(centerOffset);\n const snap = {\n type: \"gap\",\n direction: \"center_horizontal\",\n gap,\n offset: centerOffset\n };\n nearestSnapsX.push(snap);\n continue;\n } // side gap, from the right\n\n\n const [,, endMaxX] = gap.endBounds;\n const distanceToEndElementX = minX - endMaxX;\n const sideOffsetRight = round(gap.length - distanceToEndElementX);\n\n if (Math.abs(sideOffsetRight) <= minOffset.x) {\n if (Math.abs(sideOffsetRight) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n minOffset.x = Math.abs(sideOffsetRight);\n const snap = {\n type: \"gap\",\n direction: \"side_right\",\n gap,\n offset: sideOffsetRight\n };\n nearestSnapsX.push(snap);\n continue;\n } // side gap, from the left\n\n\n const [startMinX,,,] = gap.startBounds;\n const distanceToStartElementX = startMinX - maxX;\n const sideOffsetLeft = round(distanceToStartElementX - gap.length);\n\n if (Math.abs(sideOffsetLeft) <= minOffset.x) {\n if (Math.abs(sideOffsetLeft) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n minOffset.x = Math.abs(sideOffsetLeft);\n const snap = {\n type: \"gap\",\n direction: \"side_left\",\n gap,\n offset: sideOffsetLeft\n };\n nearestSnapsX.push(snap);\n continue;\n }\n }\n\n for (const gap of verticalGaps) {\n if (!(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minX, maxX), gap.overlap)) {\n continue;\n } // center gap\n\n\n const gapMidY = gap.startSide[0][1] + gap.length / 2;\n const centerOffset = round(gapMidY - centerY);\n const gapIsLargerThanSelection = gap.length > maxY - minY;\n\n if (gapIsLargerThanSelection && Math.abs(centerOffset) <= minOffset.y) {\n if (Math.abs(centerOffset) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n minOffset.y = Math.abs(centerOffset);\n const snap = {\n type: \"gap\",\n direction: \"center_vertical\",\n gap,\n offset: centerOffset\n };\n nearestSnapsY.push(snap);\n continue;\n } // side gap, from the top\n\n\n const [, startMinY,,] = gap.startBounds;\n const distanceToStartElementY = startMinY - maxY;\n const sideOffsetTop = round(distanceToStartElementY - gap.length);\n\n if (Math.abs(sideOffsetTop) <= minOffset.y) {\n if (Math.abs(sideOffsetTop) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n minOffset.y = Math.abs(sideOffsetTop);\n const snap = {\n type: \"gap\",\n direction: \"side_top\",\n gap,\n offset: sideOffsetTop\n };\n nearestSnapsY.push(snap);\n continue;\n } // side gap, from the bottom\n\n\n const [,,, endMaxY] = gap.endBounds;\n const distanceToEndElementY = round(minY - endMaxY);\n const sideOffsetBottom = gap.length - distanceToEndElementY;\n\n if (Math.abs(sideOffsetBottom) <= minOffset.y) {\n if (Math.abs(sideOffsetBottom) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n minOffset.y = Math.abs(sideOffsetBottom);\n const snap = {\n type: \"gap\",\n direction: \"side_bottom\",\n gap,\n offset: sideOffsetBottom\n };\n nearestSnapsY.push(snap);\n continue;\n }\n }\n }\n};\n\nconst getReferenceSnapPoints = (elements, selectedElements, appState, elementsMap) => {\n const referenceElements = getReferenceElements(elements, selectedElements, appState, elementsMap);\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getMaximumGroups)(referenceElements, elementsMap).filter(elementsGroup => !(elementsGroup.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isBoundToContainer)(elementsGroup[0]))).flatMap(elementGroup => getElementsCorners(elementGroup, elementsMap));\n};\n\nconst getPointSnaps = (selectedElements, selectionSnapPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset) => {\n if (!isSnappingEnabled({\n app,\n event,\n selectedElements\n }) || selectedElements.length === 0 && selectionSnapPoints.length === 0) {\n return [];\n }\n\n const referenceSnapPoints = SnapCache.getReferenceSnapPoints();\n\n if (referenceSnapPoints) {\n for (const thisSnapPoint of selectionSnapPoints) {\n for (const otherSnapPoint of referenceSnapPoints) {\n const offsetX = otherSnapPoint[0] - thisSnapPoint[0];\n const offsetY = otherSnapPoint[1] - thisSnapPoint[1];\n\n if (Math.abs(offsetX) <= minOffset.x) {\n if (Math.abs(offsetX) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n nearestSnapsX.push({\n type: \"point\",\n points: [thisSnapPoint, otherSnapPoint],\n offset: offsetX\n });\n minOffset.x = Math.abs(offsetX);\n }\n\n if (Math.abs(offsetY) <= minOffset.y) {\n if (Math.abs(offsetY) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n nearestSnapsY.push({\n type: \"point\",\n points: [thisSnapPoint, otherSnapPoint],\n offset: offsetY\n });\n minOffset.y = Math.abs(offsetY);\n }\n }\n }\n }\n};\n\nconst snapDraggedElements = (elements, dragOffset, app, event, elementsMap) => {\n var _a, _b, _c, _d;\n\n const appState = app.state;\n const selectedElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getSelectedElements)(elements, appState);\n\n if (!isSnappingEnabled({\n app,\n event,\n selectedElements\n }) || selectedElements.length === 0) {\n return {\n snapOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n dragOffset.x = round(dragOffset.x);\n dragOffset.y = round(dragOffset.y);\n const nearestSnapsX = [];\n const nearestSnapsY = [];\n const snapDistance = getSnapDistance(appState.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const selectionPoints = getElementsCorners(selectedElements, elementsMap, {\n dragOffset\n }); // get the nearest horizontal and vertical point and gap snaps\n\n getPointSnaps(selectedElements, selectionPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n getGapSnaps(selectedElements, dragOffset, app, event, nearestSnapsX, nearestSnapsY, minOffset); // using the nearest snaps to figure out how\n // much the elements need to be offset to be snapped\n // to some reference elements\n\n const snapOffset = {\n x: (_b = (_a = nearestSnapsX[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0,\n y: (_d = (_c = nearestSnapsY[0]) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0\n }; // once the elements are snapped\n // and moved to the snapped position\n // we want to use the element's snapped position\n // to update nearest snaps so that we can create\n // point and gap snap lines correctly without any shifting\n\n minOffset.x = 0;\n minOffset.y = 0;\n nearestSnapsX.length = 0;\n nearestSnapsY.length = 0;\n const newDragOffset = {\n x: round(dragOffset.x + snapOffset.x),\n y: round(dragOffset.y + snapOffset.y)\n };\n getPointSnaps(selectedElements, getElementsCorners(selectedElements, elementsMap, {\n dragOffset: newDragOffset\n }), app, event, nearestSnapsX, nearestSnapsY, minOffset);\n getGapSnaps(selectedElements, newDragOffset, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);\n const gapSnapLines = createGapSnapLines(selectedElements, newDragOffset, [...nearestSnapsX, ...nearestSnapsY].filter(snap => snap.type === \"gap\"));\n return {\n snapOffset,\n snapLines: [...pointSnapLines, ...gapSnapLines]\n };\n};\n\nconst round = x => {\n const decimalPlaces = 6;\n return Math.round(x * 10 ** decimalPlaces) / 10 ** decimalPlaces;\n};\n\nconst dedupePoints = points => {\n const map = new Map();\n\n for (const point of points) {\n const key = point.join(\",\");\n\n if (!map.has(key)) {\n map.set(key, point);\n }\n }\n\n return Array.from(map.values());\n};\n\nconst createPointSnapLines = (nearestSnapsX, nearestSnapsY) => {\n const snapsX = {};\n const snapsY = {};\n\n if (nearestSnapsX.length > 0) {\n for (const snap of nearestSnapsX) {\n if (snap.type === \"point\") {\n // key = thisPoint.x\n const key = round(snap.points[0][0]);\n\n if (!snapsX[key]) {\n snapsX[key] = [];\n }\n\n snapsX[key].push(...snap.points.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1]))));\n }\n }\n }\n\n if (nearestSnapsY.length > 0) {\n for (const snap of nearestSnapsY) {\n if (snap.type === \"point\") {\n // key = thisPoint.y\n const key = round(snap.points[0][1]);\n\n if (!snapsY[key]) {\n snapsY[key] = [];\n }\n\n snapsY[key].push(...snap.points.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1]))));\n }\n }\n }\n\n return Object.entries(snapsX).map(([key, points]) => {\n return {\n type: \"points\",\n points: dedupePoints(points.map(p => {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(Number(key), p[1]);\n }).sort((a, b) => a[1] - b[1]))\n };\n }).concat(Object.entries(snapsY).map(([key, points]) => {\n return {\n type: \"points\",\n points: dedupePoints(points.map(p => {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(p[0], Number(key));\n }).sort((a, b) => a[0] - b[0]))\n };\n }));\n};\n\nconst dedupeGapSnapLines = gapSnapLines => {\n const map = new Map();\n\n for (const gapSnapLine of gapSnapLines) {\n const key = gapSnapLine.points.flat().map(point => [round(point)]).join(\",\");\n\n if (!map.has(key)) {\n map.set(key, gapSnapLine);\n }\n }\n\n return Array.from(map.values());\n};\n\nconst createGapSnapLines = (selectedElements, dragOffset, gapSnaps) => {\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getDraggedElementsBounds)(selectedElements, dragOffset);\n const gapSnapLines = [];\n\n for (const gapSnap of gapSnaps) {\n const [startMinX, startMinY, startMaxX, startMaxY] = gapSnap.gap.startBounds;\n const [endMinX, endMinY, endMaxX, endMaxY] = gapSnap.gap.endBounds;\n const verticalIntersection = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minY, maxY), gapSnap.gap.overlap);\n const horizontalGapIntersection = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minX, maxX), gapSnap.gap.overlap);\n\n switch (gapSnap.direction) {\n case \"center_horizontal\":\n {\n if (verticalIntersection) {\n const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapSnap.gap.startSide[0][0], gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, gapLineY)]\n }, {\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapSnap.gap.endSide[0][0], gapLineY)]\n });\n }\n\n break;\n }\n\n case \"center_vertical\":\n {\n if (horizontalGapIntersection) {\n const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, gapSnap.gap.startSide[0][1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, minY)]\n }, {\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, maxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, gapSnap.gap.endSide[0][1])]\n });\n }\n\n break;\n }\n\n case \"side_right\":\n {\n if (verticalIntersection) {\n const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, gapLineY)]\n }, {\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMaxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, gapLineY)]\n });\n }\n\n break;\n }\n\n case \"side_left\":\n {\n if (verticalIntersection) {\n const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMinX, gapLineY)]\n }, {\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, gapLineY)]\n });\n }\n\n break;\n }\n\n case \"side_top\":\n {\n if (horizontalGapIntersection) {\n const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, maxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, startMinY)]\n }, {\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, endMinY)]\n });\n }\n\n break;\n }\n\n case \"side_bottom\":\n {\n if (horizontalGapIntersection) {\n const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, endMinY)]\n }, {\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, endMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, minY)]\n });\n }\n\n break;\n }\n }\n }\n\n return dedupeGapSnapLines(gapSnapLines.map(gapSnapLine => {\n return Object.assign(Object.assign({}, gapSnapLine), {\n points: gapSnapLine.points.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1])))\n });\n }));\n};\n\nconst snapResizingElements = ( // use the latest elements to create snap lines\nselectedElements, // while using the original elements to appy dragOffset to calculate snaps\nselectedOriginalElements, app, event, dragOffset, transformHandle) => {\n var _a, _b, _c, _d;\n\n if (!isSnappingEnabled({\n event,\n selectedElements,\n app\n }) || selectedElements.length === 0 || selectedElements.length === 1 && !areRoughlyEqual(selectedElements[0].angle, 0)) {\n return {\n snapOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n let [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(selectedOriginalElements);\n\n if (transformHandle) {\n if (transformHandle.includes(\"e\")) {\n maxX += dragOffset.x;\n } else if (transformHandle.includes(\"w\")) {\n minX += dragOffset.x;\n }\n\n if (transformHandle.includes(\"n\")) {\n minY += dragOffset.y;\n } else if (transformHandle.includes(\"s\")) {\n maxY += dragOffset.y;\n }\n }\n\n const selectionSnapPoints = [];\n\n if (transformHandle) {\n switch (transformHandle) {\n case \"e\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY));\n break;\n }\n\n case \"w\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY));\n break;\n }\n\n case \"n\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY));\n break;\n }\n\n case \"s\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY));\n break;\n }\n\n case \"ne\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY));\n break;\n }\n\n case \"nw\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY));\n break;\n }\n\n case \"se\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY));\n break;\n }\n\n case \"sw\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY));\n break;\n }\n }\n }\n\n const snapDistance = getSnapDistance(app.state.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const nearestSnapsX = [];\n const nearestSnapsY = [];\n getPointSnaps(selectedOriginalElements, selectionSnapPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const snapOffset = {\n x: (_b = (_a = nearestSnapsX[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0,\n y: (_d = (_c = nearestSnapsY[0]) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0\n }; // again, once snap offset is calculated\n // reset to recompute for creating snap lines to be rendered\n\n minOffset.x = 0;\n minOffset.y = 0;\n nearestSnapsX.length = 0;\n nearestSnapsY.length = 0;\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(selectedElements).map(bound => round(bound));\n const corners = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y2)];\n getPointSnaps(selectedElements, corners, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);\n return {\n snapOffset,\n snapLines: pointSnapLines\n };\n};\nconst snapNewElement = (newElement, app, event, origin, dragOffset, elementsMap) => {\n var _a, _b, _c, _d;\n\n if (!isSnappingEnabled({\n event,\n selectedElements: [newElement],\n app\n })) {\n return {\n snapOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n const selectionSnapPoints = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(origin.x + dragOffset.x, origin.y + dragOffset.y)];\n const snapDistance = getSnapDistance(app.state.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const nearestSnapsX = [];\n const nearestSnapsY = [];\n getPointSnaps([newElement], selectionSnapPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const snapOffset = {\n x: (_b = (_a = nearestSnapsX[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0,\n y: (_d = (_c = nearestSnapsY[0]) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0\n };\n minOffset.x = 0;\n minOffset.y = 0;\n nearestSnapsX.length = 0;\n nearestSnapsY.length = 0;\n const corners = getElementsCorners([newElement], elementsMap, {\n boundingBoxCorners: true,\n omitCenter: true\n });\n getPointSnaps([newElement], corners, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);\n return {\n snapOffset,\n snapLines: pointSnapLines\n };\n};\nconst getSnapLinesAtPointer = (elements, app, pointer, event, elementsMap) => {\n if (!isSnappingEnabled({\n event,\n selectedElements: [],\n app\n })) {\n return {\n originOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n const referenceElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getVisibleAndNonSelectedElements)(elements, [], app.state, elementsMap);\n const snapDistance = getSnapDistance(app.state.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const horizontalSnapLines = [];\n const verticalSnapLines = [];\n\n for (const referenceElement of referenceElements) {\n const corners = getElementsCorners([referenceElement], elementsMap);\n\n for (const corner of corners) {\n const offsetX = corner[0] - pointer.x;\n\n if (Math.abs(offsetX) <= Math.abs(minOffset.x)) {\n if (Math.abs(offsetX) < Math.abs(minOffset.x)) {\n verticalSnapLines.length = 0;\n }\n\n verticalSnapLines.push({\n type: \"pointer\",\n points: [corner, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(corner[0], pointer.y)],\n direction: \"vertical\"\n });\n minOffset.x = offsetX;\n }\n\n const offsetY = corner[1] - pointer.y;\n\n if (Math.abs(offsetY) <= Math.abs(minOffset.y)) {\n if (Math.abs(offsetY) < Math.abs(minOffset.y)) {\n horizontalSnapLines.length = 0;\n }\n\n horizontalSnapLines.push({\n type: \"pointer\",\n points: [corner, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(pointer.x, corner[1])],\n direction: \"horizontal\"\n });\n minOffset.y = offsetY;\n }\n }\n }\n\n return {\n originOffset: {\n x: verticalSnapLines.length > 0 ? verticalSnapLines[0].points[0][0] - pointer.x : 0,\n y: horizontalSnapLines.length > 0 ? horizontalSnapLines[0].points[0][1] - pointer.y : 0\n },\n snapLines: [...verticalSnapLines, ...horizontalSnapLines]\n };\n};\nconst isActiveToolNonLinearSnappable = activeToolType => {\n return activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.rectangle || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.ellipse || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.diamond || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.frame || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.magicframe || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.image || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.text;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./snapping.ts?");
20705
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SnapCache: () => (/* binding */ SnapCache),\n/* harmony export */ areRoughlyEqual: () => (/* binding */ areRoughlyEqual),\n/* harmony export */ getElementsCorners: () => (/* binding */ getElementsCorners),\n/* harmony export */ getReferenceSnapPoints: () => (/* binding */ getReferenceSnapPoints),\n/* harmony export */ getSnapDistance: () => (/* binding */ getSnapDistance),\n/* harmony export */ getSnapLinesAtPointer: () => (/* binding */ getSnapLinesAtPointer),\n/* harmony export */ getVisibleGaps: () => (/* binding */ getVisibleGaps),\n/* harmony export */ isActiveToolNonLinearSnappable: () => (/* binding */ isActiveToolNonLinearSnappable),\n/* harmony export */ isGridModeEnabled: () => (/* binding */ isGridModeEnabled),\n/* harmony export */ isSnappingEnabled: () => (/* binding */ isSnappingEnabled),\n/* harmony export */ snapDraggedElements: () => (/* binding */ snapDraggedElements),\n/* harmony export */ snapNewElement: () => (/* binding */ snapNewElement),\n/* harmony export */ snapResizingElements: () => (/* binding */ snapResizingElements)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n\n\n\n\n\n\nconst SNAP_DISTANCE = 8; // do not comput more gaps per axis than this limit\n// TODO increase or remove once we optimize\n\nconst VISIBLE_GAPS_LIMIT_PER_AXIS = 99999; // snap distance with zoom value taken into consideration\n\nconst getSnapDistance = zoomValue => {\n return SNAP_DISTANCE / zoomValue;\n}; // -----------------------------------------------------------------------------\n\nclass SnapCache {}\nSnapCache.referenceSnapPoints = null;\nSnapCache.visibleGaps = null;\n\nSnapCache.setReferenceSnapPoints = snapPoints => {\n SnapCache.referenceSnapPoints = snapPoints;\n};\n\nSnapCache.getReferenceSnapPoints = () => {\n return SnapCache.referenceSnapPoints;\n};\n\nSnapCache.setVisibleGaps = gaps => {\n SnapCache.visibleGaps = gaps;\n};\n\nSnapCache.getVisibleGaps = () => {\n return SnapCache.visibleGaps;\n};\n\nSnapCache.destroy = () => {\n SnapCache.referenceSnapPoints = null;\n SnapCache.visibleGaps = null;\n}; // -----------------------------------------------------------------------------\n\n\nconst isGridModeEnabled = app => {\n var _a;\n\n return (_a = app.props.gridModeEnabled) !== null && _a !== void 0 ? _a : app.state.gridModeEnabled;\n};\nconst isSnappingEnabled = ({\n event,\n app,\n selectedElements\n}) => {\n if (event) {\n return app.state.activeTool.type !== \"lasso\" && (app.state.objectsSnapModeEnabled && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || !app.state.objectsSnapModeEnabled && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] && !isGridModeEnabled(app));\n } // do not suggest snaps for an arrow to give way to binding\n\n\n if (selectedElements.length === 1 && selectedElements[0].type === \"arrow\") {\n return false;\n }\n\n return app.state.objectsSnapModeEnabled;\n};\nconst areRoughlyEqual = (a, b, precision = 0.01) => {\n return Math.abs(a - b) <= precision;\n};\nconst getElementsCorners = (elements, elementsMap, {\n omitCenter,\n boundingBoxCorners,\n dragOffset\n} = {\n omitCenter: false,\n boundingBoxCorners: false\n}) => {\n let result = [];\n\n if (elements.length === 1) {\n const element = elements[0];\n let [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getElementAbsoluteCoords)(element, elementsMap);\n\n if (dragOffset) {\n x1 += dragOffset.x;\n x2 += dragOffset.x;\n cx += dragOffset.x;\n y1 += dragOffset.y;\n y2 += dragOffset.y;\n cy += dragOffset.y;\n }\n\n const halfWidth = (x2 - x1) / 2;\n const halfHeight = (y2 - y1) / 2;\n\n if ((element.type === \"diamond\" || element.type === \"ellipse\") && !boundingBoxCorners) {\n const leftMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y1 + halfHeight), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const topMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1 + halfWidth, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const rightMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y1 + halfHeight), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const bottomMid = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1 + halfWidth, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy);\n result = omitCenter ? [leftMid, topMid, rightMid, bottomMid] : [leftMid, topMid, rightMid, bottomMid, center];\n } else {\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const bottomRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy), element.angle);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(cx, cy);\n result = omitCenter ? [topLeft, topRight, bottomLeft, bottomRight] : [topLeft, topRight, bottomLeft, bottomRight, center];\n }\n } else if (elements.length > 1) {\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getDraggedElementsBounds)(elements, dragOffset !== null && dragOffset !== void 0 ? dragOffset : {\n x: 0,\n y: 0\n });\n const width = maxX - minX;\n const height = maxY - minY;\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY);\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY);\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY);\n const bottomRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY);\n const center = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX + width / 2, minY + height / 2);\n result = omitCenter ? [topLeft, topRight, bottomLeft, bottomRight] : [topLeft, topRight, bottomLeft, bottomRight, center];\n }\n\n return result.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1])));\n};\n\nconst getReferenceElements = (elements, selectedElements, appState, elementsMap) => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getVisibleAndNonSelectedElements)(elements, selectedElements, appState, elementsMap);\n\nconst getVisibleGaps = (elements, selectedElements, appState, elementsMap) => {\n const referenceElements = getReferenceElements(elements, selectedElements, appState, elementsMap);\n const referenceBounds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getMaximumGroups)(referenceElements, elementsMap).filter(elementsGroup => !(elementsGroup.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isBoundToContainer)(elementsGroup[0]))).map(group => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(group).map(bound => round(bound)));\n const horizontallySorted = referenceBounds.sort((a, b) => a[0] - b[0]);\n const horizontalGaps = [];\n let c = 0;\n\n horizontal: for (let i = 0; i < horizontallySorted.length; i++) {\n const startBounds = horizontallySorted[i];\n\n for (let j = i + 1; j < horizontallySorted.length; j++) {\n if (++c > VISIBLE_GAPS_LIMIT_PER_AXIS) {\n break horizontal;\n }\n\n const endBounds = horizontallySorted[j];\n const [, startMinY, startMaxX, startMaxY] = startBounds;\n const [endMinX, endMinY,, endMaxY] = endBounds;\n\n if (startMaxX < endMinX && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinY, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinY, endMaxY))) {\n horizontalGaps.push({\n startBounds,\n endBounds,\n startSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, startMinY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, startMaxY)],\n endSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, endMinY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, endMaxY)],\n length: endMinX - startMaxX,\n overlap: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinY, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinY, endMaxY))\n });\n }\n }\n }\n\n const verticallySorted = referenceBounds.sort((a, b) => a[1] - b[1]);\n const verticalGaps = [];\n c = 0;\n\n vertical: for (let i = 0; i < verticallySorted.length; i++) {\n const startBounds = verticallySorted[i];\n\n for (let j = i + 1; j < verticallySorted.length; j++) {\n if (++c > VISIBLE_GAPS_LIMIT_PER_AXIS) {\n break vertical;\n }\n\n const endBounds = verticallySorted[j];\n const [startMinX,, startMaxX, startMaxY] = startBounds;\n const [endMinX, endMinY, endMaxX] = endBounds;\n\n if (startMaxY < endMinY && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinX, startMaxX), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinX, endMaxX))) {\n verticalGaps.push({\n startBounds,\n endBounds,\n startSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMinX, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, startMaxY)],\n endSide: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, endMinY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMaxX, endMinY)],\n length: endMinY - startMaxY,\n overlap: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(startMinX, startMaxX), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(endMinX, endMaxX))\n });\n }\n }\n }\n\n return {\n horizontalGaps,\n verticalGaps\n };\n};\n\nconst getGapSnaps = (selectedElements, dragOffset, app, event, nearestSnapsX, nearestSnapsY, minOffset) => {\n if (!isSnappingEnabled({\n app,\n event,\n selectedElements\n })) {\n return [];\n }\n\n if (selectedElements.length === 0) {\n return [];\n }\n\n const visibleGaps = SnapCache.getVisibleGaps();\n\n if (visibleGaps) {\n const {\n horizontalGaps,\n verticalGaps\n } = visibleGaps;\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getDraggedElementsBounds)(selectedElements, dragOffset).map(bound => round(bound));\n const centerX = (minX + maxX) / 2;\n const centerY = (minY + maxY) / 2;\n\n for (const gap of horizontalGaps) {\n if (!(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minY, maxY), gap.overlap)) {\n continue;\n } // center gap\n\n\n const gapMidX = gap.startSide[0][0] + gap.length / 2;\n const centerOffset = round(gapMidX - centerX);\n const gapIsLargerThanSelection = gap.length > maxX - minX;\n\n if (gapIsLargerThanSelection && Math.abs(centerOffset) <= minOffset.x) {\n if (Math.abs(centerOffset) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n minOffset.x = Math.abs(centerOffset);\n const snap = {\n type: \"gap\",\n direction: \"center_horizontal\",\n gap,\n offset: centerOffset\n };\n nearestSnapsX.push(snap);\n continue;\n } // side gap, from the right\n\n\n const [,, endMaxX] = gap.endBounds;\n const distanceToEndElementX = minX - endMaxX;\n const sideOffsetRight = round(gap.length - distanceToEndElementX);\n\n if (Math.abs(sideOffsetRight) <= minOffset.x) {\n if (Math.abs(sideOffsetRight) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n minOffset.x = Math.abs(sideOffsetRight);\n const snap = {\n type: \"gap\",\n direction: \"side_right\",\n gap,\n offset: sideOffsetRight\n };\n nearestSnapsX.push(snap);\n continue;\n } // side gap, from the left\n\n\n const [startMinX,,,] = gap.startBounds;\n const distanceToStartElementX = startMinX - maxX;\n const sideOffsetLeft = round(distanceToStartElementX - gap.length);\n\n if (Math.abs(sideOffsetLeft) <= minOffset.x) {\n if (Math.abs(sideOffsetLeft) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n minOffset.x = Math.abs(sideOffsetLeft);\n const snap = {\n type: \"gap\",\n direction: \"side_left\",\n gap,\n offset: sideOffsetLeft\n };\n nearestSnapsX.push(snap);\n continue;\n }\n }\n\n for (const gap of verticalGaps) {\n if (!(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangesOverlap)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minX, maxX), gap.overlap)) {\n continue;\n } // center gap\n\n\n const gapMidY = gap.startSide[0][1] + gap.length / 2;\n const centerOffset = round(gapMidY - centerY);\n const gapIsLargerThanSelection = gap.length > maxY - minY;\n\n if (gapIsLargerThanSelection && Math.abs(centerOffset) <= minOffset.y) {\n if (Math.abs(centerOffset) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n minOffset.y = Math.abs(centerOffset);\n const snap = {\n type: \"gap\",\n direction: \"center_vertical\",\n gap,\n offset: centerOffset\n };\n nearestSnapsY.push(snap);\n continue;\n } // side gap, from the top\n\n\n const [, startMinY,,] = gap.startBounds;\n const distanceToStartElementY = startMinY - maxY;\n const sideOffsetTop = round(distanceToStartElementY - gap.length);\n\n if (Math.abs(sideOffsetTop) <= minOffset.y) {\n if (Math.abs(sideOffsetTop) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n minOffset.y = Math.abs(sideOffsetTop);\n const snap = {\n type: \"gap\",\n direction: \"side_top\",\n gap,\n offset: sideOffsetTop\n };\n nearestSnapsY.push(snap);\n continue;\n } // side gap, from the bottom\n\n\n const [,,, endMaxY] = gap.endBounds;\n const distanceToEndElementY = round(minY - endMaxY);\n const sideOffsetBottom = gap.length - distanceToEndElementY;\n\n if (Math.abs(sideOffsetBottom) <= minOffset.y) {\n if (Math.abs(sideOffsetBottom) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n minOffset.y = Math.abs(sideOffsetBottom);\n const snap = {\n type: \"gap\",\n direction: \"side_bottom\",\n gap,\n offset: sideOffsetBottom\n };\n nearestSnapsY.push(snap);\n continue;\n }\n }\n }\n};\n\nconst getReferenceSnapPoints = (elements, selectedElements, appState, elementsMap) => {\n const referenceElements = getReferenceElements(elements, selectedElements, appState, elementsMap);\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getMaximumGroups)(referenceElements, elementsMap).filter(elementsGroup => !(elementsGroup.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.isBoundToContainer)(elementsGroup[0]))).flatMap(elementGroup => getElementsCorners(elementGroup, elementsMap));\n};\n\nconst getPointSnaps = (selectedElements, selectionSnapPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset) => {\n if (!isSnappingEnabled({\n app,\n event,\n selectedElements\n }) || selectedElements.length === 0 && selectionSnapPoints.length === 0) {\n return [];\n }\n\n const referenceSnapPoints = SnapCache.getReferenceSnapPoints();\n\n if (referenceSnapPoints) {\n for (const thisSnapPoint of selectionSnapPoints) {\n for (const otherSnapPoint of referenceSnapPoints) {\n const offsetX = otherSnapPoint[0] - thisSnapPoint[0];\n const offsetY = otherSnapPoint[1] - thisSnapPoint[1];\n\n if (Math.abs(offsetX) <= minOffset.x) {\n if (Math.abs(offsetX) < minOffset.x) {\n nearestSnapsX.length = 0;\n }\n\n nearestSnapsX.push({\n type: \"point\",\n points: [thisSnapPoint, otherSnapPoint],\n offset: offsetX\n });\n minOffset.x = Math.abs(offsetX);\n }\n\n if (Math.abs(offsetY) <= minOffset.y) {\n if (Math.abs(offsetY) < minOffset.y) {\n nearestSnapsY.length = 0;\n }\n\n nearestSnapsY.push({\n type: \"point\",\n points: [thisSnapPoint, otherSnapPoint],\n offset: offsetY\n });\n minOffset.y = Math.abs(offsetY);\n }\n }\n }\n }\n};\n\nconst snapDraggedElements = (elements, dragOffset, app, event, elementsMap) => {\n var _a, _b, _c, _d;\n\n const appState = app.state;\n const selectedElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getSelectedElements)(elements, appState);\n\n if (!isSnappingEnabled({\n app,\n event,\n selectedElements\n }) || selectedElements.length === 0) {\n return {\n snapOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n dragOffset.x = round(dragOffset.x);\n dragOffset.y = round(dragOffset.y);\n const nearestSnapsX = [];\n const nearestSnapsY = [];\n const snapDistance = getSnapDistance(appState.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const selectionPoints = getElementsCorners(selectedElements, elementsMap, {\n dragOffset\n }); // get the nearest horizontal and vertical point and gap snaps\n\n getPointSnaps(selectedElements, selectionPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n getGapSnaps(selectedElements, dragOffset, app, event, nearestSnapsX, nearestSnapsY, minOffset); // using the nearest snaps to figure out how\n // much the elements need to be offset to be snapped\n // to some reference elements\n\n const snapOffset = {\n x: (_b = (_a = nearestSnapsX[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0,\n y: (_d = (_c = nearestSnapsY[0]) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0\n }; // once the elements are snapped\n // and moved to the snapped position\n // we want to use the element's snapped position\n // to update nearest snaps so that we can create\n // point and gap snap lines correctly without any shifting\n\n minOffset.x = 0;\n minOffset.y = 0;\n nearestSnapsX.length = 0;\n nearestSnapsY.length = 0;\n const newDragOffset = {\n x: round(dragOffset.x + snapOffset.x),\n y: round(dragOffset.y + snapOffset.y)\n };\n getPointSnaps(selectedElements, getElementsCorners(selectedElements, elementsMap, {\n dragOffset: newDragOffset\n }), app, event, nearestSnapsX, nearestSnapsY, minOffset);\n getGapSnaps(selectedElements, newDragOffset, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);\n const gapSnapLines = createGapSnapLines(selectedElements, newDragOffset, [...nearestSnapsX, ...nearestSnapsY].filter(snap => snap.type === \"gap\"));\n return {\n snapOffset,\n snapLines: [...pointSnapLines, ...gapSnapLines]\n };\n};\n\nconst round = x => {\n const decimalPlaces = 6;\n return Math.round(x * 10 ** decimalPlaces) / 10 ** decimalPlaces;\n};\n\nconst dedupePoints = points => {\n const map = new Map();\n\n for (const point of points) {\n const key = point.join(\",\");\n\n if (!map.has(key)) {\n map.set(key, point);\n }\n }\n\n return Array.from(map.values());\n};\n\nconst createPointSnapLines = (nearestSnapsX, nearestSnapsY) => {\n const snapsX = {};\n const snapsY = {};\n\n if (nearestSnapsX.length > 0) {\n for (const snap of nearestSnapsX) {\n if (snap.type === \"point\") {\n // key = thisPoint.x\n const key = round(snap.points[0][0]);\n\n if (!snapsX[key]) {\n snapsX[key] = [];\n }\n\n snapsX[key].push(...snap.points.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1]))));\n }\n }\n }\n\n if (nearestSnapsY.length > 0) {\n for (const snap of nearestSnapsY) {\n if (snap.type === \"point\") {\n // key = thisPoint.y\n const key = round(snap.points[0][1]);\n\n if (!snapsY[key]) {\n snapsY[key] = [];\n }\n\n snapsY[key].push(...snap.points.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1]))));\n }\n }\n }\n\n return Object.entries(snapsX).map(([key, points]) => {\n return {\n type: \"points\",\n points: dedupePoints(points.map(p => {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(Number(key), p[1]);\n }).sort((a, b) => a[1] - b[1]))\n };\n }).concat(Object.entries(snapsY).map(([key, points]) => {\n return {\n type: \"points\",\n points: dedupePoints(points.map(p => {\n return (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(p[0], Number(key));\n }).sort((a, b) => a[0] - b[0]))\n };\n }));\n};\n\nconst dedupeGapSnapLines = gapSnapLines => {\n const map = new Map();\n\n for (const gapSnapLine of gapSnapLines) {\n const key = gapSnapLine.points.flat().map(point => [round(point)]).join(\",\");\n\n if (!map.has(key)) {\n map.set(key, gapSnapLine);\n }\n }\n\n return Array.from(map.values());\n};\n\nconst createGapSnapLines = (selectedElements, dragOffset, gapSnaps) => {\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getDraggedElementsBounds)(selectedElements, dragOffset);\n const gapSnapLines = [];\n\n for (const gapSnap of gapSnaps) {\n const [startMinX, startMinY, startMaxX, startMaxY] = gapSnap.gap.startBounds;\n const [endMinX, endMinY, endMaxX, endMaxY] = gapSnap.gap.endBounds;\n const verticalIntersection = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minY, maxY), gapSnap.gap.overlap);\n const horizontalGapIntersection = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeIntersection)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.rangeInclusive)(minX, maxX), gapSnap.gap.overlap);\n\n switch (gapSnap.direction) {\n case \"center_horizontal\":\n {\n if (verticalIntersection) {\n const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapSnap.gap.startSide[0][0], gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, gapLineY)]\n }, {\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapSnap.gap.endSide[0][0], gapLineY)]\n });\n }\n\n break;\n }\n\n case \"center_vertical\":\n {\n if (horizontalGapIntersection) {\n const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, gapSnap.gap.startSide[0][1]), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, minY)]\n }, {\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, maxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, gapSnap.gap.endSide[0][1])]\n });\n }\n\n break;\n }\n\n case \"side_right\":\n {\n if (verticalIntersection) {\n const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, gapLineY)]\n }, {\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMaxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, gapLineY)]\n });\n }\n\n break;\n }\n\n case \"side_left\":\n {\n if (verticalIntersection) {\n const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMinX, gapLineY)]\n }, {\n type: \"gap\",\n direction: \"horizontal\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(startMaxX, gapLineY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(endMinX, gapLineY)]\n });\n }\n\n break;\n }\n\n case \"side_top\":\n {\n if (horizontalGapIntersection) {\n const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, maxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, startMinY)]\n }, {\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, endMinY)]\n });\n }\n\n break;\n }\n\n case \"side_bottom\":\n {\n if (horizontalGapIntersection) {\n const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;\n gapSnapLines.push({\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, startMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, endMinY)]\n }, {\n type: \"gap\",\n direction: \"vertical\",\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, endMaxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(gapLineX, minY)]\n });\n }\n\n break;\n }\n }\n }\n\n return dedupeGapSnapLines(gapSnapLines.map(gapSnapLine => {\n return Object.assign(Object.assign({}, gapSnapLine), {\n points: gapSnapLine.points.map(p => (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(round(p[0]), round(p[1])))\n });\n }));\n};\n\nconst snapResizingElements = ( // use the latest elements to create snap lines\nselectedElements, // while using the original elements to appy dragOffset to calculate snaps\nselectedOriginalElements, app, event, dragOffset, transformHandle) => {\n var _a, _b, _c, _d;\n\n if (!isSnappingEnabled({\n event,\n selectedElements,\n app\n }) || selectedElements.length === 0 || selectedElements.length === 1 && !areRoughlyEqual(selectedElements[0].angle, 0)) {\n return {\n snapOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n let [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(selectedOriginalElements);\n\n if (transformHandle) {\n if (transformHandle.includes(\"e\")) {\n maxX += dragOffset.x;\n } else if (transformHandle.includes(\"w\")) {\n minX += dragOffset.x;\n }\n\n if (transformHandle.includes(\"n\")) {\n minY += dragOffset.y;\n } else if (transformHandle.includes(\"s\")) {\n maxY += dragOffset.y;\n }\n }\n\n const selectionSnapPoints = [];\n\n if (transformHandle) {\n switch (transformHandle) {\n case \"e\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY));\n break;\n }\n\n case \"w\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY));\n break;\n }\n\n case \"n\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY));\n break;\n }\n\n case \"s\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY));\n break;\n }\n\n case \"ne\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, minY));\n break;\n }\n\n case \"nw\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, minY));\n break;\n }\n\n case \"se\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(maxX, maxY));\n break;\n }\n\n case \"sw\":\n {\n selectionSnapPoints.push((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(minX, maxY));\n break;\n }\n }\n }\n\n const snapDistance = getSnapDistance(app.state.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const nearestSnapsX = [];\n const nearestSnapsY = [];\n getPointSnaps(selectedOriginalElements, selectionSnapPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const snapOffset = {\n x: (_b = (_a = nearestSnapsX[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0,\n y: (_d = (_c = nearestSnapsY[0]) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0\n }; // again, once snap offset is calculated\n // reset to recompute for creating snap lines to be rendered\n\n minOffset.x = 0;\n minOffset.y = 0;\n nearestSnapsX.length = 0;\n nearestSnapsY.length = 0;\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)(selectedElements).map(bound => round(bound));\n const corners = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(x2, y2)];\n getPointSnaps(selectedElements, corners, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);\n return {\n snapOffset,\n snapLines: pointSnapLines\n };\n};\nconst snapNewElement = (newElement, app, event, origin, dragOffset, elementsMap) => {\n var _a, _b, _c, _d;\n\n if (!isSnappingEnabled({\n event,\n selectedElements: [newElement],\n app\n })) {\n return {\n snapOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n const selectionSnapPoints = [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(origin.x + dragOffset.x, origin.y + dragOffset.y)];\n const snapDistance = getSnapDistance(app.state.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const nearestSnapsX = [];\n const nearestSnapsY = [];\n getPointSnaps([newElement], selectionSnapPoints, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const snapOffset = {\n x: (_b = (_a = nearestSnapsX[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0,\n y: (_d = (_c = nearestSnapsY[0]) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0\n };\n minOffset.x = 0;\n minOffset.y = 0;\n nearestSnapsX.length = 0;\n nearestSnapsY.length = 0;\n const corners = getElementsCorners([newElement], elementsMap, {\n boundingBoxCorners: true,\n omitCenter: true\n });\n getPointSnaps([newElement], corners, app, event, nearestSnapsX, nearestSnapsY, minOffset);\n const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);\n return {\n snapOffset,\n snapLines: pointSnapLines\n };\n};\nconst getSnapLinesAtPointer = (elements, app, pointer, event, elementsMap) => {\n if (!isSnappingEnabled({\n event,\n selectedElements: [],\n app\n })) {\n return {\n originOffset: {\n x: 0,\n y: 0\n },\n snapLines: []\n };\n }\n\n const referenceElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getVisibleAndNonSelectedElements)(elements, [], app.state, elementsMap);\n const snapDistance = getSnapDistance(app.state.zoom.value);\n const minOffset = {\n x: snapDistance,\n y: snapDistance\n };\n const horizontalSnapLines = [];\n const verticalSnapLines = [];\n\n for (const referenceElement of referenceElements) {\n const corners = getElementsCorners([referenceElement], elementsMap);\n\n for (const corner of corners) {\n const offsetX = corner[0] - pointer.x;\n\n if (Math.abs(offsetX) <= Math.abs(minOffset.x)) {\n if (Math.abs(offsetX) < Math.abs(minOffset.x)) {\n verticalSnapLines.length = 0;\n }\n\n verticalSnapLines.push({\n type: \"pointer\",\n points: [corner, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(corner[0], pointer.y)],\n direction: \"vertical\"\n });\n minOffset.x = offsetX;\n }\n\n const offsetY = corner[1] - pointer.y;\n\n if (Math.abs(offsetY) <= Math.abs(minOffset.y)) {\n if (Math.abs(offsetY) < Math.abs(minOffset.y)) {\n horizontalSnapLines.length = 0;\n }\n\n horizontalSnapLines.push({\n type: \"pointer\",\n points: [corner, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.pointFrom)(pointer.x, corner[1])],\n direction: \"horizontal\"\n });\n minOffset.y = offsetY;\n }\n }\n }\n\n return {\n originOffset: {\n x: verticalSnapLines.length > 0 ? verticalSnapLines[0].points[0][0] - pointer.x : 0,\n y: horizontalSnapLines.length > 0 ? horizontalSnapLines[0].points[0][1] - pointer.y : 0\n },\n snapLines: [...verticalSnapLines, ...horizontalSnapLines]\n };\n};\nconst isActiveToolNonLinearSnappable = activeToolType => {\n return activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.rectangle || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.ellipse || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.diamond || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.frame || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.magicframe || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.image || activeToolType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.TOOL_TYPE.text;\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./snapping.ts?");
20706
20706
 
20707
20707
  /***/ }),
20708
20708