diff options
| author | marcellus <msimon_fr@hotmail.com> | 2025-04-14 18:00:23 +0200 |
|---|---|---|
| committer | marcellus <msimon_fr@hotmail.com> | 2025-04-14 18:00:23 +0200 |
| commit | ec8b70c184b847f886e63f9718a9cb1329ae71d2 (patch) | |
| tree | 75fb15602be9d400e3395a12456c91672a7f0357 /.obsidian/plugins/ink | |
| parent | 51584e1fe07456a01dc14504b214d068c62e8fe6 (diff) | |
chore: rm-d .obsidian
Diffstat (limited to '.obsidian/plugins/ink')
| -rwxr-xr-x | .obsidian/plugins/ink/data.json | 21 | ||||
| -rwxr-xr-x | .obsidian/plugins/ink/main.js | 76675 | ||||
| -rwxr-xr-x | .obsidian/plugins/ink/manifest.json | 11 | ||||
| -rwxr-xr-x | .obsidian/plugins/ink/styles.css | 6585 |
4 files changed, 0 insertions, 83292 deletions
diff --git a/.obsidian/plugins/ink/data.json b/.obsidian/plugins/ink/data.json deleted file mode 100755 index 129107f..0000000 --- a/.obsidian/plugins/ink/data.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "onboardingTips": { - "welcomeTipRead": true, - "strokeLimitTipRead": false, - "lastVersionTipRead": "0.3.4" - }, - "customAttachmentFolders": false, - "noteAttachmentFolderLocation": "obsidian", - "notelessAttachmentFolderLocation": "obsidian", - "writingSubfolder": "Ink/Writing", - "drawingSubfolder": "Ink/Drawing", - "writingEnabled": true, - "writingStrokeLimit": 200, - "writingDynamicStrokeThickness": true, - "writingSmoothing": false, - "writingLinesWhenLocked": true, - "writingBackgroundWhenLocked": true, - "drawingEnabled": true, - "drawingFrameWhenLocked": false, - "drawingBackgroundWhenLocked": false -}
\ No newline at end of file diff --git a/.obsidian/plugins/ink/main.js b/.obsidian/plugins/ink/main.js deleted file mode 100755 index e3b1eb7..0000000 --- a/.obsidian/plugins/ink/main.js +++ /dev/null @@ -1,76675 +0,0 @@ -/* -THIS IS A GENERATED/BUNDLED FILE BY ESBUILD -if you want to view the source, please visit the github repository of this plugin -*/ - -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -var __publicField = (obj, key, value) => { - __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); - return value; -}; - -// node_modules/react/cjs/react.production.min.js -var require_react_production_min = __commonJS({ - "node_modules/react/cjs/react.production.min.js"(exports) { - "use strict"; - var l = Symbol.for("react.element"); - var n = Symbol.for("react.portal"); - var p = Symbol.for("react.fragment"); - var q = Symbol.for("react.strict_mode"); - var r = Symbol.for("react.profiler"); - var t2 = Symbol.for("react.provider"); - var u = Symbol.for("react.context"); - var v = Symbol.for("react.forward_ref"); - var w = Symbol.for("react.suspense"); - var x = Symbol.for("react.memo"); - var y = Symbol.for("react.lazy"); - var z = Symbol.iterator; - function A(a) { - if (a === null || typeof a !== "object") - return null; - a = z && a[z] || a["@@iterator"]; - return typeof a === "function" ? a : null; - } - var B = { isMounted: function() { - return false; - }, enqueueForceUpdate: function() { - }, enqueueReplaceState: function() { - }, enqueueSetState: function() { - } }; - var C = Object.assign; - var D = {}; - function E(a, b, e) { - this.props = a; - this.context = b; - this.refs = D; - this.updater = e || B; - } - E.prototype.isReactComponent = {}; - E.prototype.setState = function(a, b) { - if (typeof a !== "object" && typeof a !== "function" && a != null) - throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."); - this.updater.enqueueSetState(this, a, b, "setState"); - }; - E.prototype.forceUpdate = function(a) { - this.updater.enqueueForceUpdate(this, a, "forceUpdate"); - }; - function F() { - } - F.prototype = E.prototype; - function G(a, b, e) { - this.props = a; - this.context = b; - this.refs = D; - this.updater = e || B; - } - var H = G.prototype = new F(); - H.constructor = G; - C(H, E.prototype); - H.isPureReactComponent = true; - var I = Array.isArray; - var J = Object.prototype.hasOwnProperty; - var K = { current: null }; - var L = { key: true, ref: true, __self: true, __source: true }; - function M(a, b, e) { - var d, c = {}, k = null, h = null; - if (b != null) - for (d in b.ref !== void 0 && (h = b.ref), b.key !== void 0 && (k = "" + b.key), b) - J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]); - var g = arguments.length - 2; - if (g === 1) - c.children = e; - else if (1 < g) { - for (var f = Array(g), m = 0; m < g; m++) - f[m] = arguments[m + 2]; - c.children = f; - } - if (a && a.defaultProps) - for (d in g = a.defaultProps, g) - c[d] === void 0 && (c[d] = g[d]); - return { $$typeof: l, type: a, key: k, ref: h, props: c, _owner: K.current }; - } - function N(a, b) { - return { $$typeof: l, type: a.type, key: b, ref: a.ref, props: a.props, _owner: a._owner }; - } - function O(a) { - return typeof a === "object" && a !== null && a.$$typeof === l; - } - function escape(a) { - var b = { "=": "=0", ":": "=2" }; - return "$" + a.replace(/[=:]/g, function(a2) { - return b[a2]; - }); - } - var P = /\/+/g; - function Q(a, b) { - return typeof a === "object" && a !== null && a.key != null ? escape("" + a.key) : b.toString(36); - } - function R(a, b, e, d, c) { - var k = typeof a; - if (k === "undefined" || k === "boolean") - a = null; - var h = false; - if (a === null) - h = true; - else - switch (k) { - case "string": - case "number": - h = true; - break; - case "object": - switch (a.$$typeof) { - case l: - case n: - h = true; - } - } - if (h) - return h = a, c = c(h), a = d === "" ? "." + Q(h, 0) : d, I(c) ? (e = "", a != null && (e = a.replace(P, "$&/") + "/"), R(c, b, e, "", function(a2) { - return a2; - })) : c != null && (O(c) && (c = N(c, e + (!c.key || h && h.key === c.key ? "" : ("" + c.key).replace(P, "$&/") + "/") + a)), b.push(c)), 1; - h = 0; - d = d === "" ? "." : d + ":"; - if (I(a)) - for (var g = 0; g < a.length; g++) { - k = a[g]; - var f = d + Q(k, g); - h += R(k, b, e, f, c); - } - else if (f = A(a), typeof f === "function") - for (a = f.call(a), g = 0; !(k = a.next()).done; ) - k = k.value, f = d + Q(k, g++), h += R(k, b, e, f, c); - else if (k === "object") - throw b = String(a), Error("Objects are not valid as a React child (found: " + (b === "[object Object]" ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead."); - return h; - } - function S(a, b, e) { - if (a == null) - return a; - var d = [], c = 0; - R(a, d, "", "", function(a2) { - return b.call(e, a2, c++); - }); - return d; - } - function T(a) { - if (a._status === -1) { - var b = a._result; - b = b(); - b.then(function(b2) { - if (a._status === 0 || a._status === -1) - a._status = 1, a._result = b2; - }, function(b2) { - if (a._status === 0 || a._status === -1) - a._status = 2, a._result = b2; - }); - a._status === -1 && (a._status = 0, a._result = b); - } - if (a._status === 1) - return a._result.default; - throw a._result; - } - var U = { current: null }; - var V = { transition: null }; - var W = { ReactCurrentDispatcher: U, ReactCurrentBatchConfig: V, ReactCurrentOwner: K }; - exports.Children = { map: S, forEach: function(a, b, e) { - S(a, function() { - b.apply(this, arguments); - }, e); - }, count: function(a) { - var b = 0; - S(a, function() { - b++; - }); - return b; - }, toArray: function(a) { - return S(a, function(a2) { - return a2; - }) || []; - }, only: function(a) { - if (!O(a)) - throw Error("React.Children.only expected to receive a single React element child."); - return a; - } }; - exports.Component = E; - exports.Fragment = p; - exports.Profiler = r; - exports.PureComponent = G; - exports.StrictMode = q; - exports.Suspense = w; - exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = W; - exports.cloneElement = function(a, b, e) { - if (a === null || a === void 0) - throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + a + "."); - var d = C({}, a.props), c = a.key, k = a.ref, h = a._owner; - if (b != null) { - b.ref !== void 0 && (k = b.ref, h = K.current); - b.key !== void 0 && (c = "" + b.key); - if (a.type && a.type.defaultProps) - var g = a.type.defaultProps; - for (f in b) - J.call(b, f) && !L.hasOwnProperty(f) && (d[f] = b[f] === void 0 && g !== void 0 ? g[f] : b[f]); - } - var f = arguments.length - 2; - if (f === 1) - d.children = e; - else if (1 < f) { - g = Array(f); - for (var m = 0; m < f; m++) - g[m] = arguments[m + 2]; - d.children = g; - } - return { $$typeof: l, type: a.type, key: c, ref: k, props: d, _owner: h }; - }; - exports.createContext = function(a) { - a = { $$typeof: u, _currentValue: a, _currentValue2: a, _threadCount: 0, Provider: null, Consumer: null, _defaultValue: null, _globalName: null }; - a.Provider = { $$typeof: t2, _context: a }; - return a.Consumer = a; - }; - exports.createElement = M; - exports.createFactory = function(a) { - var b = M.bind(null, a); - b.type = a; - return b; - }; - exports.createRef = function() { - return { current: null }; - }; - exports.forwardRef = function(a) { - return { $$typeof: v, render: a }; - }; - exports.isValidElement = O; - exports.lazy = function(a) { - return { $$typeof: y, _payload: { _status: -1, _result: a }, _init: T }; - }; - exports.memo = function(a, b) { - return { $$typeof: x, type: a, compare: b === void 0 ? null : b }; - }; - exports.startTransition = function(a) { - var b = V.transition; - V.transition = {}; - try { - a(); - } finally { - V.transition = b; - } - }; - exports.unstable_act = function() { - throw Error("act(...) is not supported in production builds of React."); - }; - exports.useCallback = function(a, b) { - return U.current.useCallback(a, b); - }; - exports.useContext = function(a) { - return U.current.useContext(a); - }; - exports.useDebugValue = function() { - }; - exports.useDeferredValue = function(a) { - return U.current.useDeferredValue(a); - }; - exports.useEffect = function(a, b) { - return U.current.useEffect(a, b); - }; - exports.useId = function() { - return U.current.useId(); - }; - exports.useImperativeHandle = function(a, b, e) { - return U.current.useImperativeHandle(a, b, e); - }; - exports.useInsertionEffect = function(a, b) { - return U.current.useInsertionEffect(a, b); - }; - exports.useLayoutEffect = function(a, b) { - return U.current.useLayoutEffect(a, b); - }; - exports.useMemo = function(a, b) { - return U.current.useMemo(a, b); - }; - exports.useReducer = function(a, b, e) { - return U.current.useReducer(a, b, e); - }; - exports.useRef = function(a) { - return U.current.useRef(a); - }; - exports.useState = function(a) { - return U.current.useState(a); - }; - exports.useSyncExternalStore = function(a, b, e) { - return U.current.useSyncExternalStore(a, b, e); - }; - exports.useTransition = function() { - return U.current.useTransition(); - }; - exports.version = "18.2.0"; - } -}); - -// node_modules/react/index.js -var require_react = __commonJS({ - "node_modules/react/index.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_react_production_min(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/scheduler/cjs/scheduler.production.min.js -var require_scheduler_production_min = __commonJS({ - "node_modules/scheduler/cjs/scheduler.production.min.js"(exports) { - "use strict"; - function f(a, b) { - var c = a.length; - a.push(b); - a: - for (; 0 < c; ) { - var d = c - 1 >>> 1, e = a[d]; - if (0 < g(e, b)) - a[d] = b, a[c] = e, c = d; - else - break a; - } - } - function h(a) { - return a.length === 0 ? null : a[0]; - } - function k(a) { - if (a.length === 0) - return null; - var b = a[0], c = a.pop(); - if (c !== b) { - a[0] = c; - a: - for (var d = 0, e = a.length, w = e >>> 1; d < w; ) { - var m = 2 * (d + 1) - 1, C = a[m], n = m + 1, x = a[n]; - if (0 > g(C, c)) - n < e && 0 > g(x, C) ? (a[d] = x, a[n] = c, d = n) : (a[d] = C, a[m] = c, d = m); - else if (n < e && 0 > g(x, c)) - a[d] = x, a[n] = c, d = n; - else - break a; - } - } - return b; - } - function g(a, b) { - var c = a.sortIndex - b.sortIndex; - return c !== 0 ? c : a.id - b.id; - } - if (typeof performance === "object" && typeof performance.now === "function") { - l = performance; - exports.unstable_now = function() { - return l.now(); - }; - } else { - p = Date, q = p.now(); - exports.unstable_now = function() { - return p.now() - q; - }; - } - var l; - var p; - var q; - var r = []; - var t2 = []; - var u = 1; - var v = null; - var y = 3; - var z = false; - var A = false; - var B = false; - var D = typeof setTimeout === "function" ? setTimeout : null; - var E = typeof clearTimeout === "function" ? clearTimeout : null; - var F = typeof setImmediate !== "undefined" ? setImmediate : null; - typeof navigator !== "undefined" && navigator.scheduling !== void 0 && navigator.scheduling.isInputPending !== void 0 && navigator.scheduling.isInputPending.bind(navigator.scheduling); - function G(a) { - for (var b = h(t2); b !== null; ) { - if (b.callback === null) - k(t2); - else if (b.startTime <= a) - k(t2), b.sortIndex = b.expirationTime, f(r, b); - else - break; - b = h(t2); - } - } - function H(a) { - B = false; - G(a); - if (!A) - if (h(r) !== null) - A = true, I(J); - else { - var b = h(t2); - b !== null && K(H, b.startTime - a); - } - } - function J(a, b) { - A = false; - B && (B = false, E(L), L = -1); - z = true; - var c = y; - try { - G(b); - for (v = h(r); v !== null && (!(v.expirationTime > b) || a && !M()); ) { - var d = v.callback; - if (typeof d === "function") { - v.callback = null; - y = v.priorityLevel; - var e = d(v.expirationTime <= b); - b = exports.unstable_now(); - typeof e === "function" ? v.callback = e : v === h(r) && k(r); - G(b); - } else - k(r); - v = h(r); - } - if (v !== null) - var w = true; - else { - var m = h(t2); - m !== null && K(H, m.startTime - b); - w = false; - } - return w; - } finally { - v = null, y = c, z = false; - } - } - var N = false; - var O = null; - var L = -1; - var P = 5; - var Q = -1; - function M() { - return exports.unstable_now() - Q < P ? false : true; - } - function R() { - if (O !== null) { - var a = exports.unstable_now(); - Q = a; - var b = true; - try { - b = O(true, a); - } finally { - b ? S() : (N = false, O = null); - } - } else - N = false; - } - var S; - if (typeof F === "function") - S = function() { - F(R); - }; - else if (typeof MessageChannel !== "undefined") { - T = new MessageChannel(), U = T.port2; - T.port1.onmessage = R; - S = function() { - U.postMessage(null); - }; - } else - S = function() { - D(R, 0); - }; - var T; - var U; - function I(a) { - O = a; - N || (N = true, S()); - } - function K(a, b) { - L = D(function() { - a(exports.unstable_now()); - }, b); - } - exports.unstable_IdlePriority = 5; - exports.unstable_ImmediatePriority = 1; - exports.unstable_LowPriority = 4; - exports.unstable_NormalPriority = 3; - exports.unstable_Profiling = null; - exports.unstable_UserBlockingPriority = 2; - exports.unstable_cancelCallback = function(a) { - a.callback = null; - }; - exports.unstable_continueExecution = function() { - A || z || (A = true, I(J)); - }; - exports.unstable_forceFrameRate = function(a) { - 0 > a || 125 < a ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : P = 0 < a ? Math.floor(1e3 / a) : 5; - }; - exports.unstable_getCurrentPriorityLevel = function() { - return y; - }; - exports.unstable_getFirstCallbackNode = function() { - return h(r); - }; - exports.unstable_next = function(a) { - switch (y) { - case 1: - case 2: - case 3: - var b = 3; - break; - default: - b = y; - } - var c = y; - y = b; - try { - return a(); - } finally { - y = c; - } - }; - exports.unstable_pauseExecution = function() { - }; - exports.unstable_requestPaint = function() { - }; - exports.unstable_runWithPriority = function(a, b) { - switch (a) { - case 1: - case 2: - case 3: - case 4: - case 5: - break; - default: - a = 3; - } - var c = y; - y = a; - try { - return b(); - } finally { - y = c; - } - }; - exports.unstable_scheduleCallback = function(a, b, c) { - var d = exports.unstable_now(); - typeof c === "object" && c !== null ? (c = c.delay, c = typeof c === "number" && 0 < c ? d + c : d) : c = d; - switch (a) { - case 1: - var e = -1; - break; - case 2: - e = 250; - break; - case 5: - e = 1073741823; - break; - case 4: - e = 1e4; - break; - default: - e = 5e3; - } - e = c + e; - a = { id: u++, callback: b, priorityLevel: a, startTime: c, expirationTime: e, sortIndex: -1 }; - c > d ? (a.sortIndex = c, f(t2, a), h(r) === null && a === h(t2) && (B ? (E(L), L = -1) : B = true, K(H, c - d))) : (a.sortIndex = e, f(r, a), A || z || (A = true, I(J))); - return a; - }; - exports.unstable_shouldYield = M; - exports.unstable_wrapCallback = function(a) { - var b = y; - return function() { - var c = y; - y = b; - try { - return a.apply(this, arguments); - } finally { - y = c; - } - }; - }; - } -}); - -// node_modules/scheduler/index.js -var require_scheduler = __commonJS({ - "node_modules/scheduler/index.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_scheduler_production_min(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/react-dom/cjs/react-dom.production.min.js -var require_react_dom_production_min = __commonJS({ - "node_modules/react-dom/cjs/react-dom.production.min.js"(exports) { - "use strict"; - var aa = require_react(); - var ca = require_scheduler(); - function p(a) { - for (var b = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, c = 1; c < arguments.length; c++) - b += "&args[]=" + encodeURIComponent(arguments[c]); - return "Minified React error #" + a + "; visit " + b + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."; - } - var da = /* @__PURE__ */ new Set(); - var ea = {}; - function fa(a, b) { - ha(a, b); - ha(a + "Capture", b); - } - function ha(a, b) { - ea[a] = b; - for (a = 0; a < b.length; a++) - da.add(b[a]); - } - var ia = !(typeof window === "undefined" || typeof window.document === "undefined" || typeof window.document.createElement === "undefined"); - var ja = Object.prototype.hasOwnProperty; - var ka = /^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/; - var la = {}; - var ma = {}; - function oa(a) { - if (ja.call(ma, a)) - return true; - if (ja.call(la, a)) - return false; - if (ka.test(a)) - return ma[a] = true; - la[a] = true; - return false; - } - function pa(a, b, c, d) { - if (c !== null && c.type === 0) - return false; - switch (typeof b) { - case "function": - case "symbol": - return true; - case "boolean": - if (d) - return false; - if (c !== null) - return !c.acceptsBooleans; - a = a.toLowerCase().slice(0, 5); - return a !== "data-" && a !== "aria-"; - default: - return false; - } - } - function qa(a, b, c, d) { - if (b === null || typeof b === "undefined" || pa(a, b, c, d)) - return true; - if (d) - return false; - if (c !== null) - switch (c.type) { - case 3: - return !b; - case 4: - return b === false; - case 5: - return isNaN(b); - case 6: - return isNaN(b) || 1 > b; - } - return false; - } - function v(a, b, c, d, e, f, g) { - this.acceptsBooleans = b === 2 || b === 3 || b === 4; - this.attributeName = d; - this.attributeNamespace = e; - this.mustUseProperty = c; - this.propertyName = a; - this.type = b; - this.sanitizeURL = f; - this.removeEmptyString = g; - } - var z = {}; - "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a) { - z[a] = new v(a, 0, false, a, null, false, false); - }); - [["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(a) { - var b = a[0]; - z[b] = new v(b, 1, false, a[1], null, false, false); - }); - ["contentEditable", "draggable", "spellCheck", "value"].forEach(function(a) { - z[a] = new v(a, 2, false, a.toLowerCase(), null, false, false); - }); - ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(a) { - z[a] = new v(a, 2, false, a, null, false, false); - }); - "allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a) { - z[a] = new v(a, 3, false, a.toLowerCase(), null, false, false); - }); - ["checked", "multiple", "muted", "selected"].forEach(function(a) { - z[a] = new v(a, 3, true, a, null, false, false); - }); - ["capture", "download"].forEach(function(a) { - z[a] = new v(a, 4, false, a, null, false, false); - }); - ["cols", "rows", "size", "span"].forEach(function(a) { - z[a] = new v(a, 6, false, a, null, false, false); - }); - ["rowSpan", "start"].forEach(function(a) { - z[a] = new v(a, 5, false, a.toLowerCase(), null, false, false); - }); - var ra = /[\-:]([a-z])/g; - function sa(a) { - return a[1].toUpperCase(); - } - "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a) { - var b = a.replace(ra, sa); - z[b] = new v(b, 1, false, a, null, false, false); - }); - "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a) { - var b = a.replace(ra, sa); - z[b] = new v(b, 1, false, a, "http://www.w3.org/1999/xlink", false, false); - }); - ["xml:base", "xml:lang", "xml:space"].forEach(function(a) { - var b = a.replace(ra, sa); - z[b] = new v(b, 1, false, a, "http://www.w3.org/XML/1998/namespace", false, false); - }); - ["tabIndex", "crossOrigin"].forEach(function(a) { - z[a] = new v(a, 1, false, a.toLowerCase(), null, false, false); - }); - z.xlinkHref = new v("xlinkHref", 1, false, "xlink:href", "http://www.w3.org/1999/xlink", true, false); - ["src", "href", "action", "formAction"].forEach(function(a) { - z[a] = new v(a, 1, false, a.toLowerCase(), null, true, true); - }); - function ta(a, b, c, d) { - var e = z.hasOwnProperty(b) ? z[b] : null; - if (e !== null ? e.type !== 0 : d || !(2 < b.length) || b[0] !== "o" && b[0] !== "O" || b[1] !== "n" && b[1] !== "N") - qa(b, c, e, d) && (c = null), d || e === null ? oa(b) && (c === null ? a.removeAttribute(b) : a.setAttribute(b, "" + c)) : e.mustUseProperty ? a[e.propertyName] = c === null ? e.type === 3 ? false : "" : c : (b = e.attributeName, d = e.attributeNamespace, c === null ? a.removeAttribute(b) : (e = e.type, c = e === 3 || e === 4 && c === true ? "" : "" + c, d ? a.setAttributeNS(d, b, c) : a.setAttribute(b, c))); - } - var ua = aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - var va = Symbol.for("react.element"); - var wa = Symbol.for("react.portal"); - var ya = Symbol.for("react.fragment"); - var za = Symbol.for("react.strict_mode"); - var Aa = Symbol.for("react.profiler"); - var Ba = Symbol.for("react.provider"); - var Ca = Symbol.for("react.context"); - var Da = Symbol.for("react.forward_ref"); - var Ea = Symbol.for("react.suspense"); - var Fa = Symbol.for("react.suspense_list"); - var Ga = Symbol.for("react.memo"); - var Ha = Symbol.for("react.lazy"); - Symbol.for("react.scope"); - Symbol.for("react.debug_trace_mode"); - var Ia = Symbol.for("react.offscreen"); - Symbol.for("react.legacy_hidden"); - Symbol.for("react.cache"); - Symbol.for("react.tracing_marker"); - var Ja = Symbol.iterator; - function Ka(a) { - if (a === null || typeof a !== "object") - return null; - a = Ja && a[Ja] || a["@@iterator"]; - return typeof a === "function" ? a : null; - } - var A = Object.assign; - var La; - function Ma(a) { - if (La === void 0) - try { - throw Error(); - } catch (c) { - var b = c.stack.trim().match(/\n( *(at )?)/); - La = b && b[1] || ""; - } - return "\n" + La + a; - } - var Na = false; - function Oa(a, b) { - if (!a || Na) - return ""; - Na = true; - var c = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - try { - if (b) - if (b = function() { - throw Error(); - }, Object.defineProperty(b.prototype, "props", { set: function() { - throw Error(); - } }), typeof Reflect === "object" && Reflect.construct) { - try { - Reflect.construct(b, []); - } catch (l) { - var d = l; - } - Reflect.construct(a, [], b); - } else { - try { - b.call(); - } catch (l) { - d = l; - } - a.call(b.prototype); - } - else { - try { - throw Error(); - } catch (l) { - d = l; - } - a(); - } - } catch (l) { - if (l && d && typeof l.stack === "string") { - for (var e = l.stack.split("\n"), f = d.stack.split("\n"), g = e.length - 1, h = f.length - 1; 1 <= g && 0 <= h && e[g] !== f[h]; ) - h--; - for (; 1 <= g && 0 <= h; g--, h--) - if (e[g] !== f[h]) { - if (g !== 1 || h !== 1) { - do - if (g--, h--, 0 > h || e[g] !== f[h]) { - var k = "\n" + e[g].replace(" at new ", " at "); - a.displayName && k.includes("<anonymous>") && (k = k.replace("<anonymous>", a.displayName)); - return k; - } - while (1 <= g && 0 <= h); - } - break; - } - } - } finally { - Na = false, Error.prepareStackTrace = c; - } - return (a = a ? a.displayName || a.name : "") ? Ma(a) : ""; - } - function Pa(a) { - switch (a.tag) { - case 5: - return Ma(a.type); - case 16: - return Ma("Lazy"); - case 13: - return Ma("Suspense"); - case 19: - return Ma("SuspenseList"); - case 0: - case 2: - case 15: - return a = Oa(a.type, false), a; - case 11: - return a = Oa(a.type.render, false), a; - case 1: - return a = Oa(a.type, true), a; - default: - return ""; - } - } - function Qa(a) { - if (a == null) - return null; - if (typeof a === "function") - return a.displayName || a.name || null; - if (typeof a === "string") - return a; - switch (a) { - case ya: - return "Fragment"; - case wa: - return "Portal"; - case Aa: - return "Profiler"; - case za: - return "StrictMode"; - case Ea: - return "Suspense"; - case Fa: - return "SuspenseList"; - } - if (typeof a === "object") - switch (a.$$typeof) { - case Ca: - return (a.displayName || "Context") + ".Consumer"; - case Ba: - return (a._context.displayName || "Context") + ".Provider"; - case Da: - var b = a.render; - a = a.displayName; - a || (a = b.displayName || b.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"); - return a; - case Ga: - return b = a.displayName || null, b !== null ? b : Qa(a.type) || "Memo"; - case Ha: - b = a._payload; - a = a._init; - try { - return Qa(a(b)); - } catch (c) { - } - } - return null; - } - function Ra(a) { - var b = a.type; - switch (a.tag) { - case 24: - return "Cache"; - case 9: - return (b.displayName || "Context") + ".Consumer"; - case 10: - return (b._context.displayName || "Context") + ".Provider"; - case 18: - return "DehydratedFragment"; - case 11: - return a = b.render, a = a.displayName || a.name || "", b.displayName || (a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"); - case 7: - return "Fragment"; - case 5: - return b; - case 4: - return "Portal"; - case 3: - return "Root"; - case 6: - return "Text"; - case 16: - return Qa(b); - case 8: - return b === za ? "StrictMode" : "Mode"; - case 22: - return "Offscreen"; - case 12: - return "Profiler"; - case 21: - return "Scope"; - case 13: - return "Suspense"; - case 19: - return "SuspenseList"; - case 25: - return "TracingMarker"; - case 1: - case 0: - case 17: - case 2: - case 14: - case 15: - if (typeof b === "function") - return b.displayName || b.name || null; - if (typeof b === "string") - return b; - } - return null; - } - function Sa(a) { - switch (typeof a) { - case "boolean": - case "number": - case "string": - case "undefined": - return a; - case "object": - return a; - default: - return ""; - } - } - function Ta(a) { - var b = a.type; - return (a = a.nodeName) && a.toLowerCase() === "input" && (b === "checkbox" || b === "radio"); - } - function Ua(a) { - var b = Ta(a) ? "checked" : "value", c = Object.getOwnPropertyDescriptor(a.constructor.prototype, b), d = "" + a[b]; - if (!a.hasOwnProperty(b) && typeof c !== "undefined" && typeof c.get === "function" && typeof c.set === "function") { - var e = c.get, f = c.set; - Object.defineProperty(a, b, { configurable: true, get: function() { - return e.call(this); - }, set: function(a2) { - d = "" + a2; - f.call(this, a2); - } }); - Object.defineProperty(a, b, { enumerable: c.enumerable }); - return { getValue: function() { - return d; - }, setValue: function(a2) { - d = "" + a2; - }, stopTracking: function() { - a._valueTracker = null; - delete a[b]; - } }; - } - } - function Va(a) { - a._valueTracker || (a._valueTracker = Ua(a)); - } - function Wa(a) { - if (!a) - return false; - var b = a._valueTracker; - if (!b) - return true; - var c = b.getValue(); - var d = ""; - a && (d = Ta(a) ? a.checked ? "true" : "false" : a.value); - a = d; - return a !== c ? (b.setValue(a), true) : false; - } - function Xa(a) { - a = a || (typeof document !== "undefined" ? document : void 0); - if (typeof a === "undefined") - return null; - try { - return a.activeElement || a.body; - } catch (b) { - return a.body; - } - } - function Ya(a, b) { - var c = b.checked; - return A({}, b, { defaultChecked: void 0, defaultValue: void 0, value: void 0, checked: c != null ? c : a._wrapperState.initialChecked }); - } - function Za(a, b) { - var c = b.defaultValue == null ? "" : b.defaultValue, d = b.checked != null ? b.checked : b.defaultChecked; - c = Sa(b.value != null ? b.value : c); - a._wrapperState = { initialChecked: d, initialValue: c, controlled: b.type === "checkbox" || b.type === "radio" ? b.checked != null : b.value != null }; - } - function ab(a, b) { - b = b.checked; - b != null && ta(a, "checked", b, false); - } - function bb(a, b) { - ab(a, b); - var c = Sa(b.value), d = b.type; - if (c != null) - if (d === "number") { - if (c === 0 && a.value === "" || a.value != c) - a.value = "" + c; - } else - a.value !== "" + c && (a.value = "" + c); - else if (d === "submit" || d === "reset") { - a.removeAttribute("value"); - return; - } - b.hasOwnProperty("value") ? cb(a, b.type, c) : b.hasOwnProperty("defaultValue") && cb(a, b.type, Sa(b.defaultValue)); - b.checked == null && b.defaultChecked != null && (a.defaultChecked = !!b.defaultChecked); - } - function db(a, b, c) { - if (b.hasOwnProperty("value") || b.hasOwnProperty("defaultValue")) { - var d = b.type; - if (!(d !== "submit" && d !== "reset" || b.value !== void 0 && b.value !== null)) - return; - b = "" + a._wrapperState.initialValue; - c || b === a.value || (a.value = b); - a.defaultValue = b; - } - c = a.name; - c !== "" && (a.name = ""); - a.defaultChecked = !!a._wrapperState.initialChecked; - c !== "" && (a.name = c); - } - function cb(a, b, c) { - if (b !== "number" || Xa(a.ownerDocument) !== a) - c == null ? a.defaultValue = "" + a._wrapperState.initialValue : a.defaultValue !== "" + c && (a.defaultValue = "" + c); - } - var eb = Array.isArray; - function fb(a, b, c, d) { - a = a.options; - if (b) { - b = {}; - for (var e = 0; e < c.length; e++) - b["$" + c[e]] = true; - for (c = 0; c < a.length; c++) - e = b.hasOwnProperty("$" + a[c].value), a[c].selected !== e && (a[c].selected = e), e && d && (a[c].defaultSelected = true); - } else { - c = "" + Sa(c); - b = null; - for (e = 0; e < a.length; e++) { - if (a[e].value === c) { - a[e].selected = true; - d && (a[e].defaultSelected = true); - return; - } - b !== null || a[e].disabled || (b = a[e]); - } - b !== null && (b.selected = true); - } - } - function gb(a, b) { - if (b.dangerouslySetInnerHTML != null) - throw Error(p(91)); - return A({}, b, { value: void 0, defaultValue: void 0, children: "" + a._wrapperState.initialValue }); - } - function hb(a, b) { - var c = b.value; - if (c == null) { - c = b.children; - b = b.defaultValue; - if (c != null) { - if (b != null) - throw Error(p(92)); - if (eb(c)) { - if (1 < c.length) - throw Error(p(93)); - c = c[0]; - } - b = c; - } - b == null && (b = ""); - c = b; - } - a._wrapperState = { initialValue: Sa(c) }; - } - function ib(a, b) { - var c = Sa(b.value), d = Sa(b.defaultValue); - c != null && (c = "" + c, c !== a.value && (a.value = c), b.defaultValue == null && a.defaultValue !== c && (a.defaultValue = c)); - d != null && (a.defaultValue = "" + d); - } - function jb(a) { - var b = a.textContent; - b === a._wrapperState.initialValue && b !== "" && b !== null && (a.value = b); - } - function kb(a) { - switch (a) { - case "svg": - return "http://www.w3.org/2000/svg"; - case "math": - return "http://www.w3.org/1998/Math/MathML"; - default: - return "http://www.w3.org/1999/xhtml"; - } - } - function lb(a, b) { - return a == null || a === "http://www.w3.org/1999/xhtml" ? kb(b) : a === "http://www.w3.org/2000/svg" && b === "foreignObject" ? "http://www.w3.org/1999/xhtml" : a; - } - var mb; - var nb = function(a) { - return typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction ? function(b, c, d, e) { - MSApp.execUnsafeLocalFunction(function() { - return a(b, c, d, e); - }); - } : a; - }(function(a, b) { - if (a.namespaceURI !== "http://www.w3.org/2000/svg" || "innerHTML" in a) - a.innerHTML = b; - else { - mb = mb || document.createElement("div"); - mb.innerHTML = "<svg>" + b.valueOf().toString() + "</svg>"; - for (b = mb.firstChild; a.firstChild; ) - a.removeChild(a.firstChild); - for (; b.firstChild; ) - a.appendChild(b.firstChild); - } - }); - function ob(a, b) { - if (b) { - var c = a.firstChild; - if (c && c === a.lastChild && c.nodeType === 3) { - c.nodeValue = b; - return; - } - } - a.textContent = b; - } - var pb = { - animationIterationCount: true, - aspectRatio: true, - borderImageOutset: true, - borderImageSlice: true, - borderImageWidth: true, - boxFlex: true, - boxFlexGroup: true, - boxOrdinalGroup: true, - columnCount: true, - columns: true, - flex: true, - flexGrow: true, - flexPositive: true, - flexShrink: true, - flexNegative: true, - flexOrder: true, - gridArea: true, - gridRow: true, - gridRowEnd: true, - gridRowSpan: true, - gridRowStart: true, - gridColumn: true, - gridColumnEnd: true, - gridColumnSpan: true, - gridColumnStart: true, - fontWeight: true, - lineClamp: true, - lineHeight: true, - opacity: true, - order: true, - orphans: true, - tabSize: true, - widows: true, - zIndex: true, - zoom: true, - fillOpacity: true, - floodOpacity: true, - stopOpacity: true, - strokeDasharray: true, - strokeDashoffset: true, - strokeMiterlimit: true, - strokeOpacity: true, - strokeWidth: true - }; - var qb = ["Webkit", "ms", "Moz", "O"]; - Object.keys(pb).forEach(function(a) { - qb.forEach(function(b) { - b = b + a.charAt(0).toUpperCase() + a.substring(1); - pb[b] = pb[a]; - }); - }); - function rb(a, b, c) { - return b == null || typeof b === "boolean" || b === "" ? "" : c || typeof b !== "number" || b === 0 || pb.hasOwnProperty(a) && pb[a] ? ("" + b).trim() : b + "px"; - } - function sb(a, b) { - a = a.style; - for (var c in b) - if (b.hasOwnProperty(c)) { - var d = c.indexOf("--") === 0, e = rb(c, b[c], d); - c === "float" && (c = "cssFloat"); - d ? a.setProperty(c, e) : a[c] = e; - } - } - var tb = A({ menuitem: true }, { area: true, base: true, br: true, col: true, embed: true, hr: true, img: true, input: true, keygen: true, link: true, meta: true, param: true, source: true, track: true, wbr: true }); - function ub(a, b) { - if (b) { - if (tb[a] && (b.children != null || b.dangerouslySetInnerHTML != null)) - throw Error(p(137, a)); - if (b.dangerouslySetInnerHTML != null) { - if (b.children != null) - throw Error(p(60)); - if (typeof b.dangerouslySetInnerHTML !== "object" || !("__html" in b.dangerouslySetInnerHTML)) - throw Error(p(61)); - } - if (b.style != null && typeof b.style !== "object") - throw Error(p(62)); - } - } - function vb(a, b) { - if (a.indexOf("-") === -1) - return typeof b.is === "string"; - switch (a) { - case "annotation-xml": - case "color-profile": - case "font-face": - case "font-face-src": - case "font-face-uri": - case "font-face-format": - case "font-face-name": - case "missing-glyph": - return false; - default: - return true; - } - } - var wb = null; - function xb(a) { - a = a.target || a.srcElement || window; - a.correspondingUseElement && (a = a.correspondingUseElement); - return a.nodeType === 3 ? a.parentNode : a; - } - var yb = null; - var zb = null; - var Ab = null; - function Bb(a) { - if (a = Cb(a)) { - if (typeof yb !== "function") - throw Error(p(280)); - var b = a.stateNode; - b && (b = Db(b), yb(a.stateNode, a.type, b)); - } - } - function Eb(a) { - zb ? Ab ? Ab.push(a) : Ab = [a] : zb = a; - } - function Fb() { - if (zb) { - var a = zb, b = Ab; - Ab = zb = null; - Bb(a); - if (b) - for (a = 0; a < b.length; a++) - Bb(b[a]); - } - } - function Gb(a, b) { - return a(b); - } - function Hb() { - } - var Ib = false; - function Jb(a, b, c) { - if (Ib) - return a(b, c); - Ib = true; - try { - return Gb(a, b, c); - } finally { - if (Ib = false, zb !== null || Ab !== null) - Hb(), Fb(); - } - } - function Kb(a, b) { - var c = a.stateNode; - if (c === null) - return null; - var d = Db(c); - if (d === null) - return null; - c = d[b]; - a: - switch (b) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - (d = !d.disabled) || (a = a.type, d = !(a === "button" || a === "input" || a === "select" || a === "textarea")); - a = !d; - break a; - default: - a = false; - } - if (a) - return null; - if (c && typeof c !== "function") - throw Error(p(231, b, typeof c)); - return c; - } - var Lb = false; - if (ia) - try { - Mb = {}; - Object.defineProperty(Mb, "passive", { get: function() { - Lb = true; - } }); - window.addEventListener("test", Mb, Mb); - window.removeEventListener("test", Mb, Mb); - } catch (a) { - Lb = false; - } - var Mb; - function Nb(a, b, c, d, e, f, g, h, k) { - var l = Array.prototype.slice.call(arguments, 3); - try { - b.apply(c, l); - } catch (m) { - this.onError(m); - } - } - var Ob = false; - var Pb = null; - var Qb = false; - var Rb = null; - var Sb = { onError: function(a) { - Ob = true; - Pb = a; - } }; - function Tb(a, b, c, d, e, f, g, h, k) { - Ob = false; - Pb = null; - Nb.apply(Sb, arguments); - } - function Ub(a, b, c, d, e, f, g, h, k) { - Tb.apply(this, arguments); - if (Ob) { - if (Ob) { - var l = Pb; - Ob = false; - Pb = null; - } else - throw Error(p(198)); - Qb || (Qb = true, Rb = l); - } - } - function Vb(a) { - var b = a, c = a; - if (a.alternate) - for (; b.return; ) - b = b.return; - else { - a = b; - do - b = a, (b.flags & 4098) !== 0 && (c = b.return), a = b.return; - while (a); - } - return b.tag === 3 ? c : null; - } - function Wb(a) { - if (a.tag === 13) { - var b = a.memoizedState; - b === null && (a = a.alternate, a !== null && (b = a.memoizedState)); - if (b !== null) - return b.dehydrated; - } - return null; - } - function Xb(a) { - if (Vb(a) !== a) - throw Error(p(188)); - } - function Yb(a) { - var b = a.alternate; - if (!b) { - b = Vb(a); - if (b === null) - throw Error(p(188)); - return b !== a ? null : a; - } - for (var c = a, d = b; ; ) { - var e = c.return; - if (e === null) - break; - var f = e.alternate; - if (f === null) { - d = e.return; - if (d !== null) { - c = d; - continue; - } - break; - } - if (e.child === f.child) { - for (f = e.child; f; ) { - if (f === c) - return Xb(e), a; - if (f === d) - return Xb(e), b; - f = f.sibling; - } - throw Error(p(188)); - } - if (c.return !== d.return) - c = e, d = f; - else { - for (var g = false, h = e.child; h; ) { - if (h === c) { - g = true; - c = e; - d = f; - break; - } - if (h === d) { - g = true; - d = e; - c = f; - break; - } - h = h.sibling; - } - if (!g) { - for (h = f.child; h; ) { - if (h === c) { - g = true; - c = f; - d = e; - break; - } - if (h === d) { - g = true; - d = f; - c = e; - break; - } - h = h.sibling; - } - if (!g) - throw Error(p(189)); - } - } - if (c.alternate !== d) - throw Error(p(190)); - } - if (c.tag !== 3) - throw Error(p(188)); - return c.stateNode.current === c ? a : b; - } - function Zb(a) { - a = Yb(a); - return a !== null ? $b(a) : null; - } - function $b(a) { - if (a.tag === 5 || a.tag === 6) - return a; - for (a = a.child; a !== null; ) { - var b = $b(a); - if (b !== null) - return b; - a = a.sibling; - } - return null; - } - var ac = ca.unstable_scheduleCallback; - var bc = ca.unstable_cancelCallback; - var cc = ca.unstable_shouldYield; - var dc = ca.unstable_requestPaint; - var B = ca.unstable_now; - var ec = ca.unstable_getCurrentPriorityLevel; - var fc = ca.unstable_ImmediatePriority; - var gc = ca.unstable_UserBlockingPriority; - var hc = ca.unstable_NormalPriority; - var ic = ca.unstable_LowPriority; - var jc = ca.unstable_IdlePriority; - var kc = null; - var lc = null; - function mc(a) { - if (lc && typeof lc.onCommitFiberRoot === "function") - try { - lc.onCommitFiberRoot(kc, a, void 0, (a.current.flags & 128) === 128); - } catch (b) { - } - } - var oc = Math.clz32 ? Math.clz32 : nc; - var pc = Math.log; - var qc = Math.LN2; - function nc(a) { - a >>>= 0; - return a === 0 ? 32 : 31 - (pc(a) / qc | 0) | 0; - } - var rc = 64; - var sc = 4194304; - function tc(a) { - switch (a & -a) { - case 1: - return 1; - case 2: - return 2; - case 4: - return 4; - case 8: - return 8; - case 16: - return 16; - case 32: - return 32; - case 64: - case 128: - case 256: - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - return a & 4194240; - case 4194304: - case 8388608: - case 16777216: - case 33554432: - case 67108864: - return a & 130023424; - case 134217728: - return 134217728; - case 268435456: - return 268435456; - case 536870912: - return 536870912; - case 1073741824: - return 1073741824; - default: - return a; - } - } - function uc(a, b) { - var c = a.pendingLanes; - if (c === 0) - return 0; - var d = 0, e = a.suspendedLanes, f = a.pingedLanes, g = c & 268435455; - if (g !== 0) { - var h = g & ~e; - h !== 0 ? d = tc(h) : (f &= g, f !== 0 && (d = tc(f))); - } else - g = c & ~e, g !== 0 ? d = tc(g) : f !== 0 && (d = tc(f)); - if (d === 0) - return 0; - if (b !== 0 && b !== d && (b & e) === 0 && (e = d & -d, f = b & -b, e >= f || e === 16 && (f & 4194240) !== 0)) - return b; - (d & 4) !== 0 && (d |= c & 16); - b = a.entangledLanes; - if (b !== 0) - for (a = a.entanglements, b &= d; 0 < b; ) - c = 31 - oc(b), e = 1 << c, d |= a[c], b &= ~e; - return d; - } - function vc(a, b) { - switch (a) { - case 1: - case 2: - case 4: - return b + 250; - case 8: - case 16: - case 32: - case 64: - case 128: - case 256: - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - return b + 5e3; - case 4194304: - case 8388608: - case 16777216: - case 33554432: - case 67108864: - return -1; - case 134217728: - case 268435456: - case 536870912: - case 1073741824: - return -1; - default: - return -1; - } - } - function wc(a, b) { - for (var c = a.suspendedLanes, d = a.pingedLanes, e = a.expirationTimes, f = a.pendingLanes; 0 < f; ) { - var g = 31 - oc(f), h = 1 << g, k = e[g]; - if (k === -1) { - if ((h & c) === 0 || (h & d) !== 0) - e[g] = vc(h, b); - } else - k <= b && (a.expiredLanes |= h); - f &= ~h; - } - } - function xc(a) { - a = a.pendingLanes & -1073741825; - return a !== 0 ? a : a & 1073741824 ? 1073741824 : 0; - } - function yc() { - var a = rc; - rc <<= 1; - (rc & 4194240) === 0 && (rc = 64); - return a; - } - function zc(a) { - for (var b = [], c = 0; 31 > c; c++) - b.push(a); - return b; - } - function Ac(a, b, c) { - a.pendingLanes |= b; - b !== 536870912 && (a.suspendedLanes = 0, a.pingedLanes = 0); - a = a.eventTimes; - b = 31 - oc(b); - a[b] = c; - } - function Bc(a, b) { - var c = a.pendingLanes & ~b; - a.pendingLanes = b; - a.suspendedLanes = 0; - a.pingedLanes = 0; - a.expiredLanes &= b; - a.mutableReadLanes &= b; - a.entangledLanes &= b; - b = a.entanglements; - var d = a.eventTimes; - for (a = a.expirationTimes; 0 < c; ) { - var e = 31 - oc(c), f = 1 << e; - b[e] = 0; - d[e] = -1; - a[e] = -1; - c &= ~f; - } - } - function Cc(a, b) { - var c = a.entangledLanes |= b; - for (a = a.entanglements; c; ) { - var d = 31 - oc(c), e = 1 << d; - e & b | a[d] & b && (a[d] |= b); - c &= ~e; - } - } - var C = 0; - function Dc(a) { - a &= -a; - return 1 < a ? 4 < a ? (a & 268435455) !== 0 ? 16 : 536870912 : 4 : 1; - } - var Ec; - var Fc; - var Gc; - var Hc; - var Ic; - var Jc = false; - var Kc = []; - var Lc = null; - var Mc = null; - var Nc = null; - var Oc = /* @__PURE__ */ new Map(); - var Pc = /* @__PURE__ */ new Map(); - var Qc = []; - var Rc = "mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "); - function Sc(a, b) { - switch (a) { - case "focusin": - case "focusout": - Lc = null; - break; - case "dragenter": - case "dragleave": - Mc = null; - break; - case "mouseover": - case "mouseout": - Nc = null; - break; - case "pointerover": - case "pointerout": - Oc.delete(b.pointerId); - break; - case "gotpointercapture": - case "lostpointercapture": - Pc.delete(b.pointerId); - } - } - function Tc(a, b, c, d, e, f) { - if (a === null || a.nativeEvent !== f) - return a = { blockedOn: b, domEventName: c, eventSystemFlags: d, nativeEvent: f, targetContainers: [e] }, b !== null && (b = Cb(b), b !== null && Fc(b)), a; - a.eventSystemFlags |= d; - b = a.targetContainers; - e !== null && b.indexOf(e) === -1 && b.push(e); - return a; - } - function Uc(a, b, c, d, e) { - switch (b) { - case "focusin": - return Lc = Tc(Lc, a, b, c, d, e), true; - case "dragenter": - return Mc = Tc(Mc, a, b, c, d, e), true; - case "mouseover": - return Nc = Tc(Nc, a, b, c, d, e), true; - case "pointerover": - var f = e.pointerId; - Oc.set(f, Tc(Oc.get(f) || null, a, b, c, d, e)); - return true; - case "gotpointercapture": - return f = e.pointerId, Pc.set(f, Tc(Pc.get(f) || null, a, b, c, d, e)), true; - } - return false; - } - function Vc(a) { - var b = Wc(a.target); - if (b !== null) { - var c = Vb(b); - if (c !== null) { - if (b = c.tag, b === 13) { - if (b = Wb(c), b !== null) { - a.blockedOn = b; - Ic(a.priority, function() { - Gc(c); - }); - return; - } - } else if (b === 3 && c.stateNode.current.memoizedState.isDehydrated) { - a.blockedOn = c.tag === 3 ? c.stateNode.containerInfo : null; - return; - } - } - } - a.blockedOn = null; - } - function Xc(a) { - if (a.blockedOn !== null) - return false; - for (var b = a.targetContainers; 0 < b.length; ) { - var c = Yc(a.domEventName, a.eventSystemFlags, b[0], a.nativeEvent); - if (c === null) { - c = a.nativeEvent; - var d = new c.constructor(c.type, c); - wb = d; - c.target.dispatchEvent(d); - wb = null; - } else - return b = Cb(c), b !== null && Fc(b), a.blockedOn = c, false; - b.shift(); - } - return true; - } - function Zc(a, b, c) { - Xc(a) && c.delete(b); - } - function $c() { - Jc = false; - Lc !== null && Xc(Lc) && (Lc = null); - Mc !== null && Xc(Mc) && (Mc = null); - Nc !== null && Xc(Nc) && (Nc = null); - Oc.forEach(Zc); - Pc.forEach(Zc); - } - function ad(a, b) { - a.blockedOn === b && (a.blockedOn = null, Jc || (Jc = true, ca.unstable_scheduleCallback(ca.unstable_NormalPriority, $c))); - } - function bd(a) { - function b(b2) { - return ad(b2, a); - } - if (0 < Kc.length) { - ad(Kc[0], a); - for (var c = 1; c < Kc.length; c++) { - var d = Kc[c]; - d.blockedOn === a && (d.blockedOn = null); - } - } - Lc !== null && ad(Lc, a); - Mc !== null && ad(Mc, a); - Nc !== null && ad(Nc, a); - Oc.forEach(b); - Pc.forEach(b); - for (c = 0; c < Qc.length; c++) - d = Qc[c], d.blockedOn === a && (d.blockedOn = null); - for (; 0 < Qc.length && (c = Qc[0], c.blockedOn === null); ) - Vc(c), c.blockedOn === null && Qc.shift(); - } - var cd = ua.ReactCurrentBatchConfig; - var dd = true; - function ed(a, b, c, d) { - var e = C, f = cd.transition; - cd.transition = null; - try { - C = 1, fd(a, b, c, d); - } finally { - C = e, cd.transition = f; - } - } - function gd(a, b, c, d) { - var e = C, f = cd.transition; - cd.transition = null; - try { - C = 4, fd(a, b, c, d); - } finally { - C = e, cd.transition = f; - } - } - function fd(a, b, c, d) { - if (dd) { - var e = Yc(a, b, c, d); - if (e === null) - hd(a, b, d, id, c), Sc(a, d); - else if (Uc(e, a, b, c, d)) - d.stopPropagation(); - else if (Sc(a, d), b & 4 && -1 < Rc.indexOf(a)) { - for (; e !== null; ) { - var f = Cb(e); - f !== null && Ec(f); - f = Yc(a, b, c, d); - f === null && hd(a, b, d, id, c); - if (f === e) - break; - e = f; - } - e !== null && d.stopPropagation(); - } else - hd(a, b, d, null, c); - } - } - var id = null; - function Yc(a, b, c, d) { - id = null; - a = xb(d); - a = Wc(a); - if (a !== null) - if (b = Vb(a), b === null) - a = null; - else if (c = b.tag, c === 13) { - a = Wb(b); - if (a !== null) - return a; - a = null; - } else if (c === 3) { - if (b.stateNode.current.memoizedState.isDehydrated) - return b.tag === 3 ? b.stateNode.containerInfo : null; - a = null; - } else - b !== a && (a = null); - id = a; - return null; - } - function jd(a) { - switch (a) { - case "cancel": - case "click": - case "close": - case "contextmenu": - case "copy": - case "cut": - case "auxclick": - case "dblclick": - case "dragend": - case "dragstart": - case "drop": - case "focusin": - case "focusout": - case "input": - case "invalid": - case "keydown": - case "keypress": - case "keyup": - case "mousedown": - case "mouseup": - case "paste": - case "pause": - case "play": - case "pointercancel": - case "pointerdown": - case "pointerup": - case "ratechange": - case "reset": - case "resize": - case "seeked": - case "submit": - case "touchcancel": - case "touchend": - case "touchstart": - case "volumechange": - case "change": - case "selectionchange": - case "textInput": - case "compositionstart": - case "compositionend": - case "compositionupdate": - case "beforeblur": - case "afterblur": - case "beforeinput": - case "blur": - case "fullscreenchange": - case "focus": - case "hashchange": - case "popstate": - case "select": - case "selectstart": - return 1; - case "drag": - case "dragenter": - case "dragexit": - case "dragleave": - case "dragover": - case "mousemove": - case "mouseout": - case "mouseover": - case "pointermove": - case "pointerout": - case "pointerover": - case "scroll": - case "toggle": - case "touchmove": - case "wheel": - case "mouseenter": - case "mouseleave": - case "pointerenter": - case "pointerleave": - return 4; - case "message": - switch (ec()) { - case fc: - return 1; - case gc: - return 4; - case hc: - case ic: - return 16; - case jc: - return 536870912; - default: - return 16; - } - default: - return 16; - } - } - var kd = null; - var ld = null; - var md = null; - function nd() { - if (md) - return md; - var a, b = ld, c = b.length, d, e = "value" in kd ? kd.value : kd.textContent, f = e.length; - for (a = 0; a < c && b[a] === e[a]; a++) - ; - var g = c - a; - for (d = 1; d <= g && b[c - d] === e[f - d]; d++) - ; - return md = e.slice(a, 1 < d ? 1 - d : void 0); - } - function od(a) { - var b = a.keyCode; - "charCode" in a ? (a = a.charCode, a === 0 && b === 13 && (a = 13)) : a = b; - a === 10 && (a = 13); - return 32 <= a || a === 13 ? a : 0; - } - function pd() { - return true; - } - function qd() { - return false; - } - function rd(a) { - function b(b2, d, e, f, g) { - this._reactName = b2; - this._targetInst = e; - this.type = d; - this.nativeEvent = f; - this.target = g; - this.currentTarget = null; - for (var c in a) - a.hasOwnProperty(c) && (b2 = a[c], this[c] = b2 ? b2(f) : f[c]); - this.isDefaultPrevented = (f.defaultPrevented != null ? f.defaultPrevented : f.returnValue === false) ? pd : qd; - this.isPropagationStopped = qd; - return this; - } - A(b.prototype, { preventDefault: function() { - this.defaultPrevented = true; - var a2 = this.nativeEvent; - a2 && (a2.preventDefault ? a2.preventDefault() : typeof a2.returnValue !== "unknown" && (a2.returnValue = false), this.isDefaultPrevented = pd); - }, stopPropagation: function() { - var a2 = this.nativeEvent; - a2 && (a2.stopPropagation ? a2.stopPropagation() : typeof a2.cancelBubble !== "unknown" && (a2.cancelBubble = true), this.isPropagationStopped = pd); - }, persist: function() { - }, isPersistent: pd }); - return b; - } - var sd = { eventPhase: 0, bubbles: 0, cancelable: 0, timeStamp: function(a) { - return a.timeStamp || Date.now(); - }, defaultPrevented: 0, isTrusted: 0 }; - var td = rd(sd); - var ud = A({}, sd, { view: 0, detail: 0 }); - var vd = rd(ud); - var wd; - var xd; - var yd; - var Ad = A({}, ud, { screenX: 0, screenY: 0, clientX: 0, clientY: 0, pageX: 0, pageY: 0, ctrlKey: 0, shiftKey: 0, altKey: 0, metaKey: 0, getModifierState: zd, button: 0, buttons: 0, relatedTarget: function(a) { - return a.relatedTarget === void 0 ? a.fromElement === a.srcElement ? a.toElement : a.fromElement : a.relatedTarget; - }, movementX: function(a) { - if ("movementX" in a) - return a.movementX; - a !== yd && (yd && a.type === "mousemove" ? (wd = a.screenX - yd.screenX, xd = a.screenY - yd.screenY) : xd = wd = 0, yd = a); - return wd; - }, movementY: function(a) { - return "movementY" in a ? a.movementY : xd; - } }); - var Bd = rd(Ad); - var Cd = A({}, Ad, { dataTransfer: 0 }); - var Dd = rd(Cd); - var Ed = A({}, ud, { relatedTarget: 0 }); - var Fd = rd(Ed); - var Gd = A({}, sd, { animationName: 0, elapsedTime: 0, pseudoElement: 0 }); - var Hd = rd(Gd); - var Id = A({}, sd, { clipboardData: function(a) { - return "clipboardData" in a ? a.clipboardData : window.clipboardData; - } }); - var Jd = rd(Id); - var Kd = A({}, sd, { data: 0 }); - var Ld = rd(Kd); - var Md = { - Esc: "Escape", - Spacebar: " ", - Left: "ArrowLeft", - Up: "ArrowUp", - Right: "ArrowRight", - Down: "ArrowDown", - Del: "Delete", - Win: "OS", - Menu: "ContextMenu", - Apps: "ContextMenu", - Scroll: "ScrollLock", - MozPrintableKey: "Unidentified" - }; - var Nd = { - 8: "Backspace", - 9: "Tab", - 12: "Clear", - 13: "Enter", - 16: "Shift", - 17: "Control", - 18: "Alt", - 19: "Pause", - 20: "CapsLock", - 27: "Escape", - 32: " ", - 33: "PageUp", - 34: "PageDown", - 35: "End", - 36: "Home", - 37: "ArrowLeft", - 38: "ArrowUp", - 39: "ArrowRight", - 40: "ArrowDown", - 45: "Insert", - 46: "Delete", - 112: "F1", - 113: "F2", - 114: "F3", - 115: "F4", - 116: "F5", - 117: "F6", - 118: "F7", - 119: "F8", - 120: "F9", - 121: "F10", - 122: "F11", - 123: "F12", - 144: "NumLock", - 145: "ScrollLock", - 224: "Meta" - }; - var Od = { Alt: "altKey", Control: "ctrlKey", Meta: "metaKey", Shift: "shiftKey" }; - function Pd(a) { - var b = this.nativeEvent; - return b.getModifierState ? b.getModifierState(a) : (a = Od[a]) ? !!b[a] : false; - } - function zd() { - return Pd; - } - var Qd = A({}, ud, { key: function(a) { - if (a.key) { - var b = Md[a.key] || a.key; - if (b !== "Unidentified") - return b; - } - return a.type === "keypress" ? (a = od(a), a === 13 ? "Enter" : String.fromCharCode(a)) : a.type === "keydown" || a.type === "keyup" ? Nd[a.keyCode] || "Unidentified" : ""; - }, code: 0, location: 0, ctrlKey: 0, shiftKey: 0, altKey: 0, metaKey: 0, repeat: 0, locale: 0, getModifierState: zd, charCode: function(a) { - return a.type === "keypress" ? od(a) : 0; - }, keyCode: function(a) { - return a.type === "keydown" || a.type === "keyup" ? a.keyCode : 0; - }, which: function(a) { - return a.type === "keypress" ? od(a) : a.type === "keydown" || a.type === "keyup" ? a.keyCode : 0; - } }); - var Rd = rd(Qd); - var Sd = A({}, Ad, { pointerId: 0, width: 0, height: 0, pressure: 0, tangentialPressure: 0, tiltX: 0, tiltY: 0, twist: 0, pointerType: 0, isPrimary: 0 }); - var Td = rd(Sd); - var Ud = A({}, ud, { touches: 0, targetTouches: 0, changedTouches: 0, altKey: 0, metaKey: 0, ctrlKey: 0, shiftKey: 0, getModifierState: zd }); - var Vd = rd(Ud); - var Wd = A({}, sd, { propertyName: 0, elapsedTime: 0, pseudoElement: 0 }); - var Xd = rd(Wd); - var Yd = A({}, Ad, { - deltaX: function(a) { - return "deltaX" in a ? a.deltaX : "wheelDeltaX" in a ? -a.wheelDeltaX : 0; - }, - deltaY: function(a) { - return "deltaY" in a ? a.deltaY : "wheelDeltaY" in a ? -a.wheelDeltaY : "wheelDelta" in a ? -a.wheelDelta : 0; - }, - deltaZ: 0, - deltaMode: 0 - }); - var Zd = rd(Yd); - var $d = [9, 13, 27, 32]; - var ae = ia && "CompositionEvent" in window; - var be = null; - ia && "documentMode" in document && (be = document.documentMode); - var ce = ia && "TextEvent" in window && !be; - var de = ia && (!ae || be && 8 < be && 11 >= be); - var ee = String.fromCharCode(32); - var fe = false; - function ge(a, b) { - switch (a) { - case "keyup": - return $d.indexOf(b.keyCode) !== -1; - case "keydown": - return b.keyCode !== 229; - case "keypress": - case "mousedown": - case "focusout": - return true; - default: - return false; - } - } - function he(a) { - a = a.detail; - return typeof a === "object" && "data" in a ? a.data : null; - } - var ie = false; - function je(a, b) { - switch (a) { - case "compositionend": - return he(b); - case "keypress": - if (b.which !== 32) - return null; - fe = true; - return ee; - case "textInput": - return a = b.data, a === ee && fe ? null : a; - default: - return null; - } - } - function ke(a, b) { - if (ie) - return a === "compositionend" || !ae && ge(a, b) ? (a = nd(), md = ld = kd = null, ie = false, a) : null; - switch (a) { - case "paste": - return null; - case "keypress": - if (!(b.ctrlKey || b.altKey || b.metaKey) || b.ctrlKey && b.altKey) { - if (b.char && 1 < b.char.length) - return b.char; - if (b.which) - return String.fromCharCode(b.which); - } - return null; - case "compositionend": - return de && b.locale !== "ko" ? null : b.data; - default: - return null; - } - } - var le = { color: true, date: true, datetime: true, "datetime-local": true, email: true, month: true, number: true, password: true, range: true, search: true, tel: true, text: true, time: true, url: true, week: true }; - function me(a) { - var b = a && a.nodeName && a.nodeName.toLowerCase(); - return b === "input" ? !!le[a.type] : b === "textarea" ? true : false; - } - function ne(a, b, c, d) { - Eb(d); - b = oe(b, "onChange"); - 0 < b.length && (c = new td("onChange", "change", null, c, d), a.push({ event: c, listeners: b })); - } - var pe = null; - var qe = null; - function re(a) { - se(a, 0); - } - function te(a) { - var b = ue(a); - if (Wa(b)) - return a; - } - function ve(a, b) { - if (a === "change") - return b; - } - var we = false; - if (ia) { - if (ia) { - ye = "oninput" in document; - if (!ye) { - ze = document.createElement("div"); - ze.setAttribute("oninput", "return;"); - ye = typeof ze.oninput === "function"; - } - xe = ye; - } else - xe = false; - we = xe && (!document.documentMode || 9 < document.documentMode); - } - var xe; - var ye; - var ze; - function Ae() { - pe && (pe.detachEvent("onpropertychange", Be), qe = pe = null); - } - function Be(a) { - if (a.propertyName === "value" && te(qe)) { - var b = []; - ne(b, qe, a, xb(a)); - Jb(re, b); - } - } - function Ce(a, b, c) { - a === "focusin" ? (Ae(), pe = b, qe = c, pe.attachEvent("onpropertychange", Be)) : a === "focusout" && Ae(); - } - function De(a) { - if (a === "selectionchange" || a === "keyup" || a === "keydown") - return te(qe); - } - function Ee(a, b) { - if (a === "click") - return te(b); - } - function Fe(a, b) { - if (a === "input" || a === "change") - return te(b); - } - function Ge(a, b) { - return a === b && (a !== 0 || 1 / a === 1 / b) || a !== a && b !== b; - } - var He = typeof Object.is === "function" ? Object.is : Ge; - function Ie(a, b) { - if (He(a, b)) - return true; - if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) - return false; - var c = Object.keys(a), d = Object.keys(b); - if (c.length !== d.length) - return false; - for (d = 0; d < c.length; d++) { - var e = c[d]; - if (!ja.call(b, e) || !He(a[e], b[e])) - return false; - } - return true; - } - function Je(a) { - for (; a && a.firstChild; ) - a = a.firstChild; - return a; - } - function Ke(a, b) { - var c = Je(a); - a = 0; - for (var d; c; ) { - if (c.nodeType === 3) { - d = a + c.textContent.length; - if (a <= b && d >= b) - return { node: c, offset: b - a }; - a = d; - } - a: { - for (; c; ) { - if (c.nextSibling) { - c = c.nextSibling; - break a; - } - c = c.parentNode; - } - c = void 0; - } - c = Je(c); - } - } - function Le(a, b) { - return a && b ? a === b ? true : a && a.nodeType === 3 ? false : b && b.nodeType === 3 ? Le(a, b.parentNode) : "contains" in a ? a.contains(b) : a.compareDocumentPosition ? !!(a.compareDocumentPosition(b) & 16) : false : false; - } - function Me() { - for (var a = window, b = Xa(); b instanceof a.HTMLIFrameElement; ) { - try { - var c = typeof b.contentWindow.location.href === "string"; - } catch (d) { - c = false; - } - if (c) - a = b.contentWindow; - else - break; - b = Xa(a.document); - } - return b; - } - function Ne(a) { - var b = a && a.nodeName && a.nodeName.toLowerCase(); - return b && (b === "input" && (a.type === "text" || a.type === "search" || a.type === "tel" || a.type === "url" || a.type === "password") || b === "textarea" || a.contentEditable === "true"); - } - function Oe(a) { - var b = Me(), c = a.focusedElem, d = a.selectionRange; - if (b !== c && c && c.ownerDocument && Le(c.ownerDocument.documentElement, c)) { - if (d !== null && Ne(c)) { - if (b = d.start, a = d.end, a === void 0 && (a = b), "selectionStart" in c) - c.selectionStart = b, c.selectionEnd = Math.min(a, c.value.length); - else if (a = (b = c.ownerDocument || document) && b.defaultView || window, a.getSelection) { - a = a.getSelection(); - var e = c.textContent.length, f = Math.min(d.start, e); - d = d.end === void 0 ? f : Math.min(d.end, e); - !a.extend && f > d && (e = d, d = f, f = e); - e = Ke(c, f); - var g = Ke(c, d); - e && g && (a.rangeCount !== 1 || a.anchorNode !== e.node || a.anchorOffset !== e.offset || a.focusNode !== g.node || a.focusOffset !== g.offset) && (b = b.createRange(), b.setStart(e.node, e.offset), a.removeAllRanges(), f > d ? (a.addRange(b), a.extend(g.node, g.offset)) : (b.setEnd(g.node, g.offset), a.addRange(b))); - } - } - b = []; - for (a = c; a = a.parentNode; ) - a.nodeType === 1 && b.push({ element: a, left: a.scrollLeft, top: a.scrollTop }); - typeof c.focus === "function" && c.focus(); - for (c = 0; c < b.length; c++) - a = b[c], a.element.scrollLeft = a.left, a.element.scrollTop = a.top; - } - } - var Pe = ia && "documentMode" in document && 11 >= document.documentMode; - var Qe = null; - var Re = null; - var Se = null; - var Te = false; - function Ue(a, b, c) { - var d = c.window === c ? c.document : c.nodeType === 9 ? c : c.ownerDocument; - Te || Qe == null || Qe !== Xa(d) || (d = Qe, "selectionStart" in d && Ne(d) ? d = { start: d.selectionStart, end: d.selectionEnd } : (d = (d.ownerDocument && d.ownerDocument.defaultView || window).getSelection(), d = { anchorNode: d.anchorNode, anchorOffset: d.anchorOffset, focusNode: d.focusNode, focusOffset: d.focusOffset }), Se && Ie(Se, d) || (Se = d, d = oe(Re, "onSelect"), 0 < d.length && (b = new td("onSelect", "select", null, b, c), a.push({ event: b, listeners: d }), b.target = Qe))); - } - function Ve(a, b) { - var c = {}; - c[a.toLowerCase()] = b.toLowerCase(); - c["Webkit" + a] = "webkit" + b; - c["Moz" + a] = "moz" + b; - return c; - } - var We = { animationend: Ve("Animation", "AnimationEnd"), animationiteration: Ve("Animation", "AnimationIteration"), animationstart: Ve("Animation", "AnimationStart"), transitionend: Ve("Transition", "TransitionEnd") }; - var Xe = {}; - var Ye = {}; - ia && (Ye = document.createElement("div").style, "AnimationEvent" in window || (delete We.animationend.animation, delete We.animationiteration.animation, delete We.animationstart.animation), "TransitionEvent" in window || delete We.transitionend.transition); - function Ze(a) { - if (Xe[a]) - return Xe[a]; - if (!We[a]) - return a; - var b = We[a], c; - for (c in b) - if (b.hasOwnProperty(c) && c in Ye) - return Xe[a] = b[c]; - return a; - } - var $e = Ze("animationend"); - var af = Ze("animationiteration"); - var bf = Ze("animationstart"); - var cf = Ze("transitionend"); - var df = /* @__PURE__ */ new Map(); - var ef = "abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "); - function ff(a, b) { - df.set(a, b); - fa(b, [a]); - } - for (gf = 0; gf < ef.length; gf++) { - hf = ef[gf], jf = hf.toLowerCase(), kf = hf[0].toUpperCase() + hf.slice(1); - ff(jf, "on" + kf); - } - var hf; - var jf; - var kf; - var gf; - ff($e, "onAnimationEnd"); - ff(af, "onAnimationIteration"); - ff(bf, "onAnimationStart"); - ff("dblclick", "onDoubleClick"); - ff("focusin", "onFocus"); - ff("focusout", "onBlur"); - ff(cf, "onTransitionEnd"); - ha("onMouseEnter", ["mouseout", "mouseover"]); - ha("onMouseLeave", ["mouseout", "mouseover"]); - ha("onPointerEnter", ["pointerout", "pointerover"]); - ha("onPointerLeave", ["pointerout", "pointerover"]); - fa("onChange", "change click focusin focusout input keydown keyup selectionchange".split(" ")); - fa("onSelect", "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")); - fa("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]); - fa("onCompositionEnd", "compositionend focusout keydown keypress keyup mousedown".split(" ")); - fa("onCompositionStart", "compositionstart focusout keydown keypress keyup mousedown".split(" ")); - fa("onCompositionUpdate", "compositionupdate focusout keydown keypress keyup mousedown".split(" ")); - var lf = "abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "); - var mf = new Set("cancel close invalid load scroll toggle".split(" ").concat(lf)); - function nf(a, b, c) { - var d = a.type || "unknown-event"; - a.currentTarget = c; - Ub(d, b, void 0, a); - a.currentTarget = null; - } - function se(a, b) { - b = (b & 4) !== 0; - for (var c = 0; c < a.length; c++) { - var d = a[c], e = d.event; - d = d.listeners; - a: { - var f = void 0; - if (b) - for (var g = d.length - 1; 0 <= g; g--) { - var h = d[g], k = h.instance, l = h.currentTarget; - h = h.listener; - if (k !== f && e.isPropagationStopped()) - break a; - nf(e, h, l); - f = k; - } - else - for (g = 0; g < d.length; g++) { - h = d[g]; - k = h.instance; - l = h.currentTarget; - h = h.listener; - if (k !== f && e.isPropagationStopped()) - break a; - nf(e, h, l); - f = k; - } - } - } - if (Qb) - throw a = Rb, Qb = false, Rb = null, a; - } - function D(a, b) { - var c = b[of]; - c === void 0 && (c = b[of] = /* @__PURE__ */ new Set()); - var d = a + "__bubble"; - c.has(d) || (pf(b, a, 2, false), c.add(d)); - } - function qf(a, b, c) { - var d = 0; - b && (d |= 4); - pf(c, a, d, b); - } - var rf = "_reactListening" + Math.random().toString(36).slice(2); - function sf(a) { - if (!a[rf]) { - a[rf] = true; - da.forEach(function(b2) { - b2 !== "selectionchange" && (mf.has(b2) || qf(b2, false, a), qf(b2, true, a)); - }); - var b = a.nodeType === 9 ? a : a.ownerDocument; - b === null || b[rf] || (b[rf] = true, qf("selectionchange", false, b)); - } - } - function pf(a, b, c, d) { - switch (jd(b)) { - case 1: - var e = ed; - break; - case 4: - e = gd; - break; - default: - e = fd; - } - c = e.bind(null, b, c, a); - e = void 0; - !Lb || b !== "touchstart" && b !== "touchmove" && b !== "wheel" || (e = true); - d ? e !== void 0 ? a.addEventListener(b, c, { capture: true, passive: e }) : a.addEventListener(b, c, true) : e !== void 0 ? a.addEventListener(b, c, { passive: e }) : a.addEventListener(b, c, false); - } - function hd(a, b, c, d, e) { - var f = d; - if ((b & 1) === 0 && (b & 2) === 0 && d !== null) - a: - for (; ; ) { - if (d === null) - return; - var g = d.tag; - if (g === 3 || g === 4) { - var h = d.stateNode.containerInfo; - if (h === e || h.nodeType === 8 && h.parentNode === e) - break; - if (g === 4) - for (g = d.return; g !== null; ) { - var k = g.tag; - if (k === 3 || k === 4) { - if (k = g.stateNode.containerInfo, k === e || k.nodeType === 8 && k.parentNode === e) - return; - } - g = g.return; - } - for (; h !== null; ) { - g = Wc(h); - if (g === null) - return; - k = g.tag; - if (k === 5 || k === 6) { - d = f = g; - continue a; - } - h = h.parentNode; - } - } - d = d.return; - } - Jb(function() { - var d2 = f, e2 = xb(c), g2 = []; - a: { - var h2 = df.get(a); - if (h2 !== void 0) { - var k2 = td, n = a; - switch (a) { - case "keypress": - if (od(c) === 0) - break a; - case "keydown": - case "keyup": - k2 = Rd; - break; - case "focusin": - n = "focus"; - k2 = Fd; - break; - case "focusout": - n = "blur"; - k2 = Fd; - break; - case "beforeblur": - case "afterblur": - k2 = Fd; - break; - case "click": - if (c.button === 2) - break a; - case "auxclick": - case "dblclick": - case "mousedown": - case "mousemove": - case "mouseup": - case "mouseout": - case "mouseover": - case "contextmenu": - k2 = Bd; - break; - case "drag": - case "dragend": - case "dragenter": - case "dragexit": - case "dragleave": - case "dragover": - case "dragstart": - case "drop": - k2 = Dd; - break; - case "touchcancel": - case "touchend": - case "touchmove": - case "touchstart": - k2 = Vd; - break; - case $e: - case af: - case bf: - k2 = Hd; - break; - case cf: - k2 = Xd; - break; - case "scroll": - k2 = vd; - break; - case "wheel": - k2 = Zd; - break; - case "copy": - case "cut": - case "paste": - k2 = Jd; - break; - case "gotpointercapture": - case "lostpointercapture": - case "pointercancel": - case "pointerdown": - case "pointermove": - case "pointerout": - case "pointerover": - case "pointerup": - k2 = Td; - } - var t2 = (b & 4) !== 0, J = !t2 && a === "scroll", x = t2 ? h2 !== null ? h2 + "Capture" : null : h2; - t2 = []; - for (var w = d2, u; w !== null; ) { - u = w; - var F = u.stateNode; - u.tag === 5 && F !== null && (u = F, x !== null && (F = Kb(w, x), F != null && t2.push(tf(w, F, u)))); - if (J) - break; - w = w.return; - } - 0 < t2.length && (h2 = new k2(h2, n, null, c, e2), g2.push({ event: h2, listeners: t2 })); - } - } - if ((b & 7) === 0) { - a: { - h2 = a === "mouseover" || a === "pointerover"; - k2 = a === "mouseout" || a === "pointerout"; - if (h2 && c !== wb && (n = c.relatedTarget || c.fromElement) && (Wc(n) || n[uf])) - break a; - if (k2 || h2) { - h2 = e2.window === e2 ? e2 : (h2 = e2.ownerDocument) ? h2.defaultView || h2.parentWindow : window; - if (k2) { - if (n = c.relatedTarget || c.toElement, k2 = d2, n = n ? Wc(n) : null, n !== null && (J = Vb(n), n !== J || n.tag !== 5 && n.tag !== 6)) - n = null; - } else - k2 = null, n = d2; - if (k2 !== n) { - t2 = Bd; - F = "onMouseLeave"; - x = "onMouseEnter"; - w = "mouse"; - if (a === "pointerout" || a === "pointerover") - t2 = Td, F = "onPointerLeave", x = "onPointerEnter", w = "pointer"; - J = k2 == null ? h2 : ue(k2); - u = n == null ? h2 : ue(n); - h2 = new t2(F, w + "leave", k2, c, e2); - h2.target = J; - h2.relatedTarget = u; - F = null; - Wc(e2) === d2 && (t2 = new t2(x, w + "enter", n, c, e2), t2.target = u, t2.relatedTarget = J, F = t2); - J = F; - if (k2 && n) - b: { - t2 = k2; - x = n; - w = 0; - for (u = t2; u; u = vf(u)) - w++; - u = 0; - for (F = x; F; F = vf(F)) - u++; - for (; 0 < w - u; ) - t2 = vf(t2), w--; - for (; 0 < u - w; ) - x = vf(x), u--; - for (; w--; ) { - if (t2 === x || x !== null && t2 === x.alternate) - break b; - t2 = vf(t2); - x = vf(x); - } - t2 = null; - } - else - t2 = null; - k2 !== null && wf(g2, h2, k2, t2, false); - n !== null && J !== null && wf(g2, J, n, t2, true); - } - } - } - a: { - h2 = d2 ? ue(d2) : window; - k2 = h2.nodeName && h2.nodeName.toLowerCase(); - if (k2 === "select" || k2 === "input" && h2.type === "file") - var na = ve; - else if (me(h2)) - if (we) - na = Fe; - else { - na = De; - var xa = Ce; - } - else - (k2 = h2.nodeName) && k2.toLowerCase() === "input" && (h2.type === "checkbox" || h2.type === "radio") && (na = Ee); - if (na && (na = na(a, d2))) { - ne(g2, na, c, e2); - break a; - } - xa && xa(a, h2, d2); - a === "focusout" && (xa = h2._wrapperState) && xa.controlled && h2.type === "number" && cb(h2, "number", h2.value); - } - xa = d2 ? ue(d2) : window; - switch (a) { - case "focusin": - if (me(xa) || xa.contentEditable === "true") - Qe = xa, Re = d2, Se = null; - break; - case "focusout": - Se = Re = Qe = null; - break; - case "mousedown": - Te = true; - break; - case "contextmenu": - case "mouseup": - case "dragend": - Te = false; - Ue(g2, c, e2); - break; - case "selectionchange": - if (Pe) - break; - case "keydown": - case "keyup": - Ue(g2, c, e2); - } - var $a; - if (ae) - b: { - switch (a) { - case "compositionstart": - var ba = "onCompositionStart"; - break b; - case "compositionend": - ba = "onCompositionEnd"; - break b; - case "compositionupdate": - ba = "onCompositionUpdate"; - break b; - } - ba = void 0; - } - else - ie ? ge(a, c) && (ba = "onCompositionEnd") : a === "keydown" && c.keyCode === 229 && (ba = "onCompositionStart"); - ba && (de && c.locale !== "ko" && (ie || ba !== "onCompositionStart" ? ba === "onCompositionEnd" && ie && ($a = nd()) : (kd = e2, ld = "value" in kd ? kd.value : kd.textContent, ie = true)), xa = oe(d2, ba), 0 < xa.length && (ba = new Ld(ba, a, null, c, e2), g2.push({ event: ba, listeners: xa }), $a ? ba.data = $a : ($a = he(c), $a !== null && (ba.data = $a)))); - if ($a = ce ? je(a, c) : ke(a, c)) - d2 = oe(d2, "onBeforeInput"), 0 < d2.length && (e2 = new Ld("onBeforeInput", "beforeinput", null, c, e2), g2.push({ event: e2, listeners: d2 }), e2.data = $a); - } - se(g2, b); - }); - } - function tf(a, b, c) { - return { instance: a, listener: b, currentTarget: c }; - } - function oe(a, b) { - for (var c = b + "Capture", d = []; a !== null; ) { - var e = a, f = e.stateNode; - e.tag === 5 && f !== null && (e = f, f = Kb(a, c), f != null && d.unshift(tf(a, f, e)), f = Kb(a, b), f != null && d.push(tf(a, f, e))); - a = a.return; - } - return d; - } - function vf(a) { - if (a === null) - return null; - do - a = a.return; - while (a && a.tag !== 5); - return a ? a : null; - } - function wf(a, b, c, d, e) { - for (var f = b._reactName, g = []; c !== null && c !== d; ) { - var h = c, k = h.alternate, l = h.stateNode; - if (k !== null && k === d) - break; - h.tag === 5 && l !== null && (h = l, e ? (k = Kb(c, f), k != null && g.unshift(tf(c, k, h))) : e || (k = Kb(c, f), k != null && g.push(tf(c, k, h)))); - c = c.return; - } - g.length !== 0 && a.push({ event: b, listeners: g }); - } - var xf = /\r\n?/g; - var yf = /\u0000|\uFFFD/g; - function zf(a) { - return (typeof a === "string" ? a : "" + a).replace(xf, "\n").replace(yf, ""); - } - function Af(a, b, c) { - b = zf(b); - if (zf(a) !== b && c) - throw Error(p(425)); - } - function Bf() { - } - var Cf = null; - var Df = null; - function Ef(a, b) { - return a === "textarea" || a === "noscript" || typeof b.children === "string" || typeof b.children === "number" || typeof b.dangerouslySetInnerHTML === "object" && b.dangerouslySetInnerHTML !== null && b.dangerouslySetInnerHTML.__html != null; - } - var Ff = typeof setTimeout === "function" ? setTimeout : void 0; - var Gf = typeof clearTimeout === "function" ? clearTimeout : void 0; - var Hf = typeof Promise === "function" ? Promise : void 0; - var Jf = typeof queueMicrotask === "function" ? queueMicrotask : typeof Hf !== "undefined" ? function(a) { - return Hf.resolve(null).then(a).catch(If); - } : Ff; - function If(a) { - setTimeout(function() { - throw a; - }); - } - function Kf(a, b) { - var c = b, d = 0; - do { - var e = c.nextSibling; - a.removeChild(c); - if (e && e.nodeType === 8) - if (c = e.data, c === "/$") { - if (d === 0) { - a.removeChild(e); - bd(b); - return; - } - d--; - } else - c !== "$" && c !== "$?" && c !== "$!" || d++; - c = e; - } while (c); - bd(b); - } - function Lf(a) { - for (; a != null; a = a.nextSibling) { - var b = a.nodeType; - if (b === 1 || b === 3) - break; - if (b === 8) { - b = a.data; - if (b === "$" || b === "$!" || b === "$?") - break; - if (b === "/$") - return null; - } - } - return a; - } - function Mf(a) { - a = a.previousSibling; - for (var b = 0; a; ) { - if (a.nodeType === 8) { - var c = a.data; - if (c === "$" || c === "$!" || c === "$?") { - if (b === 0) - return a; - b--; - } else - c === "/$" && b++; - } - a = a.previousSibling; - } - return null; - } - var Nf = Math.random().toString(36).slice(2); - var Of = "__reactFiber$" + Nf; - var Pf = "__reactProps$" + Nf; - var uf = "__reactContainer$" + Nf; - var of = "__reactEvents$" + Nf; - var Qf = "__reactListeners$" + Nf; - var Rf = "__reactHandles$" + Nf; - function Wc(a) { - var b = a[Of]; - if (b) - return b; - for (var c = a.parentNode; c; ) { - if (b = c[uf] || c[Of]) { - c = b.alternate; - if (b.child !== null || c !== null && c.child !== null) - for (a = Mf(a); a !== null; ) { - if (c = a[Of]) - return c; - a = Mf(a); - } - return b; - } - a = c; - c = a.parentNode; - } - return null; - } - function Cb(a) { - a = a[Of] || a[uf]; - return !a || a.tag !== 5 && a.tag !== 6 && a.tag !== 13 && a.tag !== 3 ? null : a; - } - function ue(a) { - if (a.tag === 5 || a.tag === 6) - return a.stateNode; - throw Error(p(33)); - } - function Db(a) { - return a[Pf] || null; - } - var Sf = []; - var Tf = -1; - function Uf(a) { - return { current: a }; - } - function E(a) { - 0 > Tf || (a.current = Sf[Tf], Sf[Tf] = null, Tf--); - } - function G(a, b) { - Tf++; - Sf[Tf] = a.current; - a.current = b; - } - var Vf = {}; - var H = Uf(Vf); - var Wf = Uf(false); - var Xf = Vf; - function Yf(a, b) { - var c = a.type.contextTypes; - if (!c) - return Vf; - var d = a.stateNode; - if (d && d.__reactInternalMemoizedUnmaskedChildContext === b) - return d.__reactInternalMemoizedMaskedChildContext; - var e = {}, f; - for (f in c) - e[f] = b[f]; - d && (a = a.stateNode, a.__reactInternalMemoizedUnmaskedChildContext = b, a.__reactInternalMemoizedMaskedChildContext = e); - return e; - } - function Zf(a) { - a = a.childContextTypes; - return a !== null && a !== void 0; - } - function $f() { - E(Wf); - E(H); - } - function ag(a, b, c) { - if (H.current !== Vf) - throw Error(p(168)); - G(H, b); - G(Wf, c); - } - function bg(a, b, c) { - var d = a.stateNode; - b = b.childContextTypes; - if (typeof d.getChildContext !== "function") - return c; - d = d.getChildContext(); - for (var e in d) - if (!(e in b)) - throw Error(p(108, Ra(a) || "Unknown", e)); - return A({}, c, d); - } - function cg(a) { - a = (a = a.stateNode) && a.__reactInternalMemoizedMergedChildContext || Vf; - Xf = H.current; - G(H, a); - G(Wf, Wf.current); - return true; - } - function dg(a, b, c) { - var d = a.stateNode; - if (!d) - throw Error(p(169)); - c ? (a = bg(a, b, Xf), d.__reactInternalMemoizedMergedChildContext = a, E(Wf), E(H), G(H, a)) : E(Wf); - G(Wf, c); - } - var eg = null; - var fg = false; - var gg = false; - function hg(a) { - eg === null ? eg = [a] : eg.push(a); - } - function ig(a) { - fg = true; - hg(a); - } - function jg() { - if (!gg && eg !== null) { - gg = true; - var a = 0, b = C; - try { - var c = eg; - for (C = 1; a < c.length; a++) { - var d = c[a]; - do - d = d(true); - while (d !== null); - } - eg = null; - fg = false; - } catch (e) { - throw eg !== null && (eg = eg.slice(a + 1)), ac(fc, jg), e; - } finally { - C = b, gg = false; - } - } - return null; - } - var kg = []; - var lg = 0; - var mg = null; - var ng = 0; - var og = []; - var pg = 0; - var qg = null; - var rg = 1; - var sg = ""; - function tg(a, b) { - kg[lg++] = ng; - kg[lg++] = mg; - mg = a; - ng = b; - } - function ug(a, b, c) { - og[pg++] = rg; - og[pg++] = sg; - og[pg++] = qg; - qg = a; - var d = rg; - a = sg; - var e = 32 - oc(d) - 1; - d &= ~(1 << e); - c += 1; - var f = 32 - oc(b) + e; - if (30 < f) { - var g = e - e % 5; - f = (d & (1 << g) - 1).toString(32); - d >>= g; - e -= g; - rg = 1 << 32 - oc(b) + e | c << e | d; - sg = f + a; - } else - rg = 1 << f | c << e | d, sg = a; - } - function vg(a) { - a.return !== null && (tg(a, 1), ug(a, 1, 0)); - } - function wg(a) { - for (; a === mg; ) - mg = kg[--lg], kg[lg] = null, ng = kg[--lg], kg[lg] = null; - for (; a === qg; ) - qg = og[--pg], og[pg] = null, sg = og[--pg], og[pg] = null, rg = og[--pg], og[pg] = null; - } - var xg = null; - var yg = null; - var I = false; - var zg = null; - function Ag(a, b) { - var c = Bg(5, null, null, 0); - c.elementType = "DELETED"; - c.stateNode = b; - c.return = a; - b = a.deletions; - b === null ? (a.deletions = [c], a.flags |= 16) : b.push(c); - } - function Cg(a, b) { - switch (a.tag) { - case 5: - var c = a.type; - b = b.nodeType !== 1 || c.toLowerCase() !== b.nodeName.toLowerCase() ? null : b; - return b !== null ? (a.stateNode = b, xg = a, yg = Lf(b.firstChild), true) : false; - case 6: - return b = a.pendingProps === "" || b.nodeType !== 3 ? null : b, b !== null ? (a.stateNode = b, xg = a, yg = null, true) : false; - case 13: - return b = b.nodeType !== 8 ? null : b, b !== null ? (c = qg !== null ? { id: rg, overflow: sg } : null, a.memoizedState = { dehydrated: b, treeContext: c, retryLane: 1073741824 }, c = Bg(18, null, null, 0), c.stateNode = b, c.return = a, a.child = c, xg = a, yg = null, true) : false; - default: - return false; - } - } - function Dg(a) { - return (a.mode & 1) !== 0 && (a.flags & 128) === 0; - } - function Eg(a) { - if (I) { - var b = yg; - if (b) { - var c = b; - if (!Cg(a, b)) { - if (Dg(a)) - throw Error(p(418)); - b = Lf(c.nextSibling); - var d = xg; - b && Cg(a, b) ? Ag(d, c) : (a.flags = a.flags & -4097 | 2, I = false, xg = a); - } - } else { - if (Dg(a)) - throw Error(p(418)); - a.flags = a.flags & -4097 | 2; - I = false; - xg = a; - } - } - } - function Fg(a) { - for (a = a.return; a !== null && a.tag !== 5 && a.tag !== 3 && a.tag !== 13; ) - a = a.return; - xg = a; - } - function Gg(a) { - if (a !== xg) - return false; - if (!I) - return Fg(a), I = true, false; - var b; - (b = a.tag !== 3) && !(b = a.tag !== 5) && (b = a.type, b = b !== "head" && b !== "body" && !Ef(a.type, a.memoizedProps)); - if (b && (b = yg)) { - if (Dg(a)) - throw Hg(), Error(p(418)); - for (; b; ) - Ag(a, b), b = Lf(b.nextSibling); - } - Fg(a); - if (a.tag === 13) { - a = a.memoizedState; - a = a !== null ? a.dehydrated : null; - if (!a) - throw Error(p(317)); - a: { - a = a.nextSibling; - for (b = 0; a; ) { - if (a.nodeType === 8) { - var c = a.data; - if (c === "/$") { - if (b === 0) { - yg = Lf(a.nextSibling); - break a; - } - b--; - } else - c !== "$" && c !== "$!" && c !== "$?" || b++; - } - a = a.nextSibling; - } - yg = null; - } - } else - yg = xg ? Lf(a.stateNode.nextSibling) : null; - return true; - } - function Hg() { - for (var a = yg; a; ) - a = Lf(a.nextSibling); - } - function Ig() { - yg = xg = null; - I = false; - } - function Jg(a) { - zg === null ? zg = [a] : zg.push(a); - } - var Kg = ua.ReactCurrentBatchConfig; - function Lg(a, b) { - if (a && a.defaultProps) { - b = A({}, b); - a = a.defaultProps; - for (var c in a) - b[c] === void 0 && (b[c] = a[c]); - return b; - } - return b; - } - var Mg = Uf(null); - var Ng = null; - var Og = null; - var Pg = null; - function Qg() { - Pg = Og = Ng = null; - } - function Rg(a) { - var b = Mg.current; - E(Mg); - a._currentValue = b; - } - function Sg(a, b, c) { - for (; a !== null; ) { - var d = a.alternate; - (a.childLanes & b) !== b ? (a.childLanes |= b, d !== null && (d.childLanes |= b)) : d !== null && (d.childLanes & b) !== b && (d.childLanes |= b); - if (a === c) - break; - a = a.return; - } - } - function Tg(a, b) { - Ng = a; - Pg = Og = null; - a = a.dependencies; - a !== null && a.firstContext !== null && ((a.lanes & b) !== 0 && (Ug = true), a.firstContext = null); - } - function Vg(a) { - var b = a._currentValue; - if (Pg !== a) - if (a = { context: a, memoizedValue: b, next: null }, Og === null) { - if (Ng === null) - throw Error(p(308)); - Og = a; - Ng.dependencies = { lanes: 0, firstContext: a }; - } else - Og = Og.next = a; - return b; - } - var Wg = null; - function Xg(a) { - Wg === null ? Wg = [a] : Wg.push(a); - } - function Yg(a, b, c, d) { - var e = b.interleaved; - e === null ? (c.next = c, Xg(b)) : (c.next = e.next, e.next = c); - b.interleaved = c; - return Zg(a, d); - } - function Zg(a, b) { - a.lanes |= b; - var c = a.alternate; - c !== null && (c.lanes |= b); - c = a; - for (a = a.return; a !== null; ) - a.childLanes |= b, c = a.alternate, c !== null && (c.childLanes |= b), c = a, a = a.return; - return c.tag === 3 ? c.stateNode : null; - } - var $g = false; - function ah(a) { - a.updateQueue = { baseState: a.memoizedState, firstBaseUpdate: null, lastBaseUpdate: null, shared: { pending: null, interleaved: null, lanes: 0 }, effects: null }; - } - function bh(a, b) { - a = a.updateQueue; - b.updateQueue === a && (b.updateQueue = { baseState: a.baseState, firstBaseUpdate: a.firstBaseUpdate, lastBaseUpdate: a.lastBaseUpdate, shared: a.shared, effects: a.effects }); - } - function ch(a, b) { - return { eventTime: a, lane: b, tag: 0, payload: null, callback: null, next: null }; - } - function dh(a, b, c) { - var d = a.updateQueue; - if (d === null) - return null; - d = d.shared; - if ((K & 2) !== 0) { - var e = d.pending; - e === null ? b.next = b : (b.next = e.next, e.next = b); - d.pending = b; - return Zg(a, c); - } - e = d.interleaved; - e === null ? (b.next = b, Xg(d)) : (b.next = e.next, e.next = b); - d.interleaved = b; - return Zg(a, c); - } - function eh(a, b, c) { - b = b.updateQueue; - if (b !== null && (b = b.shared, (c & 4194240) !== 0)) { - var d = b.lanes; - d &= a.pendingLanes; - c |= d; - b.lanes = c; - Cc(a, c); - } - } - function fh(a, b) { - var c = a.updateQueue, d = a.alternate; - if (d !== null && (d = d.updateQueue, c === d)) { - var e = null, f = null; - c = c.firstBaseUpdate; - if (c !== null) { - do { - var g = { eventTime: c.eventTime, lane: c.lane, tag: c.tag, payload: c.payload, callback: c.callback, next: null }; - f === null ? e = f = g : f = f.next = g; - c = c.next; - } while (c !== null); - f === null ? e = f = b : f = f.next = b; - } else - e = f = b; - c = { baseState: d.baseState, firstBaseUpdate: e, lastBaseUpdate: f, shared: d.shared, effects: d.effects }; - a.updateQueue = c; - return; - } - a = c.lastBaseUpdate; - a === null ? c.firstBaseUpdate = b : a.next = b; - c.lastBaseUpdate = b; - } - function gh(a, b, c, d) { - var e = a.updateQueue; - $g = false; - var f = e.firstBaseUpdate, g = e.lastBaseUpdate, h = e.shared.pending; - if (h !== null) { - e.shared.pending = null; - var k = h, l = k.next; - k.next = null; - g === null ? f = l : g.next = l; - g = k; - var m = a.alternate; - m !== null && (m = m.updateQueue, h = m.lastBaseUpdate, h !== g && (h === null ? m.firstBaseUpdate = l : h.next = l, m.lastBaseUpdate = k)); - } - if (f !== null) { - var q = e.baseState; - g = 0; - m = l = k = null; - h = f; - do { - var r = h.lane, y = h.eventTime; - if ((d & r) === r) { - m !== null && (m = m.next = { - eventTime: y, - lane: 0, - tag: h.tag, - payload: h.payload, - callback: h.callback, - next: null - }); - a: { - var n = a, t2 = h; - r = b; - y = c; - switch (t2.tag) { - case 1: - n = t2.payload; - if (typeof n === "function") { - q = n.call(y, q, r); - break a; - } - q = n; - break a; - case 3: - n.flags = n.flags & -65537 | 128; - case 0: - n = t2.payload; - r = typeof n === "function" ? n.call(y, q, r) : n; - if (r === null || r === void 0) - break a; - q = A({}, q, r); - break a; - case 2: - $g = true; - } - } - h.callback !== null && h.lane !== 0 && (a.flags |= 64, r = e.effects, r === null ? e.effects = [h] : r.push(h)); - } else - y = { eventTime: y, lane: r, tag: h.tag, payload: h.payload, callback: h.callback, next: null }, m === null ? (l = m = y, k = q) : m = m.next = y, g |= r; - h = h.next; - if (h === null) - if (h = e.shared.pending, h === null) - break; - else - r = h, h = r.next, r.next = null, e.lastBaseUpdate = r, e.shared.pending = null; - } while (1); - m === null && (k = q); - e.baseState = k; - e.firstBaseUpdate = l; - e.lastBaseUpdate = m; - b = e.shared.interleaved; - if (b !== null) { - e = b; - do - g |= e.lane, e = e.next; - while (e !== b); - } else - f === null && (e.shared.lanes = 0); - hh |= g; - a.lanes = g; - a.memoizedState = q; - } - } - function ih(a, b, c) { - a = b.effects; - b.effects = null; - if (a !== null) - for (b = 0; b < a.length; b++) { - var d = a[b], e = d.callback; - if (e !== null) { - d.callback = null; - d = c; - if (typeof e !== "function") - throw Error(p(191, e)); - e.call(d); - } - } - } - var jh = new aa.Component().refs; - function kh(a, b, c, d) { - b = a.memoizedState; - c = c(d, b); - c = c === null || c === void 0 ? b : A({}, b, c); - a.memoizedState = c; - a.lanes === 0 && (a.updateQueue.baseState = c); - } - var nh = { isMounted: function(a) { - return (a = a._reactInternals) ? Vb(a) === a : false; - }, enqueueSetState: function(a, b, c) { - a = a._reactInternals; - var d = L(), e = lh(a), f = ch(d, e); - f.payload = b; - c !== void 0 && c !== null && (f.callback = c); - b = dh(a, f, e); - b !== null && (mh(b, a, e, d), eh(b, a, e)); - }, enqueueReplaceState: function(a, b, c) { - a = a._reactInternals; - var d = L(), e = lh(a), f = ch(d, e); - f.tag = 1; - f.payload = b; - c !== void 0 && c !== null && (f.callback = c); - b = dh(a, f, e); - b !== null && (mh(b, a, e, d), eh(b, a, e)); - }, enqueueForceUpdate: function(a, b) { - a = a._reactInternals; - var c = L(), d = lh(a), e = ch(c, d); - e.tag = 2; - b !== void 0 && b !== null && (e.callback = b); - b = dh(a, e, d); - b !== null && (mh(b, a, d, c), eh(b, a, d)); - } }; - function oh(a, b, c, d, e, f, g) { - a = a.stateNode; - return typeof a.shouldComponentUpdate === "function" ? a.shouldComponentUpdate(d, f, g) : b.prototype && b.prototype.isPureReactComponent ? !Ie(c, d) || !Ie(e, f) : true; - } - function ph(a, b, c) { - var d = false, e = Vf; - var f = b.contextType; - typeof f === "object" && f !== null ? f = Vg(f) : (e = Zf(b) ? Xf : H.current, d = b.contextTypes, f = (d = d !== null && d !== void 0) ? Yf(a, e) : Vf); - b = new b(c, f); - a.memoizedState = b.state !== null && b.state !== void 0 ? b.state : null; - b.updater = nh; - a.stateNode = b; - b._reactInternals = a; - d && (a = a.stateNode, a.__reactInternalMemoizedUnmaskedChildContext = e, a.__reactInternalMemoizedMaskedChildContext = f); - return b; - } - function qh(a, b, c, d) { - a = b.state; - typeof b.componentWillReceiveProps === "function" && b.componentWillReceiveProps(c, d); - typeof b.UNSAFE_componentWillReceiveProps === "function" && b.UNSAFE_componentWillReceiveProps(c, d); - b.state !== a && nh.enqueueReplaceState(b, b.state, null); - } - function rh(a, b, c, d) { - var e = a.stateNode; - e.props = c; - e.state = a.memoizedState; - e.refs = jh; - ah(a); - var f = b.contextType; - typeof f === "object" && f !== null ? e.context = Vg(f) : (f = Zf(b) ? Xf : H.current, e.context = Yf(a, f)); - e.state = a.memoizedState; - f = b.getDerivedStateFromProps; - typeof f === "function" && (kh(a, b, f, c), e.state = a.memoizedState); - typeof b.getDerivedStateFromProps === "function" || typeof e.getSnapshotBeforeUpdate === "function" || typeof e.UNSAFE_componentWillMount !== "function" && typeof e.componentWillMount !== "function" || (b = e.state, typeof e.componentWillMount === "function" && e.componentWillMount(), typeof e.UNSAFE_componentWillMount === "function" && e.UNSAFE_componentWillMount(), b !== e.state && nh.enqueueReplaceState(e, e.state, null), gh(a, c, e, d), e.state = a.memoizedState); - typeof e.componentDidMount === "function" && (a.flags |= 4194308); - } - function sh(a, b, c) { - a = c.ref; - if (a !== null && typeof a !== "function" && typeof a !== "object") { - if (c._owner) { - c = c._owner; - if (c) { - if (c.tag !== 1) - throw Error(p(309)); - var d = c.stateNode; - } - if (!d) - throw Error(p(147, a)); - var e = d, f = "" + a; - if (b !== null && b.ref !== null && typeof b.ref === "function" && b.ref._stringRef === f) - return b.ref; - b = function(a2) { - var b2 = e.refs; - b2 === jh && (b2 = e.refs = {}); - a2 === null ? delete b2[f] : b2[f] = a2; - }; - b._stringRef = f; - return b; - } - if (typeof a !== "string") - throw Error(p(284)); - if (!c._owner) - throw Error(p(290, a)); - } - return a; - } - function th(a, b) { - a = Object.prototype.toString.call(b); - throw Error(p(31, a === "[object Object]" ? "object with keys {" + Object.keys(b).join(", ") + "}" : a)); - } - function uh(a) { - var b = a._init; - return b(a._payload); - } - function vh(a) { - function b(b2, c2) { - if (a) { - var d2 = b2.deletions; - d2 === null ? (b2.deletions = [c2], b2.flags |= 16) : d2.push(c2); - } - } - function c(c2, d2) { - if (!a) - return null; - for (; d2 !== null; ) - b(c2, d2), d2 = d2.sibling; - return null; - } - function d(a2, b2) { - for (a2 = /* @__PURE__ */ new Map(); b2 !== null; ) - b2.key !== null ? a2.set(b2.key, b2) : a2.set(b2.index, b2), b2 = b2.sibling; - return a2; - } - function e(a2, b2) { - a2 = wh(a2, b2); - a2.index = 0; - a2.sibling = null; - return a2; - } - function f(b2, c2, d2) { - b2.index = d2; - if (!a) - return b2.flags |= 1048576, c2; - d2 = b2.alternate; - if (d2 !== null) - return d2 = d2.index, d2 < c2 ? (b2.flags |= 2, c2) : d2; - b2.flags |= 2; - return c2; - } - function g(b2) { - a && b2.alternate === null && (b2.flags |= 2); - return b2; - } - function h(a2, b2, c2, d2) { - if (b2 === null || b2.tag !== 6) - return b2 = xh(c2, a2.mode, d2), b2.return = a2, b2; - b2 = e(b2, c2); - b2.return = a2; - return b2; - } - function k(a2, b2, c2, d2) { - var f2 = c2.type; - if (f2 === ya) - return m(a2, b2, c2.props.children, d2, c2.key); - if (b2 !== null && (b2.elementType === f2 || typeof f2 === "object" && f2 !== null && f2.$$typeof === Ha && uh(f2) === b2.type)) - return d2 = e(b2, c2.props), d2.ref = sh(a2, b2, c2), d2.return = a2, d2; - d2 = yh(c2.type, c2.key, c2.props, null, a2.mode, d2); - d2.ref = sh(a2, b2, c2); - d2.return = a2; - return d2; - } - function l(a2, b2, c2, d2) { - if (b2 === null || b2.tag !== 4 || b2.stateNode.containerInfo !== c2.containerInfo || b2.stateNode.implementation !== c2.implementation) - return b2 = zh(c2, a2.mode, d2), b2.return = a2, b2; - b2 = e(b2, c2.children || []); - b2.return = a2; - return b2; - } - function m(a2, b2, c2, d2, f2) { - if (b2 === null || b2.tag !== 7) - return b2 = Ah(c2, a2.mode, d2, f2), b2.return = a2, b2; - b2 = e(b2, c2); - b2.return = a2; - return b2; - } - function q(a2, b2, c2) { - if (typeof b2 === "string" && b2 !== "" || typeof b2 === "number") - return b2 = xh("" + b2, a2.mode, c2), b2.return = a2, b2; - if (typeof b2 === "object" && b2 !== null) { - switch (b2.$$typeof) { - case va: - return c2 = yh(b2.type, b2.key, b2.props, null, a2.mode, c2), c2.ref = sh(a2, null, b2), c2.return = a2, c2; - case wa: - return b2 = zh(b2, a2.mode, c2), b2.return = a2, b2; - case Ha: - var d2 = b2._init; - return q(a2, d2(b2._payload), c2); - } - if (eb(b2) || Ka(b2)) - return b2 = Ah(b2, a2.mode, c2, null), b2.return = a2, b2; - th(a2, b2); - } - return null; - } - function r(a2, b2, c2, d2) { - var e2 = b2 !== null ? b2.key : null; - if (typeof c2 === "string" && c2 !== "" || typeof c2 === "number") - return e2 !== null ? null : h(a2, b2, "" + c2, d2); - if (typeof c2 === "object" && c2 !== null) { - switch (c2.$$typeof) { - case va: - return c2.key === e2 ? k(a2, b2, c2, d2) : null; - case wa: - return c2.key === e2 ? l(a2, b2, c2, d2) : null; - case Ha: - return e2 = c2._init, r(a2, b2, e2(c2._payload), d2); - } - if (eb(c2) || Ka(c2)) - return e2 !== null ? null : m(a2, b2, c2, d2, null); - th(a2, c2); - } - return null; - } - function y(a2, b2, c2, d2, e2) { - if (typeof d2 === "string" && d2 !== "" || typeof d2 === "number") - return a2 = a2.get(c2) || null, h(b2, a2, "" + d2, e2); - if (typeof d2 === "object" && d2 !== null) { - switch (d2.$$typeof) { - case va: - return a2 = a2.get(d2.key === null ? c2 : d2.key) || null, k(b2, a2, d2, e2); - case wa: - return a2 = a2.get(d2.key === null ? c2 : d2.key) || null, l(b2, a2, d2, e2); - case Ha: - var f2 = d2._init; - return y(a2, b2, c2, f2(d2._payload), e2); - } - if (eb(d2) || Ka(d2)) - return a2 = a2.get(c2) || null, m(b2, a2, d2, e2, null); - th(b2, d2); - } - return null; - } - function n(e2, g2, h2, k2) { - for (var l2 = null, m2 = null, u = g2, w = g2 = 0, x = null; u !== null && w < h2.length; w++) { - u.index > w ? (x = u, u = null) : x = u.sibling; - var n2 = r(e2, u, h2[w], k2); - if (n2 === null) { - u === null && (u = x); - break; - } - a && u && n2.alternate === null && b(e2, u); - g2 = f(n2, g2, w); - m2 === null ? l2 = n2 : m2.sibling = n2; - m2 = n2; - u = x; - } - if (w === h2.length) - return c(e2, u), I && tg(e2, w), l2; - if (u === null) { - for (; w < h2.length; w++) - u = q(e2, h2[w], k2), u !== null && (g2 = f(u, g2, w), m2 === null ? l2 = u : m2.sibling = u, m2 = u); - I && tg(e2, w); - return l2; - } - for (u = d(e2, u); w < h2.length; w++) - x = y(u, e2, w, h2[w], k2), x !== null && (a && x.alternate !== null && u.delete(x.key === null ? w : x.key), g2 = f(x, g2, w), m2 === null ? l2 = x : m2.sibling = x, m2 = x); - a && u.forEach(function(a2) { - return b(e2, a2); - }); - I && tg(e2, w); - return l2; - } - function t2(e2, g2, h2, k2) { - var l2 = Ka(h2); - if (typeof l2 !== "function") - throw Error(p(150)); - h2 = l2.call(h2); - if (h2 == null) - throw Error(p(151)); - for (var u = l2 = null, m2 = g2, w = g2 = 0, x = null, n2 = h2.next(); m2 !== null && !n2.done; w++, n2 = h2.next()) { - m2.index > w ? (x = m2, m2 = null) : x = m2.sibling; - var t3 = r(e2, m2, n2.value, k2); - if (t3 === null) { - m2 === null && (m2 = x); - break; - } - a && m2 && t3.alternate === null && b(e2, m2); - g2 = f(t3, g2, w); - u === null ? l2 = t3 : u.sibling = t3; - u = t3; - m2 = x; - } - if (n2.done) - return c(e2, m2), I && tg(e2, w), l2; - if (m2 === null) { - for (; !n2.done; w++, n2 = h2.next()) - n2 = q(e2, n2.value, k2), n2 !== null && (g2 = f(n2, g2, w), u === null ? l2 = n2 : u.sibling = n2, u = n2); - I && tg(e2, w); - return l2; - } - for (m2 = d(e2, m2); !n2.done; w++, n2 = h2.next()) - n2 = y(m2, e2, w, n2.value, k2), n2 !== null && (a && n2.alternate !== null && m2.delete(n2.key === null ? w : n2.key), g2 = f(n2, g2, w), u === null ? l2 = n2 : u.sibling = n2, u = n2); - a && m2.forEach(function(a2) { - return b(e2, a2); - }); - I && tg(e2, w); - return l2; - } - function J(a2, d2, f2, h2) { - typeof f2 === "object" && f2 !== null && f2.type === ya && f2.key === null && (f2 = f2.props.children); - if (typeof f2 === "object" && f2 !== null) { - switch (f2.$$typeof) { - case va: - a: { - for (var k2 = f2.key, l2 = d2; l2 !== null; ) { - if (l2.key === k2) { - k2 = f2.type; - if (k2 === ya) { - if (l2.tag === 7) { - c(a2, l2.sibling); - d2 = e(l2, f2.props.children); - d2.return = a2; - a2 = d2; - break a; - } - } else if (l2.elementType === k2 || typeof k2 === "object" && k2 !== null && k2.$$typeof === Ha && uh(k2) === l2.type) { - c(a2, l2.sibling); - d2 = e(l2, f2.props); - d2.ref = sh(a2, l2, f2); - d2.return = a2; - a2 = d2; - break a; - } - c(a2, l2); - break; - } else - b(a2, l2); - l2 = l2.sibling; - } - f2.type === ya ? (d2 = Ah(f2.props.children, a2.mode, h2, f2.key), d2.return = a2, a2 = d2) : (h2 = yh(f2.type, f2.key, f2.props, null, a2.mode, h2), h2.ref = sh(a2, d2, f2), h2.return = a2, a2 = h2); - } - return g(a2); - case wa: - a: { - for (l2 = f2.key; d2 !== null; ) { - if (d2.key === l2) - if (d2.tag === 4 && d2.stateNode.containerInfo === f2.containerInfo && d2.stateNode.implementation === f2.implementation) { - c(a2, d2.sibling); - d2 = e(d2, f2.children || []); - d2.return = a2; - a2 = d2; - break a; - } else { - c(a2, d2); - break; - } - else - b(a2, d2); - d2 = d2.sibling; - } - d2 = zh(f2, a2.mode, h2); - d2.return = a2; - a2 = d2; - } - return g(a2); - case Ha: - return l2 = f2._init, J(a2, d2, l2(f2._payload), h2); - } - if (eb(f2)) - return n(a2, d2, f2, h2); - if (Ka(f2)) - return t2(a2, d2, f2, h2); - th(a2, f2); - } - return typeof f2 === "string" && f2 !== "" || typeof f2 === "number" ? (f2 = "" + f2, d2 !== null && d2.tag === 6 ? (c(a2, d2.sibling), d2 = e(d2, f2), d2.return = a2, a2 = d2) : (c(a2, d2), d2 = xh(f2, a2.mode, h2), d2.return = a2, a2 = d2), g(a2)) : c(a2, d2); - } - return J; - } - var Bh = vh(true); - var Ch = vh(false); - var Dh = {}; - var Eh = Uf(Dh); - var Fh = Uf(Dh); - var Gh = Uf(Dh); - function Hh(a) { - if (a === Dh) - throw Error(p(174)); - return a; - } - function Ih(a, b) { - G(Gh, b); - G(Fh, a); - G(Eh, Dh); - a = b.nodeType; - switch (a) { - case 9: - case 11: - b = (b = b.documentElement) ? b.namespaceURI : lb(null, ""); - break; - default: - a = a === 8 ? b.parentNode : b, b = a.namespaceURI || null, a = a.tagName, b = lb(b, a); - } - E(Eh); - G(Eh, b); - } - function Jh() { - E(Eh); - E(Fh); - E(Gh); - } - function Kh(a) { - Hh(Gh.current); - var b = Hh(Eh.current); - var c = lb(b, a.type); - b !== c && (G(Fh, a), G(Eh, c)); - } - function Lh(a) { - Fh.current === a && (E(Eh), E(Fh)); - } - var M = Uf(0); - function Mh(a) { - for (var b = a; b !== null; ) { - if (b.tag === 13) { - var c = b.memoizedState; - if (c !== null && (c = c.dehydrated, c === null || c.data === "$?" || c.data === "$!")) - return b; - } else if (b.tag === 19 && b.memoizedProps.revealOrder !== void 0) { - if ((b.flags & 128) !== 0) - return b; - } else if (b.child !== null) { - b.child.return = b; - b = b.child; - continue; - } - if (b === a) - break; - for (; b.sibling === null; ) { - if (b.return === null || b.return === a) - return null; - b = b.return; - } - b.sibling.return = b.return; - b = b.sibling; - } - return null; - } - var Nh = []; - function Oh() { - for (var a = 0; a < Nh.length; a++) - Nh[a]._workInProgressVersionPrimary = null; - Nh.length = 0; - } - var Ph = ua.ReactCurrentDispatcher; - var Qh = ua.ReactCurrentBatchConfig; - var Rh = 0; - var N = null; - var O = null; - var P = null; - var Sh = false; - var Th = false; - var Uh = 0; - var Vh = 0; - function Q() { - throw Error(p(321)); - } - function Wh(a, b) { - if (b === null) - return false; - for (var c = 0; c < b.length && c < a.length; c++) - if (!He(a[c], b[c])) - return false; - return true; - } - function Xh(a, b, c, d, e, f) { - Rh = f; - N = b; - b.memoizedState = null; - b.updateQueue = null; - b.lanes = 0; - Ph.current = a === null || a.memoizedState === null ? Yh : Zh; - a = c(d, e); - if (Th) { - f = 0; - do { - Th = false; - Uh = 0; - if (25 <= f) - throw Error(p(301)); - f += 1; - P = O = null; - b.updateQueue = null; - Ph.current = $h; - a = c(d, e); - } while (Th); - } - Ph.current = ai; - b = O !== null && O.next !== null; - Rh = 0; - P = O = N = null; - Sh = false; - if (b) - throw Error(p(300)); - return a; - } - function bi() { - var a = Uh !== 0; - Uh = 0; - return a; - } - function ci() { - var a = { memoizedState: null, baseState: null, baseQueue: null, queue: null, next: null }; - P === null ? N.memoizedState = P = a : P = P.next = a; - return P; - } - function di() { - if (O === null) { - var a = N.alternate; - a = a !== null ? a.memoizedState : null; - } else - a = O.next; - var b = P === null ? N.memoizedState : P.next; - if (b !== null) - P = b, O = a; - else { - if (a === null) - throw Error(p(310)); - O = a; - a = { memoizedState: O.memoizedState, baseState: O.baseState, baseQueue: O.baseQueue, queue: O.queue, next: null }; - P === null ? N.memoizedState = P = a : P = P.next = a; - } - return P; - } - function ei(a, b) { - return typeof b === "function" ? b(a) : b; - } - function fi(a) { - var b = di(), c = b.queue; - if (c === null) - throw Error(p(311)); - c.lastRenderedReducer = a; - var d = O, e = d.baseQueue, f = c.pending; - if (f !== null) { - if (e !== null) { - var g = e.next; - e.next = f.next; - f.next = g; - } - d.baseQueue = e = f; - c.pending = null; - } - if (e !== null) { - f = e.next; - d = d.baseState; - var h = g = null, k = null, l = f; - do { - var m = l.lane; - if ((Rh & m) === m) - k !== null && (k = k.next = { lane: 0, action: l.action, hasEagerState: l.hasEagerState, eagerState: l.eagerState, next: null }), d = l.hasEagerState ? l.eagerState : a(d, l.action); - else { - var q = { - lane: m, - action: l.action, - hasEagerState: l.hasEagerState, - eagerState: l.eagerState, - next: null - }; - k === null ? (h = k = q, g = d) : k = k.next = q; - N.lanes |= m; - hh |= m; - } - l = l.next; - } while (l !== null && l !== f); - k === null ? g = d : k.next = h; - He(d, b.memoizedState) || (Ug = true); - b.memoizedState = d; - b.baseState = g; - b.baseQueue = k; - c.lastRenderedState = d; - } - a = c.interleaved; - if (a !== null) { - e = a; - do - f = e.lane, N.lanes |= f, hh |= f, e = e.next; - while (e !== a); - } else - e === null && (c.lanes = 0); - return [b.memoizedState, c.dispatch]; - } - function gi(a) { - var b = di(), c = b.queue; - if (c === null) - throw Error(p(311)); - c.lastRenderedReducer = a; - var d = c.dispatch, e = c.pending, f = b.memoizedState; - if (e !== null) { - c.pending = null; - var g = e = e.next; - do - f = a(f, g.action), g = g.next; - while (g !== e); - He(f, b.memoizedState) || (Ug = true); - b.memoizedState = f; - b.baseQueue === null && (b.baseState = f); - c.lastRenderedState = f; - } - return [f, d]; - } - function hi() { - } - function ii(a, b) { - var c = N, d = di(), e = b(), f = !He(d.memoizedState, e); - f && (d.memoizedState = e, Ug = true); - d = d.queue; - ji(ki.bind(null, c, d, a), [a]); - if (d.getSnapshot !== b || f || P !== null && P.memoizedState.tag & 1) { - c.flags |= 2048; - li(9, mi.bind(null, c, d, e, b), void 0, null); - if (R === null) - throw Error(p(349)); - (Rh & 30) !== 0 || ni(c, b, e); - } - return e; - } - function ni(a, b, c) { - a.flags |= 16384; - a = { getSnapshot: b, value: c }; - b = N.updateQueue; - b === null ? (b = { lastEffect: null, stores: null }, N.updateQueue = b, b.stores = [a]) : (c = b.stores, c === null ? b.stores = [a] : c.push(a)); - } - function mi(a, b, c, d) { - b.value = c; - b.getSnapshot = d; - oi(b) && pi(a); - } - function ki(a, b, c) { - return c(function() { - oi(b) && pi(a); - }); - } - function oi(a) { - var b = a.getSnapshot; - a = a.value; - try { - var c = b(); - return !He(a, c); - } catch (d) { - return true; - } - } - function pi(a) { - var b = Zg(a, 1); - b !== null && mh(b, a, 1, -1); - } - function qi(a) { - var b = ci(); - typeof a === "function" && (a = a()); - b.memoizedState = b.baseState = a; - a = { pending: null, interleaved: null, lanes: 0, dispatch: null, lastRenderedReducer: ei, lastRenderedState: a }; - b.queue = a; - a = a.dispatch = ri.bind(null, N, a); - return [b.memoizedState, a]; - } - function li(a, b, c, d) { - a = { tag: a, create: b, destroy: c, deps: d, next: null }; - b = N.updateQueue; - b === null ? (b = { lastEffect: null, stores: null }, N.updateQueue = b, b.lastEffect = a.next = a) : (c = b.lastEffect, c === null ? b.lastEffect = a.next = a : (d = c.next, c.next = a, a.next = d, b.lastEffect = a)); - return a; - } - function si() { - return di().memoizedState; - } - function ti(a, b, c, d) { - var e = ci(); - N.flags |= a; - e.memoizedState = li(1 | b, c, void 0, d === void 0 ? null : d); - } - function ui(a, b, c, d) { - var e = di(); - d = d === void 0 ? null : d; - var f = void 0; - if (O !== null) { - var g = O.memoizedState; - f = g.destroy; - if (d !== null && Wh(d, g.deps)) { - e.memoizedState = li(b, c, f, d); - return; - } - } - N.flags |= a; - e.memoizedState = li(1 | b, c, f, d); - } - function vi(a, b) { - return ti(8390656, 8, a, b); - } - function ji(a, b) { - return ui(2048, 8, a, b); - } - function wi(a, b) { - return ui(4, 2, a, b); - } - function xi(a, b) { - return ui(4, 4, a, b); - } - function yi(a, b) { - if (typeof b === "function") - return a = a(), b(a), function() { - b(null); - }; - if (b !== null && b !== void 0) - return a = a(), b.current = a, function() { - b.current = null; - }; - } - function zi(a, b, c) { - c = c !== null && c !== void 0 ? c.concat([a]) : null; - return ui(4, 4, yi.bind(null, b, a), c); - } - function Ai() { - } - function Bi(a, b) { - var c = di(); - b = b === void 0 ? null : b; - var d = c.memoizedState; - if (d !== null && b !== null && Wh(b, d[1])) - return d[0]; - c.memoizedState = [a, b]; - return a; - } - function Ci(a, b) { - var c = di(); - b = b === void 0 ? null : b; - var d = c.memoizedState; - if (d !== null && b !== null && Wh(b, d[1])) - return d[0]; - a = a(); - c.memoizedState = [a, b]; - return a; - } - function Di(a, b, c) { - if ((Rh & 21) === 0) - return a.baseState && (a.baseState = false, Ug = true), a.memoizedState = c; - He(c, b) || (c = yc(), N.lanes |= c, hh |= c, a.baseState = true); - return b; - } - function Ei(a, b) { - var c = C; - C = c !== 0 && 4 > c ? c : 4; - a(true); - var d = Qh.transition; - Qh.transition = {}; - try { - a(false), b(); - } finally { - C = c, Qh.transition = d; - } - } - function Fi() { - return di().memoizedState; - } - function Gi(a, b, c) { - var d = lh(a); - c = { lane: d, action: c, hasEagerState: false, eagerState: null, next: null }; - if (Hi(a)) - Ii(b, c); - else if (c = Yg(a, b, c, d), c !== null) { - var e = L(); - mh(c, a, d, e); - Ji(c, b, d); - } - } - function ri(a, b, c) { - var d = lh(a), e = { lane: d, action: c, hasEagerState: false, eagerState: null, next: null }; - if (Hi(a)) - Ii(b, e); - else { - var f = a.alternate; - if (a.lanes === 0 && (f === null || f.lanes === 0) && (f = b.lastRenderedReducer, f !== null)) - try { - var g = b.lastRenderedState, h = f(g, c); - e.hasEagerState = true; - e.eagerState = h; - if (He(h, g)) { - var k = b.interleaved; - k === null ? (e.next = e, Xg(b)) : (e.next = k.next, k.next = e); - b.interleaved = e; - return; - } - } catch (l) { - } finally { - } - c = Yg(a, b, e, d); - c !== null && (e = L(), mh(c, a, d, e), Ji(c, b, d)); - } - } - function Hi(a) { - var b = a.alternate; - return a === N || b !== null && b === N; - } - function Ii(a, b) { - Th = Sh = true; - var c = a.pending; - c === null ? b.next = b : (b.next = c.next, c.next = b); - a.pending = b; - } - function Ji(a, b, c) { - if ((c & 4194240) !== 0) { - var d = b.lanes; - d &= a.pendingLanes; - c |= d; - b.lanes = c; - Cc(a, c); - } - } - var ai = { readContext: Vg, useCallback: Q, useContext: Q, useEffect: Q, useImperativeHandle: Q, useInsertionEffect: Q, useLayoutEffect: Q, useMemo: Q, useReducer: Q, useRef: Q, useState: Q, useDebugValue: Q, useDeferredValue: Q, useTransition: Q, useMutableSource: Q, useSyncExternalStore: Q, useId: Q, unstable_isNewReconciler: false }; - var Yh = { readContext: Vg, useCallback: function(a, b) { - ci().memoizedState = [a, b === void 0 ? null : b]; - return a; - }, useContext: Vg, useEffect: vi, useImperativeHandle: function(a, b, c) { - c = c !== null && c !== void 0 ? c.concat([a]) : null; - return ti(4194308, 4, yi.bind(null, b, a), c); - }, useLayoutEffect: function(a, b) { - return ti(4194308, 4, a, b); - }, useInsertionEffect: function(a, b) { - return ti(4, 2, a, b); - }, useMemo: function(a, b) { - var c = ci(); - b = b === void 0 ? null : b; - a = a(); - c.memoizedState = [a, b]; - return a; - }, useReducer: function(a, b, c) { - var d = ci(); - b = c !== void 0 ? c(b) : b; - d.memoizedState = d.baseState = b; - a = { pending: null, interleaved: null, lanes: 0, dispatch: null, lastRenderedReducer: a, lastRenderedState: b }; - d.queue = a; - a = a.dispatch = Gi.bind(null, N, a); - return [d.memoizedState, a]; - }, useRef: function(a) { - var b = ci(); - a = { current: a }; - return b.memoizedState = a; - }, useState: qi, useDebugValue: Ai, useDeferredValue: function(a) { - return ci().memoizedState = a; - }, useTransition: function() { - var a = qi(false), b = a[0]; - a = Ei.bind(null, a[1]); - ci().memoizedState = a; - return [b, a]; - }, useMutableSource: function() { - }, useSyncExternalStore: function(a, b, c) { - var d = N, e = ci(); - if (I) { - if (c === void 0) - throw Error(p(407)); - c = c(); - } else { - c = b(); - if (R === null) - throw Error(p(349)); - (Rh & 30) !== 0 || ni(d, b, c); - } - e.memoizedState = c; - var f = { value: c, getSnapshot: b }; - e.queue = f; - vi(ki.bind(null, d, f, a), [a]); - d.flags |= 2048; - li(9, mi.bind(null, d, f, c, b), void 0, null); - return c; - }, useId: function() { - var a = ci(), b = R.identifierPrefix; - if (I) { - var c = sg; - var d = rg; - c = (d & ~(1 << 32 - oc(d) - 1)).toString(32) + c; - b = ":" + b + "R" + c; - c = Uh++; - 0 < c && (b += "H" + c.toString(32)); - b += ":"; - } else - c = Vh++, b = ":" + b + "r" + c.toString(32) + ":"; - return a.memoizedState = b; - }, unstable_isNewReconciler: false }; - var Zh = { - readContext: Vg, - useCallback: Bi, - useContext: Vg, - useEffect: ji, - useImperativeHandle: zi, - useInsertionEffect: wi, - useLayoutEffect: xi, - useMemo: Ci, - useReducer: fi, - useRef: si, - useState: function() { - return fi(ei); - }, - useDebugValue: Ai, - useDeferredValue: function(a) { - var b = di(); - return Di(b, O.memoizedState, a); - }, - useTransition: function() { - var a = fi(ei)[0], b = di().memoizedState; - return [a, b]; - }, - useMutableSource: hi, - useSyncExternalStore: ii, - useId: Fi, - unstable_isNewReconciler: false - }; - var $h = { readContext: Vg, useCallback: Bi, useContext: Vg, useEffect: ji, useImperativeHandle: zi, useInsertionEffect: wi, useLayoutEffect: xi, useMemo: Ci, useReducer: gi, useRef: si, useState: function() { - return gi(ei); - }, useDebugValue: Ai, useDeferredValue: function(a) { - var b = di(); - return O === null ? b.memoizedState = a : Di(b, O.memoizedState, a); - }, useTransition: function() { - var a = gi(ei)[0], b = di().memoizedState; - return [a, b]; - }, useMutableSource: hi, useSyncExternalStore: ii, useId: Fi, unstable_isNewReconciler: false }; - function Ki(a, b) { - try { - var c = "", d = b; - do - c += Pa(d), d = d.return; - while (d); - var e = c; - } catch (f) { - e = "\nError generating stack: " + f.message + "\n" + f.stack; - } - return { value: a, source: b, stack: e, digest: null }; - } - function Li(a, b, c) { - return { value: a, source: null, stack: c != null ? c : null, digest: b != null ? b : null }; - } - function Mi(a, b) { - try { - console.error(b.value); - } catch (c) { - setTimeout(function() { - throw c; - }); - } - } - var Ni = typeof WeakMap === "function" ? WeakMap : Map; - function Oi(a, b, c) { - c = ch(-1, c); - c.tag = 3; - c.payload = { element: null }; - var d = b.value; - c.callback = function() { - Pi || (Pi = true, Qi = d); - Mi(a, b); - }; - return c; - } - function Ri(a, b, c) { - c = ch(-1, c); - c.tag = 3; - var d = a.type.getDerivedStateFromError; - if (typeof d === "function") { - var e = b.value; - c.payload = function() { - return d(e); - }; - c.callback = function() { - Mi(a, b); - }; - } - var f = a.stateNode; - f !== null && typeof f.componentDidCatch === "function" && (c.callback = function() { - Mi(a, b); - typeof d !== "function" && (Si === null ? Si = /* @__PURE__ */ new Set([this]) : Si.add(this)); - var c2 = b.stack; - this.componentDidCatch(b.value, { componentStack: c2 !== null ? c2 : "" }); - }); - return c; - } - function Ti(a, b, c) { - var d = a.pingCache; - if (d === null) { - d = a.pingCache = new Ni(); - var e = /* @__PURE__ */ new Set(); - d.set(b, e); - } else - e = d.get(b), e === void 0 && (e = /* @__PURE__ */ new Set(), d.set(b, e)); - e.has(c) || (e.add(c), a = Ui.bind(null, a, b, c), b.then(a, a)); - } - function Vi(a) { - do { - var b; - if (b = a.tag === 13) - b = a.memoizedState, b = b !== null ? b.dehydrated !== null ? true : false : true; - if (b) - return a; - a = a.return; - } while (a !== null); - return null; - } - function Wi(a, b, c, d, e) { - if ((a.mode & 1) === 0) - return a === b ? a.flags |= 65536 : (a.flags |= 128, c.flags |= 131072, c.flags &= -52805, c.tag === 1 && (c.alternate === null ? c.tag = 17 : (b = ch(-1, 1), b.tag = 2, dh(c, b, 1))), c.lanes |= 1), a; - a.flags |= 65536; - a.lanes = e; - return a; - } - var Xi = ua.ReactCurrentOwner; - var Ug = false; - function Yi(a, b, c, d) { - b.child = a === null ? Ch(b, null, c, d) : Bh(b, a.child, c, d); - } - function Zi(a, b, c, d, e) { - c = c.render; - var f = b.ref; - Tg(b, e); - d = Xh(a, b, c, d, f, e); - c = bi(); - if (a !== null && !Ug) - return b.updateQueue = a.updateQueue, b.flags &= -2053, a.lanes &= ~e, $i(a, b, e); - I && c && vg(b); - b.flags |= 1; - Yi(a, b, d, e); - return b.child; - } - function aj(a, b, c, d, e) { - if (a === null) { - var f = c.type; - if (typeof f === "function" && !bj(f) && f.defaultProps === void 0 && c.compare === null && c.defaultProps === void 0) - return b.tag = 15, b.type = f, cj(a, b, f, d, e); - a = yh(c.type, null, d, b, b.mode, e); - a.ref = b.ref; - a.return = b; - return b.child = a; - } - f = a.child; - if ((a.lanes & e) === 0) { - var g = f.memoizedProps; - c = c.compare; - c = c !== null ? c : Ie; - if (c(g, d) && a.ref === b.ref) - return $i(a, b, e); - } - b.flags |= 1; - a = wh(f, d); - a.ref = b.ref; - a.return = b; - return b.child = a; - } - function cj(a, b, c, d, e) { - if (a !== null) { - var f = a.memoizedProps; - if (Ie(f, d) && a.ref === b.ref) - if (Ug = false, b.pendingProps = d = f, (a.lanes & e) !== 0) - (a.flags & 131072) !== 0 && (Ug = true); - else - return b.lanes = a.lanes, $i(a, b, e); - } - return dj(a, b, c, d, e); - } - function ej(a, b, c) { - var d = b.pendingProps, e = d.children, f = a !== null ? a.memoizedState : null; - if (d.mode === "hidden") - if ((b.mode & 1) === 0) - b.memoizedState = { baseLanes: 0, cachePool: null, transitions: null }, G(fj, gj), gj |= c; - else { - if ((c & 1073741824) === 0) - return a = f !== null ? f.baseLanes | c : c, b.lanes = b.childLanes = 1073741824, b.memoizedState = { baseLanes: a, cachePool: null, transitions: null }, b.updateQueue = null, G(fj, gj), gj |= a, null; - b.memoizedState = { baseLanes: 0, cachePool: null, transitions: null }; - d = f !== null ? f.baseLanes : c; - G(fj, gj); - gj |= d; - } - else - f !== null ? (d = f.baseLanes | c, b.memoizedState = null) : d = c, G(fj, gj), gj |= d; - Yi(a, b, e, c); - return b.child; - } - function hj(a, b) { - var c = b.ref; - if (a === null && c !== null || a !== null && a.ref !== c) - b.flags |= 512, b.flags |= 2097152; - } - function dj(a, b, c, d, e) { - var f = Zf(c) ? Xf : H.current; - f = Yf(b, f); - Tg(b, e); - c = Xh(a, b, c, d, f, e); - d = bi(); - if (a !== null && !Ug) - return b.updateQueue = a.updateQueue, b.flags &= -2053, a.lanes &= ~e, $i(a, b, e); - I && d && vg(b); - b.flags |= 1; - Yi(a, b, c, e); - return b.child; - } - function ij(a, b, c, d, e) { - if (Zf(c)) { - var f = true; - cg(b); - } else - f = false; - Tg(b, e); - if (b.stateNode === null) - jj(a, b), ph(b, c, d), rh(b, c, d, e), d = true; - else if (a === null) { - var g = b.stateNode, h = b.memoizedProps; - g.props = h; - var k = g.context, l = c.contextType; - typeof l === "object" && l !== null ? l = Vg(l) : (l = Zf(c) ? Xf : H.current, l = Yf(b, l)); - var m = c.getDerivedStateFromProps, q = typeof m === "function" || typeof g.getSnapshotBeforeUpdate === "function"; - q || typeof g.UNSAFE_componentWillReceiveProps !== "function" && typeof g.componentWillReceiveProps !== "function" || (h !== d || k !== l) && qh(b, g, d, l); - $g = false; - var r = b.memoizedState; - g.state = r; - gh(b, d, g, e); - k = b.memoizedState; - h !== d || r !== k || Wf.current || $g ? (typeof m === "function" && (kh(b, c, m, d), k = b.memoizedState), (h = $g || oh(b, c, h, d, r, k, l)) ? (q || typeof g.UNSAFE_componentWillMount !== "function" && typeof g.componentWillMount !== "function" || (typeof g.componentWillMount === "function" && g.componentWillMount(), typeof g.UNSAFE_componentWillMount === "function" && g.UNSAFE_componentWillMount()), typeof g.componentDidMount === "function" && (b.flags |= 4194308)) : (typeof g.componentDidMount === "function" && (b.flags |= 4194308), b.memoizedProps = d, b.memoizedState = k), g.props = d, g.state = k, g.context = l, d = h) : (typeof g.componentDidMount === "function" && (b.flags |= 4194308), d = false); - } else { - g = b.stateNode; - bh(a, b); - h = b.memoizedProps; - l = b.type === b.elementType ? h : Lg(b.type, h); - g.props = l; - q = b.pendingProps; - r = g.context; - k = c.contextType; - typeof k === "object" && k !== null ? k = Vg(k) : (k = Zf(c) ? Xf : H.current, k = Yf(b, k)); - var y = c.getDerivedStateFromProps; - (m = typeof y === "function" || typeof g.getSnapshotBeforeUpdate === "function") || typeof g.UNSAFE_componentWillReceiveProps !== "function" && typeof g.componentWillReceiveProps !== "function" || (h !== q || r !== k) && qh(b, g, d, k); - $g = false; - r = b.memoizedState; - g.state = r; - gh(b, d, g, e); - var n = b.memoizedState; - h !== q || r !== n || Wf.current || $g ? (typeof y === "function" && (kh(b, c, y, d), n = b.memoizedState), (l = $g || oh(b, c, l, d, r, n, k) || false) ? (m || typeof g.UNSAFE_componentWillUpdate !== "function" && typeof g.componentWillUpdate !== "function" || (typeof g.componentWillUpdate === "function" && g.componentWillUpdate(d, n, k), typeof g.UNSAFE_componentWillUpdate === "function" && g.UNSAFE_componentWillUpdate(d, n, k)), typeof g.componentDidUpdate === "function" && (b.flags |= 4), typeof g.getSnapshotBeforeUpdate === "function" && (b.flags |= 1024)) : (typeof g.componentDidUpdate !== "function" || h === a.memoizedProps && r === a.memoizedState || (b.flags |= 4), typeof g.getSnapshotBeforeUpdate !== "function" || h === a.memoizedProps && r === a.memoizedState || (b.flags |= 1024), b.memoizedProps = d, b.memoizedState = n), g.props = d, g.state = n, g.context = k, d = l) : (typeof g.componentDidUpdate !== "function" || h === a.memoizedProps && r === a.memoizedState || (b.flags |= 4), typeof g.getSnapshotBeforeUpdate !== "function" || h === a.memoizedProps && r === a.memoizedState || (b.flags |= 1024), d = false); - } - return kj(a, b, c, d, f, e); - } - function kj(a, b, c, d, e, f) { - hj(a, b); - var g = (b.flags & 128) !== 0; - if (!d && !g) - return e && dg(b, c, false), $i(a, b, f); - d = b.stateNode; - Xi.current = b; - var h = g && typeof c.getDerivedStateFromError !== "function" ? null : d.render(); - b.flags |= 1; - a !== null && g ? (b.child = Bh(b, a.child, null, f), b.child = Bh(b, null, h, f)) : Yi(a, b, h, f); - b.memoizedState = d.state; - e && dg(b, c, true); - return b.child; - } - function lj(a) { - var b = a.stateNode; - b.pendingContext ? ag(a, b.pendingContext, b.pendingContext !== b.context) : b.context && ag(a, b.context, false); - Ih(a, b.containerInfo); - } - function mj(a, b, c, d, e) { - Ig(); - Jg(e); - b.flags |= 256; - Yi(a, b, c, d); - return b.child; - } - var nj = { dehydrated: null, treeContext: null, retryLane: 0 }; - function oj(a) { - return { baseLanes: a, cachePool: null, transitions: null }; - } - function pj(a, b, c) { - var d = b.pendingProps, e = M.current, f = false, g = (b.flags & 128) !== 0, h; - (h = g) || (h = a !== null && a.memoizedState === null ? false : (e & 2) !== 0); - if (h) - f = true, b.flags &= -129; - else if (a === null || a.memoizedState !== null) - e |= 1; - G(M, e & 1); - if (a === null) { - Eg(b); - a = b.memoizedState; - if (a !== null && (a = a.dehydrated, a !== null)) - return (b.mode & 1) === 0 ? b.lanes = 1 : a.data === "$!" ? b.lanes = 8 : b.lanes = 1073741824, null; - g = d.children; - a = d.fallback; - return f ? (d = b.mode, f = b.child, g = { mode: "hidden", children: g }, (d & 1) === 0 && f !== null ? (f.childLanes = 0, f.pendingProps = g) : f = qj(g, d, 0, null), a = Ah(a, d, c, null), f.return = b, a.return = b, f.sibling = a, b.child = f, b.child.memoizedState = oj(c), b.memoizedState = nj, a) : rj(b, g); - } - e = a.memoizedState; - if (e !== null && (h = e.dehydrated, h !== null)) - return sj(a, b, g, d, h, e, c); - if (f) { - f = d.fallback; - g = b.mode; - e = a.child; - h = e.sibling; - var k = { mode: "hidden", children: d.children }; - (g & 1) === 0 && b.child !== e ? (d = b.child, d.childLanes = 0, d.pendingProps = k, b.deletions = null) : (d = wh(e, k), d.subtreeFlags = e.subtreeFlags & 14680064); - h !== null ? f = wh(h, f) : (f = Ah(f, g, c, null), f.flags |= 2); - f.return = b; - d.return = b; - d.sibling = f; - b.child = d; - d = f; - f = b.child; - g = a.child.memoizedState; - g = g === null ? oj(c) : { baseLanes: g.baseLanes | c, cachePool: null, transitions: g.transitions }; - f.memoizedState = g; - f.childLanes = a.childLanes & ~c; - b.memoizedState = nj; - return d; - } - f = a.child; - a = f.sibling; - d = wh(f, { mode: "visible", children: d.children }); - (b.mode & 1) === 0 && (d.lanes = c); - d.return = b; - d.sibling = null; - a !== null && (c = b.deletions, c === null ? (b.deletions = [a], b.flags |= 16) : c.push(a)); - b.child = d; - b.memoizedState = null; - return d; - } - function rj(a, b) { - b = qj({ mode: "visible", children: b }, a.mode, 0, null); - b.return = a; - return a.child = b; - } - function tj(a, b, c, d) { - d !== null && Jg(d); - Bh(b, a.child, null, c); - a = rj(b, b.pendingProps.children); - a.flags |= 2; - b.memoizedState = null; - return a; - } - function sj(a, b, c, d, e, f, g) { - if (c) { - if (b.flags & 256) - return b.flags &= -257, d = Li(Error(p(422))), tj(a, b, g, d); - if (b.memoizedState !== null) - return b.child = a.child, b.flags |= 128, null; - f = d.fallback; - e = b.mode; - d = qj({ mode: "visible", children: d.children }, e, 0, null); - f = Ah(f, e, g, null); - f.flags |= 2; - d.return = b; - f.return = b; - d.sibling = f; - b.child = d; - (b.mode & 1) !== 0 && Bh(b, a.child, null, g); - b.child.memoizedState = oj(g); - b.memoizedState = nj; - return f; - } - if ((b.mode & 1) === 0) - return tj(a, b, g, null); - if (e.data === "$!") { - d = e.nextSibling && e.nextSibling.dataset; - if (d) - var h = d.dgst; - d = h; - f = Error(p(419)); - d = Li(f, d, void 0); - return tj(a, b, g, d); - } - h = (g & a.childLanes) !== 0; - if (Ug || h) { - d = R; - if (d !== null) { - switch (g & -g) { - case 4: - e = 2; - break; - case 16: - e = 8; - break; - case 64: - case 128: - case 256: - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - case 4194304: - case 8388608: - case 16777216: - case 33554432: - case 67108864: - e = 32; - break; - case 536870912: - e = 268435456; - break; - default: - e = 0; - } - e = (e & (d.suspendedLanes | g)) !== 0 ? 0 : e; - e !== 0 && e !== f.retryLane && (f.retryLane = e, Zg(a, e), mh(d, a, e, -1)); - } - uj(); - d = Li(Error(p(421))); - return tj(a, b, g, d); - } - if (e.data === "$?") - return b.flags |= 128, b.child = a.child, b = vj.bind(null, a), e._reactRetry = b, null; - a = f.treeContext; - yg = Lf(e.nextSibling); - xg = b; - I = true; - zg = null; - a !== null && (og[pg++] = rg, og[pg++] = sg, og[pg++] = qg, rg = a.id, sg = a.overflow, qg = b); - b = rj(b, d.children); - b.flags |= 4096; - return b; - } - function wj(a, b, c) { - a.lanes |= b; - var d = a.alternate; - d !== null && (d.lanes |= b); - Sg(a.return, b, c); - } - function xj(a, b, c, d, e) { - var f = a.memoizedState; - f === null ? a.memoizedState = { isBackwards: b, rendering: null, renderingStartTime: 0, last: d, tail: c, tailMode: e } : (f.isBackwards = b, f.rendering = null, f.renderingStartTime = 0, f.last = d, f.tail = c, f.tailMode = e); - } - function yj(a, b, c) { - var d = b.pendingProps, e = d.revealOrder, f = d.tail; - Yi(a, b, d.children, c); - d = M.current; - if ((d & 2) !== 0) - d = d & 1 | 2, b.flags |= 128; - else { - if (a !== null && (a.flags & 128) !== 0) - a: - for (a = b.child; a !== null; ) { - if (a.tag === 13) - a.memoizedState !== null && wj(a, c, b); - else if (a.tag === 19) - wj(a, c, b); - else if (a.child !== null) { - a.child.return = a; - a = a.child; - continue; - } - if (a === b) - break a; - for (; a.sibling === null; ) { - if (a.return === null || a.return === b) - break a; - a = a.return; - } - a.sibling.return = a.return; - a = a.sibling; - } - d &= 1; - } - G(M, d); - if ((b.mode & 1) === 0) - b.memoizedState = null; - else - switch (e) { - case "forwards": - c = b.child; - for (e = null; c !== null; ) - a = c.alternate, a !== null && Mh(a) === null && (e = c), c = c.sibling; - c = e; - c === null ? (e = b.child, b.child = null) : (e = c.sibling, c.sibling = null); - xj(b, false, e, c, f); - break; - case "backwards": - c = null; - e = b.child; - for (b.child = null; e !== null; ) { - a = e.alternate; - if (a !== null && Mh(a) === null) { - b.child = e; - break; - } - a = e.sibling; - e.sibling = c; - c = e; - e = a; - } - xj(b, true, c, null, f); - break; - case "together": - xj(b, false, null, null, void 0); - break; - default: - b.memoizedState = null; - } - return b.child; - } - function jj(a, b) { - (b.mode & 1) === 0 && a !== null && (a.alternate = null, b.alternate = null, b.flags |= 2); - } - function $i(a, b, c) { - a !== null && (b.dependencies = a.dependencies); - hh |= b.lanes; - if ((c & b.childLanes) === 0) - return null; - if (a !== null && b.child !== a.child) - throw Error(p(153)); - if (b.child !== null) { - a = b.child; - c = wh(a, a.pendingProps); - b.child = c; - for (c.return = b; a.sibling !== null; ) - a = a.sibling, c = c.sibling = wh(a, a.pendingProps), c.return = b; - c.sibling = null; - } - return b.child; - } - function zj(a, b, c) { - switch (b.tag) { - case 3: - lj(b); - Ig(); - break; - case 5: - Kh(b); - break; - case 1: - Zf(b.type) && cg(b); - break; - case 4: - Ih(b, b.stateNode.containerInfo); - break; - case 10: - var d = b.type._context, e = b.memoizedProps.value; - G(Mg, d._currentValue); - d._currentValue = e; - break; - case 13: - d = b.memoizedState; - if (d !== null) { - if (d.dehydrated !== null) - return G(M, M.current & 1), b.flags |= 128, null; - if ((c & b.child.childLanes) !== 0) - return pj(a, b, c); - G(M, M.current & 1); - a = $i(a, b, c); - return a !== null ? a.sibling : null; - } - G(M, M.current & 1); - break; - case 19: - d = (c & b.childLanes) !== 0; - if ((a.flags & 128) !== 0) { - if (d) - return yj(a, b, c); - b.flags |= 128; - } - e = b.memoizedState; - e !== null && (e.rendering = null, e.tail = null, e.lastEffect = null); - G(M, M.current); - if (d) - break; - else - return null; - case 22: - case 23: - return b.lanes = 0, ej(a, b, c); - } - return $i(a, b, c); - } - var Aj; - var Bj; - var Cj; - var Dj; - Aj = function(a, b) { - for (var c = b.child; c !== null; ) { - if (c.tag === 5 || c.tag === 6) - a.appendChild(c.stateNode); - else if (c.tag !== 4 && c.child !== null) { - c.child.return = c; - c = c.child; - continue; - } - if (c === b) - break; - for (; c.sibling === null; ) { - if (c.return === null || c.return === b) - return; - c = c.return; - } - c.sibling.return = c.return; - c = c.sibling; - } - }; - Bj = function() { - }; - Cj = function(a, b, c, d) { - var e = a.memoizedProps; - if (e !== d) { - a = b.stateNode; - Hh(Eh.current); - var f = null; - switch (c) { - case "input": - e = Ya(a, e); - d = Ya(a, d); - f = []; - break; - case "select": - e = A({}, e, { value: void 0 }); - d = A({}, d, { value: void 0 }); - f = []; - break; - case "textarea": - e = gb(a, e); - d = gb(a, d); - f = []; - break; - default: - typeof e.onClick !== "function" && typeof d.onClick === "function" && (a.onclick = Bf); - } - ub(c, d); - var g; - c = null; - for (l in e) - if (!d.hasOwnProperty(l) && e.hasOwnProperty(l) && e[l] != null) - if (l === "style") { - var h = e[l]; - for (g in h) - h.hasOwnProperty(g) && (c || (c = {}), c[g] = ""); - } else - l !== "dangerouslySetInnerHTML" && l !== "children" && l !== "suppressContentEditableWarning" && l !== "suppressHydrationWarning" && l !== "autoFocus" && (ea.hasOwnProperty(l) ? f || (f = []) : (f = f || []).push(l, null)); - for (l in d) { - var k = d[l]; - h = e != null ? e[l] : void 0; - if (d.hasOwnProperty(l) && k !== h && (k != null || h != null)) - if (l === "style") - if (h) { - for (g in h) - !h.hasOwnProperty(g) || k && k.hasOwnProperty(g) || (c || (c = {}), c[g] = ""); - for (g in k) - k.hasOwnProperty(g) && h[g] !== k[g] && (c || (c = {}), c[g] = k[g]); - } else - c || (f || (f = []), f.push(l, c)), c = k; - else - l === "dangerouslySetInnerHTML" ? (k = k ? k.__html : void 0, h = h ? h.__html : void 0, k != null && h !== k && (f = f || []).push(l, k)) : l === "children" ? typeof k !== "string" && typeof k !== "number" || (f = f || []).push(l, "" + k) : l !== "suppressContentEditableWarning" && l !== "suppressHydrationWarning" && (ea.hasOwnProperty(l) ? (k != null && l === "onScroll" && D("scroll", a), f || h === k || (f = [])) : (f = f || []).push(l, k)); - } - c && (f = f || []).push("style", c); - var l = f; - if (b.updateQueue = l) - b.flags |= 4; - } - }; - Dj = function(a, b, c, d) { - c !== d && (b.flags |= 4); - }; - function Ej(a, b) { - if (!I) - switch (a.tailMode) { - case "hidden": - b = a.tail; - for (var c = null; b !== null; ) - b.alternate !== null && (c = b), b = b.sibling; - c === null ? a.tail = null : c.sibling = null; - break; - case "collapsed": - c = a.tail; - for (var d = null; c !== null; ) - c.alternate !== null && (d = c), c = c.sibling; - d === null ? b || a.tail === null ? a.tail = null : a.tail.sibling = null : d.sibling = null; - } - } - function S(a) { - var b = a.alternate !== null && a.alternate.child === a.child, c = 0, d = 0; - if (b) - for (var e = a.child; e !== null; ) - c |= e.lanes | e.childLanes, d |= e.subtreeFlags & 14680064, d |= e.flags & 14680064, e.return = a, e = e.sibling; - else - for (e = a.child; e !== null; ) - c |= e.lanes | e.childLanes, d |= e.subtreeFlags, d |= e.flags, e.return = a, e = e.sibling; - a.subtreeFlags |= d; - a.childLanes = c; - return b; - } - function Fj(a, b, c) { - var d = b.pendingProps; - wg(b); - switch (b.tag) { - case 2: - case 16: - case 15: - case 0: - case 11: - case 7: - case 8: - case 12: - case 9: - case 14: - return S(b), null; - case 1: - return Zf(b.type) && $f(), S(b), null; - case 3: - d = b.stateNode; - Jh(); - E(Wf); - E(H); - Oh(); - d.pendingContext && (d.context = d.pendingContext, d.pendingContext = null); - if (a === null || a.child === null) - Gg(b) ? b.flags |= 4 : a === null || a.memoizedState.isDehydrated && (b.flags & 256) === 0 || (b.flags |= 1024, zg !== null && (Gj(zg), zg = null)); - Bj(a, b); - S(b); - return null; - case 5: - Lh(b); - var e = Hh(Gh.current); - c = b.type; - if (a !== null && b.stateNode != null) - Cj(a, b, c, d, e), a.ref !== b.ref && (b.flags |= 512, b.flags |= 2097152); - else { - if (!d) { - if (b.stateNode === null) - throw Error(p(166)); - S(b); - return null; - } - a = Hh(Eh.current); - if (Gg(b)) { - d = b.stateNode; - c = b.type; - var f = b.memoizedProps; - d[Of] = b; - d[Pf] = f; - a = (b.mode & 1) !== 0; - switch (c) { - case "dialog": - D("cancel", d); - D("close", d); - break; - case "iframe": - case "object": - case "embed": - D("load", d); - break; - case "video": - case "audio": - for (e = 0; e < lf.length; e++) - D(lf[e], d); - break; - case "source": - D("error", d); - break; - case "img": - case "image": - case "link": - D("error", d); - D("load", d); - break; - case "details": - D("toggle", d); - break; - case "input": - Za(d, f); - D("invalid", d); - break; - case "select": - d._wrapperState = { wasMultiple: !!f.multiple }; - D("invalid", d); - break; - case "textarea": - hb(d, f), D("invalid", d); - } - ub(c, f); - e = null; - for (var g in f) - if (f.hasOwnProperty(g)) { - var h = f[g]; - g === "children" ? typeof h === "string" ? d.textContent !== h && (f.suppressHydrationWarning !== true && Af(d.textContent, h, a), e = ["children", h]) : typeof h === "number" && d.textContent !== "" + h && (f.suppressHydrationWarning !== true && Af(d.textContent, h, a), e = ["children", "" + h]) : ea.hasOwnProperty(g) && h != null && g === "onScroll" && D("scroll", d); - } - switch (c) { - case "input": - Va(d); - db(d, f, true); - break; - case "textarea": - Va(d); - jb(d); - break; - case "select": - case "option": - break; - default: - typeof f.onClick === "function" && (d.onclick = Bf); - } - d = e; - b.updateQueue = d; - d !== null && (b.flags |= 4); - } else { - g = e.nodeType === 9 ? e : e.ownerDocument; - a === "http://www.w3.org/1999/xhtml" && (a = kb(c)); - a === "http://www.w3.org/1999/xhtml" ? c === "script" ? (a = g.createElement("div"), a.innerHTML = "<script><\/script>", a = a.removeChild(a.firstChild)) : typeof d.is === "string" ? a = g.createElement(c, { is: d.is }) : (a = g.createElement(c), c === "select" && (g = a, d.multiple ? g.multiple = true : d.size && (g.size = d.size))) : a = g.createElementNS(a, c); - a[Of] = b; - a[Pf] = d; - Aj(a, b, false, false); - b.stateNode = a; - a: { - g = vb(c, d); - switch (c) { - case "dialog": - D("cancel", a); - D("close", a); - e = d; - break; - case "iframe": - case "object": - case "embed": - D("load", a); - e = d; - break; - case "video": - case "audio": - for (e = 0; e < lf.length; e++) - D(lf[e], a); - e = d; - break; - case "source": - D("error", a); - e = d; - break; - case "img": - case "image": - case "link": - D("error", a); - D("load", a); - e = d; - break; - case "details": - D("toggle", a); - e = d; - break; - case "input": - Za(a, d); - e = Ya(a, d); - D("invalid", a); - break; - case "option": - e = d; - break; - case "select": - a._wrapperState = { wasMultiple: !!d.multiple }; - e = A({}, d, { value: void 0 }); - D("invalid", a); - break; - case "textarea": - hb(a, d); - e = gb(a, d); - D("invalid", a); - break; - default: - e = d; - } - ub(c, e); - h = e; - for (f in h) - if (h.hasOwnProperty(f)) { - var k = h[f]; - f === "style" ? sb(a, k) : f === "dangerouslySetInnerHTML" ? (k = k ? k.__html : void 0, k != null && nb(a, k)) : f === "children" ? typeof k === "string" ? (c !== "textarea" || k !== "") && ob(a, k) : typeof k === "number" && ob(a, "" + k) : f !== "suppressContentEditableWarning" && f !== "suppressHydrationWarning" && f !== "autoFocus" && (ea.hasOwnProperty(f) ? k != null && f === "onScroll" && D("scroll", a) : k != null && ta(a, f, k, g)); - } - switch (c) { - case "input": - Va(a); - db(a, d, false); - break; - case "textarea": - Va(a); - jb(a); - break; - case "option": - d.value != null && a.setAttribute("value", "" + Sa(d.value)); - break; - case "select": - a.multiple = !!d.multiple; - f = d.value; - f != null ? fb(a, !!d.multiple, f, false) : d.defaultValue != null && fb(a, !!d.multiple, d.defaultValue, true); - break; - default: - typeof e.onClick === "function" && (a.onclick = Bf); - } - switch (c) { - case "button": - case "input": - case "select": - case "textarea": - d = !!d.autoFocus; - break a; - case "img": - d = true; - break a; - default: - d = false; - } - } - d && (b.flags |= 4); - } - b.ref !== null && (b.flags |= 512, b.flags |= 2097152); - } - S(b); - return null; - case 6: - if (a && b.stateNode != null) - Dj(a, b, a.memoizedProps, d); - else { - if (typeof d !== "string" && b.stateNode === null) - throw Error(p(166)); - c = Hh(Gh.current); - Hh(Eh.current); - if (Gg(b)) { - d = b.stateNode; - c = b.memoizedProps; - d[Of] = b; - if (f = d.nodeValue !== c) { - if (a = xg, a !== null) - switch (a.tag) { - case 3: - Af(d.nodeValue, c, (a.mode & 1) !== 0); - break; - case 5: - a.memoizedProps.suppressHydrationWarning !== true && Af(d.nodeValue, c, (a.mode & 1) !== 0); - } - } - f && (b.flags |= 4); - } else - d = (c.nodeType === 9 ? c : c.ownerDocument).createTextNode(d), d[Of] = b, b.stateNode = d; - } - S(b); - return null; - case 13: - E(M); - d = b.memoizedState; - if (a === null || a.memoizedState !== null && a.memoizedState.dehydrated !== null) { - if (I && yg !== null && (b.mode & 1) !== 0 && (b.flags & 128) === 0) - Hg(), Ig(), b.flags |= 98560, f = false; - else if (f = Gg(b), d !== null && d.dehydrated !== null) { - if (a === null) { - if (!f) - throw Error(p(318)); - f = b.memoizedState; - f = f !== null ? f.dehydrated : null; - if (!f) - throw Error(p(317)); - f[Of] = b; - } else - Ig(), (b.flags & 128) === 0 && (b.memoizedState = null), b.flags |= 4; - S(b); - f = false; - } else - zg !== null && (Gj(zg), zg = null), f = true; - if (!f) - return b.flags & 65536 ? b : null; - } - if ((b.flags & 128) !== 0) - return b.lanes = c, b; - d = d !== null; - d !== (a !== null && a.memoizedState !== null) && d && (b.child.flags |= 8192, (b.mode & 1) !== 0 && (a === null || (M.current & 1) !== 0 ? T === 0 && (T = 3) : uj())); - b.updateQueue !== null && (b.flags |= 4); - S(b); - return null; - case 4: - return Jh(), Bj(a, b), a === null && sf(b.stateNode.containerInfo), S(b), null; - case 10: - return Rg(b.type._context), S(b), null; - case 17: - return Zf(b.type) && $f(), S(b), null; - case 19: - E(M); - f = b.memoizedState; - if (f === null) - return S(b), null; - d = (b.flags & 128) !== 0; - g = f.rendering; - if (g === null) - if (d) - Ej(f, false); - else { - if (T !== 0 || a !== null && (a.flags & 128) !== 0) - for (a = b.child; a !== null; ) { - g = Mh(a); - if (g !== null) { - b.flags |= 128; - Ej(f, false); - d = g.updateQueue; - d !== null && (b.updateQueue = d, b.flags |= 4); - b.subtreeFlags = 0; - d = c; - for (c = b.child; c !== null; ) - f = c, a = d, f.flags &= 14680066, g = f.alternate, g === null ? (f.childLanes = 0, f.lanes = a, f.child = null, f.subtreeFlags = 0, f.memoizedProps = null, f.memoizedState = null, f.updateQueue = null, f.dependencies = null, f.stateNode = null) : (f.childLanes = g.childLanes, f.lanes = g.lanes, f.child = g.child, f.subtreeFlags = 0, f.deletions = null, f.memoizedProps = g.memoizedProps, f.memoizedState = g.memoizedState, f.updateQueue = g.updateQueue, f.type = g.type, a = g.dependencies, f.dependencies = a === null ? null : { lanes: a.lanes, firstContext: a.firstContext }), c = c.sibling; - G(M, M.current & 1 | 2); - return b.child; - } - a = a.sibling; - } - f.tail !== null && B() > Hj && (b.flags |= 128, d = true, Ej(f, false), b.lanes = 4194304); - } - else { - if (!d) - if (a = Mh(g), a !== null) { - if (b.flags |= 128, d = true, c = a.updateQueue, c !== null && (b.updateQueue = c, b.flags |= 4), Ej(f, true), f.tail === null && f.tailMode === "hidden" && !g.alternate && !I) - return S(b), null; - } else - 2 * B() - f.renderingStartTime > Hj && c !== 1073741824 && (b.flags |= 128, d = true, Ej(f, false), b.lanes = 4194304); - f.isBackwards ? (g.sibling = b.child, b.child = g) : (c = f.last, c !== null ? c.sibling = g : b.child = g, f.last = g); - } - if (f.tail !== null) - return b = f.tail, f.rendering = b, f.tail = b.sibling, f.renderingStartTime = B(), b.sibling = null, c = M.current, G(M, d ? c & 1 | 2 : c & 1), b; - S(b); - return null; - case 22: - case 23: - return Ij(), d = b.memoizedState !== null, a !== null && a.memoizedState !== null !== d && (b.flags |= 8192), d && (b.mode & 1) !== 0 ? (gj & 1073741824) !== 0 && (S(b), b.subtreeFlags & 6 && (b.flags |= 8192)) : S(b), null; - case 24: - return null; - case 25: - return null; - } - throw Error(p(156, b.tag)); - } - function Jj(a, b) { - wg(b); - switch (b.tag) { - case 1: - return Zf(b.type) && $f(), a = b.flags, a & 65536 ? (b.flags = a & -65537 | 128, b) : null; - case 3: - return Jh(), E(Wf), E(H), Oh(), a = b.flags, (a & 65536) !== 0 && (a & 128) === 0 ? (b.flags = a & -65537 | 128, b) : null; - case 5: - return Lh(b), null; - case 13: - E(M); - a = b.memoizedState; - if (a !== null && a.dehydrated !== null) { - if (b.alternate === null) - throw Error(p(340)); - Ig(); - } - a = b.flags; - return a & 65536 ? (b.flags = a & -65537 | 128, b) : null; - case 19: - return E(M), null; - case 4: - return Jh(), null; - case 10: - return Rg(b.type._context), null; - case 22: - case 23: - return Ij(), null; - case 24: - return null; - default: - return null; - } - } - var Kj = false; - var U = false; - var Lj = typeof WeakSet === "function" ? WeakSet : Set; - var V = null; - function Mj(a, b) { - var c = a.ref; - if (c !== null) - if (typeof c === "function") - try { - c(null); - } catch (d) { - W(a, b, d); - } - else - c.current = null; - } - function Nj(a, b, c) { - try { - c(); - } catch (d) { - W(a, b, d); - } - } - var Oj = false; - function Pj(a, b) { - Cf = dd; - a = Me(); - if (Ne(a)) { - if ("selectionStart" in a) - var c = { start: a.selectionStart, end: a.selectionEnd }; - else - a: { - c = (c = a.ownerDocument) && c.defaultView || window; - var d = c.getSelection && c.getSelection(); - if (d && d.rangeCount !== 0) { - c = d.anchorNode; - var e = d.anchorOffset, f = d.focusNode; - d = d.focusOffset; - try { - c.nodeType, f.nodeType; - } catch (F) { - c = null; - break a; - } - var g = 0, h = -1, k = -1, l = 0, m = 0, q = a, r = null; - b: - for (; ; ) { - for (var y; ; ) { - q !== c || e !== 0 && q.nodeType !== 3 || (h = g + e); - q !== f || d !== 0 && q.nodeType !== 3 || (k = g + d); - q.nodeType === 3 && (g += q.nodeValue.length); - if ((y = q.firstChild) === null) - break; - r = q; - q = y; - } - for (; ; ) { - if (q === a) - break b; - r === c && ++l === e && (h = g); - r === f && ++m === d && (k = g); - if ((y = q.nextSibling) !== null) - break; - q = r; - r = q.parentNode; - } - q = y; - } - c = h === -1 || k === -1 ? null : { start: h, end: k }; - } else - c = null; - } - c = c || { start: 0, end: 0 }; - } else - c = null; - Df = { focusedElem: a, selectionRange: c }; - dd = false; - for (V = b; V !== null; ) - if (b = V, a = b.child, (b.subtreeFlags & 1028) !== 0 && a !== null) - a.return = b, V = a; - else - for (; V !== null; ) { - b = V; - try { - var n = b.alternate; - if ((b.flags & 1024) !== 0) - switch (b.tag) { - case 0: - case 11: - case 15: - break; - case 1: - if (n !== null) { - var t2 = n.memoizedProps, J = n.memoizedState, x = b.stateNode, w = x.getSnapshotBeforeUpdate(b.elementType === b.type ? t2 : Lg(b.type, t2), J); - x.__reactInternalSnapshotBeforeUpdate = w; - } - break; - case 3: - var u = b.stateNode.containerInfo; - u.nodeType === 1 ? u.textContent = "" : u.nodeType === 9 && u.documentElement && u.removeChild(u.documentElement); - break; - case 5: - case 6: - case 4: - case 17: - break; - default: - throw Error(p(163)); - } - } catch (F) { - W(b, b.return, F); - } - a = b.sibling; - if (a !== null) { - a.return = b.return; - V = a; - break; - } - V = b.return; - } - n = Oj; - Oj = false; - return n; - } - function Qj(a, b, c) { - var d = b.updateQueue; - d = d !== null ? d.lastEffect : null; - if (d !== null) { - var e = d = d.next; - do { - if ((e.tag & a) === a) { - var f = e.destroy; - e.destroy = void 0; - f !== void 0 && Nj(b, c, f); - } - e = e.next; - } while (e !== d); - } - } - function Rj(a, b) { - b = b.updateQueue; - b = b !== null ? b.lastEffect : null; - if (b !== null) { - var c = b = b.next; - do { - if ((c.tag & a) === a) { - var d = c.create; - c.destroy = d(); - } - c = c.next; - } while (c !== b); - } - } - function Sj(a) { - var b = a.ref; - if (b !== null) { - var c = a.stateNode; - switch (a.tag) { - case 5: - a = c; - break; - default: - a = c; - } - typeof b === "function" ? b(a) : b.current = a; - } - } - function Tj(a) { - var b = a.alternate; - b !== null && (a.alternate = null, Tj(b)); - a.child = null; - a.deletions = null; - a.sibling = null; - a.tag === 5 && (b = a.stateNode, b !== null && (delete b[Of], delete b[Pf], delete b[of], delete b[Qf], delete b[Rf])); - a.stateNode = null; - a.return = null; - a.dependencies = null; - a.memoizedProps = null; - a.memoizedState = null; - a.pendingProps = null; - a.stateNode = null; - a.updateQueue = null; - } - function Uj(a) { - return a.tag === 5 || a.tag === 3 || a.tag === 4; - } - function Vj(a) { - a: - for (; ; ) { - for (; a.sibling === null; ) { - if (a.return === null || Uj(a.return)) - return null; - a = a.return; - } - a.sibling.return = a.return; - for (a = a.sibling; a.tag !== 5 && a.tag !== 6 && a.tag !== 18; ) { - if (a.flags & 2) - continue a; - if (a.child === null || a.tag === 4) - continue a; - else - a.child.return = a, a = a.child; - } - if (!(a.flags & 2)) - return a.stateNode; - } - } - function Wj(a, b, c) { - var d = a.tag; - if (d === 5 || d === 6) - a = a.stateNode, b ? c.nodeType === 8 ? c.parentNode.insertBefore(a, b) : c.insertBefore(a, b) : (c.nodeType === 8 ? (b = c.parentNode, b.insertBefore(a, c)) : (b = c, b.appendChild(a)), c = c._reactRootContainer, c !== null && c !== void 0 || b.onclick !== null || (b.onclick = Bf)); - else if (d !== 4 && (a = a.child, a !== null)) - for (Wj(a, b, c), a = a.sibling; a !== null; ) - Wj(a, b, c), a = a.sibling; - } - function Xj(a, b, c) { - var d = a.tag; - if (d === 5 || d === 6) - a = a.stateNode, b ? c.insertBefore(a, b) : c.appendChild(a); - else if (d !== 4 && (a = a.child, a !== null)) - for (Xj(a, b, c), a = a.sibling; a !== null; ) - Xj(a, b, c), a = a.sibling; - } - var X = null; - var Yj = false; - function Zj(a, b, c) { - for (c = c.child; c !== null; ) - ak(a, b, c), c = c.sibling; - } - function ak(a, b, c) { - if (lc && typeof lc.onCommitFiberUnmount === "function") - try { - lc.onCommitFiberUnmount(kc, c); - } catch (h) { - } - switch (c.tag) { - case 5: - U || Mj(c, b); - case 6: - var d = X, e = Yj; - X = null; - Zj(a, b, c); - X = d; - Yj = e; - X !== null && (Yj ? (a = X, c = c.stateNode, a.nodeType === 8 ? a.parentNode.removeChild(c) : a.removeChild(c)) : X.removeChild(c.stateNode)); - break; - case 18: - X !== null && (Yj ? (a = X, c = c.stateNode, a.nodeType === 8 ? Kf(a.parentNode, c) : a.nodeType === 1 && Kf(a, c), bd(a)) : Kf(X, c.stateNode)); - break; - case 4: - d = X; - e = Yj; - X = c.stateNode.containerInfo; - Yj = true; - Zj(a, b, c); - X = d; - Yj = e; - break; - case 0: - case 11: - case 14: - case 15: - if (!U && (d = c.updateQueue, d !== null && (d = d.lastEffect, d !== null))) { - e = d = d.next; - do { - var f = e, g = f.destroy; - f = f.tag; - g !== void 0 && ((f & 2) !== 0 ? Nj(c, b, g) : (f & 4) !== 0 && Nj(c, b, g)); - e = e.next; - } while (e !== d); - } - Zj(a, b, c); - break; - case 1: - if (!U && (Mj(c, b), d = c.stateNode, typeof d.componentWillUnmount === "function")) - try { - d.props = c.memoizedProps, d.state = c.memoizedState, d.componentWillUnmount(); - } catch (h) { - W(c, b, h); - } - Zj(a, b, c); - break; - case 21: - Zj(a, b, c); - break; - case 22: - c.mode & 1 ? (U = (d = U) || c.memoizedState !== null, Zj(a, b, c), U = d) : Zj(a, b, c); - break; - default: - Zj(a, b, c); - } - } - function bk(a) { - var b = a.updateQueue; - if (b !== null) { - a.updateQueue = null; - var c = a.stateNode; - c === null && (c = a.stateNode = new Lj()); - b.forEach(function(b2) { - var d = ck.bind(null, a, b2); - c.has(b2) || (c.add(b2), b2.then(d, d)); - }); - } - } - function dk(a, b) { - var c = b.deletions; - if (c !== null) - for (var d = 0; d < c.length; d++) { - var e = c[d]; - try { - var f = a, g = b, h = g; - a: - for (; h !== null; ) { - switch (h.tag) { - case 5: - X = h.stateNode; - Yj = false; - break a; - case 3: - X = h.stateNode.containerInfo; - Yj = true; - break a; - case 4: - X = h.stateNode.containerInfo; - Yj = true; - break a; - } - h = h.return; - } - if (X === null) - throw Error(p(160)); - ak(f, g, e); - X = null; - Yj = false; - var k = e.alternate; - k !== null && (k.return = null); - e.return = null; - } catch (l) { - W(e, b, l); - } - } - if (b.subtreeFlags & 12854) - for (b = b.child; b !== null; ) - ek(b, a), b = b.sibling; - } - function ek(a, b) { - var c = a.alternate, d = a.flags; - switch (a.tag) { - case 0: - case 11: - case 14: - case 15: - dk(b, a); - fk(a); - if (d & 4) { - try { - Qj(3, a, a.return), Rj(3, a); - } catch (t2) { - W(a, a.return, t2); - } - try { - Qj(5, a, a.return); - } catch (t2) { - W(a, a.return, t2); - } - } - break; - case 1: - dk(b, a); - fk(a); - d & 512 && c !== null && Mj(c, c.return); - break; - case 5: - dk(b, a); - fk(a); - d & 512 && c !== null && Mj(c, c.return); - if (a.flags & 32) { - var e = a.stateNode; - try { - ob(e, ""); - } catch (t2) { - W(a, a.return, t2); - } - } - if (d & 4 && (e = a.stateNode, e != null)) { - var f = a.memoizedProps, g = c !== null ? c.memoizedProps : f, h = a.type, k = a.updateQueue; - a.updateQueue = null; - if (k !== null) - try { - h === "input" && f.type === "radio" && f.name != null && ab(e, f); - vb(h, g); - var l = vb(h, f); - for (g = 0; g < k.length; g += 2) { - var m = k[g], q = k[g + 1]; - m === "style" ? sb(e, q) : m === "dangerouslySetInnerHTML" ? nb(e, q) : m === "children" ? ob(e, q) : ta(e, m, q, l); - } - switch (h) { - case "input": - bb(e, f); - break; - case "textarea": - ib(e, f); - break; - case "select": - var r = e._wrapperState.wasMultiple; - e._wrapperState.wasMultiple = !!f.multiple; - var y = f.value; - y != null ? fb(e, !!f.multiple, y, false) : r !== !!f.multiple && (f.defaultValue != null ? fb(e, !!f.multiple, f.defaultValue, true) : fb(e, !!f.multiple, f.multiple ? [] : "", false)); - } - e[Pf] = f; - } catch (t2) { - W(a, a.return, t2); - } - } - break; - case 6: - dk(b, a); - fk(a); - if (d & 4) { - if (a.stateNode === null) - throw Error(p(162)); - e = a.stateNode; - f = a.memoizedProps; - try { - e.nodeValue = f; - } catch (t2) { - W(a, a.return, t2); - } - } - break; - case 3: - dk(b, a); - fk(a); - if (d & 4 && c !== null && c.memoizedState.isDehydrated) - try { - bd(b.containerInfo); - } catch (t2) { - W(a, a.return, t2); - } - break; - case 4: - dk(b, a); - fk(a); - break; - case 13: - dk(b, a); - fk(a); - e = a.child; - e.flags & 8192 && (f = e.memoizedState !== null, e.stateNode.isHidden = f, !f || e.alternate !== null && e.alternate.memoizedState !== null || (gk = B())); - d & 4 && bk(a); - break; - case 22: - m = c !== null && c.memoizedState !== null; - a.mode & 1 ? (U = (l = U) || m, dk(b, a), U = l) : dk(b, a); - fk(a); - if (d & 8192) { - l = a.memoizedState !== null; - if ((a.stateNode.isHidden = l) && !m && (a.mode & 1) !== 0) - for (V = a, m = a.child; m !== null; ) { - for (q = V = m; V !== null; ) { - r = V; - y = r.child; - switch (r.tag) { - case 0: - case 11: - case 14: - case 15: - Qj(4, r, r.return); - break; - case 1: - Mj(r, r.return); - var n = r.stateNode; - if (typeof n.componentWillUnmount === "function") { - d = r; - c = r.return; - try { - b = d, n.props = b.memoizedProps, n.state = b.memoizedState, n.componentWillUnmount(); - } catch (t2) { - W(d, c, t2); - } - } - break; - case 5: - Mj(r, r.return); - break; - case 22: - if (r.memoizedState !== null) { - hk(q); - continue; - } - } - y !== null ? (y.return = r, V = y) : hk(q); - } - m = m.sibling; - } - a: - for (m = null, q = a; ; ) { - if (q.tag === 5) { - if (m === null) { - m = q; - try { - e = q.stateNode, l ? (f = e.style, typeof f.setProperty === "function" ? f.setProperty("display", "none", "important") : f.display = "none") : (h = q.stateNode, k = q.memoizedProps.style, g = k !== void 0 && k !== null && k.hasOwnProperty("display") ? k.display : null, h.style.display = rb("display", g)); - } catch (t2) { - W(a, a.return, t2); - } - } - } else if (q.tag === 6) { - if (m === null) - try { - q.stateNode.nodeValue = l ? "" : q.memoizedProps; - } catch (t2) { - W(a, a.return, t2); - } - } else if ((q.tag !== 22 && q.tag !== 23 || q.memoizedState === null || q === a) && q.child !== null) { - q.child.return = q; - q = q.child; - continue; - } - if (q === a) - break a; - for (; q.sibling === null; ) { - if (q.return === null || q.return === a) - break a; - m === q && (m = null); - q = q.return; - } - m === q && (m = null); - q.sibling.return = q.return; - q = q.sibling; - } - } - break; - case 19: - dk(b, a); - fk(a); - d & 4 && bk(a); - break; - case 21: - break; - default: - dk(b, a), fk(a); - } - } - function fk(a) { - var b = a.flags; - if (b & 2) { - try { - a: { - for (var c = a.return; c !== null; ) { - if (Uj(c)) { - var d = c; - break a; - } - c = c.return; - } - throw Error(p(160)); - } - switch (d.tag) { - case 5: - var e = d.stateNode; - d.flags & 32 && (ob(e, ""), d.flags &= -33); - var f = Vj(a); - Xj(a, f, e); - break; - case 3: - case 4: - var g = d.stateNode.containerInfo, h = Vj(a); - Wj(a, h, g); - break; - default: - throw Error(p(161)); - } - } catch (k) { - W(a, a.return, k); - } - a.flags &= -3; - } - b & 4096 && (a.flags &= -4097); - } - function ik(a, b, c) { - V = a; - jk(a, b, c); - } - function jk(a, b, c) { - for (var d = (a.mode & 1) !== 0; V !== null; ) { - var e = V, f = e.child; - if (e.tag === 22 && d) { - var g = e.memoizedState !== null || Kj; - if (!g) { - var h = e.alternate, k = h !== null && h.memoizedState !== null || U; - h = Kj; - var l = U; - Kj = g; - if ((U = k) && !l) - for (V = e; V !== null; ) - g = V, k = g.child, g.tag === 22 && g.memoizedState !== null ? kk(e) : k !== null ? (k.return = g, V = k) : kk(e); - for (; f !== null; ) - V = f, jk(f, b, c), f = f.sibling; - V = e; - Kj = h; - U = l; - } - lk(a, b, c); - } else - (e.subtreeFlags & 8772) !== 0 && f !== null ? (f.return = e, V = f) : lk(a, b, c); - } - } - function lk(a) { - for (; V !== null; ) { - var b = V; - if ((b.flags & 8772) !== 0) { - var c = b.alternate; - try { - if ((b.flags & 8772) !== 0) - switch (b.tag) { - case 0: - case 11: - case 15: - U || Rj(5, b); - break; - case 1: - var d = b.stateNode; - if (b.flags & 4 && !U) - if (c === null) - d.componentDidMount(); - else { - var e = b.elementType === b.type ? c.memoizedProps : Lg(b.type, c.memoizedProps); - d.componentDidUpdate(e, c.memoizedState, d.__reactInternalSnapshotBeforeUpdate); - } - var f = b.updateQueue; - f !== null && ih(b, f, d); - break; - case 3: - var g = b.updateQueue; - if (g !== null) { - c = null; - if (b.child !== null) - switch (b.child.tag) { - case 5: - c = b.child.stateNode; - break; - case 1: - c = b.child.stateNode; - } - ih(b, g, c); - } - break; - case 5: - var h = b.stateNode; - if (c === null && b.flags & 4) { - c = h; - var k = b.memoizedProps; - switch (b.type) { - case "button": - case "input": - case "select": - case "textarea": - k.autoFocus && c.focus(); - break; - case "img": - k.src && (c.src = k.src); - } - } - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - if (b.memoizedState === null) { - var l = b.alternate; - if (l !== null) { - var m = l.memoizedState; - if (m !== null) { - var q = m.dehydrated; - q !== null && bd(q); - } - } - } - break; - case 19: - case 17: - case 21: - case 22: - case 23: - case 25: - break; - default: - throw Error(p(163)); - } - U || b.flags & 512 && Sj(b); - } catch (r) { - W(b, b.return, r); - } - } - if (b === a) { - V = null; - break; - } - c = b.sibling; - if (c !== null) { - c.return = b.return; - V = c; - break; - } - V = b.return; - } - } - function hk(a) { - for (; V !== null; ) { - var b = V; - if (b === a) { - V = null; - break; - } - var c = b.sibling; - if (c !== null) { - c.return = b.return; - V = c; - break; - } - V = b.return; - } - } - function kk(a) { - for (; V !== null; ) { - var b = V; - try { - switch (b.tag) { - case 0: - case 11: - case 15: - var c = b.return; - try { - Rj(4, b); - } catch (k) { - W(b, c, k); - } - break; - case 1: - var d = b.stateNode; - if (typeof d.componentDidMount === "function") { - var e = b.return; - try { - d.componentDidMount(); - } catch (k) { - W(b, e, k); - } - } - var f = b.return; - try { - Sj(b); - } catch (k) { - W(b, f, k); - } - break; - case 5: - var g = b.return; - try { - Sj(b); - } catch (k) { - W(b, g, k); - } - } - } catch (k) { - W(b, b.return, k); - } - if (b === a) { - V = null; - break; - } - var h = b.sibling; - if (h !== null) { - h.return = b.return; - V = h; - break; - } - V = b.return; - } - } - var mk = Math.ceil; - var nk = ua.ReactCurrentDispatcher; - var ok = ua.ReactCurrentOwner; - var pk = ua.ReactCurrentBatchConfig; - var K = 0; - var R = null; - var Y = null; - var Z = 0; - var gj = 0; - var fj = Uf(0); - var T = 0; - var qk = null; - var hh = 0; - var rk = 0; - var sk = 0; - var tk = null; - var uk = null; - var gk = 0; - var Hj = Infinity; - var vk = null; - var Pi = false; - var Qi = null; - var Si = null; - var wk = false; - var xk = null; - var yk = 0; - var zk = 0; - var Ak = null; - var Bk = -1; - var Ck = 0; - function L() { - return (K & 6) !== 0 ? B() : Bk !== -1 ? Bk : Bk = B(); - } - function lh(a) { - if ((a.mode & 1) === 0) - return 1; - if ((K & 2) !== 0 && Z !== 0) - return Z & -Z; - if (Kg.transition !== null) - return Ck === 0 && (Ck = yc()), Ck; - a = C; - if (a !== 0) - return a; - a = window.event; - a = a === void 0 ? 16 : jd(a.type); - return a; - } - function mh(a, b, c, d) { - if (50 < zk) - throw zk = 0, Ak = null, Error(p(185)); - Ac(a, c, d); - if ((K & 2) === 0 || a !== R) - a === R && ((K & 2) === 0 && (rk |= c), T === 4 && Dk(a, Z)), Ek(a, d), c === 1 && K === 0 && (b.mode & 1) === 0 && (Hj = B() + 500, fg && jg()); - } - function Ek(a, b) { - var c = a.callbackNode; - wc(a, b); - var d = uc(a, a === R ? Z : 0); - if (d === 0) - c !== null && bc(c), a.callbackNode = null, a.callbackPriority = 0; - else if (b = d & -d, a.callbackPriority !== b) { - c != null && bc(c); - if (b === 1) - a.tag === 0 ? ig(Fk.bind(null, a)) : hg(Fk.bind(null, a)), Jf(function() { - (K & 6) === 0 && jg(); - }), c = null; - else { - switch (Dc(d)) { - case 1: - c = fc; - break; - case 4: - c = gc; - break; - case 16: - c = hc; - break; - case 536870912: - c = jc; - break; - default: - c = hc; - } - c = Gk(c, Hk.bind(null, a)); - } - a.callbackPriority = b; - a.callbackNode = c; - } - } - function Hk(a, b) { - Bk = -1; - Ck = 0; - if ((K & 6) !== 0) - throw Error(p(327)); - var c = a.callbackNode; - if (Ik() && a.callbackNode !== c) - return null; - var d = uc(a, a === R ? Z : 0); - if (d === 0) - return null; - if ((d & 30) !== 0 || (d & a.expiredLanes) !== 0 || b) - b = Jk(a, d); - else { - b = d; - var e = K; - K |= 2; - var f = Kk(); - if (R !== a || Z !== b) - vk = null, Hj = B() + 500, Lk(a, b); - do - try { - Mk(); - break; - } catch (h) { - Nk(a, h); - } - while (1); - Qg(); - nk.current = f; - K = e; - Y !== null ? b = 0 : (R = null, Z = 0, b = T); - } - if (b !== 0) { - b === 2 && (e = xc(a), e !== 0 && (d = e, b = Ok(a, e))); - if (b === 1) - throw c = qk, Lk(a, 0), Dk(a, d), Ek(a, B()), c; - if (b === 6) - Dk(a, d); - else { - e = a.current.alternate; - if ((d & 30) === 0 && !Pk(e) && (b = Jk(a, d), b === 2 && (f = xc(a), f !== 0 && (d = f, b = Ok(a, f))), b === 1)) - throw c = qk, Lk(a, 0), Dk(a, d), Ek(a, B()), c; - a.finishedWork = e; - a.finishedLanes = d; - switch (b) { - case 0: - case 1: - throw Error(p(345)); - case 2: - Qk(a, uk, vk); - break; - case 3: - Dk(a, d); - if ((d & 130023424) === d && (b = gk + 500 - B(), 10 < b)) { - if (uc(a, 0) !== 0) - break; - e = a.suspendedLanes; - if ((e & d) !== d) { - L(); - a.pingedLanes |= a.suspendedLanes & e; - break; - } - a.timeoutHandle = Ff(Qk.bind(null, a, uk, vk), b); - break; - } - Qk(a, uk, vk); - break; - case 4: - Dk(a, d); - if ((d & 4194240) === d) - break; - b = a.eventTimes; - for (e = -1; 0 < d; ) { - var g = 31 - oc(d); - f = 1 << g; - g = b[g]; - g > e && (e = g); - d &= ~f; - } - d = e; - d = B() - d; - d = (120 > d ? 120 : 480 > d ? 480 : 1080 > d ? 1080 : 1920 > d ? 1920 : 3e3 > d ? 3e3 : 4320 > d ? 4320 : 1960 * mk(d / 1960)) - d; - if (10 < d) { - a.timeoutHandle = Ff(Qk.bind(null, a, uk, vk), d); - break; - } - Qk(a, uk, vk); - break; - case 5: - Qk(a, uk, vk); - break; - default: - throw Error(p(329)); - } - } - } - Ek(a, B()); - return a.callbackNode === c ? Hk.bind(null, a) : null; - } - function Ok(a, b) { - var c = tk; - a.current.memoizedState.isDehydrated && (Lk(a, b).flags |= 256); - a = Jk(a, b); - a !== 2 && (b = uk, uk = c, b !== null && Gj(b)); - return a; - } - function Gj(a) { - uk === null ? uk = a : uk.push.apply(uk, a); - } - function Pk(a) { - for (var b = a; ; ) { - if (b.flags & 16384) { - var c = b.updateQueue; - if (c !== null && (c = c.stores, c !== null)) - for (var d = 0; d < c.length; d++) { - var e = c[d], f = e.getSnapshot; - e = e.value; - try { - if (!He(f(), e)) - return false; - } catch (g) { - return false; - } - } - } - c = b.child; - if (b.subtreeFlags & 16384 && c !== null) - c.return = b, b = c; - else { - if (b === a) - break; - for (; b.sibling === null; ) { - if (b.return === null || b.return === a) - return true; - b = b.return; - } - b.sibling.return = b.return; - b = b.sibling; - } - } - return true; - } - function Dk(a, b) { - b &= ~sk; - b &= ~rk; - a.suspendedLanes |= b; - a.pingedLanes &= ~b; - for (a = a.expirationTimes; 0 < b; ) { - var c = 31 - oc(b), d = 1 << c; - a[c] = -1; - b &= ~d; - } - } - function Fk(a) { - if ((K & 6) !== 0) - throw Error(p(327)); - Ik(); - var b = uc(a, 0); - if ((b & 1) === 0) - return Ek(a, B()), null; - var c = Jk(a, b); - if (a.tag !== 0 && c === 2) { - var d = xc(a); - d !== 0 && (b = d, c = Ok(a, d)); - } - if (c === 1) - throw c = qk, Lk(a, 0), Dk(a, b), Ek(a, B()), c; - if (c === 6) - throw Error(p(345)); - a.finishedWork = a.current.alternate; - a.finishedLanes = b; - Qk(a, uk, vk); - Ek(a, B()); - return null; - } - function Rk(a, b) { - var c = K; - K |= 1; - try { - return a(b); - } finally { - K = c, K === 0 && (Hj = B() + 500, fg && jg()); - } - } - function Sk(a) { - xk !== null && xk.tag === 0 && (K & 6) === 0 && Ik(); - var b = K; - K |= 1; - var c = pk.transition, d = C; - try { - if (pk.transition = null, C = 1, a) - return a(); - } finally { - C = d, pk.transition = c, K = b, (K & 6) === 0 && jg(); - } - } - function Ij() { - gj = fj.current; - E(fj); - } - function Lk(a, b) { - a.finishedWork = null; - a.finishedLanes = 0; - var c = a.timeoutHandle; - c !== -1 && (a.timeoutHandle = -1, Gf(c)); - if (Y !== null) - for (c = Y.return; c !== null; ) { - var d = c; - wg(d); - switch (d.tag) { - case 1: - d = d.type.childContextTypes; - d !== null && d !== void 0 && $f(); - break; - case 3: - Jh(); - E(Wf); - E(H); - Oh(); - break; - case 5: - Lh(d); - break; - case 4: - Jh(); - break; - case 13: - E(M); - break; - case 19: - E(M); - break; - case 10: - Rg(d.type._context); - break; - case 22: - case 23: - Ij(); - } - c = c.return; - } - R = a; - Y = a = wh(a.current, null); - Z = gj = b; - T = 0; - qk = null; - sk = rk = hh = 0; - uk = tk = null; - if (Wg !== null) { - for (b = 0; b < Wg.length; b++) - if (c = Wg[b], d = c.interleaved, d !== null) { - c.interleaved = null; - var e = d.next, f = c.pending; - if (f !== null) { - var g = f.next; - f.next = e; - d.next = g; - } - c.pending = d; - } - Wg = null; - } - return a; - } - function Nk(a, b) { - do { - var c = Y; - try { - Qg(); - Ph.current = ai; - if (Sh) { - for (var d = N.memoizedState; d !== null; ) { - var e = d.queue; - e !== null && (e.pending = null); - d = d.next; - } - Sh = false; - } - Rh = 0; - P = O = N = null; - Th = false; - Uh = 0; - ok.current = null; - if (c === null || c.return === null) { - T = 1; - qk = b; - Y = null; - break; - } - a: { - var f = a, g = c.return, h = c, k = b; - b = Z; - h.flags |= 32768; - if (k !== null && typeof k === "object" && typeof k.then === "function") { - var l = k, m = h, q = m.tag; - if ((m.mode & 1) === 0 && (q === 0 || q === 11 || q === 15)) { - var r = m.alternate; - r ? (m.updateQueue = r.updateQueue, m.memoizedState = r.memoizedState, m.lanes = r.lanes) : (m.updateQueue = null, m.memoizedState = null); - } - var y = Vi(g); - if (y !== null) { - y.flags &= -257; - Wi(y, g, h, f, b); - y.mode & 1 && Ti(f, l, b); - b = y; - k = l; - var n = b.updateQueue; - if (n === null) { - var t2 = /* @__PURE__ */ new Set(); - t2.add(k); - b.updateQueue = t2; - } else - n.add(k); - break a; - } else { - if ((b & 1) === 0) { - Ti(f, l, b); - uj(); - break a; - } - k = Error(p(426)); - } - } else if (I && h.mode & 1) { - var J = Vi(g); - if (J !== null) { - (J.flags & 65536) === 0 && (J.flags |= 256); - Wi(J, g, h, f, b); - Jg(Ki(k, h)); - break a; - } - } - f = k = Ki(k, h); - T !== 4 && (T = 2); - tk === null ? tk = [f] : tk.push(f); - f = g; - do { - switch (f.tag) { - case 3: - f.flags |= 65536; - b &= -b; - f.lanes |= b; - var x = Oi(f, k, b); - fh(f, x); - break a; - case 1: - h = k; - var w = f.type, u = f.stateNode; - if ((f.flags & 128) === 0 && (typeof w.getDerivedStateFromError === "function" || u !== null && typeof u.componentDidCatch === "function" && (Si === null || !Si.has(u)))) { - f.flags |= 65536; - b &= -b; - f.lanes |= b; - var F = Ri(f, h, b); - fh(f, F); - break a; - } - } - f = f.return; - } while (f !== null); - } - Tk(c); - } catch (na) { - b = na; - Y === c && c !== null && (Y = c = c.return); - continue; - } - break; - } while (1); - } - function Kk() { - var a = nk.current; - nk.current = ai; - return a === null ? ai : a; - } - function uj() { - if (T === 0 || T === 3 || T === 2) - T = 4; - R === null || (hh & 268435455) === 0 && (rk & 268435455) === 0 || Dk(R, Z); - } - function Jk(a, b) { - var c = K; - K |= 2; - var d = Kk(); - if (R !== a || Z !== b) - vk = null, Lk(a, b); - do - try { - Uk(); - break; - } catch (e) { - Nk(a, e); - } - while (1); - Qg(); - K = c; - nk.current = d; - if (Y !== null) - throw Error(p(261)); - R = null; - Z = 0; - return T; - } - function Uk() { - for (; Y !== null; ) - Vk(Y); - } - function Mk() { - for (; Y !== null && !cc(); ) - Vk(Y); - } - function Vk(a) { - var b = Wk(a.alternate, a, gj); - a.memoizedProps = a.pendingProps; - b === null ? Tk(a) : Y = b; - ok.current = null; - } - function Tk(a) { - var b = a; - do { - var c = b.alternate; - a = b.return; - if ((b.flags & 32768) === 0) { - if (c = Fj(c, b, gj), c !== null) { - Y = c; - return; - } - } else { - c = Jj(c, b); - if (c !== null) { - c.flags &= 32767; - Y = c; - return; - } - if (a !== null) - a.flags |= 32768, a.subtreeFlags = 0, a.deletions = null; - else { - T = 6; - Y = null; - return; - } - } - b = b.sibling; - if (b !== null) { - Y = b; - return; - } - Y = b = a; - } while (b !== null); - T === 0 && (T = 5); - } - function Qk(a, b, c) { - var d = C, e = pk.transition; - try { - pk.transition = null, C = 1, Xk(a, b, c, d); - } finally { - pk.transition = e, C = d; - } - return null; - } - function Xk(a, b, c, d) { - do - Ik(); - while (xk !== null); - if ((K & 6) !== 0) - throw Error(p(327)); - c = a.finishedWork; - var e = a.finishedLanes; - if (c === null) - return null; - a.finishedWork = null; - a.finishedLanes = 0; - if (c === a.current) - throw Error(p(177)); - a.callbackNode = null; - a.callbackPriority = 0; - var f = c.lanes | c.childLanes; - Bc(a, f); - a === R && (Y = R = null, Z = 0); - (c.subtreeFlags & 2064) === 0 && (c.flags & 2064) === 0 || wk || (wk = true, Gk(hc, function() { - Ik(); - return null; - })); - f = (c.flags & 15990) !== 0; - if ((c.subtreeFlags & 15990) !== 0 || f) { - f = pk.transition; - pk.transition = null; - var g = C; - C = 1; - var h = K; - K |= 4; - ok.current = null; - Pj(a, c); - ek(c, a); - Oe(Df); - dd = !!Cf; - Df = Cf = null; - a.current = c; - ik(c, a, e); - dc(); - K = h; - C = g; - pk.transition = f; - } else - a.current = c; - wk && (wk = false, xk = a, yk = e); - f = a.pendingLanes; - f === 0 && (Si = null); - mc(c.stateNode, d); - Ek(a, B()); - if (b !== null) - for (d = a.onRecoverableError, c = 0; c < b.length; c++) - e = b[c], d(e.value, { componentStack: e.stack, digest: e.digest }); - if (Pi) - throw Pi = false, a = Qi, Qi = null, a; - (yk & 1) !== 0 && a.tag !== 0 && Ik(); - f = a.pendingLanes; - (f & 1) !== 0 ? a === Ak ? zk++ : (zk = 0, Ak = a) : zk = 0; - jg(); - return null; - } - function Ik() { - if (xk !== null) { - var a = Dc(yk), b = pk.transition, c = C; - try { - pk.transition = null; - C = 16 > a ? 16 : a; - if (xk === null) - var d = false; - else { - a = xk; - xk = null; - yk = 0; - if ((K & 6) !== 0) - throw Error(p(331)); - var e = K; - K |= 4; - for (V = a.current; V !== null; ) { - var f = V, g = f.child; - if ((V.flags & 16) !== 0) { - var h = f.deletions; - if (h !== null) { - for (var k = 0; k < h.length; k++) { - var l = h[k]; - for (V = l; V !== null; ) { - var m = V; - switch (m.tag) { - case 0: - case 11: - case 15: - Qj(8, m, f); - } - var q = m.child; - if (q !== null) - q.return = m, V = q; - else - for (; V !== null; ) { - m = V; - var r = m.sibling, y = m.return; - Tj(m); - if (m === l) { - V = null; - break; - } - if (r !== null) { - r.return = y; - V = r; - break; - } - V = y; - } - } - } - var n = f.alternate; - if (n !== null) { - var t2 = n.child; - if (t2 !== null) { - n.child = null; - do { - var J = t2.sibling; - t2.sibling = null; - t2 = J; - } while (t2 !== null); - } - } - V = f; - } - } - if ((f.subtreeFlags & 2064) !== 0 && g !== null) - g.return = f, V = g; - else - b: - for (; V !== null; ) { - f = V; - if ((f.flags & 2048) !== 0) - switch (f.tag) { - case 0: - case 11: - case 15: - Qj(9, f, f.return); - } - var x = f.sibling; - if (x !== null) { - x.return = f.return; - V = x; - break b; - } - V = f.return; - } - } - var w = a.current; - for (V = w; V !== null; ) { - g = V; - var u = g.child; - if ((g.subtreeFlags & 2064) !== 0 && u !== null) - u.return = g, V = u; - else - b: - for (g = w; V !== null; ) { - h = V; - if ((h.flags & 2048) !== 0) - try { - switch (h.tag) { - case 0: - case 11: - case 15: - Rj(9, h); - } - } catch (na) { - W(h, h.return, na); - } - if (h === g) { - V = null; - break b; - } - var F = h.sibling; - if (F !== null) { - F.return = h.return; - V = F; - break b; - } - V = h.return; - } - } - K = e; - jg(); - if (lc && typeof lc.onPostCommitFiberRoot === "function") - try { - lc.onPostCommitFiberRoot(kc, a); - } catch (na) { - } - d = true; - } - return d; - } finally { - C = c, pk.transition = b; - } - } - return false; - } - function Yk(a, b, c) { - b = Ki(c, b); - b = Oi(a, b, 1); - a = dh(a, b, 1); - b = L(); - a !== null && (Ac(a, 1, b), Ek(a, b)); - } - function W(a, b, c) { - if (a.tag === 3) - Yk(a, a, c); - else - for (; b !== null; ) { - if (b.tag === 3) { - Yk(b, a, c); - break; - } else if (b.tag === 1) { - var d = b.stateNode; - if (typeof b.type.getDerivedStateFromError === "function" || typeof d.componentDidCatch === "function" && (Si === null || !Si.has(d))) { - a = Ki(c, a); - a = Ri(b, a, 1); - b = dh(b, a, 1); - a = L(); - b !== null && (Ac(b, 1, a), Ek(b, a)); - break; - } - } - b = b.return; - } - } - function Ui(a, b, c) { - var d = a.pingCache; - d !== null && d.delete(b); - b = L(); - a.pingedLanes |= a.suspendedLanes & c; - R === a && (Z & c) === c && (T === 4 || T === 3 && (Z & 130023424) === Z && 500 > B() - gk ? Lk(a, 0) : sk |= c); - Ek(a, b); - } - function Zk(a, b) { - b === 0 && ((a.mode & 1) === 0 ? b = 1 : (b = sc, sc <<= 1, (sc & 130023424) === 0 && (sc = 4194304))); - var c = L(); - a = Zg(a, b); - a !== null && (Ac(a, b, c), Ek(a, c)); - } - function vj(a) { - var b = a.memoizedState, c = 0; - b !== null && (c = b.retryLane); - Zk(a, c); - } - function ck(a, b) { - var c = 0; - switch (a.tag) { - case 13: - var d = a.stateNode; - var e = a.memoizedState; - e !== null && (c = e.retryLane); - break; - case 19: - d = a.stateNode; - break; - default: - throw Error(p(314)); - } - d !== null && d.delete(b); - Zk(a, c); - } - var Wk; - Wk = function(a, b, c) { - if (a !== null) - if (a.memoizedProps !== b.pendingProps || Wf.current) - Ug = true; - else { - if ((a.lanes & c) === 0 && (b.flags & 128) === 0) - return Ug = false, zj(a, b, c); - Ug = (a.flags & 131072) !== 0 ? true : false; - } - else - Ug = false, I && (b.flags & 1048576) !== 0 && ug(b, ng, b.index); - b.lanes = 0; - switch (b.tag) { - case 2: - var d = b.type; - jj(a, b); - a = b.pendingProps; - var e = Yf(b, H.current); - Tg(b, c); - e = Xh(null, b, d, a, e, c); - var f = bi(); - b.flags |= 1; - typeof e === "object" && e !== null && typeof e.render === "function" && e.$$typeof === void 0 ? (b.tag = 1, b.memoizedState = null, b.updateQueue = null, Zf(d) ? (f = true, cg(b)) : f = false, b.memoizedState = e.state !== null && e.state !== void 0 ? e.state : null, ah(b), e.updater = nh, b.stateNode = e, e._reactInternals = b, rh(b, d, a, c), b = kj(null, b, d, true, f, c)) : (b.tag = 0, I && f && vg(b), Yi(null, b, e, c), b = b.child); - return b; - case 16: - d = b.elementType; - a: { - jj(a, b); - a = b.pendingProps; - e = d._init; - d = e(d._payload); - b.type = d; - e = b.tag = $k(d); - a = Lg(d, a); - switch (e) { - case 0: - b = dj(null, b, d, a, c); - break a; - case 1: - b = ij(null, b, d, a, c); - break a; - case 11: - b = Zi(null, b, d, a, c); - break a; - case 14: - b = aj(null, b, d, Lg(d.type, a), c); - break a; - } - throw Error(p(306, d, "")); - } - return b; - case 0: - return d = b.type, e = b.pendingProps, e = b.elementType === d ? e : Lg(d, e), dj(a, b, d, e, c); - case 1: - return d = b.type, e = b.pendingProps, e = b.elementType === d ? e : Lg(d, e), ij(a, b, d, e, c); - case 3: - a: { - lj(b); - if (a === null) - throw Error(p(387)); - d = b.pendingProps; - f = b.memoizedState; - e = f.element; - bh(a, b); - gh(b, d, null, c); - var g = b.memoizedState; - d = g.element; - if (f.isDehydrated) - if (f = { element: d, isDehydrated: false, cache: g.cache, pendingSuspenseBoundaries: g.pendingSuspenseBoundaries, transitions: g.transitions }, b.updateQueue.baseState = f, b.memoizedState = f, b.flags & 256) { - e = Ki(Error(p(423)), b); - b = mj(a, b, d, c, e); - break a; - } else if (d !== e) { - e = Ki(Error(p(424)), b); - b = mj(a, b, d, c, e); - break a; - } else - for (yg = Lf(b.stateNode.containerInfo.firstChild), xg = b, I = true, zg = null, c = Ch(b, null, d, c), b.child = c; c; ) - c.flags = c.flags & -3 | 4096, c = c.sibling; - else { - Ig(); - if (d === e) { - b = $i(a, b, c); - break a; - } - Yi(a, b, d, c); - } - b = b.child; - } - return b; - case 5: - return Kh(b), a === null && Eg(b), d = b.type, e = b.pendingProps, f = a !== null ? a.memoizedProps : null, g = e.children, Ef(d, e) ? g = null : f !== null && Ef(d, f) && (b.flags |= 32), hj(a, b), Yi(a, b, g, c), b.child; - case 6: - return a === null && Eg(b), null; - case 13: - return pj(a, b, c); - case 4: - return Ih(b, b.stateNode.containerInfo), d = b.pendingProps, a === null ? b.child = Bh(b, null, d, c) : Yi(a, b, d, c), b.child; - case 11: - return d = b.type, e = b.pendingProps, e = b.elementType === d ? e : Lg(d, e), Zi(a, b, d, e, c); - case 7: - return Yi(a, b, b.pendingProps, c), b.child; - case 8: - return Yi(a, b, b.pendingProps.children, c), b.child; - case 12: - return Yi(a, b, b.pendingProps.children, c), b.child; - case 10: - a: { - d = b.type._context; - e = b.pendingProps; - f = b.memoizedProps; - g = e.value; - G(Mg, d._currentValue); - d._currentValue = g; - if (f !== null) - if (He(f.value, g)) { - if (f.children === e.children && !Wf.current) { - b = $i(a, b, c); - break a; - } - } else - for (f = b.child, f !== null && (f.return = b); f !== null; ) { - var h = f.dependencies; - if (h !== null) { - g = f.child; - for (var k = h.firstContext; k !== null; ) { - if (k.context === d) { - if (f.tag === 1) { - k = ch(-1, c & -c); - k.tag = 2; - var l = f.updateQueue; - if (l !== null) { - l = l.shared; - var m = l.pending; - m === null ? k.next = k : (k.next = m.next, m.next = k); - l.pending = k; - } - } - f.lanes |= c; - k = f.alternate; - k !== null && (k.lanes |= c); - Sg(f.return, c, b); - h.lanes |= c; - break; - } - k = k.next; - } - } else if (f.tag === 10) - g = f.type === b.type ? null : f.child; - else if (f.tag === 18) { - g = f.return; - if (g === null) - throw Error(p(341)); - g.lanes |= c; - h = g.alternate; - h !== null && (h.lanes |= c); - Sg(g, c, b); - g = f.sibling; - } else - g = f.child; - if (g !== null) - g.return = f; - else - for (g = f; g !== null; ) { - if (g === b) { - g = null; - break; - } - f = g.sibling; - if (f !== null) { - f.return = g.return; - g = f; - break; - } - g = g.return; - } - f = g; - } - Yi(a, b, e.children, c); - b = b.child; - } - return b; - case 9: - return e = b.type, d = b.pendingProps.children, Tg(b, c), e = Vg(e), d = d(e), b.flags |= 1, Yi(a, b, d, c), b.child; - case 14: - return d = b.type, e = Lg(d, b.pendingProps), e = Lg(d.type, e), aj(a, b, d, e, c); - case 15: - return cj(a, b, b.type, b.pendingProps, c); - case 17: - return d = b.type, e = b.pendingProps, e = b.elementType === d ? e : Lg(d, e), jj(a, b), b.tag = 1, Zf(d) ? (a = true, cg(b)) : a = false, Tg(b, c), ph(b, d, e), rh(b, d, e, c), kj(null, b, d, true, a, c); - case 19: - return yj(a, b, c); - case 22: - return ej(a, b, c); - } - throw Error(p(156, b.tag)); - }; - function Gk(a, b) { - return ac(a, b); - } - function al(a, b, c, d) { - this.tag = a; - this.key = c; - this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; - this.index = 0; - this.ref = null; - this.pendingProps = b; - this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; - this.mode = d; - this.subtreeFlags = this.flags = 0; - this.deletions = null; - this.childLanes = this.lanes = 0; - this.alternate = null; - } - function Bg(a, b, c, d) { - return new al(a, b, c, d); - } - function bj(a) { - a = a.prototype; - return !(!a || !a.isReactComponent); - } - function $k(a) { - if (typeof a === "function") - return bj(a) ? 1 : 0; - if (a !== void 0 && a !== null) { - a = a.$$typeof; - if (a === Da) - return 11; - if (a === Ga) - return 14; - } - return 2; - } - function wh(a, b) { - var c = a.alternate; - c === null ? (c = Bg(a.tag, b, a.key, a.mode), c.elementType = a.elementType, c.type = a.type, c.stateNode = a.stateNode, c.alternate = a, a.alternate = c) : (c.pendingProps = b, c.type = a.type, c.flags = 0, c.subtreeFlags = 0, c.deletions = null); - c.flags = a.flags & 14680064; - c.childLanes = a.childLanes; - c.lanes = a.lanes; - c.child = a.child; - c.memoizedProps = a.memoizedProps; - c.memoizedState = a.memoizedState; - c.updateQueue = a.updateQueue; - b = a.dependencies; - c.dependencies = b === null ? null : { lanes: b.lanes, firstContext: b.firstContext }; - c.sibling = a.sibling; - c.index = a.index; - c.ref = a.ref; - return c; - } - function yh(a, b, c, d, e, f) { - var g = 2; - d = a; - if (typeof a === "function") - bj(a) && (g = 1); - else if (typeof a === "string") - g = 5; - else - a: - switch (a) { - case ya: - return Ah(c.children, e, f, b); - case za: - g = 8; - e |= 8; - break; - case Aa: - return a = Bg(12, c, b, e | 2), a.elementType = Aa, a.lanes = f, a; - case Ea: - return a = Bg(13, c, b, e), a.elementType = Ea, a.lanes = f, a; - case Fa: - return a = Bg(19, c, b, e), a.elementType = Fa, a.lanes = f, a; - case Ia: - return qj(c, e, f, b); - default: - if (typeof a === "object" && a !== null) - switch (a.$$typeof) { - case Ba: - g = 10; - break a; - case Ca: - g = 9; - break a; - case Da: - g = 11; - break a; - case Ga: - g = 14; - break a; - case Ha: - g = 16; - d = null; - break a; - } - throw Error(p(130, a == null ? a : typeof a, "")); - } - b = Bg(g, c, b, e); - b.elementType = a; - b.type = d; - b.lanes = f; - return b; - } - function Ah(a, b, c, d) { - a = Bg(7, a, d, b); - a.lanes = c; - return a; - } - function qj(a, b, c, d) { - a = Bg(22, a, d, b); - a.elementType = Ia; - a.lanes = c; - a.stateNode = { isHidden: false }; - return a; - } - function xh(a, b, c) { - a = Bg(6, a, null, b); - a.lanes = c; - return a; - } - function zh(a, b, c) { - b = Bg(4, a.children !== null ? a.children : [], a.key, b); - b.lanes = c; - b.stateNode = { containerInfo: a.containerInfo, pendingChildren: null, implementation: a.implementation }; - return b; - } - function bl(a, b, c, d, e) { - this.tag = b; - this.containerInfo = a; - this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; - this.timeoutHandle = -1; - this.callbackNode = this.pendingContext = this.context = null; - this.callbackPriority = 0; - this.eventTimes = zc(0); - this.expirationTimes = zc(-1); - this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = zc(0); - this.identifierPrefix = d; - this.onRecoverableError = e; - this.mutableSourceEagerHydrationData = null; - } - function cl(a, b, c, d, e, f, g, h, k) { - a = new bl(a, b, c, h, k); - b === 1 ? (b = 1, f === true && (b |= 8)) : b = 0; - f = Bg(3, null, null, b); - a.current = f; - f.stateNode = a; - f.memoizedState = { element: d, isDehydrated: c, cache: null, transitions: null, pendingSuspenseBoundaries: null }; - ah(f); - return a; - } - function dl(a, b, c) { - var d = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null; - return { $$typeof: wa, key: d == null ? null : "" + d, children: a, containerInfo: b, implementation: c }; - } - function el(a) { - if (!a) - return Vf; - a = a._reactInternals; - a: { - if (Vb(a) !== a || a.tag !== 1) - throw Error(p(170)); - var b = a; - do { - switch (b.tag) { - case 3: - b = b.stateNode.context; - break a; - case 1: - if (Zf(b.type)) { - b = b.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - } - b = b.return; - } while (b !== null); - throw Error(p(171)); - } - if (a.tag === 1) { - var c = a.type; - if (Zf(c)) - return bg(a, c, b); - } - return b; - } - function fl(a, b, c, d, e, f, g, h, k) { - a = cl(c, d, true, a, e, f, g, h, k); - a.context = el(null); - c = a.current; - d = L(); - e = lh(c); - f = ch(d, e); - f.callback = b !== void 0 && b !== null ? b : null; - dh(c, f, e); - a.current.lanes = e; - Ac(a, e, d); - Ek(a, d); - return a; - } - function gl(a, b, c, d) { - var e = b.current, f = L(), g = lh(e); - c = el(c); - b.context === null ? b.context = c : b.pendingContext = c; - b = ch(f, g); - b.payload = { element: a }; - d = d === void 0 ? null : d; - d !== null && (b.callback = d); - a = dh(e, b, g); - a !== null && (mh(a, e, g, f), eh(a, e, g)); - return g; - } - function hl(a) { - a = a.current; - if (!a.child) - return null; - switch (a.child.tag) { - case 5: - return a.child.stateNode; - default: - return a.child.stateNode; - } - } - function il(a, b) { - a = a.memoizedState; - if (a !== null && a.dehydrated !== null) { - var c = a.retryLane; - a.retryLane = c !== 0 && c < b ? c : b; - } - } - function jl(a, b) { - il(a, b); - (a = a.alternate) && il(a, b); - } - function kl() { - return null; - } - var ll = typeof reportError === "function" ? reportError : function(a) { - console.error(a); - }; - function ml(a) { - this._internalRoot = a; - } - nl.prototype.render = ml.prototype.render = function(a) { - var b = this._internalRoot; - if (b === null) - throw Error(p(409)); - gl(a, b, null, null); - }; - nl.prototype.unmount = ml.prototype.unmount = function() { - var a = this._internalRoot; - if (a !== null) { - this._internalRoot = null; - var b = a.containerInfo; - Sk(function() { - gl(null, a, null, null); - }); - b[uf] = null; - } - }; - function nl(a) { - this._internalRoot = a; - } - nl.prototype.unstable_scheduleHydration = function(a) { - if (a) { - var b = Hc(); - a = { blockedOn: null, target: a, priority: b }; - for (var c = 0; c < Qc.length && b !== 0 && b < Qc[c].priority; c++) - ; - Qc.splice(c, 0, a); - c === 0 && Vc(a); - } - }; - function ol(a) { - return !(!a || a.nodeType !== 1 && a.nodeType !== 9 && a.nodeType !== 11); - } - function pl(a) { - return !(!a || a.nodeType !== 1 && a.nodeType !== 9 && a.nodeType !== 11 && (a.nodeType !== 8 || a.nodeValue !== " react-mount-point-unstable ")); - } - function ql() { - } - function rl(a, b, c, d, e) { - if (e) { - if (typeof d === "function") { - var f = d; - d = function() { - var a2 = hl(g); - f.call(a2); - }; - } - var g = fl(b, d, a, 0, null, false, false, "", ql); - a._reactRootContainer = g; - a[uf] = g.current; - sf(a.nodeType === 8 ? a.parentNode : a); - Sk(); - return g; - } - for (; e = a.lastChild; ) - a.removeChild(e); - if (typeof d === "function") { - var h = d; - d = function() { - var a2 = hl(k); - h.call(a2); - }; - } - var k = cl(a, 0, false, null, null, false, false, "", ql); - a._reactRootContainer = k; - a[uf] = k.current; - sf(a.nodeType === 8 ? a.parentNode : a); - Sk(function() { - gl(b, k, c, d); - }); - return k; - } - function sl(a, b, c, d, e) { - var f = c._reactRootContainer; - if (f) { - var g = f; - if (typeof e === "function") { - var h = e; - e = function() { - var a2 = hl(g); - h.call(a2); - }; - } - gl(b, g, a, e); - } else - g = rl(c, b, a, e, d); - return hl(g); - } - Ec = function(a) { - switch (a.tag) { - case 3: - var b = a.stateNode; - if (b.current.memoizedState.isDehydrated) { - var c = tc(b.pendingLanes); - c !== 0 && (Cc(b, c | 1), Ek(b, B()), (K & 6) === 0 && (Hj = B() + 500, jg())); - } - break; - case 13: - Sk(function() { - var b2 = Zg(a, 1); - if (b2 !== null) { - var c2 = L(); - mh(b2, a, 1, c2); - } - }), jl(a, 1); - } - }; - Fc = function(a) { - if (a.tag === 13) { - var b = Zg(a, 134217728); - if (b !== null) { - var c = L(); - mh(b, a, 134217728, c); - } - jl(a, 134217728); - } - }; - Gc = function(a) { - if (a.tag === 13) { - var b = lh(a), c = Zg(a, b); - if (c !== null) { - var d = L(); - mh(c, a, b, d); - } - jl(a, b); - } - }; - Hc = function() { - return C; - }; - Ic = function(a, b) { - var c = C; - try { - return C = a, b(); - } finally { - C = c; - } - }; - yb = function(a, b, c) { - switch (b) { - case "input": - bb(a, c); - b = c.name; - if (c.type === "radio" && b != null) { - for (c = a; c.parentNode; ) - c = c.parentNode; - c = c.querySelectorAll("input[name=" + JSON.stringify("" + b) + '][type="radio"]'); - for (b = 0; b < c.length; b++) { - var d = c[b]; - if (d !== a && d.form === a.form) { - var e = Db(d); - if (!e) - throw Error(p(90)); - Wa(d); - bb(d, e); - } - } - } - break; - case "textarea": - ib(a, c); - break; - case "select": - b = c.value, b != null && fb(a, !!c.multiple, b, false); - } - }; - Gb = Rk; - Hb = Sk; - var tl = { usingClientEntryPoint: false, Events: [Cb, ue, Db, Eb, Fb, Rk] }; - var ul = { findFiberByHostInstance: Wc, bundleType: 0, version: "18.2.0", rendererPackageName: "react-dom" }; - var vl = { bundleType: ul.bundleType, version: ul.version, rendererPackageName: ul.rendererPackageName, rendererConfig: ul.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, overrideProps: null, overridePropsDeletePath: null, overridePropsRenamePath: null, setErrorHandler: null, setSuspenseHandler: null, scheduleUpdate: null, currentDispatcherRef: ua.ReactCurrentDispatcher, findHostInstanceByFiber: function(a) { - a = Zb(a); - return a === null ? null : a.stateNode; - }, findFiberByHostInstance: ul.findFiberByHostInstance || kl, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, reconcilerVersion: "18.2.0-next-9e3b772b8-20220608" }; - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined") { - wl = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (!wl.isDisabled && wl.supportsFiber) - try { - kc = wl.inject(vl), lc = wl; - } catch (a) { - } - } - var wl; - exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = tl; - exports.createPortal = function(a, b) { - var c = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null; - if (!ol(b)) - throw Error(p(200)); - return dl(a, b, null, c); - }; - exports.createRoot = function(a, b) { - if (!ol(a)) - throw Error(p(299)); - var c = false, d = "", e = ll; - b !== null && b !== void 0 && (b.unstable_strictMode === true && (c = true), b.identifierPrefix !== void 0 && (d = b.identifierPrefix), b.onRecoverableError !== void 0 && (e = b.onRecoverableError)); - b = cl(a, 1, false, null, null, c, false, d, e); - a[uf] = b.current; - sf(a.nodeType === 8 ? a.parentNode : a); - return new ml(b); - }; - exports.findDOMNode = function(a) { - if (a == null) - return null; - if (a.nodeType === 1) - return a; - var b = a._reactInternals; - if (b === void 0) { - if (typeof a.render === "function") - throw Error(p(188)); - a = Object.keys(a).join(","); - throw Error(p(268, a)); - } - a = Zb(b); - a = a === null ? null : a.stateNode; - return a; - }; - exports.flushSync = function(a) { - return Sk(a); - }; - exports.hydrate = function(a, b, c) { - if (!pl(b)) - throw Error(p(200)); - return sl(null, a, b, true, c); - }; - exports.hydrateRoot = function(a, b, c) { - if (!ol(a)) - throw Error(p(405)); - var d = c != null && c.hydratedSources || null, e = false, f = "", g = ll; - c !== null && c !== void 0 && (c.unstable_strictMode === true && (e = true), c.identifierPrefix !== void 0 && (f = c.identifierPrefix), c.onRecoverableError !== void 0 && (g = c.onRecoverableError)); - b = fl(b, null, a, 1, c != null ? c : null, e, false, f, g); - a[uf] = b.current; - sf(a); - if (d) - for (a = 0; a < d.length; a++) - c = d[a], e = c._getVersion, e = e(c._source), b.mutableSourceEagerHydrationData == null ? b.mutableSourceEagerHydrationData = [c, e] : b.mutableSourceEagerHydrationData.push(c, e); - return new nl(b); - }; - exports.render = function(a, b, c) { - if (!pl(b)) - throw Error(p(200)); - return sl(null, a, b, false, c); - }; - exports.unmountComponentAtNode = function(a) { - if (!pl(a)) - throw Error(p(40)); - return a._reactRootContainer ? (Sk(function() { - sl(null, null, a, false, function() { - a._reactRootContainer = null; - a[uf] = null; - }); - }), true) : false; - }; - exports.unstable_batchedUpdates = Rk; - exports.unstable_renderSubtreeIntoContainer = function(a, b, c, d) { - if (!pl(c)) - throw Error(p(200)); - if (a == null || a._reactInternals === void 0) - throw Error(p(38)); - return sl(a, b, c, false, d); - }; - exports.version = "18.2.0-next-9e3b772b8-20220608"; - } -}); - -// node_modules/react-dom/index.js -var require_react_dom = __commonJS({ - "node_modules/react-dom/index.js"(exports, module2) { - "use strict"; - function checkDCE() { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== "function") { - return; - } - if (false) { - throw new Error("^_^"); - } - try { - __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); - } catch (err) { - console.error(err); - } - } - if (true) { - checkDCE(); - module2.exports = require_react_dom_production_min(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/react-dom/client.js -var require_client = __commonJS({ - "node_modules/react-dom/client.js"(exports) { - "use strict"; - var m = require_react_dom(); - if (true) { - exports.createRoot = m.createRoot; - exports.hydrateRoot = m.hydrateRoot; - } else { - i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - exports.createRoot = function(c, o) { - i.usingClientEntryPoint = true; - try { - return m.createRoot(c, o); - } finally { - i.usingClientEntryPoint = false; - } - }; - exports.hydrateRoot = function(c, h, o) { - i.usingClientEntryPoint = true; - try { - return m.hydrateRoot(c, h, o); - } finally { - i.usingClientEntryPoint = false; - } - }; - } - var i; - } -}); - -// manifest.json -var require_manifest = __commonJS({ - "manifest.json"(exports, module2) { - module2.exports = { - id: "ink", - name: "Ink", - author: "Dale de Silva", - description: "Hand write or draw directly between paragraphs in your notes using a digital pen, stylus, or Apple pencil. Useful for handwriting, sketches, scribbles, or even math equations and scientific notation. Runs on the tldraw framework and drawing provides an infinite canvas.", - version: "0.3.4", - minAppVersion: "1.00.0", - authorUrl: "https://designdebt.club", - fundingUrl: "https://ko-fi.com/daledesilva", - isDesktopOnly: false - }; - } -}); - -// node_modules/core-js/internals/global.js -var require_global = __commonJS({ - "node_modules/core-js/internals/global.js"(exports, module2) { - "use strict"; - var check = function(it) { - return it && it.Math === Math && it; - }; - module2.exports = check(typeof globalThis == "object" && globalThis) || check(typeof window == "object" && window) || check(typeof self == "object" && self) || check(typeof global == "object" && global) || check(typeof exports == "object" && exports) || function() { - return this; - }() || Function("return this")(); - } -}); - -// node_modules/core-js/internals/fails.js -var require_fails = __commonJS({ - "node_modules/core-js/internals/fails.js"(exports, module2) { - "use strict"; - module2.exports = function(exec) { - try { - return !!exec(); - } catch (error3) { - return true; - } - }; - } -}); - -// node_modules/core-js/internals/descriptors.js -var require_descriptors = __commonJS({ - "node_modules/core-js/internals/descriptors.js"(exports, module2) { - "use strict"; - var fails = require_fails(); - module2.exports = !fails(function() { - return Object.defineProperty({}, 1, { get: function() { - return 7; - } })[1] !== 7; - }); - } -}); - -// node_modules/core-js/internals/function-bind-native.js -var require_function_bind_native = __commonJS({ - "node_modules/core-js/internals/function-bind-native.js"(exports, module2) { - "use strict"; - var fails = require_fails(); - module2.exports = !fails(function() { - var test2 = function() { - }.bind(); - return typeof test2 != "function" || test2.hasOwnProperty("prototype"); - }); - } -}); - -// node_modules/core-js/internals/function-call.js -var require_function_call = __commonJS({ - "node_modules/core-js/internals/function-call.js"(exports, module2) { - "use strict"; - var NATIVE_BIND = require_function_bind_native(); - var call = Function.prototype.call; - module2.exports = NATIVE_BIND ? call.bind(call) : function() { - return call.apply(call, arguments); - }; - } -}); - -// node_modules/core-js/internals/object-property-is-enumerable.js -var require_object_property_is_enumerable = __commonJS({ - "node_modules/core-js/internals/object-property-is-enumerable.js"(exports) { - "use strict"; - var $propertyIsEnumerable = {}.propertyIsEnumerable; - var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1); - exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) { - var descriptor = getOwnPropertyDescriptor(this, V); - return !!descriptor && descriptor.enumerable; - } : $propertyIsEnumerable; - } -}); - -// node_modules/core-js/internals/create-property-descriptor.js -var require_create_property_descriptor = __commonJS({ - "node_modules/core-js/internals/create-property-descriptor.js"(exports, module2) { - "use strict"; - module2.exports = function(bitmap, value) { - return { - enumerable: !(bitmap & 1), - configurable: !(bitmap & 2), - writable: !(bitmap & 4), - value - }; - }; - } -}); - -// node_modules/core-js/internals/function-uncurry-this.js -var require_function_uncurry_this = __commonJS({ - "node_modules/core-js/internals/function-uncurry-this.js"(exports, module2) { - "use strict"; - var NATIVE_BIND = require_function_bind_native(); - var FunctionPrototype = Function.prototype; - var call = FunctionPrototype.call; - var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call); - module2.exports = NATIVE_BIND ? uncurryThisWithBind : function(fn) { - return function() { - return call.apply(fn, arguments); - }; - }; - } -}); - -// node_modules/core-js/internals/classof-raw.js -var require_classof_raw = __commonJS({ - "node_modules/core-js/internals/classof-raw.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var toString = uncurryThis({}.toString); - var stringSlice = uncurryThis("".slice); - module2.exports = function(it) { - return stringSlice(toString(it), 8, -1); - }; - } -}); - -// node_modules/core-js/internals/indexed-object.js -var require_indexed_object = __commonJS({ - "node_modules/core-js/internals/indexed-object.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var fails = require_fails(); - var classof = require_classof_raw(); - var $Object = Object; - var split = uncurryThis("".split); - module2.exports = fails(function() { - return !$Object("z").propertyIsEnumerable(0); - }) ? function(it) { - return classof(it) === "String" ? split(it, "") : $Object(it); - } : $Object; - } -}); - -// node_modules/core-js/internals/is-null-or-undefined.js -var require_is_null_or_undefined = __commonJS({ - "node_modules/core-js/internals/is-null-or-undefined.js"(exports, module2) { - "use strict"; - module2.exports = function(it) { - return it === null || it === void 0; - }; - } -}); - -// node_modules/core-js/internals/require-object-coercible.js -var require_require_object_coercible = __commonJS({ - "node_modules/core-js/internals/require-object-coercible.js"(exports, module2) { - "use strict"; - var isNullOrUndefined = require_is_null_or_undefined(); - var $TypeError = TypeError; - module2.exports = function(it) { - if (isNullOrUndefined(it)) - throw new $TypeError("Can't call method on " + it); - return it; - }; - } -}); - -// node_modules/core-js/internals/to-indexed-object.js -var require_to_indexed_object = __commonJS({ - "node_modules/core-js/internals/to-indexed-object.js"(exports, module2) { - "use strict"; - var IndexedObject = require_indexed_object(); - var requireObjectCoercible = require_require_object_coercible(); - module2.exports = function(it) { - return IndexedObject(requireObjectCoercible(it)); - }; - } -}); - -// node_modules/core-js/internals/is-callable.js -var require_is_callable = __commonJS({ - "node_modules/core-js/internals/is-callable.js"(exports, module2) { - "use strict"; - var documentAll = typeof document == "object" && document.all; - module2.exports = typeof documentAll == "undefined" && documentAll !== void 0 ? function(argument) { - return typeof argument == "function" || argument === documentAll; - } : function(argument) { - return typeof argument == "function"; - }; - } -}); - -// node_modules/core-js/internals/is-object.js -var require_is_object = __commonJS({ - "node_modules/core-js/internals/is-object.js"(exports, module2) { - "use strict"; - var isCallable = require_is_callable(); - module2.exports = function(it) { - return typeof it == "object" ? it !== null : isCallable(it); - }; - } -}); - -// node_modules/core-js/internals/get-built-in.js -var require_get_built_in = __commonJS({ - "node_modules/core-js/internals/get-built-in.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var isCallable = require_is_callable(); - var aFunction = function(argument) { - return isCallable(argument) ? argument : void 0; - }; - module2.exports = function(namespace, method) { - return arguments.length < 2 ? aFunction(global2[namespace]) : global2[namespace] && global2[namespace][method]; - }; - } -}); - -// node_modules/core-js/internals/object-is-prototype-of.js -var require_object_is_prototype_of = __commonJS({ - "node_modules/core-js/internals/object-is-prototype-of.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - module2.exports = uncurryThis({}.isPrototypeOf); - } -}); - -// node_modules/core-js/internals/engine-user-agent.js -var require_engine_user_agent = __commonJS({ - "node_modules/core-js/internals/engine-user-agent.js"(exports, module2) { - "use strict"; - module2.exports = typeof navigator != "undefined" && String(navigator.userAgent) || ""; - } -}); - -// node_modules/core-js/internals/engine-v8-version.js -var require_engine_v8_version = __commonJS({ - "node_modules/core-js/internals/engine-v8-version.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var userAgent = require_engine_user_agent(); - var process2 = global2.process; - var Deno = global2.Deno; - var versions = process2 && process2.versions || Deno && Deno.version; - var v8 = versions && versions.v8; - var match; - var version2; - if (v8) { - match = v8.split("."); - version2 = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); - } - if (!version2 && userAgent) { - match = userAgent.match(/Edge\/(\d+)/); - if (!match || match[1] >= 74) { - match = userAgent.match(/Chrome\/(\d+)/); - if (match) - version2 = +match[1]; - } - } - module2.exports = version2; - } -}); - -// node_modules/core-js/internals/symbol-constructor-detection.js -var require_symbol_constructor_detection = __commonJS({ - "node_modules/core-js/internals/symbol-constructor-detection.js"(exports, module2) { - "use strict"; - var V8_VERSION = require_engine_v8_version(); - var fails = require_fails(); - var global2 = require_global(); - var $String = global2.String; - module2.exports = !!Object.getOwnPropertySymbols && !fails(function() { - var symbol = Symbol("symbol detection"); - return !$String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41; - }); - } -}); - -// node_modules/core-js/internals/use-symbol-as-uid.js -var require_use_symbol_as_uid = __commonJS({ - "node_modules/core-js/internals/use-symbol-as-uid.js"(exports, module2) { - "use strict"; - var NATIVE_SYMBOL = require_symbol_constructor_detection(); - module2.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == "symbol"; - } -}); - -// node_modules/core-js/internals/is-symbol.js -var require_is_symbol = __commonJS({ - "node_modules/core-js/internals/is-symbol.js"(exports, module2) { - "use strict"; - var getBuiltIn = require_get_built_in(); - var isCallable = require_is_callable(); - var isPrototypeOf = require_object_is_prototype_of(); - var USE_SYMBOL_AS_UID = require_use_symbol_as_uid(); - var $Object = Object; - module2.exports = USE_SYMBOL_AS_UID ? function(it) { - return typeof it == "symbol"; - } : function(it) { - var $Symbol = getBuiltIn("Symbol"); - return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it)); - }; - } -}); - -// node_modules/core-js/internals/try-to-string.js -var require_try_to_string = __commonJS({ - "node_modules/core-js/internals/try-to-string.js"(exports, module2) { - "use strict"; - var $String = String; - module2.exports = function(argument) { - try { - return $String(argument); - } catch (error3) { - return "Object"; - } - }; - } -}); - -// node_modules/core-js/internals/a-callable.js -var require_a_callable = __commonJS({ - "node_modules/core-js/internals/a-callable.js"(exports, module2) { - "use strict"; - var isCallable = require_is_callable(); - var tryToString = require_try_to_string(); - var $TypeError = TypeError; - module2.exports = function(argument) { - if (isCallable(argument)) - return argument; - throw new $TypeError(tryToString(argument) + " is not a function"); - }; - } -}); - -// node_modules/core-js/internals/get-method.js -var require_get_method = __commonJS({ - "node_modules/core-js/internals/get-method.js"(exports, module2) { - "use strict"; - var aCallable = require_a_callable(); - var isNullOrUndefined = require_is_null_or_undefined(); - module2.exports = function(V, P) { - var func = V[P]; - return isNullOrUndefined(func) ? void 0 : aCallable(func); - }; - } -}); - -// node_modules/core-js/internals/ordinary-to-primitive.js -var require_ordinary_to_primitive = __commonJS({ - "node_modules/core-js/internals/ordinary-to-primitive.js"(exports, module2) { - "use strict"; - var call = require_function_call(); - var isCallable = require_is_callable(); - var isObject = require_is_object(); - var $TypeError = TypeError; - module2.exports = function(input, pref) { - var fn, val; - if (pref === "string" && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) - return val; - if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) - return val; - if (pref !== "string" && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) - return val; - throw new $TypeError("Can't convert object to primitive value"); - }; - } -}); - -// node_modules/core-js/internals/is-pure.js -var require_is_pure = __commonJS({ - "node_modules/core-js/internals/is-pure.js"(exports, module2) { - "use strict"; - module2.exports = false; - } -}); - -// node_modules/core-js/internals/define-global-property.js -var require_define_global_property = __commonJS({ - "node_modules/core-js/internals/define-global-property.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var defineProperty = Object.defineProperty; - module2.exports = function(key, value) { - try { - defineProperty(global2, key, { value, configurable: true, writable: true }); - } catch (error3) { - global2[key] = value; - } - return value; - }; - } -}); - -// node_modules/core-js/internals/shared-store.js -var require_shared_store = __commonJS({ - "node_modules/core-js/internals/shared-store.js"(exports, module2) { - "use strict"; - var IS_PURE = require_is_pure(); - var globalThis2 = require_global(); - var defineGlobalProperty = require_define_global_property(); - var SHARED = "__core-js_shared__"; - var store = module2.exports = globalThis2[SHARED] || defineGlobalProperty(SHARED, {}); - (store.versions || (store.versions = [])).push({ - version: "3.37.1", - mode: IS_PURE ? "pure" : "global", - copyright: "\xA9 2014-2024 Denis Pushkarev (zloirock.ru)", - license: "https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE", - source: "https://github.com/zloirock/core-js" - }); - } -}); - -// node_modules/core-js/internals/shared.js -var require_shared = __commonJS({ - "node_modules/core-js/internals/shared.js"(exports, module2) { - "use strict"; - var store = require_shared_store(); - module2.exports = function(key, value) { - return store[key] || (store[key] = value || {}); - }; - } -}); - -// node_modules/core-js/internals/to-object.js -var require_to_object = __commonJS({ - "node_modules/core-js/internals/to-object.js"(exports, module2) { - "use strict"; - var requireObjectCoercible = require_require_object_coercible(); - var $Object = Object; - module2.exports = function(argument) { - return $Object(requireObjectCoercible(argument)); - }; - } -}); - -// node_modules/core-js/internals/has-own-property.js -var require_has_own_property = __commonJS({ - "node_modules/core-js/internals/has-own-property.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var toObject = require_to_object(); - var hasOwnProperty2 = uncurryThis({}.hasOwnProperty); - module2.exports = Object.hasOwn || function hasOwn(it, key) { - return hasOwnProperty2(toObject(it), key); - }; - } -}); - -// node_modules/core-js/internals/uid.js -var require_uid = __commonJS({ - "node_modules/core-js/internals/uid.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var id = 0; - var postfix = Math.random(); - var toString = uncurryThis(1 .toString); - module2.exports = function(key) { - return "Symbol(" + (key === void 0 ? "" : key) + ")_" + toString(++id + postfix, 36); - }; - } -}); - -// node_modules/core-js/internals/well-known-symbol.js -var require_well_known_symbol = __commonJS({ - "node_modules/core-js/internals/well-known-symbol.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var shared = require_shared(); - var hasOwn = require_has_own_property(); - var uid = require_uid(); - var NATIVE_SYMBOL = require_symbol_constructor_detection(); - var USE_SYMBOL_AS_UID = require_use_symbol_as_uid(); - var Symbol2 = global2.Symbol; - var WellKnownSymbolsStore = shared("wks"); - var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol2["for"] || Symbol2 : Symbol2 && Symbol2.withoutSetter || uid; - module2.exports = function(name) { - if (!hasOwn(WellKnownSymbolsStore, name)) { - WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol2, name) ? Symbol2[name] : createWellKnownSymbol("Symbol." + name); - } - return WellKnownSymbolsStore[name]; - }; - } -}); - -// node_modules/core-js/internals/to-primitive.js -var require_to_primitive = __commonJS({ - "node_modules/core-js/internals/to-primitive.js"(exports, module2) { - "use strict"; - var call = require_function_call(); - var isObject = require_is_object(); - var isSymbol = require_is_symbol(); - var getMethod2 = require_get_method(); - var ordinaryToPrimitive = require_ordinary_to_primitive(); - var wellKnownSymbol = require_well_known_symbol(); - var $TypeError = TypeError; - var TO_PRIMITIVE = wellKnownSymbol("toPrimitive"); - module2.exports = function(input, pref) { - if (!isObject(input) || isSymbol(input)) - return input; - var exoticToPrim = getMethod2(input, TO_PRIMITIVE); - var result; - if (exoticToPrim) { - if (pref === void 0) - pref = "default"; - result = call(exoticToPrim, input, pref); - if (!isObject(result) || isSymbol(result)) - return result; - throw new $TypeError("Can't convert object to primitive value"); - } - if (pref === void 0) - pref = "number"; - return ordinaryToPrimitive(input, pref); - }; - } -}); - -// node_modules/core-js/internals/to-property-key.js -var require_to_property_key = __commonJS({ - "node_modules/core-js/internals/to-property-key.js"(exports, module2) { - "use strict"; - var toPrimitive = require_to_primitive(); - var isSymbol = require_is_symbol(); - module2.exports = function(argument) { - var key = toPrimitive(argument, "string"); - return isSymbol(key) ? key : key + ""; - }; - } -}); - -// node_modules/core-js/internals/document-create-element.js -var require_document_create_element = __commonJS({ - "node_modules/core-js/internals/document-create-element.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var isObject = require_is_object(); - var document2 = global2.document; - var EXISTS = isObject(document2) && isObject(document2.createElement); - module2.exports = function(it) { - return EXISTS ? document2.createElement(it) : {}; - }; - } -}); - -// node_modules/core-js/internals/ie8-dom-define.js -var require_ie8_dom_define = __commonJS({ - "node_modules/core-js/internals/ie8-dom-define.js"(exports, module2) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var fails = require_fails(); - var createElement38 = require_document_create_element(); - module2.exports = !DESCRIPTORS && !fails(function() { - return Object.defineProperty(createElement38("div"), "a", { - get: function() { - return 7; - } - }).a !== 7; - }); - } -}); - -// node_modules/core-js/internals/object-get-own-property-descriptor.js -var require_object_get_own_property_descriptor = __commonJS({ - "node_modules/core-js/internals/object-get-own-property-descriptor.js"(exports) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var call = require_function_call(); - var propertyIsEnumerableModule = require_object_property_is_enumerable(); - var createPropertyDescriptor = require_create_property_descriptor(); - var toIndexedObject = require_to_indexed_object(); - var toPropertyKey = require_to_property_key(); - var hasOwn = require_has_own_property(); - var IE8_DOM_DEFINE = require_ie8_dom_define(); - var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { - O = toIndexedObject(O); - P = toPropertyKey(P); - if (IE8_DOM_DEFINE) - try { - return $getOwnPropertyDescriptor(O, P); - } catch (error3) { - } - if (hasOwn(O, P)) - return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]); - }; - } -}); - -// node_modules/core-js/internals/v8-prototype-define-bug.js -var require_v8_prototype_define_bug = __commonJS({ - "node_modules/core-js/internals/v8-prototype-define-bug.js"(exports, module2) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var fails = require_fails(); - module2.exports = DESCRIPTORS && fails(function() { - return Object.defineProperty(function() { - }, "prototype", { - value: 42, - writable: false - }).prototype !== 42; - }); - } -}); - -// node_modules/core-js/internals/an-object.js -var require_an_object = __commonJS({ - "node_modules/core-js/internals/an-object.js"(exports, module2) { - "use strict"; - var isObject = require_is_object(); - var $String = String; - var $TypeError = TypeError; - module2.exports = function(argument) { - if (isObject(argument)) - return argument; - throw new $TypeError($String(argument) + " is not an object"); - }; - } -}); - -// node_modules/core-js/internals/object-define-property.js -var require_object_define_property = __commonJS({ - "node_modules/core-js/internals/object-define-property.js"(exports) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var IE8_DOM_DEFINE = require_ie8_dom_define(); - var V8_PROTOTYPE_DEFINE_BUG = require_v8_prototype_define_bug(); - var anObject = require_an_object(); - var toPropertyKey = require_to_property_key(); - var $TypeError = TypeError; - var $defineProperty = Object.defineProperty; - var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ENUMERABLE = "enumerable"; - var CONFIGURABLE = "configurable"; - var WRITABLE = "writable"; - exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) { - anObject(O); - P = toPropertyKey(P); - anObject(Attributes); - if (typeof O === "function" && P === "prototype" && "value" in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { - var current = $getOwnPropertyDescriptor(O, P); - if (current && current[WRITABLE]) { - O[P] = Attributes.value; - Attributes = { - configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], - enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], - writable: false - }; - } - } - return $defineProperty(O, P, Attributes); - } : $defineProperty : function defineProperty(O, P, Attributes) { - anObject(O); - P = toPropertyKey(P); - anObject(Attributes); - if (IE8_DOM_DEFINE) - try { - return $defineProperty(O, P, Attributes); - } catch (error3) { - } - if ("get" in Attributes || "set" in Attributes) - throw new $TypeError("Accessors not supported"); - if ("value" in Attributes) - O[P] = Attributes.value; - return O; - }; - } -}); - -// node_modules/core-js/internals/create-non-enumerable-property.js -var require_create_non_enumerable_property = __commonJS({ - "node_modules/core-js/internals/create-non-enumerable-property.js"(exports, module2) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var definePropertyModule = require_object_define_property(); - var createPropertyDescriptor = require_create_property_descriptor(); - module2.exports = DESCRIPTORS ? function(object2, key, value) { - return definePropertyModule.f(object2, key, createPropertyDescriptor(1, value)); - } : function(object2, key, value) { - object2[key] = value; - return object2; - }; - } -}); - -// node_modules/core-js/internals/function-name.js -var require_function_name = __commonJS({ - "node_modules/core-js/internals/function-name.js"(exports, module2) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var hasOwn = require_has_own_property(); - var FunctionPrototype = Function.prototype; - var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor; - var EXISTS = hasOwn(FunctionPrototype, "name"); - var PROPER = EXISTS && function something() { - }.name === "something"; - var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, "name").configurable); - module2.exports = { - EXISTS, - PROPER, - CONFIGURABLE - }; - } -}); - -// node_modules/core-js/internals/inspect-source.js -var require_inspect_source = __commonJS({ - "node_modules/core-js/internals/inspect-source.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var isCallable = require_is_callable(); - var store = require_shared_store(); - var functionToString = uncurryThis(Function.toString); - if (!isCallable(store.inspectSource)) { - store.inspectSource = function(it) { - return functionToString(it); - }; - } - module2.exports = store.inspectSource; - } -}); - -// node_modules/core-js/internals/weak-map-basic-detection.js -var require_weak_map_basic_detection = __commonJS({ - "node_modules/core-js/internals/weak-map-basic-detection.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var isCallable = require_is_callable(); - var WeakMap2 = global2.WeakMap; - module2.exports = isCallable(WeakMap2) && /native code/.test(String(WeakMap2)); - } -}); - -// node_modules/core-js/internals/shared-key.js -var require_shared_key = __commonJS({ - "node_modules/core-js/internals/shared-key.js"(exports, module2) { - "use strict"; - var shared = require_shared(); - var uid = require_uid(); - var keys = shared("keys"); - module2.exports = function(key) { - return keys[key] || (keys[key] = uid(key)); - }; - } -}); - -// node_modules/core-js/internals/hidden-keys.js -var require_hidden_keys = __commonJS({ - "node_modules/core-js/internals/hidden-keys.js"(exports, module2) { - "use strict"; - module2.exports = {}; - } -}); - -// node_modules/core-js/internals/internal-state.js -var require_internal_state = __commonJS({ - "node_modules/core-js/internals/internal-state.js"(exports, module2) { - "use strict"; - var NATIVE_WEAK_MAP = require_weak_map_basic_detection(); - var global2 = require_global(); - var isObject = require_is_object(); - var createNonEnumerableProperty = require_create_non_enumerable_property(); - var hasOwn = require_has_own_property(); - var shared = require_shared_store(); - var sharedKey = require_shared_key(); - var hiddenKeys = require_hidden_keys(); - var OBJECT_ALREADY_INITIALIZED = "Object already initialized"; - var TypeError2 = global2.TypeError; - var WeakMap2 = global2.WeakMap; - var set; - var get; - var has; - var enforce = function(it) { - return has(it) ? get(it) : set(it, {}); - }; - var getterFor = function(TYPE) { - return function(it) { - var state; - if (!isObject(it) || (state = get(it)).type !== TYPE) { - throw new TypeError2("Incompatible receiver, " + TYPE + " required"); - } - return state; - }; - }; - if (NATIVE_WEAK_MAP || shared.state) { - store = shared.state || (shared.state = new WeakMap2()); - store.get = store.get; - store.has = store.has; - store.set = store.set; - set = function(it, metadata) { - if (store.has(it)) - throw new TypeError2(OBJECT_ALREADY_INITIALIZED); - metadata.facade = it; - store.set(it, metadata); - return metadata; - }; - get = function(it) { - return store.get(it) || {}; - }; - has = function(it) { - return store.has(it); - }; - } else { - STATE = sharedKey("state"); - hiddenKeys[STATE] = true; - set = function(it, metadata) { - if (hasOwn(it, STATE)) - throw new TypeError2(OBJECT_ALREADY_INITIALIZED); - metadata.facade = it; - createNonEnumerableProperty(it, STATE, metadata); - return metadata; - }; - get = function(it) { - return hasOwn(it, STATE) ? it[STATE] : {}; - }; - has = function(it) { - return hasOwn(it, STATE); - }; - } - var store; - var STATE; - module2.exports = { - set, - get, - has, - enforce, - getterFor - }; - } -}); - -// node_modules/core-js/internals/make-built-in.js -var require_make_built_in = __commonJS({ - "node_modules/core-js/internals/make-built-in.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var fails = require_fails(); - var isCallable = require_is_callable(); - var hasOwn = require_has_own_property(); - var DESCRIPTORS = require_descriptors(); - var CONFIGURABLE_FUNCTION_NAME = require_function_name().CONFIGURABLE; - var inspectSource = require_inspect_source(); - var InternalStateModule = require_internal_state(); - var enforceInternalState = InternalStateModule.enforce; - var getInternalState = InternalStateModule.get; - var $String = String; - var defineProperty = Object.defineProperty; - var stringSlice = uncurryThis("".slice); - var replace = uncurryThis("".replace); - var join = uncurryThis([].join); - var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function() { - return defineProperty(function() { - }, "length", { value: 8 }).length !== 8; - }); - var TEMPLATE = String(String).split("String"); - var makeBuiltIn = module2.exports = function(value, name, options) { - if (stringSlice($String(name), 0, 7) === "Symbol(") { - name = "[" + replace($String(name), /^Symbol\(([^)]*)\).*$/, "$1") + "]"; - } - if (options && options.getter) - name = "get " + name; - if (options && options.setter) - name = "set " + name; - if (!hasOwn(value, "name") || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { - if (DESCRIPTORS) - defineProperty(value, "name", { value: name, configurable: true }); - else - value.name = name; - } - if (CONFIGURABLE_LENGTH && options && hasOwn(options, "arity") && value.length !== options.arity) { - defineProperty(value, "length", { value: options.arity }); - } - try { - if (options && hasOwn(options, "constructor") && options.constructor) { - if (DESCRIPTORS) - defineProperty(value, "prototype", { writable: false }); - } else if (value.prototype) - value.prototype = void 0; - } catch (error3) { - } - var state = enforceInternalState(value); - if (!hasOwn(state, "source")) { - state.source = join(TEMPLATE, typeof name == "string" ? name : ""); - } - return value; - }; - Function.prototype.toString = makeBuiltIn(function toString() { - return isCallable(this) && getInternalState(this).source || inspectSource(this); - }, "toString"); - } -}); - -// node_modules/core-js/internals/define-built-in.js -var require_define_built_in = __commonJS({ - "node_modules/core-js/internals/define-built-in.js"(exports, module2) { - "use strict"; - var isCallable = require_is_callable(); - var definePropertyModule = require_object_define_property(); - var makeBuiltIn = require_make_built_in(); - var defineGlobalProperty = require_define_global_property(); - module2.exports = function(O, key, value, options) { - if (!options) - options = {}; - var simple = options.enumerable; - var name = options.name !== void 0 ? options.name : key; - if (isCallable(value)) - makeBuiltIn(value, name, options); - if (options.global) { - if (simple) - O[key] = value; - else - defineGlobalProperty(key, value); - } else { - try { - if (!options.unsafe) - delete O[key]; - else if (O[key]) - simple = true; - } catch (error3) { - } - if (simple) - O[key] = value; - else - definePropertyModule.f(O, key, { - value, - enumerable: false, - configurable: !options.nonConfigurable, - writable: !options.nonWritable - }); - } - return O; - }; - } -}); - -// node_modules/core-js/internals/math-trunc.js -var require_math_trunc = __commonJS({ - "node_modules/core-js/internals/math-trunc.js"(exports, module2) { - "use strict"; - var ceil = Math.ceil; - var floor2 = Math.floor; - module2.exports = Math.trunc || function trunc(x) { - var n = +x; - return (n > 0 ? floor2 : ceil)(n); - }; - } -}); - -// node_modules/core-js/internals/to-integer-or-infinity.js -var require_to_integer_or_infinity = __commonJS({ - "node_modules/core-js/internals/to-integer-or-infinity.js"(exports, module2) { - "use strict"; - var trunc = require_math_trunc(); - module2.exports = function(argument) { - var number2 = +argument; - return number2 !== number2 || number2 === 0 ? 0 : trunc(number2); - }; - } -}); - -// node_modules/core-js/internals/to-absolute-index.js -var require_to_absolute_index = __commonJS({ - "node_modules/core-js/internals/to-absolute-index.js"(exports, module2) { - "use strict"; - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var max2 = Math.max; - var min3 = Math.min; - module2.exports = function(index2, length) { - var integer2 = toIntegerOrInfinity(index2); - return integer2 < 0 ? max2(integer2 + length, 0) : min3(integer2, length); - }; - } -}); - -// node_modules/core-js/internals/to-length.js -var require_to_length = __commonJS({ - "node_modules/core-js/internals/to-length.js"(exports, module2) { - "use strict"; - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var min3 = Math.min; - module2.exports = function(argument) { - var len = toIntegerOrInfinity(argument); - return len > 0 ? min3(len, 9007199254740991) : 0; - }; - } -}); - -// node_modules/core-js/internals/length-of-array-like.js -var require_length_of_array_like = __commonJS({ - "node_modules/core-js/internals/length-of-array-like.js"(exports, module2) { - "use strict"; - var toLength = require_to_length(); - module2.exports = function(obj) { - return toLength(obj.length); - }; - } -}); - -// node_modules/core-js/internals/array-includes.js -var require_array_includes = __commonJS({ - "node_modules/core-js/internals/array-includes.js"(exports, module2) { - "use strict"; - var toIndexedObject = require_to_indexed_object(); - var toAbsoluteIndex = require_to_absolute_index(); - var lengthOfArrayLike = require_length_of_array_like(); - var createMethod = function(IS_INCLUDES) { - return function($this, el, fromIndex) { - var O = toIndexedObject($this); - var length = lengthOfArrayLike(O); - if (length === 0) - return !IS_INCLUDES && -1; - var index2 = toAbsoluteIndex(fromIndex, length); - var value; - if (IS_INCLUDES && el !== el) - while (length > index2) { - value = O[index2++]; - if (value !== value) - return true; - } - else - for (; length > index2; index2++) { - if ((IS_INCLUDES || index2 in O) && O[index2] === el) - return IS_INCLUDES || index2 || 0; - } - return !IS_INCLUDES && -1; - }; - }; - module2.exports = { - includes: createMethod(true), - indexOf: createMethod(false) - }; - } -}); - -// node_modules/core-js/internals/object-keys-internal.js -var require_object_keys_internal = __commonJS({ - "node_modules/core-js/internals/object-keys-internal.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var hasOwn = require_has_own_property(); - var toIndexedObject = require_to_indexed_object(); - var indexOf = require_array_includes().indexOf; - var hiddenKeys = require_hidden_keys(); - var push = uncurryThis([].push); - module2.exports = function(object2, names) { - var O = toIndexedObject(object2); - var i = 0; - var result = []; - var key; - for (key in O) - !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key); - while (names.length > i) - if (hasOwn(O, key = names[i++])) { - ~indexOf(result, key) || push(result, key); - } - return result; - }; - } -}); - -// node_modules/core-js/internals/enum-bug-keys.js -var require_enum_bug_keys = __commonJS({ - "node_modules/core-js/internals/enum-bug-keys.js"(exports, module2) { - "use strict"; - module2.exports = [ - "constructor", - "hasOwnProperty", - "isPrototypeOf", - "propertyIsEnumerable", - "toLocaleString", - "toString", - "valueOf" - ]; - } -}); - -// node_modules/core-js/internals/object-get-own-property-names.js -var require_object_get_own_property_names = __commonJS({ - "node_modules/core-js/internals/object-get-own-property-names.js"(exports) { - "use strict"; - var internalObjectKeys = require_object_keys_internal(); - var enumBugKeys = require_enum_bug_keys(); - var hiddenKeys = enumBugKeys.concat("length", "prototype"); - exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { - return internalObjectKeys(O, hiddenKeys); - }; - } -}); - -// node_modules/core-js/internals/object-get-own-property-symbols.js -var require_object_get_own_property_symbols = __commonJS({ - "node_modules/core-js/internals/object-get-own-property-symbols.js"(exports) { - "use strict"; - exports.f = Object.getOwnPropertySymbols; - } -}); - -// node_modules/core-js/internals/own-keys.js -var require_own_keys = __commonJS({ - "node_modules/core-js/internals/own-keys.js"(exports, module2) { - "use strict"; - var getBuiltIn = require_get_built_in(); - var uncurryThis = require_function_uncurry_this(); - var getOwnPropertyNamesModule = require_object_get_own_property_names(); - var getOwnPropertySymbolsModule = require_object_get_own_property_symbols(); - var anObject = require_an_object(); - var concat = uncurryThis([].concat); - module2.exports = getBuiltIn("Reflect", "ownKeys") || function ownKeys2(it) { - var keys = getOwnPropertyNamesModule.f(anObject(it)); - var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; - return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; - }; - } -}); - -// node_modules/core-js/internals/copy-constructor-properties.js -var require_copy_constructor_properties = __commonJS({ - "node_modules/core-js/internals/copy-constructor-properties.js"(exports, module2) { - "use strict"; - var hasOwn = require_has_own_property(); - var ownKeys2 = require_own_keys(); - var getOwnPropertyDescriptorModule = require_object_get_own_property_descriptor(); - var definePropertyModule = require_object_define_property(); - module2.exports = function(target, source, exceptions) { - var keys = ownKeys2(source); - var defineProperty = definePropertyModule.f; - var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) { - defineProperty(target, key, getOwnPropertyDescriptor(source, key)); - } - } - }; - } -}); - -// node_modules/core-js/internals/is-forced.js -var require_is_forced = __commonJS({ - "node_modules/core-js/internals/is-forced.js"(exports, module2) { - "use strict"; - var fails = require_fails(); - var isCallable = require_is_callable(); - var replacement = /#|\.prototype\./; - var isForced = function(feature, detection) { - var value = data[normalize(feature)]; - return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; - }; - var normalize = isForced.normalize = function(string2) { - return String(string2).replace(replacement, ".").toLowerCase(); - }; - var data = isForced.data = {}; - var NATIVE = isForced.NATIVE = "N"; - var POLYFILL = isForced.POLYFILL = "P"; - module2.exports = isForced; - } -}); - -// node_modules/core-js/internals/export.js -var require_export = __commonJS({ - "node_modules/core-js/internals/export.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var getOwnPropertyDescriptor = require_object_get_own_property_descriptor().f; - var createNonEnumerableProperty = require_create_non_enumerable_property(); - var defineBuiltIn = require_define_built_in(); - var defineGlobalProperty = require_define_global_property(); - var copyConstructorProperties = require_copy_constructor_properties(); - var isForced = require_is_forced(); - module2.exports = function(options, source) { - var TARGET = options.target; - var GLOBAL = options.global; - var STATIC = options.stat; - var FORCED, target, key, targetProperty, sourceProperty, descriptor; - if (GLOBAL) { - target = global2; - } else if (STATIC) { - target = global2[TARGET] || defineGlobalProperty(TARGET, {}); - } else { - target = global2[TARGET] && global2[TARGET].prototype; - } - if (target) - for (key in source) { - sourceProperty = source[key]; - if (options.dontCallGetSet) { - descriptor = getOwnPropertyDescriptor(target, key); - targetProperty = descriptor && descriptor.value; - } else - targetProperty = target[key]; - FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? "." : "#") + key, options.forced); - if (!FORCED && targetProperty !== void 0) { - if (typeof sourceProperty == typeof targetProperty) - continue; - copyConstructorProperties(sourceProperty, targetProperty); - } - if (options.sham || targetProperty && targetProperty.sham) { - createNonEnumerableProperty(sourceProperty, "sham", true); - } - defineBuiltIn(target, key, sourceProperty, options); - } - }; - } -}); - -// node_modules/core-js/internals/object-keys.js -var require_object_keys = __commonJS({ - "node_modules/core-js/internals/object-keys.js"(exports, module2) { - "use strict"; - var internalObjectKeys = require_object_keys_internal(); - var enumBugKeys = require_enum_bug_keys(); - module2.exports = Object.keys || function keys(O) { - return internalObjectKeys(O, enumBugKeys); - }; - } -}); - -// node_modules/core-js/internals/object-define-properties.js -var require_object_define_properties = __commonJS({ - "node_modules/core-js/internals/object-define-properties.js"(exports) { - "use strict"; - var DESCRIPTORS = require_descriptors(); - var V8_PROTOTYPE_DEFINE_BUG = require_v8_prototype_define_bug(); - var definePropertyModule = require_object_define_property(); - var anObject = require_an_object(); - var toIndexedObject = require_to_indexed_object(); - var objectKeys = require_object_keys(); - exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { - anObject(O); - var props = toIndexedObject(Properties); - var keys = objectKeys(Properties); - var length = keys.length; - var index2 = 0; - var key; - while (length > index2) - definePropertyModule.f(O, key = keys[index2++], props[key]); - return O; - }; - } -}); - -// node_modules/core-js/internals/html.js -var require_html = __commonJS({ - "node_modules/core-js/internals/html.js"(exports, module2) { - "use strict"; - var getBuiltIn = require_get_built_in(); - module2.exports = getBuiltIn("document", "documentElement"); - } -}); - -// node_modules/core-js/internals/object-create.js -var require_object_create = __commonJS({ - "node_modules/core-js/internals/object-create.js"(exports, module2) { - "use strict"; - var anObject = require_an_object(); - var definePropertiesModule = require_object_define_properties(); - var enumBugKeys = require_enum_bug_keys(); - var hiddenKeys = require_hidden_keys(); - var html = require_html(); - var documentCreateElement = require_document_create_element(); - var sharedKey = require_shared_key(); - var GT = ">"; - var LT = "<"; - var PROTOTYPE = "prototype"; - var SCRIPT = "script"; - var IE_PROTO = sharedKey("IE_PROTO"); - var EmptyConstructor = function() { - }; - var scriptTag = function(content) { - return LT + SCRIPT + GT + content + LT + "/" + SCRIPT + GT; - }; - var NullProtoObjectViaActiveX = function(activeXDocument2) { - activeXDocument2.write(scriptTag("")); - activeXDocument2.close(); - var temp = activeXDocument2.parentWindow.Object; - activeXDocument2 = null; - return temp; - }; - var NullProtoObjectViaIFrame = function() { - var iframe = documentCreateElement("iframe"); - var JS = "java" + SCRIPT + ":"; - var iframeDocument; - iframe.style.display = "none"; - html.appendChild(iframe); - iframe.src = String(JS); - iframeDocument = iframe.contentWindow.document; - iframeDocument.open(); - iframeDocument.write(scriptTag("document.F=Object")); - iframeDocument.close(); - return iframeDocument.F; - }; - var activeXDocument; - var NullProtoObject = function() { - try { - activeXDocument = new ActiveXObject("htmlfile"); - } catch (error3) { - } - NullProtoObject = typeof document != "undefined" ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); - var length = enumBugKeys.length; - while (length--) - delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; - return NullProtoObject(); - }; - hiddenKeys[IE_PROTO] = true; - module2.exports = Object.create || function create(O, Properties) { - var result; - if (O !== null) { - EmptyConstructor[PROTOTYPE] = anObject(O); - result = new EmptyConstructor(); - EmptyConstructor[PROTOTYPE] = null; - result[IE_PROTO] = O; - } else - result = NullProtoObject(); - return Properties === void 0 ? result : definePropertiesModule.f(result, Properties); - }; - } -}); - -// node_modules/core-js/internals/add-to-unscopables.js -var require_add_to_unscopables = __commonJS({ - "node_modules/core-js/internals/add-to-unscopables.js"(exports, module2) { - "use strict"; - var wellKnownSymbol = require_well_known_symbol(); - var create = require_object_create(); - var defineProperty = require_object_define_property().f; - var UNSCOPABLES = wellKnownSymbol("unscopables"); - var ArrayPrototype = Array.prototype; - if (ArrayPrototype[UNSCOPABLES] === void 0) { - defineProperty(ArrayPrototype, UNSCOPABLES, { - configurable: true, - value: create(null) - }); - } - module2.exports = function(key) { - ArrayPrototype[UNSCOPABLES][key] = true; - }; - } -}); - -// node_modules/core-js/modules/es.array.at.js -var require_es_array_at = __commonJS({ - "node_modules/core-js/modules/es.array.at.js"() { - "use strict"; - var $ = require_export(); - var toObject = require_to_object(); - var lengthOfArrayLike = require_length_of_array_like(); - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var addToUnscopables = require_add_to_unscopables(); - $({ target: "Array", proto: true }, { - at: function at(index2) { - var O = toObject(this); - var len = lengthOfArrayLike(O); - var relativeIndex = toIntegerOrInfinity(index2); - var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; - return k < 0 || k >= len ? void 0 : O[k]; - } - }); - addToUnscopables("at"); - } -}); - -// node_modules/core-js/internals/entry-unbind.js -var require_entry_unbind = __commonJS({ - "node_modules/core-js/internals/entry-unbind.js"(exports, module2) { - "use strict"; - var global2 = require_global(); - var uncurryThis = require_function_uncurry_this(); - module2.exports = function(CONSTRUCTOR, METHOD) { - return uncurryThis(global2[CONSTRUCTOR].prototype[METHOD]); - }; - } -}); - -// node_modules/core-js/es/array/at.js -var require_at = __commonJS({ - "node_modules/core-js/es/array/at.js"(exports, module2) { - "use strict"; - require_es_array_at(); - var entryUnbind = require_entry_unbind(); - module2.exports = entryUnbind("Array", "at"); - } -}); - -// node_modules/core-js/stable/array/at.js -var require_at2 = __commonJS({ - "node_modules/core-js/stable/array/at.js"(exports, module2) { - "use strict"; - var parent = require_at(); - module2.exports = parent; - } -}); - -// node_modules/core-js/internals/is-array.js -var require_is_array = __commonJS({ - "node_modules/core-js/internals/is-array.js"(exports, module2) { - "use strict"; - var classof = require_classof_raw(); - module2.exports = Array.isArray || function isArray(argument) { - return classof(argument) === "Array"; - }; - } -}); - -// node_modules/core-js/internals/does-not-exceed-safe-integer.js -var require_does_not_exceed_safe_integer = __commonJS({ - "node_modules/core-js/internals/does-not-exceed-safe-integer.js"(exports, module2) { - "use strict"; - var $TypeError = TypeError; - var MAX_SAFE_INTEGER = 9007199254740991; - module2.exports = function(it) { - if (it > MAX_SAFE_INTEGER) - throw $TypeError("Maximum allowed index exceeded"); - return it; - }; - } -}); - -// node_modules/core-js/internals/function-uncurry-this-clause.js -var require_function_uncurry_this_clause = __commonJS({ - "node_modules/core-js/internals/function-uncurry-this-clause.js"(exports, module2) { - "use strict"; - var classofRaw = require_classof_raw(); - var uncurryThis = require_function_uncurry_this(); - module2.exports = function(fn) { - if (classofRaw(fn) === "Function") - return uncurryThis(fn); - }; - } -}); - -// node_modules/core-js/internals/function-bind-context.js -var require_function_bind_context = __commonJS({ - "node_modules/core-js/internals/function-bind-context.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this_clause(); - var aCallable = require_a_callable(); - var NATIVE_BIND = require_function_bind_native(); - var bind = uncurryThis(uncurryThis.bind); - module2.exports = function(fn, that) { - aCallable(fn); - return that === void 0 ? fn : NATIVE_BIND ? bind(fn, that) : function() { - return fn.apply(that, arguments); - }; - }; - } -}); - -// node_modules/core-js/internals/flatten-into-array.js -var require_flatten_into_array = __commonJS({ - "node_modules/core-js/internals/flatten-into-array.js"(exports, module2) { - "use strict"; - var isArray = require_is_array(); - var lengthOfArrayLike = require_length_of_array_like(); - var doesNotExceedSafeInteger = require_does_not_exceed_safe_integer(); - var bind = require_function_bind_context(); - var flattenIntoArray = function(target, original, source, sourceLen, start, depth, mapper, thisArg) { - var targetIndex = start; - var sourceIndex = 0; - var mapFn = mapper ? bind(mapper, thisArg) : false; - var element, elementLen; - while (sourceIndex < sourceLen) { - if (sourceIndex in source) { - element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex]; - if (depth > 0 && isArray(element)) { - elementLen = lengthOfArrayLike(element); - targetIndex = flattenIntoArray(target, original, element, elementLen, targetIndex, depth - 1) - 1; - } else { - doesNotExceedSafeInteger(targetIndex + 1); - target[targetIndex] = element; - } - targetIndex++; - } - sourceIndex++; - } - return targetIndex; - }; - module2.exports = flattenIntoArray; - } -}); - -// node_modules/core-js/internals/to-string-tag-support.js -var require_to_string_tag_support = __commonJS({ - "node_modules/core-js/internals/to-string-tag-support.js"(exports, module2) { - "use strict"; - var wellKnownSymbol = require_well_known_symbol(); - var TO_STRING_TAG = wellKnownSymbol("toStringTag"); - var test2 = {}; - test2[TO_STRING_TAG] = "z"; - module2.exports = String(test2) === "[object z]"; - } -}); - -// node_modules/core-js/internals/classof.js -var require_classof = __commonJS({ - "node_modules/core-js/internals/classof.js"(exports, module2) { - "use strict"; - var TO_STRING_TAG_SUPPORT = require_to_string_tag_support(); - var isCallable = require_is_callable(); - var classofRaw = require_classof_raw(); - var wellKnownSymbol = require_well_known_symbol(); - var TO_STRING_TAG = wellKnownSymbol("toStringTag"); - var $Object = Object; - var CORRECT_ARGUMENTS = classofRaw(function() { - return arguments; - }()) === "Arguments"; - var tryGet = function(it, key) { - try { - return it[key]; - } catch (error3) { - } - }; - module2.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function(it) { - var O, tag, result; - return it === void 0 ? "Undefined" : it === null ? "Null" : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == "string" ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) === "Object" && isCallable(O.callee) ? "Arguments" : result; - }; - } -}); - -// node_modules/core-js/internals/is-constructor.js -var require_is_constructor = __commonJS({ - "node_modules/core-js/internals/is-constructor.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var fails = require_fails(); - var isCallable = require_is_callable(); - var classof = require_classof(); - var getBuiltIn = require_get_built_in(); - var inspectSource = require_inspect_source(); - var noop2 = function() { - }; - var construct = getBuiltIn("Reflect", "construct"); - var constructorRegExp = /^\s*(?:class|function)\b/; - var exec = uncurryThis(constructorRegExp.exec); - var INCORRECT_TO_STRING = !constructorRegExp.test(noop2); - var isConstructorModern = function isConstructor(argument) { - if (!isCallable(argument)) - return false; - try { - construct(noop2, [], argument); - return true; - } catch (error3) { - return false; - } - }; - var isConstructorLegacy = function isConstructor(argument) { - if (!isCallable(argument)) - return false; - switch (classof(argument)) { - case "AsyncFunction": - case "GeneratorFunction": - case "AsyncGeneratorFunction": - return false; - } - try { - return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); - } catch (error3) { - return true; - } - }; - isConstructorLegacy.sham = true; - module2.exports = !construct || fails(function() { - var called; - return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function() { - called = true; - }) || called; - }) ? isConstructorLegacy : isConstructorModern; - } -}); - -// node_modules/core-js/internals/array-species-constructor.js -var require_array_species_constructor = __commonJS({ - "node_modules/core-js/internals/array-species-constructor.js"(exports, module2) { - "use strict"; - var isArray = require_is_array(); - var isConstructor = require_is_constructor(); - var isObject = require_is_object(); - var wellKnownSymbol = require_well_known_symbol(); - var SPECIES = wellKnownSymbol("species"); - var $Array = Array; - module2.exports = function(originalArray) { - var C; - if (isArray(originalArray)) { - C = originalArray.constructor; - if (isConstructor(C) && (C === $Array || isArray(C.prototype))) - C = void 0; - else if (isObject(C)) { - C = C[SPECIES]; - if (C === null) - C = void 0; - } - } - return C === void 0 ? $Array : C; - }; - } -}); - -// node_modules/core-js/internals/array-species-create.js -var require_array_species_create = __commonJS({ - "node_modules/core-js/internals/array-species-create.js"(exports, module2) { - "use strict"; - var arraySpeciesConstructor = require_array_species_constructor(); - module2.exports = function(originalArray, length) { - return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); - }; - } -}); - -// node_modules/core-js/modules/es.array.flat-map.js -var require_es_array_flat_map = __commonJS({ - "node_modules/core-js/modules/es.array.flat-map.js"() { - "use strict"; - var $ = require_export(); - var flattenIntoArray = require_flatten_into_array(); - var aCallable = require_a_callable(); - var toObject = require_to_object(); - var lengthOfArrayLike = require_length_of_array_like(); - var arraySpeciesCreate = require_array_species_create(); - $({ target: "Array", proto: true }, { - flatMap: function flatMap(callbackfn) { - var O = toObject(this); - var sourceLen = lengthOfArrayLike(O); - var A; - aCallable(callbackfn); - A = arraySpeciesCreate(O, 0); - A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : void 0); - return A; - } - }); - } -}); - -// node_modules/core-js/modules/es.array.unscopables.flat-map.js -var require_es_array_unscopables_flat_map = __commonJS({ - "node_modules/core-js/modules/es.array.unscopables.flat-map.js"() { - "use strict"; - var addToUnscopables = require_add_to_unscopables(); - addToUnscopables("flatMap"); - } -}); - -// node_modules/core-js/es/array/flat-map.js -var require_flat_map = __commonJS({ - "node_modules/core-js/es/array/flat-map.js"(exports, module2) { - "use strict"; - require_es_array_flat_map(); - require_es_array_unscopables_flat_map(); - var entryUnbind = require_entry_unbind(); - module2.exports = entryUnbind("Array", "flatMap"); - } -}); - -// node_modules/core-js/stable/array/flat-map.js -var require_flat_map2 = __commonJS({ - "node_modules/core-js/stable/array/flat-map.js"(exports, module2) { - "use strict"; - var parent = require_flat_map(); - module2.exports = parent; - } -}); - -// node_modules/core-js/modules/es.array.flat.js -var require_es_array_flat = __commonJS({ - "node_modules/core-js/modules/es.array.flat.js"() { - "use strict"; - var $ = require_export(); - var flattenIntoArray = require_flatten_into_array(); - var toObject = require_to_object(); - var lengthOfArrayLike = require_length_of_array_like(); - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var arraySpeciesCreate = require_array_species_create(); - $({ target: "Array", proto: true }, { - flat: function flat() { - var depthArg = arguments.length ? arguments[0] : void 0; - var O = toObject(this); - var sourceLen = lengthOfArrayLike(O); - var A = arraySpeciesCreate(O, 0); - A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === void 0 ? 1 : toIntegerOrInfinity(depthArg)); - return A; - } - }); - } -}); - -// node_modules/core-js/modules/es.array.unscopables.flat.js -var require_es_array_unscopables_flat = __commonJS({ - "node_modules/core-js/modules/es.array.unscopables.flat.js"() { - "use strict"; - var addToUnscopables = require_add_to_unscopables(); - addToUnscopables("flat"); - } -}); - -// node_modules/core-js/es/array/flat.js -var require_flat = __commonJS({ - "node_modules/core-js/es/array/flat.js"(exports, module2) { - "use strict"; - require_es_array_flat(); - require_es_array_unscopables_flat(); - var entryUnbind = require_entry_unbind(); - module2.exports = entryUnbind("Array", "flat"); - } -}); - -// node_modules/core-js/stable/array/flat.js -var require_flat2 = __commonJS({ - "node_modules/core-js/stable/array/flat.js"(exports, module2) { - "use strict"; - var parent = require_flat(); - module2.exports = parent; - } -}); - -// node_modules/core-js/internals/to-string.js -var require_to_string = __commonJS({ - "node_modules/core-js/internals/to-string.js"(exports, module2) { - "use strict"; - var classof = require_classof(); - var $String = String; - module2.exports = function(argument) { - if (classof(argument) === "Symbol") - throw new TypeError("Cannot convert a Symbol value to a string"); - return $String(argument); - }; - } -}); - -// node_modules/core-js/modules/es.string.at-alternative.js -var require_es_string_at_alternative = __commonJS({ - "node_modules/core-js/modules/es.string.at-alternative.js"() { - "use strict"; - var $ = require_export(); - var uncurryThis = require_function_uncurry_this(); - var requireObjectCoercible = require_require_object_coercible(); - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var toString = require_to_string(); - var fails = require_fails(); - var charAt = uncurryThis("".charAt); - var FORCED = fails(function() { - return "\u{20BB7}".at(-2) !== "\uD842"; - }); - $({ target: "String", proto: true, forced: FORCED }, { - at: function at(index2) { - var S = toString(requireObjectCoercible(this)); - var len = S.length; - var relativeIndex = toIntegerOrInfinity(index2); - var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; - return k < 0 || k >= len ? void 0 : charAt(S, k); - } - }); - } -}); - -// node_modules/core-js/es/string/at.js -var require_at3 = __commonJS({ - "node_modules/core-js/es/string/at.js"(exports, module2) { - "use strict"; - require_es_string_at_alternative(); - var entryUnbind = require_entry_unbind(); - module2.exports = entryUnbind("String", "at"); - } -}); - -// node_modules/core-js/stable/string/at.js -var require_at4 = __commonJS({ - "node_modules/core-js/stable/string/at.js"(exports, module2) { - "use strict"; - var parent = require_at3(); - module2.exports = parent; - } -}); - -// node_modules/core-js/internals/regexp-flags.js -var require_regexp_flags = __commonJS({ - "node_modules/core-js/internals/regexp-flags.js"(exports, module2) { - "use strict"; - var anObject = require_an_object(); - module2.exports = function() { - var that = anObject(this); - var result = ""; - if (that.hasIndices) - result += "d"; - if (that.global) - result += "g"; - if (that.ignoreCase) - result += "i"; - if (that.multiline) - result += "m"; - if (that.dotAll) - result += "s"; - if (that.unicode) - result += "u"; - if (that.unicodeSets) - result += "v"; - if (that.sticky) - result += "y"; - return result; - }; - } -}); - -// node_modules/core-js/internals/regexp-sticky-helpers.js -var require_regexp_sticky_helpers = __commonJS({ - "node_modules/core-js/internals/regexp-sticky-helpers.js"(exports, module2) { - "use strict"; - var fails = require_fails(); - var global2 = require_global(); - var $RegExp = global2.RegExp; - var UNSUPPORTED_Y = fails(function() { - var re = $RegExp("a", "y"); - re.lastIndex = 2; - return re.exec("abcd") !== null; - }); - var MISSED_STICKY = UNSUPPORTED_Y || fails(function() { - return !$RegExp("a", "y").sticky; - }); - var BROKEN_CARET = UNSUPPORTED_Y || fails(function() { - var re = $RegExp("^r", "gy"); - re.lastIndex = 2; - return re.exec("str") !== null; - }); - module2.exports = { - BROKEN_CARET, - MISSED_STICKY, - UNSUPPORTED_Y - }; - } -}); - -// node_modules/core-js/internals/regexp-unsupported-dot-all.js -var require_regexp_unsupported_dot_all = __commonJS({ - "node_modules/core-js/internals/regexp-unsupported-dot-all.js"(exports, module2) { - "use strict"; - var fails = require_fails(); - var global2 = require_global(); - var $RegExp = global2.RegExp; - module2.exports = fails(function() { - var re = $RegExp(".", "s"); - return !(re.dotAll && re.test("\n") && re.flags === "s"); - }); - } -}); - -// node_modules/core-js/internals/regexp-unsupported-ncg.js -var require_regexp_unsupported_ncg = __commonJS({ - "node_modules/core-js/internals/regexp-unsupported-ncg.js"(exports, module2) { - "use strict"; - var fails = require_fails(); - var global2 = require_global(); - var $RegExp = global2.RegExp; - module2.exports = fails(function() { - var re = $RegExp("(?<a>b)", "g"); - return re.exec("b").groups.a !== "b" || "b".replace(re, "$<a>c") !== "bc"; - }); - } -}); - -// node_modules/core-js/internals/regexp-exec.js -var require_regexp_exec = __commonJS({ - "node_modules/core-js/internals/regexp-exec.js"(exports, module2) { - "use strict"; - var call = require_function_call(); - var uncurryThis = require_function_uncurry_this(); - var toString = require_to_string(); - var regexpFlags = require_regexp_flags(); - var stickyHelpers = require_regexp_sticky_helpers(); - var shared = require_shared(); - var create = require_object_create(); - var getInternalState = require_internal_state().get; - var UNSUPPORTED_DOT_ALL = require_regexp_unsupported_dot_all(); - var UNSUPPORTED_NCG = require_regexp_unsupported_ncg(); - var nativeReplace = shared("native-string-replace", String.prototype.replace); - var nativeExec = RegExp.prototype.exec; - var patchedExec = nativeExec; - var charAt = uncurryThis("".charAt); - var indexOf = uncurryThis("".indexOf); - var replace = uncurryThis("".replace); - var stringSlice = uncurryThis("".slice); - var UPDATES_LAST_INDEX_WRONG = function() { - var re1 = /a/; - var re2 = /b*/g; - call(nativeExec, re1, "a"); - call(nativeExec, re2, "a"); - return re1.lastIndex !== 0 || re2.lastIndex !== 0; - }(); - var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET; - var NPCG_INCLUDED = /()??/.exec("")[1] !== void 0; - var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG; - if (PATCH) { - patchedExec = function exec(string2) { - var re = this; - var state = getInternalState(re); - var str = toString(string2); - var raw = state.raw; - var result, reCopy, lastIndex, match, i, object2, group; - if (raw) { - raw.lastIndex = re.lastIndex; - result = call(patchedExec, raw, str); - re.lastIndex = raw.lastIndex; - return result; - } - var groups = state.groups; - var sticky = UNSUPPORTED_Y && re.sticky; - var flags = call(regexpFlags, re); - var source = re.source; - var charsAdded = 0; - var strCopy = str; - if (sticky) { - flags = replace(flags, "y", ""); - if (indexOf(flags, "g") === -1) { - flags += "g"; - } - strCopy = stringSlice(str, re.lastIndex); - if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== "\n")) { - source = "(?: " + source + ")"; - strCopy = " " + strCopy; - charsAdded++; - } - reCopy = new RegExp("^(?:" + source + ")", flags); - } - if (NPCG_INCLUDED) { - reCopy = new RegExp("^" + source + "$(?!\\s)", flags); - } - if (UPDATES_LAST_INDEX_WRONG) - lastIndex = re.lastIndex; - match = call(nativeExec, sticky ? reCopy : re, strCopy); - if (sticky) { - if (match) { - match.input = stringSlice(match.input, charsAdded); - match[0] = stringSlice(match[0], charsAdded); - match.index = re.lastIndex; - re.lastIndex += match[0].length; - } else - re.lastIndex = 0; - } else if (UPDATES_LAST_INDEX_WRONG && match) { - re.lastIndex = re.global ? match.index + match[0].length : lastIndex; - } - if (NPCG_INCLUDED && match && match.length > 1) { - call(nativeReplace, match[0], reCopy, function() { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === void 0) - match[i] = void 0; - } - }); - } - if (match && groups) { - match.groups = object2 = create(null); - for (i = 0; i < groups.length; i++) { - group = groups[i]; - object2[group[0]] = match[group[1]]; - } - } - return match; - }; - } - module2.exports = patchedExec; - } -}); - -// node_modules/core-js/modules/es.regexp.exec.js -var require_es_regexp_exec = __commonJS({ - "node_modules/core-js/modules/es.regexp.exec.js"() { - "use strict"; - var $ = require_export(); - var exec = require_regexp_exec(); - $({ target: "RegExp", proto: true, forced: /./.exec !== exec }, { - exec - }); - } -}); - -// node_modules/core-js/internals/function-apply.js -var require_function_apply = __commonJS({ - "node_modules/core-js/internals/function-apply.js"(exports, module2) { - "use strict"; - var NATIVE_BIND = require_function_bind_native(); - var FunctionPrototype = Function.prototype; - var apply = FunctionPrototype.apply; - var call = FunctionPrototype.call; - module2.exports = typeof Reflect == "object" && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function() { - return call.apply(apply, arguments); - }); - } -}); - -// node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js -var require_fix_regexp_well_known_symbol_logic = __commonJS({ - "node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js"(exports, module2) { - "use strict"; - require_es_regexp_exec(); - var call = require_function_call(); - var defineBuiltIn = require_define_built_in(); - var regexpExec = require_regexp_exec(); - var fails = require_fails(); - var wellKnownSymbol = require_well_known_symbol(); - var createNonEnumerableProperty = require_create_non_enumerable_property(); - var SPECIES = wellKnownSymbol("species"); - var RegExpPrototype = RegExp.prototype; - module2.exports = function(KEY, exec, FORCED, SHAM) { - var SYMBOL = wellKnownSymbol(KEY); - var DELEGATES_TO_SYMBOL = !fails(function() { - var O = {}; - O[SYMBOL] = function() { - return 7; - }; - return ""[KEY](O) !== 7; - }); - var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function() { - var execCalled = false; - var re = /a/; - if (KEY === "split") { - re = {}; - re.constructor = {}; - re.constructor[SPECIES] = function() { - return re; - }; - re.flags = ""; - re[SYMBOL] = /./[SYMBOL]; - } - re.exec = function() { - execCalled = true; - return null; - }; - re[SYMBOL](""); - return !execCalled; - }); - if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || FORCED) { - var nativeRegExpMethod = /./[SYMBOL]; - var methods = exec(SYMBOL, ""[KEY], function(nativeMethod, regexp, str, arg2, forceStringMethod) { - var $exec = regexp.exec; - if ($exec === regexpExec || $exec === RegExpPrototype.exec) { - if (DELEGATES_TO_SYMBOL && !forceStringMethod) { - return { done: true, value: call(nativeRegExpMethod, regexp, str, arg2) }; - } - return { done: true, value: call(nativeMethod, str, regexp, arg2) }; - } - return { done: false }; - }); - defineBuiltIn(String.prototype, KEY, methods[0]); - defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]); - } - if (SHAM) - createNonEnumerableProperty(RegExpPrototype[SYMBOL], "sham", true); - }; - } -}); - -// node_modules/core-js/internals/string-multibyte.js -var require_string_multibyte = __commonJS({ - "node_modules/core-js/internals/string-multibyte.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var toString = require_to_string(); - var requireObjectCoercible = require_require_object_coercible(); - var charAt = uncurryThis("".charAt); - var charCodeAt = uncurryThis("".charCodeAt); - var stringSlice = uncurryThis("".slice); - var createMethod = function(CONVERT_TO_STRING) { - return function($this, pos) { - var S = toString(requireObjectCoercible($this)); - var position = toIntegerOrInfinity(pos); - var size4 = S.length; - var first, second; - if (position < 0 || position >= size4) - return CONVERT_TO_STRING ? "" : void 0; - first = charCodeAt(S, position); - return first < 55296 || first > 56319 || position + 1 === size4 || (second = charCodeAt(S, position + 1)) < 56320 || second > 57343 ? CONVERT_TO_STRING ? charAt(S, position) : first : CONVERT_TO_STRING ? stringSlice(S, position, position + 2) : (first - 55296 << 10) + (second - 56320) + 65536; - }; - }; - module2.exports = { - codeAt: createMethod(false), - charAt: createMethod(true) - }; - } -}); - -// node_modules/core-js/internals/advance-string-index.js -var require_advance_string_index = __commonJS({ - "node_modules/core-js/internals/advance-string-index.js"(exports, module2) { - "use strict"; - var charAt = require_string_multibyte().charAt; - module2.exports = function(S, index2, unicode) { - return index2 + (unicode ? charAt(S, index2).length : 1); - }; - } -}); - -// node_modules/core-js/internals/get-substitution.js -var require_get_substitution = __commonJS({ - "node_modules/core-js/internals/get-substitution.js"(exports, module2) { - "use strict"; - var uncurryThis = require_function_uncurry_this(); - var toObject = require_to_object(); - var floor2 = Math.floor; - var charAt = uncurryThis("".charAt); - var replace = uncurryThis("".replace); - var stringSlice = uncurryThis("".slice); - var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; - var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; - module2.exports = function(matched, str, position, captures, namedCaptures, replacement) { - var tailPos = position + matched.length; - var m = captures.length; - var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; - if (namedCaptures !== void 0) { - namedCaptures = toObject(namedCaptures); - symbols = SUBSTITUTION_SYMBOLS; - } - return replace(replacement, symbols, function(match, ch) { - var capture; - switch (charAt(ch, 0)) { - case "$": - return "$"; - case "&": - return matched; - case "`": - return stringSlice(str, 0, position); - case "'": - return stringSlice(str, tailPos); - case "<": - capture = namedCaptures[stringSlice(ch, 1, -1)]; - break; - default: - var n = +ch; - if (n === 0) - return match; - if (n > m) { - var f = floor2(n / 10); - if (f === 0) - return match; - if (f <= m) - return captures[f - 1] === void 0 ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1); - return match; - } - capture = captures[n - 1]; - } - return capture === void 0 ? "" : capture; - }); - }; - } -}); - -// node_modules/core-js/internals/regexp-exec-abstract.js -var require_regexp_exec_abstract = __commonJS({ - "node_modules/core-js/internals/regexp-exec-abstract.js"(exports, module2) { - "use strict"; - var call = require_function_call(); - var anObject = require_an_object(); - var isCallable = require_is_callable(); - var classof = require_classof_raw(); - var regexpExec = require_regexp_exec(); - var $TypeError = TypeError; - module2.exports = function(R, S) { - var exec = R.exec; - if (isCallable(exec)) { - var result = call(exec, R, S); - if (result !== null) - anObject(result); - return result; - } - if (classof(R) === "RegExp") - return call(regexpExec, R, S); - throw new $TypeError("RegExp#exec called on incompatible receiver"); - }; - } -}); - -// node_modules/core-js/modules/es.string.replace.js -var require_es_string_replace = __commonJS({ - "node_modules/core-js/modules/es.string.replace.js"() { - "use strict"; - var apply = require_function_apply(); - var call = require_function_call(); - var uncurryThis = require_function_uncurry_this(); - var fixRegExpWellKnownSymbolLogic = require_fix_regexp_well_known_symbol_logic(); - var fails = require_fails(); - var anObject = require_an_object(); - var isCallable = require_is_callable(); - var isNullOrUndefined = require_is_null_or_undefined(); - var toIntegerOrInfinity = require_to_integer_or_infinity(); - var toLength = require_to_length(); - var toString = require_to_string(); - var requireObjectCoercible = require_require_object_coercible(); - var advanceStringIndex = require_advance_string_index(); - var getMethod2 = require_get_method(); - var getSubstitution = require_get_substitution(); - var regExpExec = require_regexp_exec_abstract(); - var wellKnownSymbol = require_well_known_symbol(); - var REPLACE = wellKnownSymbol("replace"); - var max2 = Math.max; - var min3 = Math.min; - var concat = uncurryThis([].concat); - var push = uncurryThis([].push); - var stringIndexOf = uncurryThis("".indexOf); - var stringSlice = uncurryThis("".slice); - var maybeToString = function(it) { - return it === void 0 ? it : String(it); - }; - var REPLACE_KEEPS_$0 = function() { - return "a".replace(/./, "$0") === "$0"; - }(); - var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = function() { - if (/./[REPLACE]) { - return /./[REPLACE]("a", "$0") === ""; - } - return false; - }(); - var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function() { - var re = /./; - re.exec = function() { - var result = []; - result.groups = { a: "7" }; - return result; - }; - return "".replace(re, "$<a>") !== "7"; - }); - fixRegExpWellKnownSymbolLogic("replace", function(_, nativeReplace, maybeCallNative) { - var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? "$" : "$0"; - return [ - function replace(searchValue, replaceValue) { - var O = requireObjectCoercible(this); - var replacer = isNullOrUndefined(searchValue) ? void 0 : getMethod2(searchValue, REPLACE); - return replacer ? call(replacer, searchValue, O, replaceValue) : call(nativeReplace, toString(O), searchValue, replaceValue); - }, - function(string2, replaceValue) { - var rx = anObject(this); - var S = toString(string2); - if (typeof replaceValue == "string" && stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 && stringIndexOf(replaceValue, "$<") === -1) { - var res = maybeCallNative(nativeReplace, rx, S, replaceValue); - if (res.done) - return res.value; - } - var functionalReplace = isCallable(replaceValue); - if (!functionalReplace) - replaceValue = toString(replaceValue); - var global2 = rx.global; - var fullUnicode; - if (global2) { - fullUnicode = rx.unicode; - rx.lastIndex = 0; - } - var results = []; - var result; - while (true) { - result = regExpExec(rx, S); - if (result === null) - break; - push(results, result); - if (!global2) - break; - var matchStr = toString(result[0]); - if (matchStr === "") - rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); - } - var accumulatedResult = ""; - var nextSourcePosition = 0; - for (var i = 0; i < results.length; i++) { - result = results[i]; - var matched = toString(result[0]); - var position = max2(min3(toIntegerOrInfinity(result.index), S.length), 0); - var captures = []; - var replacement; - for (var j = 1; j < result.length; j++) - push(captures, maybeToString(result[j])); - var namedCaptures = result.groups; - if (functionalReplace) { - var replacerArgs = concat([matched], captures, position, S); - if (namedCaptures !== void 0) - push(replacerArgs, namedCaptures); - replacement = toString(apply(replaceValue, void 0, replacerArgs)); - } else { - replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); - } - if (position >= nextSourcePosition) { - accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement; - nextSourcePosition = position + matched.length; - } - } - return accumulatedResult + stringSlice(S, nextSourcePosition); - } - ]; - }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); - } -}); - -// node_modules/core-js/internals/is-regexp.js -var require_is_regexp = __commonJS({ - "node_modules/core-js/internals/is-regexp.js"(exports, module2) { - "use strict"; - var isObject = require_is_object(); - var classof = require_classof_raw(); - var wellKnownSymbol = require_well_known_symbol(); - var MATCH = wellKnownSymbol("match"); - module2.exports = function(it) { - var isRegExp; - return isObject(it) && ((isRegExp = it[MATCH]) !== void 0 ? !!isRegExp : classof(it) === "RegExp"); - }; - } -}); - -// node_modules/core-js/internals/regexp-get-flags.js -var require_regexp_get_flags = __commonJS({ - "node_modules/core-js/internals/regexp-get-flags.js"(exports, module2) { - "use strict"; - var call = require_function_call(); - var hasOwn = require_has_own_property(); - var isPrototypeOf = require_object_is_prototype_of(); - var regExpFlags = require_regexp_flags(); - var RegExpPrototype = RegExp.prototype; - module2.exports = function(R) { - var flags = R.flags; - return flags === void 0 && !("flags" in RegExpPrototype) && !hasOwn(R, "flags") && isPrototypeOf(RegExpPrototype, R) ? call(regExpFlags, R) : flags; - }; - } -}); - -// node_modules/core-js/modules/es.string.replace-all.js -var require_es_string_replace_all = __commonJS({ - "node_modules/core-js/modules/es.string.replace-all.js"() { - "use strict"; - var $ = require_export(); - var call = require_function_call(); - var uncurryThis = require_function_uncurry_this(); - var requireObjectCoercible = require_require_object_coercible(); - var isCallable = require_is_callable(); - var isNullOrUndefined = require_is_null_or_undefined(); - var isRegExp = require_is_regexp(); - var toString = require_to_string(); - var getMethod2 = require_get_method(); - var getRegExpFlags = require_regexp_get_flags(); - var getSubstitution = require_get_substitution(); - var wellKnownSymbol = require_well_known_symbol(); - var IS_PURE = require_is_pure(); - var REPLACE = wellKnownSymbol("replace"); - var $TypeError = TypeError; - var indexOf = uncurryThis("".indexOf); - var replace = uncurryThis("".replace); - var stringSlice = uncurryThis("".slice); - var max2 = Math.max; - $({ target: "String", proto: true }, { - replaceAll: function replaceAll(searchValue, replaceValue) { - var O = requireObjectCoercible(this); - var IS_REG_EXP, flags, replacer, string2, searchString, functionalReplace, searchLength, advanceBy, replacement; - var position = 0; - var endOfLastMatch = 0; - var result = ""; - if (!isNullOrUndefined(searchValue)) { - IS_REG_EXP = isRegExp(searchValue); - if (IS_REG_EXP) { - flags = toString(requireObjectCoercible(getRegExpFlags(searchValue))); - if (!~indexOf(flags, "g")) - throw new $TypeError("`.replaceAll` does not allow non-global regexes"); - } - replacer = getMethod2(searchValue, REPLACE); - if (replacer) { - return call(replacer, searchValue, O, replaceValue); - } else if (IS_PURE && IS_REG_EXP) { - return replace(toString(O), searchValue, replaceValue); - } - } - string2 = toString(O); - searchString = toString(searchValue); - functionalReplace = isCallable(replaceValue); - if (!functionalReplace) - replaceValue = toString(replaceValue); - searchLength = searchString.length; - advanceBy = max2(1, searchLength); - position = indexOf(string2, searchString); - while (position !== -1) { - replacement = functionalReplace ? toString(replaceValue(searchString, position, string2)) : getSubstitution(searchString, string2, position, [], void 0, replaceValue); - result += stringSlice(string2, endOfLastMatch, position) + replacement; - endOfLastMatch = position + searchLength; - position = position + advanceBy > string2.length ? -1 : indexOf(string2, searchString, position + advanceBy); - } - if (endOfLastMatch < string2.length) { - result += stringSlice(string2, endOfLastMatch); - } - return result; - } - }); - } -}); - -// node_modules/core-js/es/string/replace-all.js -var require_replace_all = __commonJS({ - "node_modules/core-js/es/string/replace-all.js"(exports, module2) { - "use strict"; - require_es_regexp_exec(); - require_es_string_replace(); - require_es_string_replace_all(); - var entryUnbind = require_entry_unbind(); - module2.exports = entryUnbind("String", "replaceAll"); - } -}); - -// node_modules/core-js/stable/string/replace-all.js -var require_replace_all2 = __commonJS({ - "node_modules/core-js/stable/string/replace-all.js"(exports, module2) { - "use strict"; - var parent = require_replace_all(); - module2.exports = parent; - } -}); - -// node_modules/lodash.throttle/index.js -var require_lodash = __commonJS({ - "node_modules/lodash.throttle/index.js"(exports, module2) { - var FUNC_ERROR_TEXT = "Expected a function"; - var NAN = 0 / 0; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var freeParseInt = parseInt; - var freeGlobal = typeof global == "object" && global && global.Object === Object && global; - var freeSelf = typeof self == "object" && self && self.Object === Object && self; - var root = freeGlobal || freeSelf || Function("return this")(); - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - var nativeMax = Math.max; - var nativeMin = Math.min; - var now = function() { - return root.Date.now(); - }; - function debounce2(func, wait, options) { - var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true; - if (typeof func != "function") { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = toNumber(wait) || 0; - if (isObject(options)) { - leading = !!options.leading; - maxing = "maxWait" in options; - maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; - trailing = "trailing" in options ? !!options.trailing : trailing; - } - function invokeFunc(time2) { - var args = lastArgs, thisArg = lastThis; - lastArgs = lastThis = void 0; - lastInvokeTime = time2; - result = func.apply(thisArg, args); - return result; - } - function leadingEdge(time2) { - lastInvokeTime = time2; - timerId = setTimeout(timerExpired, wait); - return leading ? invokeFunc(time2) : result; - } - function remainingWait(time2) { - var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, result2 = wait - timeSinceLastCall; - return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2; - } - function shouldInvoke(time2) { - var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime; - return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; - } - function timerExpired() { - var time2 = now(); - if (shouldInvoke(time2)) { - return trailingEdge(time2); - } - timerId = setTimeout(timerExpired, remainingWait(time2)); - } - function trailingEdge(time2) { - timerId = void 0; - if (trailing && lastArgs) { - return invokeFunc(time2); - } - lastArgs = lastThis = void 0; - return result; - } - function cancel() { - if (timerId !== void 0) { - clearTimeout(timerId); - } - lastInvokeTime = 0; - lastArgs = lastCallTime = lastThis = timerId = void 0; - } - function flush2() { - return timerId === void 0 ? result : trailingEdge(now()); - } - function debounced() { - var time2 = now(), isInvoking = shouldInvoke(time2); - lastArgs = arguments; - lastThis = this; - lastCallTime = time2; - if (isInvoking) { - if (timerId === void 0) { - return leadingEdge(lastCallTime); - } - if (maxing) { - timerId = setTimeout(timerExpired, wait); - return invokeFunc(lastCallTime); - } - } - if (timerId === void 0) { - timerId = setTimeout(timerExpired, wait); - } - return result; - } - debounced.cancel = cancel; - debounced.flush = flush2; - return debounced; - } - function throttle(func, wait, options) { - var leading = true, trailing = true; - if (typeof func != "function") { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (isObject(options)) { - leading = "leading" in options ? !!options.leading : leading; - trailing = "trailing" in options ? !!options.trailing : trailing; - } - return debounce2(func, wait, { - "leading": leading, - "maxWait": wait, - "trailing": trailing - }); - } - function isObject(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; - } - function toNumber(value) { - if (typeof value == "number") { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject(other) ? other + "" : other; - } - if (typeof value != "string") { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ""); - var isBinary = reIsBinary.test(value); - return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; - } - module2.exports = throttle; - } -}); - -// node_modules/lodash.uniq/index.js -var require_lodash2 = __commonJS({ - "node_modules/lodash.uniq/index.js"(exports, module2) { - var LARGE_ARRAY_SIZE = 200; - var HASH_UNDEFINED = "__lodash_hash_undefined__"; - var INFINITY = 1 / 0; - var funcTag = "[object Function]"; - var genTag = "[object GeneratorFunction]"; - var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - var reIsHostCtor = /^\[object .+?Constructor\]$/; - var freeGlobal = typeof global == "object" && global && global.Object === Object && global; - var freeSelf = typeof self == "object" && self && self.Object === Object && self; - var root = freeGlobal || freeSelf || Function("return this")(); - function arrayIncludes(array2, value) { - var length = array2 ? array2.length : 0; - return !!length && baseIndexOf(array2, value, 0) > -1; - } - function arrayIncludesWith(array2, value, comparator) { - var index2 = -1, length = array2 ? array2.length : 0; - while (++index2 < length) { - if (comparator(value, array2[index2])) { - return true; - } - } - return false; - } - function baseFindIndex(array2, predicate, fromIndex, fromRight) { - var length = array2.length, index2 = fromIndex + (fromRight ? 1 : -1); - while (fromRight ? index2-- : ++index2 < length) { - if (predicate(array2[index2], index2, array2)) { - return index2; - } - } - return -1; - } - function baseIndexOf(array2, value, fromIndex) { - if (value !== value) { - return baseFindIndex(array2, baseIsNaN, fromIndex); - } - var index2 = fromIndex - 1, length = array2.length; - while (++index2 < length) { - if (array2[index2] === value) { - return index2; - } - } - return -1; - } - function baseIsNaN(value) { - return value !== value; - } - function cacheHas(cache, key) { - return cache.has(key); - } - function getValue(object2, key) { - return object2 == null ? void 0 : object2[key]; - } - function isHostObject(value) { - var result = false; - if (value != null && typeof value.toString != "function") { - try { - result = !!(value + ""); - } catch (e) { - } - } - return result; - } - function setToArray(set) { - var index2 = -1, result = Array(set.size); - set.forEach(function(value) { - result[++index2] = value; - }); - return result; - } - var arrayProto = Array.prototype; - var funcProto = Function.prototype; - var objectProto = Object.prototype; - var coreJsData = root["__core-js_shared__"]; - var maskSrcKey = function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); - return uid ? "Symbol(src)_1." + uid : ""; - }(); - var funcToString = funcProto.toString; - var hasOwnProperty2 = objectProto.hasOwnProperty; - var objectToString = objectProto.toString; - var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"); - var splice = arrayProto.splice; - var Map2 = getNative(root, "Map"); - var Set2 = getNative(root, "Set"); - var nativeCreate = getNative(Object, "create"); - function Hash(entries) { - var index2 = -1, length = entries ? entries.length : 0; - this.clear(); - while (++index2 < length) { - var entry = entries[index2]; - this.set(entry[0], entry[1]); - } - } - function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - } - function hashDelete(key) { - return this.has(key) && delete this.__data__[key]; - } - function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? void 0 : result; - } - return hasOwnProperty2.call(data, key) ? data[key] : void 0; - } - function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== void 0 : hasOwnProperty2.call(data, key); - } - function hashSet(key, value) { - var data = this.__data__; - data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; - return this; - } - Hash.prototype.clear = hashClear; - Hash.prototype["delete"] = hashDelete; - Hash.prototype.get = hashGet; - Hash.prototype.has = hashHas; - Hash.prototype.set = hashSet; - function ListCache(entries) { - var index2 = -1, length = entries ? entries.length : 0; - this.clear(); - while (++index2 < length) { - var entry = entries[index2]; - this.set(entry[0], entry[1]); - } - } - function listCacheClear() { - this.__data__ = []; - } - function listCacheDelete(key) { - var data = this.__data__, index2 = assocIndexOf(data, key); - if (index2 < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index2 == lastIndex) { - data.pop(); - } else { - splice.call(data, index2, 1); - } - return true; - } - function listCacheGet(key) { - var data = this.__data__, index2 = assocIndexOf(data, key); - return index2 < 0 ? void 0 : data[index2][1]; - } - function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; - } - function listCacheSet(key, value) { - var data = this.__data__, index2 = assocIndexOf(data, key); - if (index2 < 0) { - data.push([key, value]); - } else { - data[index2][1] = value; - } - return this; - } - ListCache.prototype.clear = listCacheClear; - ListCache.prototype["delete"] = listCacheDelete; - ListCache.prototype.get = listCacheGet; - ListCache.prototype.has = listCacheHas; - ListCache.prototype.set = listCacheSet; - function MapCache(entries) { - var index2 = -1, length = entries ? entries.length : 0; - this.clear(); - while (++index2 < length) { - var entry = entries[index2]; - this.set(entry[0], entry[1]); - } - } - function mapCacheClear() { - this.__data__ = { - "hash": new Hash(), - "map": new (Map2 || ListCache)(), - "string": new Hash() - }; - } - function mapCacheDelete(key) { - return getMapData(this, key)["delete"](key); - } - function mapCacheGet(key) { - return getMapData(this, key).get(key); - } - function mapCacheHas(key) { - return getMapData(this, key).has(key); - } - function mapCacheSet(key, value) { - getMapData(this, key).set(key, value); - return this; - } - MapCache.prototype.clear = mapCacheClear; - MapCache.prototype["delete"] = mapCacheDelete; - MapCache.prototype.get = mapCacheGet; - MapCache.prototype.has = mapCacheHas; - MapCache.prototype.set = mapCacheSet; - function SetCache(values) { - var index2 = -1, length = values ? values.length : 0; - this.__data__ = new MapCache(); - while (++index2 < length) { - this.add(values[index2]); - } - } - function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; - } - function setCacheHas(value) { - return this.__data__.has(value); - } - SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; - SetCache.prototype.has = setCacheHas; - function assocIndexOf(array2, key) { - var length = array2.length; - while (length--) { - if (eq(array2[length][0], key)) { - return length; - } - } - return -1; - } - function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); - } - function baseUniq(array2, iteratee, comparator) { - var index2 = -1, includes = arrayIncludes, length = array2.length, isCommon = true, result = [], seen = result; - if (comparator) { - isCommon = false; - includes = arrayIncludesWith; - } else if (length >= LARGE_ARRAY_SIZE) { - var set = iteratee ? null : createSet(array2); - if (set) { - return setToArray(set); - } - isCommon = false; - includes = cacheHas; - seen = new SetCache(); - } else { - seen = iteratee ? [] : result; - } - outer: - while (++index2 < length) { - var value = array2[index2], computed2 = iteratee ? iteratee(value) : value; - value = comparator || value !== 0 ? value : 0; - if (isCommon && computed2 === computed2) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed2) { - continue outer; - } - } - if (iteratee) { - seen.push(computed2); - } - result.push(value); - } else if (!includes(seen, computed2, comparator)) { - if (seen !== result) { - seen.push(computed2); - } - result.push(value); - } - } - return result; - } - var createSet = !(Set2 && 1 / setToArray(new Set2([, -0]))[1] == INFINITY) ? noop2 : function(values) { - return new Set2(values); - }; - function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; - } - function getNative(object2, key) { - var value = getValue(object2, key); - return baseIsNative(value) ? value : void 0; - } - function isKeyable(value) { - var type = typeof value; - return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; - } - function isMasked(func) { - return !!maskSrcKey && maskSrcKey in func; - } - function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) { - } - try { - return func + ""; - } catch (e) { - } - } - return ""; - } - function uniq2(array2) { - return array2 && array2.length ? baseUniq(array2) : []; - } - function eq(value, other) { - return value === other || value !== value && other !== other; - } - function isFunction(value) { - var tag = isObject(value) ? objectToString.call(value) : ""; - return tag == funcTag || tag == genTag; - } - function isObject(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function noop2() { - } - module2.exports = uniq2; - } -}); - -// node_modules/lodash.isequal/index.js -var require_lodash3 = __commonJS({ - "node_modules/lodash.isequal/index.js"(exports, module2) { - var LARGE_ARRAY_SIZE = 200; - var HASH_UNDEFINED = "__lodash_hash_undefined__"; - var COMPARE_PARTIAL_FLAG = 1; - var COMPARE_UNORDERED_FLAG = 2; - var MAX_SAFE_INTEGER = 9007199254740991; - var argsTag = "[object Arguments]"; - var arrayTag = "[object Array]"; - var asyncTag = "[object AsyncFunction]"; - var boolTag = "[object Boolean]"; - var dateTag = "[object Date]"; - var errorTag = "[object Error]"; - var funcTag = "[object Function]"; - var genTag = "[object GeneratorFunction]"; - var mapTag = "[object Map]"; - var numberTag = "[object Number]"; - var nullTag = "[object Null]"; - var objectTag = "[object Object]"; - var promiseTag = "[object Promise]"; - var proxyTag = "[object Proxy]"; - var regexpTag = "[object RegExp]"; - var setTag = "[object Set]"; - var stringTag = "[object String]"; - var symbolTag = "[object Symbol]"; - var undefinedTag = "[object Undefined]"; - var weakMapTag = "[object WeakMap]"; - var arrayBufferTag = "[object ArrayBuffer]"; - var dataViewTag = "[object DataView]"; - var float32Tag = "[object Float32Array]"; - var float64Tag = "[object Float64Array]"; - var int8Tag = "[object Int8Array]"; - var int16Tag = "[object Int16Array]"; - var int32Tag = "[object Int32Array]"; - var uint8Tag = "[object Uint8Array]"; - var uint8ClampedTag = "[object Uint8ClampedArray]"; - var uint16Tag = "[object Uint16Array]"; - var uint32Tag = "[object Uint32Array]"; - var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - var reIsHostCtor = /^\[object .+?Constructor\]$/; - var reIsUint = /^(?:0|[1-9]\d*)$/; - var typedArrayTags = {}; - typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; - typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - var freeGlobal = typeof global == "object" && global && global.Object === Object && global; - var freeSelf = typeof self == "object" && self && self.Object === Object && self; - var root = freeGlobal || freeSelf || Function("return this")(); - var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports; - var freeModule = freeExports && typeof module2 == "object" && module2 && !module2.nodeType && module2; - var moduleExports = freeModule && freeModule.exports === freeExports; - var freeProcess = moduleExports && freeGlobal.process; - var nodeUtil = function() { - try { - return freeProcess && freeProcess.binding && freeProcess.binding("util"); - } catch (e) { - } - }(); - var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - function arrayFilter(array2, predicate) { - var index2 = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result = []; - while (++index2 < length) { - var value = array2[index2]; - if (predicate(value, index2, array2)) { - result[resIndex++] = value; - } - } - return result; - } - function arrayPush(array2, values) { - var index2 = -1, length = values.length, offset4 = array2.length; - while (++index2 < length) { - array2[offset4 + index2] = values[index2]; - } - return array2; - } - function arraySome(array2, predicate) { - var index2 = -1, length = array2 == null ? 0 : array2.length; - while (++index2 < length) { - if (predicate(array2[index2], index2, array2)) { - return true; - } - } - return false; - } - function baseTimes(n, iteratee) { - var index2 = -1, result = Array(n); - while (++index2 < n) { - result[index2] = iteratee(index2); - } - return result; - } - function baseUnary(func) { - return function(value) { - return func(value); - }; - } - function cacheHas(cache, key) { - return cache.has(key); - } - function getValue(object2, key) { - return object2 == null ? void 0 : object2[key]; - } - function mapToArray(map) { - var index2 = -1, result = Array(map.size); - map.forEach(function(value, key) { - result[++index2] = [key, value]; - }); - return result; - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - function setToArray(set) { - var index2 = -1, result = Array(set.size); - set.forEach(function(value) { - result[++index2] = value; - }); - return result; - } - var arrayProto = Array.prototype; - var funcProto = Function.prototype; - var objectProto = Object.prototype; - var coreJsData = root["__core-js_shared__"]; - var funcToString = funcProto.toString; - var hasOwnProperty2 = objectProto.hasOwnProperty; - var maskSrcKey = function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); - return uid ? "Symbol(src)_1." + uid : ""; - }(); - var nativeObjectToString = objectProto.toString; - var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"); - var Buffer2 = moduleExports ? root.Buffer : void 0; - var Symbol2 = root.Symbol; - var Uint8Array2 = root.Uint8Array; - var propertyIsEnumerable = objectProto.propertyIsEnumerable; - var splice = arrayProto.splice; - var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0; - var nativeGetSymbols = Object.getOwnPropertySymbols; - var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0; - var nativeKeys = overArg(Object.keys, Object); - var DataView2 = getNative(root, "DataView"); - var Map2 = getNative(root, "Map"); - var Promise2 = getNative(root, "Promise"); - var Set2 = getNative(root, "Set"); - var WeakMap2 = getNative(root, "WeakMap"); - var nativeCreate = getNative(Object, "create"); - var dataViewCtorString = toSource(DataView2); - var mapCtorString = toSource(Map2); - var promiseCtorString = toSource(Promise2); - var setCtorString = toSource(Set2); - var weakMapCtorString = toSource(WeakMap2); - var symbolProto = Symbol2 ? Symbol2.prototype : void 0; - var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; - function Hash(entries) { - var index2 = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index2 < length) { - var entry = entries[index2]; - this.set(entry[0], entry[1]); - } - } - function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; - } - function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; - } - function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? void 0 : result; - } - return hasOwnProperty2.call(data, key) ? data[key] : void 0; - } - function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== void 0 : hasOwnProperty2.call(data, key); - } - function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; - return this; - } - Hash.prototype.clear = hashClear; - Hash.prototype["delete"] = hashDelete; - Hash.prototype.get = hashGet; - Hash.prototype.has = hashHas; - Hash.prototype.set = hashSet; - function ListCache(entries) { - var index2 = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index2 < length) { - var entry = entries[index2]; - this.set(entry[0], entry[1]); - } - } - function listCacheClear() { - this.__data__ = []; - this.size = 0; - } - function listCacheDelete(key) { - var data = this.__data__, index2 = assocIndexOf(data, key); - if (index2 < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index2 == lastIndex) { - data.pop(); - } else { - splice.call(data, index2, 1); - } - --this.size; - return true; - } - function listCacheGet(key) { - var data = this.__data__, index2 = assocIndexOf(data, key); - return index2 < 0 ? void 0 : data[index2][1]; - } - function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; - } - function listCacheSet(key, value) { - var data = this.__data__, index2 = assocIndexOf(data, key); - if (index2 < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index2][1] = value; - } - return this; - } - ListCache.prototype.clear = listCacheClear; - ListCache.prototype["delete"] = listCacheDelete; - ListCache.prototype.get = listCacheGet; - ListCache.prototype.has = listCacheHas; - ListCache.prototype.set = listCacheSet; - function MapCache(entries) { - var index2 = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index2 < length) { - var entry = entries[index2]; - this.set(entry[0], entry[1]); - } - } - function mapCacheClear() { - this.size = 0; - this.__data__ = { - "hash": new Hash(), - "map": new (Map2 || ListCache)(), - "string": new Hash() - }; - } - function mapCacheDelete(key) { - var result = getMapData(this, key)["delete"](key); - this.size -= result ? 1 : 0; - return result; - } - function mapCacheGet(key) { - return getMapData(this, key).get(key); - } - function mapCacheHas(key) { - return getMapData(this, key).has(key); - } - function mapCacheSet(key, value) { - var data = getMapData(this, key), size4 = data.size; - data.set(key, value); - this.size += data.size == size4 ? 0 : 1; - return this; - } - MapCache.prototype.clear = mapCacheClear; - MapCache.prototype["delete"] = mapCacheDelete; - MapCache.prototype.get = mapCacheGet; - MapCache.prototype.has = mapCacheHas; - MapCache.prototype.set = mapCacheSet; - function SetCache(values) { - var index2 = -1, length = values == null ? 0 : values.length; - this.__data__ = new MapCache(); - while (++index2 < length) { - this.add(values[index2]); - } - } - function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; - } - function setCacheHas(value) { - return this.__data__.has(value); - } - SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; - SetCache.prototype.has = setCacheHas; - function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; - } - function stackClear() { - this.__data__ = new ListCache(); - this.size = 0; - } - function stackDelete(key) { - var data = this.__data__, result = data["delete"](key); - this.size = data.size; - return result; - } - function stackGet(key) { - return this.__data__.get(key); - } - function stackHas(key) { - return this.__data__.has(key); - } - function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; - } - Stack.prototype.clear = stackClear; - Stack.prototype["delete"] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; - function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; - for (var key in value) { - if ((inherited || hasOwnProperty2.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex(key, length)))) { - result.push(key); - } - } - return result; - } - function assocIndexOf(array2, key) { - var length = array2.length; - while (length--) { - if (eq(array2[length][0], key)) { - return length; - } - } - return -1; - } - function baseGetAllKeys(object2, keysFunc, symbolsFunc) { - var result = keysFunc(object2); - return isArray(object2) ? result : arrayPush(result, symbolsFunc(object2)); - } - function baseGetTag(value) { - if (value == null) { - return value === void 0 ? undefinedTag : nullTag; - } - return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); - } - function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; - } - function baseIsEqual(value, other, bitmask, customizer, stack2) { - if (value === other) { - return true; - } - if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack2); - } - function baseIsEqualDeep(object2, other, bitmask, customizer, equalFunc, stack2) { - var objIsArr = isArray(object2), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object2), othTag = othIsArr ? arrayTag : getTag(other); - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; - if (isSameTag && isBuffer(object2)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack2 || (stack2 = new Stack()); - return objIsArr || isTypedArray(object2) ? equalArrays(object2, other, bitmask, customizer, equalFunc, stack2) : equalByTag(object2, other, objTag, bitmask, customizer, equalFunc, stack2); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty2.call(object2, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty2.call(other, "__wrapped__"); - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object2.value() : object2, othUnwrapped = othIsWrapped ? other.value() : other; - stack2 || (stack2 = new Stack()); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack2); - } - } - if (!isSameTag) { - return false; - } - stack2 || (stack2 = new Stack()); - return equalObjects(object2, other, bitmask, customizer, equalFunc, stack2); - } - function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); - } - function baseIsTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; - } - function baseKeys(object2) { - if (!isPrototype(object2)) { - return nativeKeys(object2); - } - var result = []; - for (var key in Object(object2)) { - if (hasOwnProperty2.call(object2, key) && key != "constructor") { - result.push(key); - } - } - return result; - } - function equalArrays(array2, other, bitmask, customizer, equalFunc, stack2) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other.length; - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - var stacked = stack2.get(array2); - if (stacked && stack2.get(other)) { - return stacked == other; - } - var index2 = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0; - stack2.set(array2, other); - stack2.set(other, array2); - while (++index2 < arrLength) { - var arrValue = array2[index2], othValue = other[index2]; - if (customizer) { - var compared = isPartial ? customizer(othValue, arrValue, index2, other, array2, stack2) : customizer(arrValue, othValue, index2, array2, other, stack2); - } - if (compared !== void 0) { - if (compared) { - continue; - } - result = false; - break; - } - if (seen) { - if (!arraySome(other, function(othValue2, othIndex) { - if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack2))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack2))) { - result = false; - break; - } - } - stack2["delete"](array2); - stack2["delete"](other); - return result; - } - function equalByTag(object2, other, tag, bitmask, customizer, equalFunc, stack2) { - switch (tag) { - case dataViewTag: - if (object2.byteLength != other.byteLength || object2.byteOffset != other.byteOffset) { - return false; - } - object2 = object2.buffer; - other = other.buffer; - case arrayBufferTag: - if (object2.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object2), new Uint8Array2(other))) { - return false; - } - return true; - case boolTag: - case dateTag: - case numberTag: - return eq(+object2, +other); - case errorTag: - return object2.name == other.name && object2.message == other.message; - case regexpTag: - case stringTag: - return object2 == other + ""; - case mapTag: - var convert2 = mapToArray; - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert2 || (convert2 = setToArray); - if (object2.size != other.size && !isPartial) { - return false; - } - var stacked = stack2.get(object2); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - stack2.set(object2, other); - var result = equalArrays(convert2(object2), convert2(other), bitmask, customizer, equalFunc, stack2); - stack2["delete"](object2); - return result; - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object2) == symbolValueOf.call(other); - } - } - return false; - } - function equalObjects(object2, other, bitmask, customizer, equalFunc, stack2) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object2), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; - if (objLength != othLength && !isPartial) { - return false; - } - var index2 = objLength; - while (index2--) { - var key = objProps[index2]; - if (!(isPartial ? key in other : hasOwnProperty2.call(other, key))) { - return false; - } - } - var stacked = stack2.get(object2); - if (stacked && stack2.get(other)) { - return stacked == other; - } - var result = true; - stack2.set(object2, other); - stack2.set(other, object2); - var skipCtor = isPartial; - while (++index2 < objLength) { - key = objProps[index2]; - var objValue = object2[key], othValue = other[key]; - if (customizer) { - var compared = isPartial ? customizer(othValue, objValue, key, other, object2, stack2) : customizer(objValue, othValue, key, object2, other, stack2); - } - if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack2) : compared)) { - result = false; - break; - } - skipCtor || (skipCtor = key == "constructor"); - } - if (result && !skipCtor) { - var objCtor = object2.constructor, othCtor = other.constructor; - if (objCtor != othCtor && ("constructor" in object2 && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { - result = false; - } - } - stack2["delete"](object2); - stack2["delete"](other); - return result; - } - function getAllKeys(object2) { - return baseGetAllKeys(object2, keys, getSymbols); - } - function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; - } - function getNative(object2, key) { - var value = getValue(object2, key); - return baseIsNative(value) ? value : void 0; - } - function getRawTag(value) { - var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag]; - try { - value[symToStringTag] = void 0; - var unmasked = true; - } catch (e) { - } - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; - } - var getSymbols = !nativeGetSymbols ? stubArray : function(object2) { - if (object2 == null) { - return []; - } - object2 = Object(object2); - return arrayFilter(nativeGetSymbols(object2), function(symbol) { - return propertyIsEnumerable.call(object2, symbol); - }); - }; - var getTag = baseGetTag; - if (DataView2 && getTag(new DataView2(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) { - getTag = function(value) { - var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : ""; - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: - return dataViewTag; - case mapCtorString: - return mapTag; - case promiseCtorString: - return promiseTag; - case setCtorString: - return setTag; - case weakMapCtorString: - return weakMapTag; - } - } - return result; - }; - } - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); - } - function isKeyable(value) { - var type = typeof value; - return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; - } - function isMasked(func) { - return !!maskSrcKey && maskSrcKey in func; - } - function isPrototype(value) { - var Ctor = value && value.constructor, proto2 = typeof Ctor == "function" && Ctor.prototype || objectProto; - return value === proto2; - } - function objectToString(value) { - return nativeObjectToString.call(value); - } - function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) { - } - try { - return func + ""; - } catch (e) { - } - } - return ""; - } - function eq(value, other) { - return value === other || value !== value && other !== other; - } - var isArguments = baseIsArguments(function() { - return arguments; - }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty2.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); - }; - var isArray = Array.isArray; - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); - } - var isBuffer = nativeIsBuffer || stubFalse; - function isEqual2(value, other) { - return baseIsEqual(value, other); - } - function isFunction(value) { - if (!isObject(value)) { - return false; - } - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; - } - function isLength(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - function isObject(value) { - var type = typeof value; - return value != null && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return value != null && typeof value == "object"; - } - var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - function keys(object2) { - return isArrayLike(object2) ? arrayLikeKeys(object2) : baseKeys(object2); - } - function stubArray() { - return []; - } - function stubFalse() { - return false; - } - module2.exports = isEqual2; - } -}); - -// node_modules/react/cjs/react-jsx-runtime.production.min.js -var require_react_jsx_runtime_production_min = __commonJS({ - "node_modules/react/cjs/react-jsx-runtime.production.min.js"(exports) { - "use strict"; - var f = require_react(); - var k = Symbol.for("react.element"); - var l = Symbol.for("react.fragment"); - var m = Object.prototype.hasOwnProperty; - var n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; - var p = { key: true, ref: true, __self: true, __source: true }; - function q(c, a, g) { - var b, d = {}, e = null, h = null; - g !== void 0 && (e = "" + g); - a.key !== void 0 && (e = "" + a.key); - a.ref !== void 0 && (h = a.ref); - for (b in a) - m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]); - if (c && c.defaultProps) - for (b in a = c.defaultProps, a) - d[b] === void 0 && (d[b] = a[b]); - return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current }; - } - exports.Fragment = l; - exports.jsx = q; - exports.jsxs = q; - } -}); - -// node_modules/react/jsx-runtime.js -var require_jsx_runtime = __commonJS({ - "node_modules/react/jsx-runtime.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_react_jsx_runtime_production_min(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/classnames/index.js -var require_classnames = __commonJS({ - "node_modules/classnames/index.js"(exports, module2) { - (function() { - "use strict"; - var hasOwn = {}.hasOwnProperty; - function classNames41() { - var classes = ""; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (arg) { - classes = appendClass(classes, parseValue(arg)); - } - } - return classes; - } - function parseValue(arg) { - if (typeof arg === "string" || typeof arg === "number") { - return arg; - } - if (typeof arg !== "object") { - return ""; - } - if (Array.isArray(arg)) { - return classNames41.apply(null, arg); - } - if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) { - return arg.toString(); - } - var classes = ""; - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes = appendClass(classes, key); - } - } - return classes; - } - function appendClass(value, newClass) { - if (!newClass) { - return value; - } - if (value) { - return value + " " + newClass; - } - return value + newClass; - } - if (typeof module2 !== "undefined" && module2.exports) { - classNames41.default = classNames41; - module2.exports = classNames41; - } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) { - define("classnames", [], function() { - return classNames41; - }); - } else { - window.classNames = classNames41; - } - })(); - } -}); - -// node_modules/@use-gesture/core/dist/maths-83bc6f64.cjs.prod.js -var require_maths_83bc6f64_cjs_prod = __commonJS({ - "node_modules/@use-gesture/core/dist/maths-83bc6f64.cjs.prod.js"(exports) { - "use strict"; - function clamp4(v, min3, max2) { - return Math.max(min3, Math.min(v, max2)); - } - var V = { - toVector(v, fallback) { - if (v === void 0) - v = fallback; - return Array.isArray(v) ? v : [v, v]; - }, - add(v1, v2) { - return [v1[0] + v2[0], v1[1] + v2[1]]; - }, - sub(v1, v2) { - return [v1[0] - v2[0], v1[1] - v2[1]]; - }, - addTo(v1, v2) { - v1[0] += v2[0]; - v1[1] += v2[1]; - }, - subTo(v1, v2) { - v1[0] -= v2[0]; - v1[1] -= v2[1]; - } - }; - function rubberband(distance, dimension, constant) { - if (dimension === 0 || Math.abs(dimension) === Infinity) - return Math.pow(distance, constant * 5); - return distance * dimension * constant / (dimension + constant * distance); - } - function rubberbandIfOutOfBounds(position, min3, max2, constant = 0.15) { - if (constant === 0) - return clamp4(position, min3, max2); - if (position < min3) - return -rubberband(min3 - position, max2 - min3, constant) + min3; - if (position > max2) - return +rubberband(position - max2, max2 - min3, constant) + max2; - return position; - } - function computeRubberband(bounds, [Vx, Vy], [Rx, Ry]) { - const [[X0, X1], [Y0, Y1]] = bounds; - return [rubberbandIfOutOfBounds(Vx, X0, X1, Rx), rubberbandIfOutOfBounds(Vy, Y0, Y1, Ry)]; - } - exports.V = V; - exports.computeRubberband = computeRubberband; - exports.rubberbandIfOutOfBounds = rubberbandIfOutOfBounds; - } -}); - -// node_modules/@use-gesture/core/dist/actions-89e642c9.cjs.prod.js -var require_actions_89e642c9_cjs_prod = __commonJS({ - "node_modules/@use-gesture/core/dist/actions-89e642c9.cjs.prod.js"(exports) { - "use strict"; - var maths = require_maths_83bc6f64_cjs_prod(); - function _toPrimitive2(input, hint) { - if (typeof input !== "object" || input === null) - return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== void 0) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") - return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); - } - function _toPropertyKey2(arg) { - var key = _toPrimitive2(arg, "string"); - return typeof key === "symbol" ? key : String(key); - } - function _defineProperty2(obj, key, value) { - key = _toPropertyKey2(key); - if (key in obj) { - Object.defineProperty(obj, key, { - value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; - } - function ownKeys2(e, r) { - var t2 = Object.keys(e); - if (Object.getOwnPropertySymbols) { - var o = Object.getOwnPropertySymbols(e); - r && (o = o.filter(function(r2) { - return Object.getOwnPropertyDescriptor(e, r2).enumerable; - })), t2.push.apply(t2, o); - } - return t2; - } - function _objectSpread22(e) { - for (var r = 1; r < arguments.length; r++) { - var t2 = arguments[r] != null ? arguments[r] : {}; - r % 2 ? ownKeys2(Object(t2), true).forEach(function(r2) { - _defineProperty2(e, r2, t2[r2]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2)) : ownKeys2(Object(t2)).forEach(function(r2) { - Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t2, r2)); - }); - } - return e; - } - var EVENT_TYPE_MAP = { - pointer: { - start: "down", - change: "move", - end: "up" - }, - mouse: { - start: "down", - change: "move", - end: "up" - }, - touch: { - start: "start", - change: "move", - end: "end" - }, - gesture: { - start: "start", - change: "change", - end: "end" - } - }; - function capitalize(string2) { - if (!string2) - return ""; - return string2[0].toUpperCase() + string2.slice(1); - } - var actionsWithoutCaptureSupported = ["enter", "leave"]; - function hasCapture(capture = false, actionKey) { - return capture && !actionsWithoutCaptureSupported.includes(actionKey); - } - function toHandlerProp(device, action = "", capture = false) { - const deviceProps = EVENT_TYPE_MAP[device]; - const actionKey = deviceProps ? deviceProps[action] || action : action; - return "on" + capitalize(device) + capitalize(actionKey) + (hasCapture(capture, actionKey) ? "Capture" : ""); - } - var pointerCaptureEvents = ["gotpointercapture", "lostpointercapture"]; - function parseProp(prop) { - let eventKey = prop.substring(2).toLowerCase(); - const passive = !!~eventKey.indexOf("passive"); - if (passive) - eventKey = eventKey.replace("passive", ""); - const captureKey = pointerCaptureEvents.includes(eventKey) ? "capturecapture" : "capture"; - const capture = !!~eventKey.indexOf(captureKey); - if (capture) - eventKey = eventKey.replace("capture", ""); - return { - device: eventKey, - capture, - passive - }; - } - function toDomEventType(device, action = "") { - const deviceProps = EVENT_TYPE_MAP[device]; - const actionKey = deviceProps ? deviceProps[action] || action : action; - return device + actionKey; - } - function isTouch(event) { - return "touches" in event; - } - function getPointerType(event) { - if (isTouch(event)) - return "touch"; - if ("pointerType" in event) - return event.pointerType; - return "mouse"; - } - function getCurrentTargetTouchList(event) { - return Array.from(event.touches).filter((e) => { - var _event$currentTarget, _event$currentTarget$; - return e.target === event.currentTarget || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || (_event$currentTarget$ = _event$currentTarget.contains) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.call(_event$currentTarget, e.target)); - }); - } - function getTouchList(event) { - return event.type === "touchend" || event.type === "touchcancel" ? event.changedTouches : event.targetTouches; - } - function getValueEvent(event) { - return isTouch(event) ? getTouchList(event)[0] : event; - } - function distanceAngle(P1, P2) { - try { - const dx = P2.clientX - P1.clientX; - const dy = P2.clientY - P1.clientY; - const cx = (P2.clientX + P1.clientX) / 2; - const cy = (P2.clientY + P1.clientY) / 2; - const distance = Math.hypot(dx, dy); - const angle = -(Math.atan2(dx, dy) * 180) / Math.PI; - const origin = [cx, cy]; - return { - angle, - distance, - origin - }; - } catch (_unused) { - } - return null; - } - function touchIds(event) { - return getCurrentTargetTouchList(event).map((touch) => touch.identifier); - } - function touchDistanceAngle(event, ids) { - const [P1, P2] = Array.from(event.touches).filter((touch) => ids.includes(touch.identifier)); - return distanceAngle(P1, P2); - } - function pointerId(event) { - const valueEvent = getValueEvent(event); - return isTouch(event) ? valueEvent.identifier : valueEvent.pointerId; - } - function pointerValues(event) { - const valueEvent = getValueEvent(event); - return [valueEvent.clientX, valueEvent.clientY]; - } - var LINE_HEIGHT = 40; - var PAGE_HEIGHT = 800; - function wheelValues(event) { - let { - deltaX, - deltaY, - deltaMode - } = event; - if (deltaMode === 1) { - deltaX *= LINE_HEIGHT; - deltaY *= LINE_HEIGHT; - } else if (deltaMode === 2) { - deltaX *= PAGE_HEIGHT; - deltaY *= PAGE_HEIGHT; - } - return [deltaX, deltaY]; - } - function scrollValues(event) { - var _ref, _ref2; - const { - scrollX, - scrollY, - scrollLeft, - scrollTop - } = event.currentTarget; - return [(_ref = scrollX !== null && scrollX !== void 0 ? scrollX : scrollLeft) !== null && _ref !== void 0 ? _ref : 0, (_ref2 = scrollY !== null && scrollY !== void 0 ? scrollY : scrollTop) !== null && _ref2 !== void 0 ? _ref2 : 0]; - } - function getEventDetails(event) { - const payload = {}; - if ("buttons" in event) - payload.buttons = event.buttons; - if ("shiftKey" in event) { - const { - shiftKey, - altKey: altKey2, - metaKey, - ctrlKey - } = event; - Object.assign(payload, { - shiftKey, - altKey: altKey2, - metaKey, - ctrlKey - }); - } - return payload; - } - function call(v, ...args) { - if (typeof v === "function") { - return v(...args); - } else { - return v; - } - } - function noop2() { - } - function chain(...fns) { - if (fns.length === 0) - return noop2; - if (fns.length === 1) - return fns[0]; - return function() { - let result; - for (const fn of fns) { - result = fn.apply(this, arguments) || result; - } - return result; - }; - } - function assignDefault(value, fallback) { - return Object.assign({}, fallback, value || {}); - } - var BEFORE_LAST_KINEMATICS_DELAY = 32; - var Engine = class { - constructor(ctrl, args, key) { - this.ctrl = ctrl; - this.args = args; - this.key = key; - if (!this.state) { - this.state = {}; - this.computeValues([0, 0]); - this.computeInitial(); - if (this.init) - this.init(); - this.reset(); - } - } - get state() { - return this.ctrl.state[this.key]; - } - set state(state) { - this.ctrl.state[this.key] = state; - } - get shared() { - return this.ctrl.state.shared; - } - get eventStore() { - return this.ctrl.gestureEventStores[this.key]; - } - get timeoutStore() { - return this.ctrl.gestureTimeoutStores[this.key]; - } - get config() { - return this.ctrl.config[this.key]; - } - get sharedConfig() { - return this.ctrl.config.shared; - } - get handler() { - return this.ctrl.handlers[this.key]; - } - reset() { - const { - state, - shared, - ingKey, - args - } = this; - shared[ingKey] = state._active = state.active = state._blocked = state._force = false; - state._step = [false, false]; - state.intentional = false; - state._movement = [0, 0]; - state._distance = [0, 0]; - state._direction = [0, 0]; - state._delta = [0, 0]; - state._bounds = [[-Infinity, Infinity], [-Infinity, Infinity]]; - state.args = args; - state.axis = void 0; - state.memo = void 0; - state.elapsedTime = state.timeDelta = 0; - state.direction = [0, 0]; - state.distance = [0, 0]; - state.overflow = [0, 0]; - state._movementBound = [false, false]; - state.velocity = [0, 0]; - state.movement = [0, 0]; - state.delta = [0, 0]; - state.timeStamp = 0; - } - start(event) { - const state = this.state; - const config = this.config; - if (!state._active) { - this.reset(); - this.computeInitial(); - state._active = true; - state.target = event.target; - state.currentTarget = event.currentTarget; - state.lastOffset = config.from ? call(config.from, state) : state.offset; - state.offset = state.lastOffset; - state.startTime = state.timeStamp = event.timeStamp; - } - } - computeValues(values) { - const state = this.state; - state._values = values; - state.values = this.config.transform(values); - } - computeInitial() { - const state = this.state; - state._initial = state._values; - state.initial = state.values; - } - compute(event) { - const { - state, - config, - shared - } = this; - state.args = this.args; - let dt = 0; - if (event) { - state.event = event; - if (config.preventDefault && event.cancelable) - state.event.preventDefault(); - state.type = event.type; - shared.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size; - shared.locked = !!document.pointerLockElement; - Object.assign(shared, getEventDetails(event)); - shared.down = shared.pressed = shared.buttons % 2 === 1 || shared.touches > 0; - dt = event.timeStamp - state.timeStamp; - state.timeStamp = event.timeStamp; - state.elapsedTime = state.timeStamp - state.startTime; - } - if (state._active) { - const _absoluteDelta = state._delta.map(Math.abs); - maths.V.addTo(state._distance, _absoluteDelta); - } - if (this.axisIntent) - this.axisIntent(event); - const [_m0, _m1] = state._movement; - const [t0, t1] = config.threshold; - const { - _step, - values - } = state; - if (config.hasCustomTransform) { - if (_step[0] === false) - _step[0] = Math.abs(_m0) >= t0 && values[0]; - if (_step[1] === false) - _step[1] = Math.abs(_m1) >= t1 && values[1]; - } else { - if (_step[0] === false) - _step[0] = Math.abs(_m0) >= t0 && Math.sign(_m0) * t0; - if (_step[1] === false) - _step[1] = Math.abs(_m1) >= t1 && Math.sign(_m1) * t1; - } - state.intentional = _step[0] !== false || _step[1] !== false; - if (!state.intentional) - return; - const movement = [0, 0]; - if (config.hasCustomTransform) { - const [v0, v1] = values; - movement[0] = _step[0] !== false ? v0 - _step[0] : 0; - movement[1] = _step[1] !== false ? v1 - _step[1] : 0; - } else { - movement[0] = _step[0] !== false ? _m0 - _step[0] : 0; - movement[1] = _step[1] !== false ? _m1 - _step[1] : 0; - } - if (this.restrictToAxis && !state._blocked) - this.restrictToAxis(movement); - const previousOffset = state.offset; - const gestureIsActive = state._active && !state._blocked || state.active; - if (gestureIsActive) { - state.first = state._active && !state.active; - state.last = !state._active && state.active; - state.active = shared[this.ingKey] = state._active; - if (event) { - if (state.first) { - if ("bounds" in config) - state._bounds = call(config.bounds, state); - if (this.setup) - this.setup(); - } - state.movement = movement; - this.computeOffset(); - } - } - const [ox, oy] = state.offset; - const [[x0, x1], [y0, y1]] = state._bounds; - state.overflow = [ox < x0 ? -1 : ox > x1 ? 1 : 0, oy < y0 ? -1 : oy > y1 ? 1 : 0]; - state._movementBound[0] = state.overflow[0] ? state._movementBound[0] === false ? state._movement[0] : state._movementBound[0] : false; - state._movementBound[1] = state.overflow[1] ? state._movementBound[1] === false ? state._movement[1] : state._movementBound[1] : false; - const rubberband = state._active ? config.rubberband || [0, 0] : [0, 0]; - state.offset = maths.computeRubberband(state._bounds, state.offset, rubberband); - state.delta = maths.V.sub(state.offset, previousOffset); - this.computeMovement(); - if (gestureIsActive && (!state.last || dt > BEFORE_LAST_KINEMATICS_DELAY)) { - state.delta = maths.V.sub(state.offset, previousOffset); - const absoluteDelta = state.delta.map(Math.abs); - maths.V.addTo(state.distance, absoluteDelta); - state.direction = state.delta.map(Math.sign); - state._direction = state._delta.map(Math.sign); - if (!state.first && dt > 0) { - state.velocity = [absoluteDelta[0] / dt, absoluteDelta[1] / dt]; - state.timeDelta = dt; - } - } - } - emit() { - const state = this.state; - const shared = this.shared; - const config = this.config; - if (!state._active) - this.clean(); - if ((state._blocked || !state.intentional) && !state._force && !config.triggerAllEvents) - return; - const memo28 = this.handler(_objectSpread22(_objectSpread22(_objectSpread22({}, shared), state), {}, { - [this.aliasKey]: state.values - })); - if (memo28 !== void 0) - state.memo = memo28; - } - clean() { - this.eventStore.clean(); - this.timeoutStore.clean(); - } - }; - function selectAxis([dx, dy], threshold) { - const absDx = Math.abs(dx); - const absDy = Math.abs(dy); - if (absDx > absDy && absDx > threshold) { - return "x"; - } - if (absDy > absDx && absDy > threshold) { - return "y"; - } - return void 0; - } - var CoordinatesEngine = class extends Engine { - constructor(...args) { - super(...args); - _defineProperty2(this, "aliasKey", "xy"); - } - reset() { - super.reset(); - this.state.axis = void 0; - } - init() { - this.state.offset = [0, 0]; - this.state.lastOffset = [0, 0]; - } - computeOffset() { - this.state.offset = maths.V.add(this.state.lastOffset, this.state.movement); - } - computeMovement() { - this.state.movement = maths.V.sub(this.state.offset, this.state.lastOffset); - } - axisIntent(event) { - const state = this.state; - const config = this.config; - if (!state.axis && event) { - const threshold = typeof config.axisThreshold === "object" ? config.axisThreshold[getPointerType(event)] : config.axisThreshold; - state.axis = selectAxis(state._movement, threshold); - } - state._blocked = (config.lockDirection || !!config.axis) && !state.axis || !!config.axis && config.axis !== state.axis; - } - restrictToAxis(v) { - if (this.config.axis || this.config.lockDirection) { - switch (this.state.axis) { - case "x": - v[1] = 0; - break; - case "y": - v[0] = 0; - break; - } - } - } - }; - var identity = (v) => v; - var DEFAULT_RUBBERBAND = 0.15; - var commonConfigResolver = { - enabled(value = true) { - return value; - }, - eventOptions(value, _k, config) { - return _objectSpread22(_objectSpread22({}, config.shared.eventOptions), value); - }, - preventDefault(value = false) { - return value; - }, - triggerAllEvents(value = false) { - return value; - }, - rubberband(value = 0) { - switch (value) { - case true: - return [DEFAULT_RUBBERBAND, DEFAULT_RUBBERBAND]; - case false: - return [0, 0]; - default: - return maths.V.toVector(value); - } - }, - from(value) { - if (typeof value === "function") - return value; - if (value != null) - return maths.V.toVector(value); - }, - transform(value, _k, config) { - const transform = value || config.shared.transform; - this.hasCustomTransform = !!transform; - return transform || identity; - }, - threshold(value) { - return maths.V.toVector(value, 0); - } - }; - var DEFAULT_AXIS_THRESHOLD = 0; - var coordinatesConfigResolver = _objectSpread22(_objectSpread22({}, commonConfigResolver), {}, { - axis(_v, _k, { - axis - }) { - this.lockDirection = axis === "lock"; - if (!this.lockDirection) - return axis; - }, - axisThreshold(value = DEFAULT_AXIS_THRESHOLD) { - return value; - }, - bounds(value = {}) { - if (typeof value === "function") { - return (state) => coordinatesConfigResolver.bounds(value(state)); - } - if ("current" in value) { - return () => value.current; - } - if (typeof HTMLElement === "function" && value instanceof HTMLElement) { - return value; - } - const { - left = -Infinity, - right = Infinity, - top = -Infinity, - bottom = Infinity - } = value; - return [[left, right], [top, bottom]]; - } - }); - var KEYS_DELTA_MAP = { - ArrowRight: (displacement, factor = 1) => [displacement * factor, 0], - ArrowLeft: (displacement, factor = 1) => [-1 * displacement * factor, 0], - ArrowUp: (displacement, factor = 1) => [0, -1 * displacement * factor], - ArrowDown: (displacement, factor = 1) => [0, displacement * factor] - }; - var DragEngine = class extends CoordinatesEngine { - constructor(...args) { - super(...args); - _defineProperty2(this, "ingKey", "dragging"); - } - reset() { - super.reset(); - const state = this.state; - state._pointerId = void 0; - state._pointerActive = false; - state._keyboardActive = false; - state._preventScroll = false; - state._delayed = false; - state.swipe = [0, 0]; - state.tap = false; - state.canceled = false; - state.cancel = this.cancel.bind(this); - } - setup() { - const state = this.state; - if (state._bounds instanceof HTMLElement) { - const boundRect = state._bounds.getBoundingClientRect(); - const targetRect = state.currentTarget.getBoundingClientRect(); - const _bounds = { - left: boundRect.left - targetRect.left + state.offset[0], - right: boundRect.right - targetRect.right + state.offset[0], - top: boundRect.top - targetRect.top + state.offset[1], - bottom: boundRect.bottom - targetRect.bottom + state.offset[1] - }; - state._bounds = coordinatesConfigResolver.bounds(_bounds); - } - } - cancel() { - const state = this.state; - if (state.canceled) - return; - state.canceled = true; - state._active = false; - setTimeout(() => { - this.compute(); - this.emit(); - }, 0); - } - setActive() { - this.state._active = this.state._pointerActive || this.state._keyboardActive; - } - clean() { - this.pointerClean(); - this.state._pointerActive = false; - this.state._keyboardActive = false; - super.clean(); - } - pointerDown(event) { - const config = this.config; - const state = this.state; - if (event.buttons != null && (Array.isArray(config.pointerButtons) ? !config.pointerButtons.includes(event.buttons) : config.pointerButtons !== -1 && config.pointerButtons !== event.buttons)) - return; - const ctrlIds = this.ctrl.setEventIds(event); - if (config.pointerCapture) { - event.target.setPointerCapture(event.pointerId); - } - if (ctrlIds && ctrlIds.size > 1 && state._pointerActive) - return; - this.start(event); - this.setupPointer(event); - state._pointerId = pointerId(event); - state._pointerActive = true; - this.computeValues(pointerValues(event)); - this.computeInitial(); - if (config.preventScrollAxis && getPointerType(event) !== "mouse") { - state._active = false; - this.setupScrollPrevention(event); - } else if (config.delay > 0) { - this.setupDelayTrigger(event); - if (config.triggerAllEvents) { - this.compute(event); - this.emit(); - } - } else { - this.startPointerDrag(event); - } - } - startPointerDrag(event) { - const state = this.state; - state._active = true; - state._preventScroll = true; - state._delayed = false; - this.compute(event); - this.emit(); - } - pointerMove(event) { - const state = this.state; - const config = this.config; - if (!state._pointerActive) - return; - const id = pointerId(event); - if (state._pointerId !== void 0 && id !== state._pointerId) - return; - const _values = pointerValues(event); - if (document.pointerLockElement === event.target) { - state._delta = [event.movementX, event.movementY]; - } else { - state._delta = maths.V.sub(_values, state._values); - this.computeValues(_values); - } - maths.V.addTo(state._movement, state._delta); - this.compute(event); - if (state._delayed && state.intentional) { - this.timeoutStore.remove("dragDelay"); - state.active = false; - this.startPointerDrag(event); - return; - } - if (config.preventScrollAxis && !state._preventScroll) { - if (state.axis) { - if (state.axis === config.preventScrollAxis || config.preventScrollAxis === "xy") { - state._active = false; - this.clean(); - return; - } else { - this.timeoutStore.remove("startPointerDrag"); - this.startPointerDrag(event); - return; - } - } else { - return; - } - } - this.emit(); - } - pointerUp(event) { - this.ctrl.setEventIds(event); - try { - if (this.config.pointerCapture && event.target.hasPointerCapture(event.pointerId)) { - ; - event.target.releasePointerCapture(event.pointerId); - } - } catch (_unused) { - } - const state = this.state; - const config = this.config; - if (!state._active || !state._pointerActive) - return; - const id = pointerId(event); - if (state._pointerId !== void 0 && id !== state._pointerId) - return; - this.state._pointerActive = false; - this.setActive(); - this.compute(event); - const [dx, dy] = state._distance; - state.tap = dx <= config.tapsThreshold && dy <= config.tapsThreshold; - if (state.tap && config.filterTaps) { - state._force = true; - } else { - const [_dx, _dy] = state._delta; - const [_mx, _my] = state._movement; - const [svx, svy] = config.swipe.velocity; - const [sx, sy] = config.swipe.distance; - const sdt = config.swipe.duration; - if (state.elapsedTime < sdt) { - const _vx = Math.abs(_dx / state.timeDelta); - const _vy = Math.abs(_dy / state.timeDelta); - if (_vx > svx && Math.abs(_mx) > sx) - state.swipe[0] = Math.sign(_dx); - if (_vy > svy && Math.abs(_my) > sy) - state.swipe[1] = Math.sign(_dy); - } - } - this.emit(); - } - pointerClick(event) { - if (!this.state.tap && event.detail > 0) { - event.preventDefault(); - event.stopPropagation(); - } - } - setupPointer(event) { - const config = this.config; - const device = config.device; - if (config.pointerLock) { - event.currentTarget.requestPointerLock(); - } - if (!config.pointerCapture) { - this.eventStore.add(this.sharedConfig.window, device, "change", this.pointerMove.bind(this)); - this.eventStore.add(this.sharedConfig.window, device, "end", this.pointerUp.bind(this)); - this.eventStore.add(this.sharedConfig.window, device, "cancel", this.pointerUp.bind(this)); - } - } - pointerClean() { - if (this.config.pointerLock && document.pointerLockElement === this.state.currentTarget) { - document.exitPointerLock(); - } - } - preventScroll(event) { - if (this.state._preventScroll && event.cancelable) { - event.preventDefault(); - } - } - setupScrollPrevention(event) { - this.state._preventScroll = false; - persistEvent(event); - const remove2 = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), { - passive: false - }); - this.eventStore.add(this.sharedConfig.window, "touch", "end", remove2); - this.eventStore.add(this.sharedConfig.window, "touch", "cancel", remove2); - this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, event); - } - setupDelayTrigger(event) { - this.state._delayed = true; - this.timeoutStore.add("dragDelay", () => { - this.state._step = [0, 0]; - this.startPointerDrag(event); - }, this.config.delay); - } - keyDown(event) { - const deltaFn = KEYS_DELTA_MAP[event.key]; - if (deltaFn) { - const state = this.state; - const factor = event.shiftKey ? 10 : event.altKey ? 0.1 : 1; - this.start(event); - state._delta = deltaFn(this.config.keyboardDisplacement, factor); - state._keyboardActive = true; - maths.V.addTo(state._movement, state._delta); - this.compute(event); - this.emit(); - } - } - keyUp(event) { - if (!(event.key in KEYS_DELTA_MAP)) - return; - this.state._keyboardActive = false; - this.setActive(); - this.compute(event); - this.emit(); - } - bind(bindFunction) { - const device = this.config.device; - bindFunction(device, "start", this.pointerDown.bind(this)); - if (this.config.pointerCapture) { - bindFunction(device, "change", this.pointerMove.bind(this)); - bindFunction(device, "end", this.pointerUp.bind(this)); - bindFunction(device, "cancel", this.pointerUp.bind(this)); - bindFunction("lostPointerCapture", "", this.pointerUp.bind(this)); - } - if (this.config.keys) { - bindFunction("key", "down", this.keyDown.bind(this)); - bindFunction("key", "up", this.keyUp.bind(this)); - } - if (this.config.filterTaps) { - bindFunction("click", "", this.pointerClick.bind(this), { - capture: true, - passive: false - }); - } - } - }; - function persistEvent(event) { - "persist" in event && typeof event.persist === "function" && event.persist(); - } - var isBrowser = typeof window !== "undefined" && window.document && window.document.createElement; - function supportsTouchEvents() { - return isBrowser && "ontouchstart" in window; - } - function isTouchScreen() { - return supportsTouchEvents() || isBrowser && window.navigator.maxTouchPoints > 1; - } - function supportsPointerEvents() { - return isBrowser && "onpointerdown" in window; - } - function supportsPointerLock() { - return isBrowser && "exitPointerLock" in window.document; - } - function supportsGestureEvents() { - try { - return "constructor" in GestureEvent; - } catch (e) { - return false; - } - } - var SUPPORT = { - isBrowser, - gesture: supportsGestureEvents(), - touch: supportsTouchEvents(), - touchscreen: isTouchScreen(), - pointer: supportsPointerEvents(), - pointerLock: supportsPointerLock() - }; - var DEFAULT_PREVENT_SCROLL_DELAY = 250; - var DEFAULT_DRAG_DELAY = 180; - var DEFAULT_SWIPE_VELOCITY = 0.5; - var DEFAULT_SWIPE_DISTANCE = 50; - var DEFAULT_SWIPE_DURATION = 250; - var DEFAULT_KEYBOARD_DISPLACEMENT = 10; - var DEFAULT_DRAG_AXIS_THRESHOLD = { - mouse: 0, - touch: 0, - pen: 8 - }; - var dragConfigResolver = _objectSpread22(_objectSpread22({}, coordinatesConfigResolver), {}, { - device(_v, _k, { - pointer: { - touch = false, - lock = false, - mouse = false - } = {} - }) { - this.pointerLock = lock && SUPPORT.pointerLock; - if (SUPPORT.touch && touch) - return "touch"; - if (this.pointerLock) - return "mouse"; - if (SUPPORT.pointer && !mouse) - return "pointer"; - if (SUPPORT.touch) - return "touch"; - return "mouse"; - }, - preventScrollAxis(value, _k, { - preventScroll - }) { - this.preventScrollDelay = typeof preventScroll === "number" ? preventScroll : preventScroll || preventScroll === void 0 && value ? DEFAULT_PREVENT_SCROLL_DELAY : void 0; - if (!SUPPORT.touchscreen || preventScroll === false) - return void 0; - return value ? value : preventScroll !== void 0 ? "y" : void 0; - }, - pointerCapture(_v, _k, { - pointer: { - capture = true, - buttons = 1, - keys = true - } = {} - }) { - this.pointerButtons = buttons; - this.keys = keys; - return !this.pointerLock && this.device === "pointer" && capture; - }, - threshold(value, _k, { - filterTaps = false, - tapsThreshold = 3, - axis = void 0 - }) { - const threshold = maths.V.toVector(value, filterTaps ? tapsThreshold : axis ? 1 : 0); - this.filterTaps = filterTaps; - this.tapsThreshold = tapsThreshold; - return threshold; - }, - swipe({ - velocity = DEFAULT_SWIPE_VELOCITY, - distance = DEFAULT_SWIPE_DISTANCE, - duration = DEFAULT_SWIPE_DURATION - } = {}) { - return { - velocity: this.transform(maths.V.toVector(velocity)), - distance: this.transform(maths.V.toVector(distance)), - duration - }; - }, - delay(value = 0) { - switch (value) { - case true: - return DEFAULT_DRAG_DELAY; - case false: - return 0; - default: - return value; - } - }, - axisThreshold(value) { - if (!value) - return DEFAULT_DRAG_AXIS_THRESHOLD; - return _objectSpread22(_objectSpread22({}, DEFAULT_DRAG_AXIS_THRESHOLD), value); - }, - keyboardDisplacement(value = DEFAULT_KEYBOARD_DISPLACEMENT) { - return value; - } - }); - function clampStateInternalMovementToBounds(state) { - const [ox, oy] = state.overflow; - const [dx, dy] = state._delta; - const [dirx, diry] = state._direction; - if (ox < 0 && dx > 0 && dirx < 0 || ox > 0 && dx < 0 && dirx > 0) { - state._movement[0] = state._movementBound[0]; - } - if (oy < 0 && dy > 0 && diry < 0 || oy > 0 && dy < 0 && diry > 0) { - state._movement[1] = state._movementBound[1]; - } - } - var SCALE_ANGLE_RATIO_INTENT_DEG = 30; - var PINCH_WHEEL_RATIO = 100; - var PinchEngine = class extends Engine { - constructor(...args) { - super(...args); - _defineProperty2(this, "ingKey", "pinching"); - _defineProperty2(this, "aliasKey", "da"); - } - init() { - this.state.offset = [1, 0]; - this.state.lastOffset = [1, 0]; - this.state._pointerEvents = /* @__PURE__ */ new Map(); - } - reset() { - super.reset(); - const state = this.state; - state._touchIds = []; - state.canceled = false; - state.cancel = this.cancel.bind(this); - state.turns = 0; - } - computeOffset() { - const { - type, - movement, - lastOffset - } = this.state; - if (type === "wheel") { - this.state.offset = maths.V.add(movement, lastOffset); - } else { - this.state.offset = [(1 + movement[0]) * lastOffset[0], movement[1] + lastOffset[1]]; - } - } - computeMovement() { - const { - offset: offset4, - lastOffset - } = this.state; - this.state.movement = [offset4[0] / lastOffset[0], offset4[1] - lastOffset[1]]; - } - axisIntent() { - const state = this.state; - const [_m0, _m1] = state._movement; - if (!state.axis) { - const axisMovementDifference = Math.abs(_m0) * SCALE_ANGLE_RATIO_INTENT_DEG - Math.abs(_m1); - if (axisMovementDifference < 0) - state.axis = "angle"; - else if (axisMovementDifference > 0) - state.axis = "scale"; - } - } - restrictToAxis(v) { - if (this.config.lockDirection) { - if (this.state.axis === "scale") - v[1] = 0; - else if (this.state.axis === "angle") - v[0] = 0; - } - } - cancel() { - const state = this.state; - if (state.canceled) - return; - setTimeout(() => { - state.canceled = true; - state._active = false; - this.compute(); - this.emit(); - }, 0); - } - touchStart(event) { - this.ctrl.setEventIds(event); - const state = this.state; - const ctrlTouchIds = this.ctrl.touchIds; - if (state._active) { - if (state._touchIds.every((id) => ctrlTouchIds.has(id))) - return; - } - if (ctrlTouchIds.size < 2) - return; - this.start(event); - state._touchIds = Array.from(ctrlTouchIds).slice(0, 2); - const payload = touchDistanceAngle(event, state._touchIds); - if (!payload) - return; - this.pinchStart(event, payload); - } - pointerStart(event) { - if (event.buttons != null && event.buttons % 2 !== 1) - return; - this.ctrl.setEventIds(event); - event.target.setPointerCapture(event.pointerId); - const state = this.state; - const _pointerEvents = state._pointerEvents; - const ctrlPointerIds = this.ctrl.pointerIds; - if (state._active) { - if (Array.from(_pointerEvents.keys()).every((id) => ctrlPointerIds.has(id))) - return; - } - if (_pointerEvents.size < 2) { - _pointerEvents.set(event.pointerId, event); - } - if (state._pointerEvents.size < 2) - return; - this.start(event); - const payload = distanceAngle(...Array.from(_pointerEvents.values())); - if (!payload) - return; - this.pinchStart(event, payload); - } - pinchStart(event, payload) { - const state = this.state; - state.origin = payload.origin; - this.computeValues([payload.distance, payload.angle]); - this.computeInitial(); - this.compute(event); - this.emit(); - } - touchMove(event) { - if (!this.state._active) - return; - const payload = touchDistanceAngle(event, this.state._touchIds); - if (!payload) - return; - this.pinchMove(event, payload); - } - pointerMove(event) { - const _pointerEvents = this.state._pointerEvents; - if (_pointerEvents.has(event.pointerId)) { - _pointerEvents.set(event.pointerId, event); - } - if (!this.state._active) - return; - const payload = distanceAngle(...Array.from(_pointerEvents.values())); - if (!payload) - return; - this.pinchMove(event, payload); - } - pinchMove(event, payload) { - const state = this.state; - const prev_a = state._values[1]; - const delta_a = payload.angle - prev_a; - let delta_turns = 0; - if (Math.abs(delta_a) > 270) - delta_turns += Math.sign(delta_a); - this.computeValues([payload.distance, payload.angle - 360 * delta_turns]); - state.origin = payload.origin; - state.turns = delta_turns; - state._movement = [state._values[0] / state._initial[0] - 1, state._values[1] - state._initial[1]]; - this.compute(event); - this.emit(); - } - touchEnd(event) { - this.ctrl.setEventIds(event); - if (!this.state._active) - return; - if (this.state._touchIds.some((id) => !this.ctrl.touchIds.has(id))) { - this.state._active = false; - this.compute(event); - this.emit(); - } - } - pointerEnd(event) { - const state = this.state; - this.ctrl.setEventIds(event); - try { - event.target.releasePointerCapture(event.pointerId); - } catch (_unused) { - } - if (state._pointerEvents.has(event.pointerId)) { - state._pointerEvents.delete(event.pointerId); - } - if (!state._active) - return; - if (state._pointerEvents.size < 2) { - state._active = false; - this.compute(event); - this.emit(); - } - } - gestureStart(event) { - if (event.cancelable) - event.preventDefault(); - const state = this.state; - if (state._active) - return; - this.start(event); - this.computeValues([event.scale, event.rotation]); - state.origin = [event.clientX, event.clientY]; - this.compute(event); - this.emit(); - } - gestureMove(event) { - if (event.cancelable) - event.preventDefault(); - if (!this.state._active) - return; - const state = this.state; - this.computeValues([event.scale, event.rotation]); - state.origin = [event.clientX, event.clientY]; - const _previousMovement = state._movement; - state._movement = [event.scale - 1, event.rotation]; - state._delta = maths.V.sub(state._movement, _previousMovement); - this.compute(event); - this.emit(); - } - gestureEnd(event) { - if (!this.state._active) - return; - this.state._active = false; - this.compute(event); - this.emit(); - } - wheel(event) { - const modifierKey = this.config.modifierKey; - if (modifierKey && (Array.isArray(modifierKey) ? !modifierKey.find((k) => event[k]) : !event[modifierKey])) - return; - if (!this.state._active) - this.wheelStart(event); - else - this.wheelChange(event); - this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this)); - } - wheelStart(event) { - this.start(event); - this.wheelChange(event); - } - wheelChange(event) { - const isR3f = "uv" in event; - if (!isR3f) { - if (event.cancelable) { - event.preventDefault(); - } - } - const state = this.state; - state._delta = [-wheelValues(event)[1] / PINCH_WHEEL_RATIO * state.offset[0], 0]; - maths.V.addTo(state._movement, state._delta); - clampStateInternalMovementToBounds(state); - this.state.origin = [event.clientX, event.clientY]; - this.compute(event); - this.emit(); - } - wheelEnd() { - if (!this.state._active) - return; - this.state._active = false; - this.compute(); - this.emit(); - } - bind(bindFunction) { - const device = this.config.device; - if (!!device) { - bindFunction(device, "start", this[device + "Start"].bind(this)); - bindFunction(device, "change", this[device + "Move"].bind(this)); - bindFunction(device, "end", this[device + "End"].bind(this)); - bindFunction(device, "cancel", this[device + "End"].bind(this)); - bindFunction("lostPointerCapture", "", this[device + "End"].bind(this)); - } - if (this.config.pinchOnWheel) { - bindFunction("wheel", "", this.wheel.bind(this), { - passive: false - }); - } - } - }; - var pinchConfigResolver = _objectSpread22(_objectSpread22({}, commonConfigResolver), {}, { - device(_v, _k, { - shared, - pointer: { - touch = false - } = {} - }) { - const sharedConfig = shared; - if (sharedConfig.target && !SUPPORT.touch && SUPPORT.gesture) - return "gesture"; - if (SUPPORT.touch && touch) - return "touch"; - if (SUPPORT.touchscreen) { - if (SUPPORT.pointer) - return "pointer"; - if (SUPPORT.touch) - return "touch"; - } - }, - bounds(_v, _k, { - scaleBounds = {}, - angleBounds = {} - }) { - const _scaleBounds = (state) => { - const D = assignDefault(call(scaleBounds, state), { - min: -Infinity, - max: Infinity - }); - return [D.min, D.max]; - }; - const _angleBounds = (state) => { - const A = assignDefault(call(angleBounds, state), { - min: -Infinity, - max: Infinity - }); - return [A.min, A.max]; - }; - if (typeof scaleBounds !== "function" && typeof angleBounds !== "function") - return [_scaleBounds(), _angleBounds()]; - return (state) => [_scaleBounds(state), _angleBounds(state)]; - }, - threshold(value, _k, config) { - this.lockDirection = config.axis === "lock"; - const threshold = maths.V.toVector(value, this.lockDirection ? [0.1, 3] : 0); - return threshold; - }, - modifierKey(value) { - if (value === void 0) - return "ctrlKey"; - return value; - }, - pinchOnWheel(value = true) { - return value; - } - }); - var MoveEngine = class extends CoordinatesEngine { - constructor(...args) { - super(...args); - _defineProperty2(this, "ingKey", "moving"); - } - move(event) { - if (this.config.mouseOnly && event.pointerType !== "mouse") - return; - if (!this.state._active) - this.moveStart(event); - else - this.moveChange(event); - this.timeoutStore.add("moveEnd", this.moveEnd.bind(this)); - } - moveStart(event) { - this.start(event); - this.computeValues(pointerValues(event)); - this.compute(event); - this.computeInitial(); - this.emit(); - } - moveChange(event) { - if (!this.state._active) - return; - const values = pointerValues(event); - const state = this.state; - state._delta = maths.V.sub(values, state._values); - maths.V.addTo(state._movement, state._delta); - this.computeValues(values); - this.compute(event); - this.emit(); - } - moveEnd(event) { - if (!this.state._active) - return; - this.state._active = false; - this.compute(event); - this.emit(); - } - bind(bindFunction) { - bindFunction("pointer", "change", this.move.bind(this)); - bindFunction("pointer", "leave", this.moveEnd.bind(this)); - } - }; - var moveConfigResolver = _objectSpread22(_objectSpread22({}, coordinatesConfigResolver), {}, { - mouseOnly: (value = true) => value - }); - var ScrollEngine = class extends CoordinatesEngine { - constructor(...args) { - super(...args); - _defineProperty2(this, "ingKey", "scrolling"); - } - scroll(event) { - if (!this.state._active) - this.start(event); - this.scrollChange(event); - this.timeoutStore.add("scrollEnd", this.scrollEnd.bind(this)); - } - scrollChange(event) { - if (event.cancelable) - event.preventDefault(); - const state = this.state; - const values = scrollValues(event); - state._delta = maths.V.sub(values, state._values); - maths.V.addTo(state._movement, state._delta); - this.computeValues(values); - this.compute(event); - this.emit(); - } - scrollEnd() { - if (!this.state._active) - return; - this.state._active = false; - this.compute(); - this.emit(); - } - bind(bindFunction) { - bindFunction("scroll", "", this.scroll.bind(this)); - } - }; - var scrollConfigResolver = coordinatesConfigResolver; - var WheelEngine = class extends CoordinatesEngine { - constructor(...args) { - super(...args); - _defineProperty2(this, "ingKey", "wheeling"); - } - wheel(event) { - if (!this.state._active) - this.start(event); - this.wheelChange(event); - this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this)); - } - wheelChange(event) { - const state = this.state; - state._delta = wheelValues(event); - maths.V.addTo(state._movement, state._delta); - clampStateInternalMovementToBounds(state); - this.compute(event); - this.emit(); - } - wheelEnd() { - if (!this.state._active) - return; - this.state._active = false; - this.compute(); - this.emit(); - } - bind(bindFunction) { - bindFunction("wheel", "", this.wheel.bind(this)); - } - }; - var wheelConfigResolver = coordinatesConfigResolver; - var HoverEngine = class extends CoordinatesEngine { - constructor(...args) { - super(...args); - _defineProperty2(this, "ingKey", "hovering"); - } - enter(event) { - if (this.config.mouseOnly && event.pointerType !== "mouse") - return; - this.start(event); - this.computeValues(pointerValues(event)); - this.compute(event); - this.emit(); - } - leave(event) { - if (this.config.mouseOnly && event.pointerType !== "mouse") - return; - const state = this.state; - if (!state._active) - return; - state._active = false; - const values = pointerValues(event); - state._movement = state._delta = maths.V.sub(values, state._values); - this.computeValues(values); - this.compute(event); - state.delta = state.movement; - this.emit(); - } - bind(bindFunction) { - bindFunction("pointer", "enter", this.enter.bind(this)); - bindFunction("pointer", "leave", this.leave.bind(this)); - } - }; - var hoverConfigResolver = _objectSpread22(_objectSpread22({}, coordinatesConfigResolver), {}, { - mouseOnly: (value = true) => value - }); - var EngineMap = /* @__PURE__ */ new Map(); - var ConfigResolverMap = /* @__PURE__ */ new Map(); - function registerAction2(action) { - EngineMap.set(action.key, action.engine); - ConfigResolverMap.set(action.key, action.resolver); - } - var dragAction2 = { - key: "drag", - engine: DragEngine, - resolver: dragConfigResolver - }; - var hoverAction2 = { - key: "hover", - engine: HoverEngine, - resolver: hoverConfigResolver - }; - var moveAction2 = { - key: "move", - engine: MoveEngine, - resolver: moveConfigResolver - }; - var pinchAction3 = { - key: "pinch", - engine: PinchEngine, - resolver: pinchConfigResolver - }; - var scrollAction2 = { - key: "scroll", - engine: ScrollEngine, - resolver: scrollConfigResolver - }; - var wheelAction3 = { - key: "wheel", - engine: WheelEngine, - resolver: wheelConfigResolver - }; - exports.ConfigResolverMap = ConfigResolverMap; - exports.EngineMap = EngineMap; - exports.SUPPORT = SUPPORT; - exports._defineProperty = _defineProperty2; - exports._objectSpread2 = _objectSpread22; - exports.chain = chain; - exports.dragAction = dragAction2; - exports.hoverAction = hoverAction2; - exports.isTouch = isTouch; - exports.moveAction = moveAction2; - exports.parseProp = parseProp; - exports.pinchAction = pinchAction3; - exports.registerAction = registerAction2; - exports.scrollAction = scrollAction2; - exports.toDomEventType = toDomEventType; - exports.toHandlerProp = toHandlerProp; - exports.touchIds = touchIds; - exports.wheelAction = wheelAction3; - } -}); - -// node_modules/@use-gesture/core/actions/dist/use-gesture-core-actions.cjs.prod.js -var require_use_gesture_core_actions_cjs_prod = __commonJS({ - "node_modules/@use-gesture/core/actions/dist/use-gesture-core-actions.cjs.prod.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var actions_dist_useGestureCoreActions = require_actions_89e642c9_cjs_prod(); - require_maths_83bc6f64_cjs_prod(); - exports.ConfigResolverMap = actions_dist_useGestureCoreActions.ConfigResolverMap; - exports.EngineMap = actions_dist_useGestureCoreActions.EngineMap; - exports.dragAction = actions_dist_useGestureCoreActions.dragAction; - exports.hoverAction = actions_dist_useGestureCoreActions.hoverAction; - exports.moveAction = actions_dist_useGestureCoreActions.moveAction; - exports.pinchAction = actions_dist_useGestureCoreActions.pinchAction; - exports.registerAction = actions_dist_useGestureCoreActions.registerAction; - exports.scrollAction = actions_dist_useGestureCoreActions.scrollAction; - exports.wheelAction = actions_dist_useGestureCoreActions.wheelAction; - } -}); - -// node_modules/@use-gesture/core/actions/dist/use-gesture-core-actions.cjs.js -var require_use_gesture_core_actions_cjs = __commonJS({ - "node_modules/@use-gesture/core/actions/dist/use-gesture-core-actions.cjs.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_use_gesture_core_actions_cjs_prod(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/@use-gesture/core/dist/use-gesture-core.cjs.prod.js -var require_use_gesture_core_cjs_prod = __commonJS({ - "node_modules/@use-gesture/core/dist/use-gesture-core.cjs.prod.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var actions_dist_useGestureCoreActions = require_actions_89e642c9_cjs_prod(); - require_maths_83bc6f64_cjs_prod(); - function _objectWithoutPropertiesLoose2(source, excluded) { - if (source == null) - return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) - continue; - target[key] = source[key]; - } - return target; - } - function _objectWithoutProperties2(source, excluded) { - if (source == null) - return {}; - var target = _objectWithoutPropertiesLoose2(source, excluded); - var key, i; - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - for (i = 0; i < sourceSymbolKeys.length; i++) { - key = sourceSymbolKeys[i]; - if (excluded.indexOf(key) >= 0) - continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key)) - continue; - target[key] = source[key]; - } - } - return target; - } - var sharedConfigResolver = { - target(value) { - if (value) { - return () => "current" in value ? value.current : value; - } - return void 0; - }, - enabled(value = true) { - return value; - }, - window(value = actions_dist_useGestureCoreActions.SUPPORT.isBrowser ? window : void 0) { - return value; - }, - eventOptions({ - passive = true, - capture = false - } = {}) { - return { - passive, - capture - }; - }, - transform(value) { - return value; - } - }; - var _excluded2 = ["target", "eventOptions", "window", "enabled", "transform"]; - function resolveWith(config = {}, resolvers) { - const result = {}; - for (const [key, resolver] of Object.entries(resolvers)) { - switch (typeof resolver) { - case "function": - { - result[key] = resolver.call(result, config[key], key, config); - } - break; - case "object": - result[key] = resolveWith(config[key], resolver); - break; - case "boolean": - if (resolver) - result[key] = config[key]; - break; - } - } - return result; - } - function parse2(newConfig, gestureKey, _config = {}) { - const _ref = newConfig, { - target, - eventOptions, - window: window3, - enabled, - transform - } = _ref, rest = _objectWithoutProperties2(_ref, _excluded2); - _config.shared = resolveWith({ - target, - eventOptions, - window: window3, - enabled, - transform - }, sharedConfigResolver); - if (gestureKey) { - const resolver = actions_dist_useGestureCoreActions.ConfigResolverMap.get(gestureKey); - _config[gestureKey] = resolveWith(actions_dist_useGestureCoreActions._objectSpread2({ - shared: _config.shared - }, rest), resolver); - } else { - for (const key in rest) { - const resolver = actions_dist_useGestureCoreActions.ConfigResolverMap.get(key); - if (resolver) { - _config[key] = resolveWith(actions_dist_useGestureCoreActions._objectSpread2({ - shared: _config.shared - }, rest[key]), resolver); - } - } - } - return _config; - } - var EventStore = class { - constructor(ctrl, gestureKey) { - actions_dist_useGestureCoreActions._defineProperty(this, "_listeners", /* @__PURE__ */ new Set()); - this._ctrl = ctrl; - this._gestureKey = gestureKey; - } - add(element, device, action, handler, options) { - const listeners = this._listeners; - const type = actions_dist_useGestureCoreActions.toDomEventType(device, action); - const _options = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}; - const eventOptions = actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, _options), options); - element.addEventListener(type, handler, eventOptions); - const remove2 = () => { - element.removeEventListener(type, handler, eventOptions); - listeners.delete(remove2); - }; - listeners.add(remove2); - return remove2; - } - clean() { - this._listeners.forEach((remove2) => remove2()); - this._listeners.clear(); - } - }; - var TimeoutStore = class { - constructor() { - actions_dist_useGestureCoreActions._defineProperty(this, "_timeouts", /* @__PURE__ */ new Map()); - } - add(key, callback, ms = 140, ...args) { - this.remove(key); - this._timeouts.set(key, window.setTimeout(callback, ms, ...args)); - } - remove(key) { - const timeout = this._timeouts.get(key); - if (timeout) - window.clearTimeout(timeout); - } - clean() { - this._timeouts.forEach((timeout) => void window.clearTimeout(timeout)); - this._timeouts.clear(); - } - }; - var Controller2 = class { - constructor(handlers) { - actions_dist_useGestureCoreActions._defineProperty(this, "gestures", /* @__PURE__ */ new Set()); - actions_dist_useGestureCoreActions._defineProperty(this, "_targetEventStore", new EventStore(this)); - actions_dist_useGestureCoreActions._defineProperty(this, "gestureEventStores", {}); - actions_dist_useGestureCoreActions._defineProperty(this, "gestureTimeoutStores", {}); - actions_dist_useGestureCoreActions._defineProperty(this, "handlers", {}); - actions_dist_useGestureCoreActions._defineProperty(this, "config", {}); - actions_dist_useGestureCoreActions._defineProperty(this, "pointerIds", /* @__PURE__ */ new Set()); - actions_dist_useGestureCoreActions._defineProperty(this, "touchIds", /* @__PURE__ */ new Set()); - actions_dist_useGestureCoreActions._defineProperty(this, "state", { - shared: { - shiftKey: false, - metaKey: false, - ctrlKey: false, - altKey: false - } - }); - resolveGestures(this, handlers); - } - setEventIds(event) { - if (actions_dist_useGestureCoreActions.isTouch(event)) { - this.touchIds = new Set(actions_dist_useGestureCoreActions.touchIds(event)); - return this.touchIds; - } else if ("pointerId" in event) { - if (event.type === "pointerup" || event.type === "pointercancel") - this.pointerIds.delete(event.pointerId); - else if (event.type === "pointerdown") - this.pointerIds.add(event.pointerId); - return this.pointerIds; - } - } - applyHandlers(handlers, nativeHandlers) { - this.handlers = handlers; - this.nativeHandlers = nativeHandlers; - } - applyConfig(config, gestureKey) { - this.config = parse2(config, gestureKey, this.config); - } - clean() { - this._targetEventStore.clean(); - for (const key of this.gestures) { - this.gestureEventStores[key].clean(); - this.gestureTimeoutStores[key].clean(); - } - } - effect() { - if (this.config.shared.target) - this.bind(); - return () => this._targetEventStore.clean(); - } - bind(...args) { - const sharedConfig = this.config.shared; - const props = {}; - let target; - if (sharedConfig.target) { - target = sharedConfig.target(); - if (!target) - return; - } - if (sharedConfig.enabled) { - for (const gestureKey of this.gestures) { - const gestureConfig = this.config[gestureKey]; - const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); - if (gestureConfig.enabled) { - const Engine = actions_dist_useGestureCoreActions.EngineMap.get(gestureKey); - new Engine(this, args, gestureKey).bind(bindFunction); - } - } - const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); - for (const eventKey in this.nativeHandlers) { - nativeBindFunction(eventKey, "", (event) => this.nativeHandlers[eventKey](actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, this.state.shared), {}, { - event, - args - })), void 0, true); - } - } - for (const handlerProp in props) { - props[handlerProp] = actions_dist_useGestureCoreActions.chain(...props[handlerProp]); - } - if (!target) - return props; - for (const handlerProp in props) { - const { - device, - capture, - passive - } = actions_dist_useGestureCoreActions.parseProp(handlerProp); - this._targetEventStore.add(target, device, "", props[handlerProp], { - capture, - passive - }); - } - } - }; - function setupGesture(ctrl, gestureKey) { - ctrl.gestures.add(gestureKey); - ctrl.gestureEventStores[gestureKey] = new EventStore(ctrl, gestureKey); - ctrl.gestureTimeoutStores[gestureKey] = new TimeoutStore(); - } - function resolveGestures(ctrl, internalHandlers) { - if (internalHandlers.drag) - setupGesture(ctrl, "drag"); - if (internalHandlers.wheel) - setupGesture(ctrl, "wheel"); - if (internalHandlers.scroll) - setupGesture(ctrl, "scroll"); - if (internalHandlers.move) - setupGesture(ctrl, "move"); - if (internalHandlers.pinch) - setupGesture(ctrl, "pinch"); - if (internalHandlers.hover) - setupGesture(ctrl, "hover"); - } - var bindToProps = (props, eventOptions, withPassiveOption) => (device, action, handler, options = {}, isNative = false) => { - var _options$capture, _options$passive; - const capture = (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : eventOptions.capture; - const passive = (_options$passive = options.passive) !== null && _options$passive !== void 0 ? _options$passive : eventOptions.passive; - let handlerProp = isNative ? device : actions_dist_useGestureCoreActions.toHandlerProp(device, action, capture); - if (withPassiveOption && passive) - handlerProp += "Passive"; - props[handlerProp] = props[handlerProp] || []; - props[handlerProp].push(handler); - }; - var RE_NOT_NATIVE = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/; - function sortHandlers(_handlers2) { - const native = {}; - const handlers = {}; - const actions = /* @__PURE__ */ new Set(); - for (let key in _handlers2) { - if (RE_NOT_NATIVE.test(key)) { - actions.add(RegExp.lastMatch); - handlers[key] = _handlers2[key]; - } else { - native[key] = _handlers2[key]; - } - } - return [handlers, native, actions]; - } - function registerGesture(actions, handlers, handlerKey, key, internalHandlers, config) { - if (!actions.has(handlerKey)) - return; - if (!actions_dist_useGestureCoreActions.EngineMap.has(key)) { - return; - } - const startKey = handlerKey + "Start"; - const endKey = handlerKey + "End"; - const fn = (state) => { - let memo28 = void 0; - if (state.first && startKey in handlers) - handlers[startKey](state); - if (handlerKey in handlers) - memo28 = handlers[handlerKey](state); - if (state.last && endKey in handlers) - handlers[endKey](state); - return memo28; - }; - internalHandlers[key] = fn; - config[key] = config[key] || {}; - } - function parseMergedHandlers2(mergedHandlers, mergedConfig) { - const [handlers, nativeHandlers, actions] = sortHandlers(mergedHandlers); - const internalHandlers = {}; - registerGesture(actions, handlers, "onDrag", "drag", internalHandlers, mergedConfig); - registerGesture(actions, handlers, "onWheel", "wheel", internalHandlers, mergedConfig); - registerGesture(actions, handlers, "onScroll", "scroll", internalHandlers, mergedConfig); - registerGesture(actions, handlers, "onPinch", "pinch", internalHandlers, mergedConfig); - registerGesture(actions, handlers, "onMove", "move", internalHandlers, mergedConfig); - registerGesture(actions, handlers, "onHover", "hover", internalHandlers, mergedConfig); - return { - handlers: internalHandlers, - config: mergedConfig, - nativeHandlers - }; - } - exports.Controller = Controller2; - exports.parseMergedHandlers = parseMergedHandlers2; - } -}); - -// node_modules/@use-gesture/core/dist/use-gesture-core.cjs.js -var require_use_gesture_core_cjs = __commonJS({ - "node_modules/@use-gesture/core/dist/use-gesture-core.cjs.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_use_gesture_core_cjs_prod(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/@use-gesture/core/utils/dist/use-gesture-core-utils.cjs.prod.js -var require_use_gesture_core_utils_cjs_prod = __commonJS({ - "node_modules/@use-gesture/core/utils/dist/use-gesture-core-utils.cjs.prod.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var maths = require_maths_83bc6f64_cjs_prod(); - exports.rubberbandIfOutOfBounds = maths.rubberbandIfOutOfBounds; - } -}); - -// node_modules/@use-gesture/core/utils/dist/use-gesture-core-utils.cjs.js -var require_use_gesture_core_utils_cjs = __commonJS({ - "node_modules/@use-gesture/core/utils/dist/use-gesture-core-utils.cjs.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_use_gesture_core_utils_cjs_prod(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/@use-gesture/core/types/dist/use-gesture-core-types.cjs.prod.js -var require_use_gesture_core_types_cjs_prod = __commonJS({ - "node_modules/@use-gesture/core/types/dist/use-gesture-core-types.cjs.prod.js"() { - "use strict"; - } -}); - -// node_modules/@use-gesture/core/types/dist/use-gesture-core-types.cjs.js -var require_use_gesture_core_types_cjs = __commonJS({ - "node_modules/@use-gesture/core/types/dist/use-gesture-core-types.cjs.js"(exports, module2) { - "use strict"; - if (true) { - module2.exports = require_use_gesture_core_types_cjs_prod(); - } else { - module2.exports = null; - } - } -}); - -// node_modules/eventemitter3/index.js -var require_eventemitter3 = __commonJS({ - "node_modules/eventemitter3/index.js"(exports, module2) { - "use strict"; - var has = Object.prototype.hasOwnProperty; - var prefix = "~"; - function Events() { - } - if (Object.create) { - Events.prototype = /* @__PURE__ */ Object.create(null); - if (!new Events().__proto__) - prefix = false; - } - function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; - } - function addListener(emitter, event, fn, context, once) { - if (typeof fn !== "function") { - throw new TypeError("The listener must be a function"); - } - var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; - if (!emitter._events[evt]) - emitter._events[evt] = listener, emitter._eventsCount++; - else if (!emitter._events[evt].fn) - emitter._events[evt].push(listener); - else - emitter._events[evt] = [emitter._events[evt], listener]; - return emitter; - } - function clearEvent(emitter, evt) { - if (--emitter._eventsCount === 0) - emitter._events = new Events(); - else - delete emitter._events[evt]; - } - function EventEmitter2() { - this._events = new Events(); - this._eventsCount = 0; - } - EventEmitter2.prototype.eventNames = function eventNames() { - var names = [], events, name; - if (this._eventsCount === 0) - return names; - for (name in events = this._events) { - if (has.call(events, name)) - names.push(prefix ? name.slice(1) : name); - } - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - return names; - }; - EventEmitter2.prototype.listeners = function listeners(event) { - var evt = prefix ? prefix + event : event, handlers = this._events[evt]; - if (!handlers) - return []; - if (handlers.fn) - return [handlers.fn]; - for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { - ee[i] = handlers[i].fn; - } - return ee; - }; - EventEmitter2.prototype.listenerCount = function listenerCount(event) { - var evt = prefix ? prefix + event : event, listeners = this._events[evt]; - if (!listeners) - return 0; - if (listeners.fn) - return 1; - return listeners.length; - }; - EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - if (!this._events[evt]) - return false; - var listeners = this._events[evt], len = arguments.length, args, i; - if (listeners.fn) { - if (listeners.once) - this.removeListener(event, listeners.fn, void 0, true); - switch (len) { - case 1: - return listeners.fn.call(listeners.context), true; - case 2: - return listeners.fn.call(listeners.context, a1), true; - case 3: - return listeners.fn.call(listeners.context, a1, a2), true; - case 4: - return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: - return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: - return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - for (i = 1, args = new Array(len - 1); i < len; i++) { - args[i - 1] = arguments[i]; - } - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length, j; - for (i = 0; i < length; i++) { - if (listeners[i].once) - this.removeListener(event, listeners[i].fn, void 0, true); - switch (len) { - case 1: - listeners[i].fn.call(listeners[i].context); - break; - case 2: - listeners[i].fn.call(listeners[i].context, a1); - break; - case 3: - listeners[i].fn.call(listeners[i].context, a1, a2); - break; - case 4: - listeners[i].fn.call(listeners[i].context, a1, a2, a3); - break; - default: - if (!args) - for (j = 1, args = new Array(len - 1); j < len; j++) { - args[j - 1] = arguments[j]; - } - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - return true; - }; - EventEmitter2.prototype.on = function on(event, fn, context) { - return addListener(this, event, fn, context, false); - }; - EventEmitter2.prototype.once = function once(event, fn, context) { - return addListener(this, event, fn, context, true); - }; - EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - if (!this._events[evt]) - return this; - if (!fn) { - clearEvent(this, evt); - return this; - } - var listeners = this._events[evt]; - if (listeners.fn) { - if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { - clearEvent(this, evt); - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) { - events.push(listeners[i]); - } - } - if (events.length) - this._events[evt] = events.length === 1 ? events[0] : events; - else - clearEvent(this, evt); - } - return this; - }; - EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) - clearEvent(this, evt); - } else { - this._events = new Events(); - this._eventsCount = 0; - } - return this; - }; - EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener; - EventEmitter2.prototype.addListener = EventEmitter2.prototype.on; - EventEmitter2.prefixed = prefix; - EventEmitter2.EventEmitter = EventEmitter2; - if (typeof module2 !== "undefined") { - module2.exports = EventEmitter2; - } - } -}); - -// node_modules/tslib/tslib.js -var require_tslib = __commonJS({ - "node_modules/tslib/tslib.js"(exports, module2) { - var __extends2; - var __assign2; - var __rest2; - var __decorate2; - var __param2; - var __metadata2; - var __awaiter2; - var __generator2; - var __exportStar2; - var __values2; - var __read2; - var __spread2; - var __spreadArrays2; - var __spreadArray2; - var __await2; - var __asyncGenerator2; - var __asyncDelegator2; - var __asyncValues2; - var __makeTemplateObject2; - var __importStar2; - var __importDefault2; - var __classPrivateFieldGet2; - var __classPrivateFieldSet2; - var __classPrivateFieldIn2; - var __createBinding2; - (function(factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function(exports2) { - factory(createExporter(root, createExporter(exports2))); - }); - } else if (typeof module2 === "object" && typeof module2.exports === "object") { - factory(createExporter(root, createExporter(module2.exports))); - } else { - factory(createExporter(root)); - } - function createExporter(exports2, previous) { - if (exports2 !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports2, "__esModule", { value: true }); - } else { - exports2.__esModule = true; - } - } - return function(id, v) { - return exports2[id] = previous ? previous(id, v) : v; - }; - } - })(function(exporter) { - var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) { - d.__proto__ = b; - } || function(d, b) { - for (var p in b) - if (Object.prototype.hasOwnProperty.call(b, p)) - d[p] = b[p]; - }; - __extends2 = function(d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - __assign2 = Object.assign || function(t2) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t2[p] = s[p]; - } - return t2; - }; - __rest2 = function(s, e) { - var t2 = {}; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t2[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t2[p[i]] = s[p[i]]; - } - return t2; - }; - __decorate2 = function(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r = Reflect.decorate(decorators, target, key, desc); - else - for (var i = decorators.length - 1; i >= 0; i--) - if (d = decorators[i]) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - __param2 = function(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; - }; - __metadata2 = function(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") - return Reflect.metadata(metadataKey, metadataValue); - }; - __awaiter2 = function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - __generator2 = function(thisArg, body) { - var _ = { label: 0, sent: function() { - if (t2[0] & 1) - throw t2[1]; - return t2[1]; - }, trys: [], ops: [] }, f, y, t2, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([n, v]); - }; - } - function step(op) { - if (f) - throw new TypeError("Generator is already executing."); - while (_) - try { - if (f = 1, y && (t2 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t2 = y["return"]) && t2.call(y), 0) : y.next) && !(t2 = t2.call(y, op[1])).done) - return t2; - if (y = 0, t2) - op = [op[0] & 2, t2.value]; - switch (op[0]) { - case 0: - case 1: - t2 = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t2 = _.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t2[1]) { - _.label = t2[1]; - t2 = op; - break; - } - if (t2 && _.label < t2[2]) { - _.label = t2[2]; - _.ops.push(op); - break; - } - if (t2[2]) - _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t2 = 0; - } - if (op[0] & 5) - throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - __exportStar2 = function(m, o) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) - __createBinding2(o, m, p); - }; - __createBinding2 = Object.create ? function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m[k]; - } }; - } - Object.defineProperty(o, k2, desc); - } : function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - }; - __values2 = function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) - return m.call(o); - if (o && typeof o.length === "number") - return { - next: function() { - if (o && i >= o.length) - o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); - }; - __read2 = function(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) - return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) - ar.push(r.value); - } catch (error3) { - e = { error: error3 }; - } finally { - try { - if (r && !r.done && (m = i["return"])) - m.call(i); - } finally { - if (e) - throw e.error; - } - } - return ar; - }; - __spread2 = function() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read2(arguments[i])); - return ar; - }; - __spreadArrays2 = function() { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) - s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - __spreadArray2 = function(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) - ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - }; - __await2 = function(v) { - return this instanceof __await2 ? (this.v = v, this) : new __await2(v); - }; - __asyncGenerator2 = function(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) - i[n] = function(v) { - return new Promise(function(a, b) { - q.push([n, v, a, b]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await2 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) - resume(q[0][0], q[0][1]); - } - }; - __asyncDelegator2 = function(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { value: __await2(o[n](v)), done: n === "return" } : f ? f(v) : v; - } : f; - } - }; - __asyncValues2 = function(o) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values2 === "function" ? __values2(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v2) { - resolve({ value: v2, done: d }); - }, reject); - } - }; - __makeTemplateObject2 = function(cooked, raw) { - if (Object.defineProperty) { - Object.defineProperty(cooked, "raw", { value: raw }); - } else { - cooked.raw = raw; - } - return cooked; - }; - var __setModuleDefault = Object.create ? function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - } : function(o, v) { - o["default"] = v; - }; - __importStar2 = function(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k in mod) - if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); - } - __setModuleDefault(result, mod); - return result; - }; - __importDefault2 = function(mod) { - return mod && mod.__esModule ? mod : { "default": mod }; - }; - __classPrivateFieldGet2 = function(receiver, state, kind, f) { - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - }; - __classPrivateFieldSet2 = function(receiver, state, value, kind, f) { - if (kind === "m") - throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; - }; - __classPrivateFieldIn2 = function(state, receiver) { - if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") - throw new TypeError("Cannot use 'in' operator on non-object"); - return typeof state === "function" ? receiver === state : state.has(receiver); - }; - exporter("__extends", __extends2); - exporter("__assign", __assign2); - exporter("__rest", __rest2); - exporter("__decorate", __decorate2); - exporter("__param", __param2); - exporter("__metadata", __metadata2); - exporter("__awaiter", __awaiter2); - exporter("__generator", __generator2); - exporter("__exportStar", __exportStar2); - exporter("__createBinding", __createBinding2); - exporter("__values", __values2); - exporter("__read", __read2); - exporter("__spread", __spread2); - exporter("__spreadArrays", __spreadArrays2); - exporter("__spreadArray", __spreadArray2); - exporter("__await", __await2); - exporter("__asyncGenerator", __asyncGenerator2); - exporter("__asyncDelegator", __asyncDelegator2); - exporter("__asyncValues", __asyncValues2); - exporter("__makeTemplateObject", __makeTemplateObject2); - exporter("__importStar", __importStar2); - exporter("__importDefault", __importDefault2); - exporter("__classPrivateFieldGet", __classPrivateFieldGet2); - exporter("__classPrivateFieldSet", __classPrivateFieldSet2); - exporter("__classPrivateFieldIn", __classPrivateFieldIn2); - }); - } -}); - -// node_modules/lz-string/libs/lz-string.js -var require_lz_string = __commonJS({ - "node_modules/lz-string/libs/lz-string.js"(exports, module2) { - var LZString = function() { - var f = String.fromCharCode; - var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$"; - var baseReverseDic = {}; - function getBaseValue(alphabet, character) { - if (!baseReverseDic[alphabet]) { - baseReverseDic[alphabet] = {}; - for (var i = 0; i < alphabet.length; i++) { - baseReverseDic[alphabet][alphabet.charAt(i)] = i; - } - } - return baseReverseDic[alphabet][character]; - } - var LZString2 = { - compressToBase64: function(input) { - if (input == null) - return ""; - var res = LZString2._compress(input, 6, function(a) { - return keyStrBase64.charAt(a); - }); - switch (res.length % 4) { - default: - case 0: - return res; - case 1: - return res + "==="; - case 2: - return res + "=="; - case 3: - return res + "="; - } - }, - decompressFromBase64: function(input) { - if (input == null) - return ""; - if (input == "") - return null; - return LZString2._decompress(input.length, 32, function(index2) { - return getBaseValue(keyStrBase64, input.charAt(index2)); - }); - }, - compressToUTF16: function(input) { - if (input == null) - return ""; - return LZString2._compress(input, 15, function(a) { - return f(a + 32); - }) + " "; - }, - decompressFromUTF16: function(compressed) { - if (compressed == null) - return ""; - if (compressed == "") - return null; - return LZString2._decompress(compressed.length, 16384, function(index2) { - return compressed.charCodeAt(index2) - 32; - }); - }, - compressToUint8Array: function(uncompressed) { - var compressed = LZString2.compress(uncompressed); - var buf = new Uint8Array(compressed.length * 2); - for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) { - var current_value = compressed.charCodeAt(i); - buf[i * 2] = current_value >>> 8; - buf[i * 2 + 1] = current_value % 256; - } - return buf; - }, - decompressFromUint8Array: function(compressed) { - if (compressed === null || compressed === void 0) { - return LZString2.decompress(compressed); - } else { - var buf = new Array(compressed.length / 2); - for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) { - buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1]; - } - var result = []; - buf.forEach(function(c) { - result.push(f(c)); - }); - return LZString2.decompress(result.join("")); - } - }, - compressToEncodedURIComponent: function(input) { - if (input == null) - return ""; - return LZString2._compress(input, 6, function(a) { - return keyStrUriSafe.charAt(a); - }); - }, - decompressFromEncodedURIComponent: function(input) { - if (input == null) - return ""; - if (input == "") - return null; - input = input.replace(/ /g, "+"); - return LZString2._decompress(input.length, 32, function(index2) { - return getBaseValue(keyStrUriSafe, input.charAt(index2)); - }); - }, - compress: function(uncompressed) { - return LZString2._compress(uncompressed, 16, function(a) { - return f(a); - }); - }, - _compress: function(uncompressed, bitsPerChar, getCharFromInt) { - if (uncompressed == null) - return ""; - var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii; - for (ii = 0; ii < uncompressed.length; ii += 1) { - context_c = uncompressed.charAt(ii); - if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) { - context_dictionary[context_c] = context_dictSize++; - context_dictionaryToCreate[context_c] = true; - } - context_wc = context_w + context_c; - if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) { - context_w = context_wc; - } else { - if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) { - if (context_w.charCodeAt(0) < 256) { - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - } - value = context_w.charCodeAt(0); - for (i = 0; i < 8; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - } else { - value = 1; - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1 | value; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = 0; - } - value = context_w.charCodeAt(0); - for (i = 0; i < 16; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - } - context_enlargeIn--; - if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); - context_numBits++; - } - delete context_dictionaryToCreate[context_w]; - } else { - value = context_dictionary[context_w]; - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - } - context_enlargeIn--; - if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); - context_numBits++; - } - context_dictionary[context_wc] = context_dictSize++; - context_w = String(context_c); - } - } - if (context_w !== "") { - if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) { - if (context_w.charCodeAt(0) < 256) { - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - } - value = context_w.charCodeAt(0); - for (i = 0; i < 8; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - } else { - value = 1; - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1 | value; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = 0; - } - value = context_w.charCodeAt(0); - for (i = 0; i < 16; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - } - context_enlargeIn--; - if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); - context_numBits++; - } - delete context_dictionaryToCreate[context_w]; - } else { - value = context_dictionary[context_w]; - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - } - context_enlargeIn--; - if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); - context_numBits++; - } - } - value = 2; - for (i = 0; i < context_numBits; i++) { - context_data_val = context_data_val << 1 | value & 1; - if (context_data_position == bitsPerChar - 1) { - context_data_position = 0; - context_data.push(getCharFromInt(context_data_val)); - context_data_val = 0; - } else { - context_data_position++; - } - value = value >> 1; - } - while (true) { - context_data_val = context_data_val << 1; - if (context_data_position == bitsPerChar - 1) { - context_data.push(getCharFromInt(context_data_val)); - break; - } else - context_data_position++; - } - return context_data.join(""); - }, - decompress: function(compressed) { - if (compressed == null) - return ""; - if (compressed == "") - return null; - return LZString2._decompress(compressed.length, 32768, function(index2) { - return compressed.charCodeAt(index2); - }); - }, - _decompress: function(length, resetValue, getNextValue) { - var dictionary = [], next, enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = { val: getNextValue(0), position: resetValue, index: 1 }; - for (i = 0; i < 3; i += 1) { - dictionary[i] = i; - } - bits = 0; - maxpower = Math.pow(2, 2); - power = 1; - while (power != maxpower) { - resb = data.val & data.position; - data.position >>= 1; - if (data.position == 0) { - data.position = resetValue; - data.val = getNextValue(data.index++); - } - bits |= (resb > 0 ? 1 : 0) * power; - power <<= 1; - } - switch (next = bits) { - case 0: - bits = 0; - maxpower = Math.pow(2, 8); - power = 1; - while (power != maxpower) { - resb = data.val & data.position; - data.position >>= 1; - if (data.position == 0) { - data.position = resetValue; - data.val = getNextValue(data.index++); - } - bits |= (resb > 0 ? 1 : 0) * power; - power <<= 1; - } - c = f(bits); - break; - case 1: - bits = 0; - maxpower = Math.pow(2, 16); - power = 1; - while (power != maxpower) { - resb = data.val & data.position; - data.position >>= 1; - if (data.position == 0) { - data.position = resetValue; - data.val = getNextValue(data.index++); - } - bits |= (resb > 0 ? 1 : 0) * power; - power <<= 1; - } - c = f(bits); - break; - case 2: - return ""; - } - dictionary[3] = c; - w = c; - result.push(c); - while (true) { - if (data.index > length) { - return ""; - } - bits = 0; - maxpower = Math.pow(2, numBits); - power = 1; - while (power != maxpower) { - resb = data.val & data.position; - data.position >>= 1; - if (data.position == 0) { - data.position = resetValue; - data.val = getNextValue(data.index++); - } - bits |= (resb > 0 ? 1 : 0) * power; - power <<= 1; - } - switch (c = bits) { - case 0: - bits = 0; - maxpower = Math.pow(2, 8); - power = 1; - while (power != maxpower) { - resb = data.val & data.position; - data.position >>= 1; - if (data.position == 0) { - data.position = resetValue; - data.val = getNextValue(data.index++); - } - bits |= (resb > 0 ? 1 : 0) * power; - power <<= 1; - } - dictionary[dictSize++] = f(bits); - c = dictSize - 1; - enlargeIn--; - break; - case 1: - bits = 0; - maxpower = Math.pow(2, 16); - power = 1; - while (power != maxpower) { - resb = data.val & data.position; - data.position >>= 1; - if (data.position == 0) { - data.position = resetValue; - data.val = getNextValue(data.index++); - } - bits |= (resb > 0 ? 1 : 0) * power; - power <<= 1; - } - dictionary[dictSize++] = f(bits); - c = dictSize - 1; - enlargeIn--; - break; - case 2: - return result.join(""); - } - if (enlargeIn == 0) { - enlargeIn = Math.pow(2, numBits); - numBits++; - } - if (dictionary[c]) { - entry = dictionary[c]; - } else { - if (c === dictSize) { - entry = w + w.charAt(0); - } else { - return null; - } - } - result.push(entry); - dictionary[dictSize++] = w + entry.charAt(0); - enlargeIn--; - w = entry; - if (enlargeIn == 0) { - enlargeIn = Math.pow(2, numBits); - numBits++; - } - } - } - }; - return LZString2; - }(); - if (typeof define === "function" && define.amd) { - define(function() { - return LZString; - }); - } else if (typeof module2 !== "undefined" && module2 != null) { - module2.exports = LZString; - } else if (typeof angular !== "undefined" && angular != null) { - angular.module("LZString", []).factory("LZString", function() { - return LZString; - }); - } - } -}); - -// src/placeholders/empty-writing-embed.svg -var require_empty_writing_embed = __commonJS({ - "src/placeholders/empty-writing-embed.svg"(exports, module2) { - module2.exports = '<svg xmlns="http://www.w3.org/2000/svg" direction="ltr" width="2064" height="289" viewBox="-32 -32 2064 289" stroke-linecap="round" stroke-linejoin="round" style="background-color: transparent;">\n <defs/>\n <g transform="matrix(1, 0, 0, 1, 0, 0)" opacity="1">\n <line x1="100" y1="150" x2="1900" y2="150"/>\n </g>\n <g transform="matrix(1, 0, 0, 1, 0, 0)" opacity="1">\n <rect width="2000" height="225" opacity="0"/>\n </g>\n</svg>'; - } -}); - -// src/placeholders/empty-drawing-embed.svg -var require_empty_drawing_embed = __commonJS({ - "src/placeholders/empty-drawing-embed.svg"(exports, module2) { - module2.exports = '<svg\n xmlns="http://www.w3.org/2000/svg"\n version="1.1"\n viewBox="0 0 395 130" \n width="395"\n height="130"\n fill="none"\n class="ddc_ink_drawing-placeholder"\n>\n <g>\n <rect rx="10" ry="10" x="1" y="1" width="393" height="128" style="fill: none; stroke-width: 1; stroke: rgb(255, 255, 255); stroke-opacity: 0.1;"/>\n </g>\n <g>\n <rect rx="2" ry="2" x="189" y="56" width="18" height="18" style="fill: none; stroke-width: 2; stroke: rgb(255, 255, 255); stroke-opacity: 1;" class="stroke-shape"/>\n <circle cx="195" cy="62" style="fill: none; stroke-width: 2; stroke: rgb(255, 255, 255); stroke-opacity: 1;" r="2" class="stroke-shape"/>\n <path d="m207 68-3.086-3.086a2 2 0 0 0-2.828 0L192 74" style="fill: none; stroke-width: 2; stroke: rgb(255, 255, 255); stroke-opacity: 1;" class="stroke-shape"/>\n </g>\n</svg>'; - } -}); - -// src/graphics/social-icons/bluesky.svg -var require_bluesky = __commonJS({ - "src/graphics/social-icons/bluesky.svg"(exports, module2) { - module2.exports = '<svg width="100" height="100" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.173 5.80097C6.54015 4.57089 4.81761 2.27767 3.21592 1.14748C1.68129 0.0647798 1.09663 0.251283 0.713148 0.425911C0.268894 0.624988 0.187866 1.30743 0.187866 1.70768C0.187866 2.10933 0.407898 4.99698 0.551093 5.47965C1.02608 7.07227 2.71229 7.61012 4.26718 7.43759C1.99003 7.77497 -0.0335624 8.6041 2.61869 11.5574C5.53708 14.5785 6.61838 10.9099 7.173 9.04976C7.72762 10.9099 8.36606 14.4465 11.6742 11.5574C14.1581 9.04976 12.3567 7.77497 10.0795 7.43759C11.6337 7.61012 13.3206 7.07227 13.7949 5.47965C13.9381 4.99768 14.1581 2.10933 14.1581 1.70838C14.1581 1.30674 14.0771 0.625686 13.6328 0.424514C13.2494 0.251283 12.6647 0.0633829 11.1301 1.14608C9.52839 2.27837 7.80515 4.57159 7.173 5.80097Z" fill="white"/>\n</svg>\n'; - } -}); - -// src/graphics/social-icons/mastodon.svg -var require_mastodon = __commonJS({ - "src/graphics/social-icons/mastodon.svg"(exports, module2) { - module2.exports = '<svg width="100" height="100" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M12.0997 7.77207C11.9245 8.67344 10.5296 9.66111 8.92761 9.85226C8.09272 9.95198 7.26998 10.044 6.39291 10.0031C4.95903 9.93728 3.82688 9.66111 3.82688 9.66111C3.82688 9.80048 3.83583 9.93344 3.85245 10.0575C4.03912 11.4734 5.25629 11.5578 6.40953 11.5981C7.573 11.6377 8.60861 11.3104 8.60861 11.3104L8.6572 12.3627C8.6572 12.3627 7.84277 12.7999 6.39291 12.8805C5.59382 12.9239 4.60104 12.86 3.4446 12.5544C0.936746 11.8902 0.505239 9.21746 0.439395 6.5044C0.419577 5.69893 0.431723 4.94011 0.431723 4.30532C0.431723 1.53089 2.24917 0.71838 2.24917 0.71838C3.16524 0.297741 4.7372 0.120663 6.37245 0.107239H6.41209C8.0467 0.120024 9.61994 0.297741 10.536 0.71838C10.536 0.71838 12.3535 1.53153 12.3535 4.30468C12.3535 4.30468 12.3765 6.35098 12.0997 7.77207ZM10.21 4.52011C10.21 3.83354 10.0355 3.28824 9.6845 2.88486C9.32204 2.48148 8.84834 2.27436 8.25957 2.27436C7.57875 2.27436 7.0635 2.53646 6.72213 3.05938L6.39099 3.61555L6.05921 3.05938C5.71848 2.53646 5.20323 2.27436 4.52241 2.27436C3.93364 2.27436 3.4593 2.48148 3.09748 2.88486C2.74652 3.28824 2.572 3.83354 2.572 4.52011V7.87819H3.90232V4.61856C3.90232 3.93135 4.19126 3.58294 4.7698 3.58294C5.40907 3.58294 5.72935 3.99655 5.72935 4.81482V6.59838H7.05263V4.81482C7.05263 3.99655 7.37227 3.58294 8.01154 3.58294C8.59007 3.58294 8.87966 3.93135 8.87966 4.61856V7.87883H10.2093V4.51947L10.21 4.52011Z" fill="white"/>\n</svg>\n'; - } -}); - -// src/graphics/social-icons/threads.svg -var require_threads = __commonJS({ - "src/graphics/social-icons/threads.svg"(exports, module2) { - module2.exports = '<svg width="100" height="100" viewBox="0 0 13 15" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M6.53736 3.69841C5.31389 3.69841 4.42969 4.07195 3.75944 5.02945C3.75944 5.02945 4.55499 5.58148 4.79377 5.74106L4.82214 5.70915C5.16495 5.31197 5.45929 4.97152 6.53618 4.97152C7.74427 4.97152 8.22184 5.93847 8.22184 6.50351C7.8944 6.43732 7.26789 6.40185 6.74777 6.40185C5.35881 6.40185 3.59986 7.07328 3.59986 8.9268C3.59986 10.2247 4.83751 11.2153 6.27139 11.2153C8.7325 11.2153 9.29281 9.37481 9.50204 8.28138C9.5576 8.28138 10.6286 8.89134 10.6286 10.1668C10.6286 12.0404 8.79279 13.3194 6.33049 13.3194C3.33744 13.3194 1.3397 11.369 1.3397 7.69624C1.3397 3.6003 3.12703 1.67585 6.28912 1.67585C8.20056 1.67585 10.2869 2.15815 11.2823 5.1843L12.488 4.87223C11.2019 0.622612 7.77974 0.407471 6.32104 0.407471C3.16249 0.407471 0.0760498 2.21134 0.0760498 7.49529C0.0760498 12.8076 3.26297 14.5926 6.33049 14.5926C9.90277 14.5926 11.8769 12.5014 11.8769 10.0935C11.8769 8.96108 11.3355 7.97285 10.352 7.31206C10.1077 7.14736 9.84051 7.00433 9.55051 6.88296C9.48195 5.877 9.18288 5.08973 8.65921 4.53888C8.13436 3.98921 7.40028 3.69841 6.53736 3.69841ZM4.87534 8.92325C4.87534 8.43859 5.10821 7.66787 6.91681 7.66787C7.47121 7.66787 7.81283 7.70806 8.27148 7.8109C8.12491 9.70934 7.19578 9.95995 6.29266 9.95995C5.79855 9.95995 4.87534 9.70225 4.87534 8.92325Z" fill="white"/>\n</svg>\n'; - } -}); - -// src/graphics/social-icons/twitter.svg -var require_twitter = __commonJS({ - "src/graphics/social-icons/twitter.svg"(exports, module2) { - module2.exports = '<svg width="100" height="100" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M14.6288 2.14845C14.094 2.38083 13.5281 2.53393 12.9491 2.60291C13.5576 2.24658 14.0153 1.68049 14.2362 1.01081C13.6608 1.34722 13.0324 1.58327 12.3779 1.70883C12.1023 1.41998 11.7708 1.19019 11.4036 1.03342C11.0364 0.876661 10.6412 0.796203 10.2419 0.796941C8.62549 0.796941 7.31735 2.08607 7.31735 3.6752C7.31621 3.89624 7.34154 4.11663 7.3928 4.33164C6.23368 4.2773 5.09867 3.98161 4.06037 3.46349C3.02208 2.94537 2.10336 2.21622 1.36301 1.32269C1.10328 1.76055 0.965917 2.26014 0.965284 2.76925C0.965284 3.76728 1.48598 4.64947 2.27223 5.16631C1.8064 5.15525 1.35012 5.03196 0.942115 4.8069V4.84254C0.942115 6.2386 1.95203 7.4 3.28868 7.66436C3.03733 7.73137 2.77831 7.76532 2.51818 7.76536C2.33359 7.76568 2.14943 7.74777 1.96837 7.71189C2.33996 8.85547 3.42146 9.68717 4.70256 9.71093C3.66157 10.5132 2.38351 10.9468 1.06925 10.9436C0.83596 10.9433 0.602892 10.9294 0.371216 10.902C1.70822 11.7558 3.26238 12.2074 4.8487 12.203C10.2357 12.203 13.1787 7.81585 13.1787 4.01085C13.1787 3.88609 13.1755 3.76134 13.1695 3.63955C13.7407 3.23323 14.2349 2.72829 14.6288 2.14845Z" fill="white"/>\n</svg>\n'; - } -}); - -// node_modules/semver/internal/constants.js -var require_constants = __commonJS({ - "node_modules/semver/internal/constants.js"(exports, module2) { - var SEMVER_SPEC_VERSION = "2.0.0"; - var MAX_LENGTH = 256; - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; - var MAX_SAFE_COMPONENT_LENGTH = 16; - var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; - var RELEASE_TYPES = [ - "major", - "premajor", - "minor", - "preminor", - "patch", - "prepatch", - "prerelease" - ]; - module2.exports = { - MAX_LENGTH, - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_SAFE_INTEGER, - RELEASE_TYPES, - SEMVER_SPEC_VERSION, - FLAG_INCLUDE_PRERELEASE: 1, - FLAG_LOOSE: 2 - }; - } -}); - -// node_modules/semver/internal/debug.js -var require_debug = __commonJS({ - "node_modules/semver/internal/debug.js"(exports, module2) { - var debug4 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => { - }; - module2.exports = debug4; - } -}); - -// node_modules/semver/internal/re.js -var require_re = __commonJS({ - "node_modules/semver/internal/re.js"(exports, module2) { - var { - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_LENGTH - } = require_constants(); - var debug4 = require_debug(); - exports = module2.exports = {}; - var re = exports.re = []; - var safeRe = exports.safeRe = []; - var src = exports.src = []; - var t2 = exports.t = {}; - var R = 0; - var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; - var safeRegexReplacements = [ - ["\\s", 1], - ["\\d", MAX_LENGTH], - [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] - ]; - var makeSafeRegex = (value) => { - for (const [token, max2] of safeRegexReplacements) { - value = value.split(`${token}*`).join(`${token}{0,${max2}}`).split(`${token}+`).join(`${token}{1,${max2}}`); - } - return value; - }; - var createToken = (name, value, isGlobal) => { - const safe = makeSafeRegex(value); - const index2 = R++; - debug4(name, index2, value); - t2[name] = index2; - src[index2] = value; - re[index2] = new RegExp(value, isGlobal ? "g" : void 0); - safeRe[index2] = new RegExp(safe, isGlobal ? "g" : void 0); - }; - createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*"); - createToken("NUMERICIDENTIFIERLOOSE", "\\d+"); - createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`); - createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`); - createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`); - createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`); - createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`); - createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`); - createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`); - createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); - createToken("BUILD", `(?:\\+(${src[t2.BUILDIDENTIFIER]}(?:\\.${src[t2.BUILDIDENTIFIER]})*))`); - createToken("FULLPLAIN", `v?${src[t2.MAINVERSION]}${src[t2.PRERELEASE]}?${src[t2.BUILD]}?`); - createToken("FULL", `^${src[t2.FULLPLAIN]}$`); - createToken("LOOSEPLAIN", `[v=\\s]*${src[t2.MAINVERSIONLOOSE]}${src[t2.PRERELEASELOOSE]}?${src[t2.BUILD]}?`); - createToken("LOOSE", `^${src[t2.LOOSEPLAIN]}$`); - createToken("GTLT", "((?:<|>)?=?)"); - createToken("XRANGEIDENTIFIERLOOSE", `${src[t2.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); - createToken("XRANGEIDENTIFIER", `${src[t2.NUMERICIDENTIFIER]}|x|X|\\*`); - createToken("XRANGEPLAIN", `[v=\\s]*(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:${src[t2.PRERELEASE]})?${src[t2.BUILD]}?)?)?`); - createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`); - createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`); - createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`); - createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`); - createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`); - createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`); - createToken("COERCERTL", src[t2.COERCE], true); - createToken("COERCERTLFULL", src[t2.COERCEFULL], true); - createToken("LONETILDE", "(?:~>?)"); - createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true); - exports.tildeTrimReplace = "$1~"; - createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`); - createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`); - createToken("LONECARET", "(?:\\^)"); - createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true); - exports.caretTrimReplace = "$1^"; - createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`); - createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`); - createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`); - createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`); - createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true); - exports.comparatorTrimReplace = "$1$2$3"; - createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`); - createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`); - createToken("STAR", "(<|>)?=?\\s*\\*"); - createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); - createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); - } -}); - -// node_modules/semver/internal/parse-options.js -var require_parse_options = __commonJS({ - "node_modules/semver/internal/parse-options.js"(exports, module2) { - var looseOption = Object.freeze({ loose: true }); - var emptyOpts = Object.freeze({}); - var parseOptions = (options) => { - if (!options) { - return emptyOpts; - } - if (typeof options !== "object") { - return looseOption; - } - return options; - }; - module2.exports = parseOptions; - } -}); - -// node_modules/semver/internal/identifiers.js -var require_identifiers = __commonJS({ - "node_modules/semver/internal/identifiers.js"(exports, module2) { - var numeric = /^[0-9]+$/; - var compareIdentifiers = (a, b) => { - const anum = numeric.test(a); - const bnum = numeric.test(b); - if (anum && bnum) { - a = +a; - b = +b; - } - return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; - }; - var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a); - module2.exports = { - compareIdentifiers, - rcompareIdentifiers - }; - } -}); - -// node_modules/semver/classes/semver.js -var require_semver = __commonJS({ - "node_modules/semver/classes/semver.js"(exports, module2) { - var debug4 = require_debug(); - var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(); - var { safeRe: re, t: t2 } = require_re(); - var parseOptions = require_parse_options(); - var { compareIdentifiers } = require_identifiers(); - var SemVer = class { - constructor(version2, options) { - options = parseOptions(options); - if (version2 instanceof SemVer) { - if (version2.loose === !!options.loose && version2.includePrerelease === !!options.includePrerelease) { - return version2; - } else { - version2 = version2.version; - } - } else if (typeof version2 !== "string") { - throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version2}".`); - } - if (version2.length > MAX_LENGTH) { - throw new TypeError(`version is longer than ${MAX_LENGTH} characters`); - } - debug4("SemVer", version2, options); - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - const m = version2.trim().match(options.loose ? re[t2.LOOSE] : re[t2.FULL]); - if (!m) { - throw new TypeError(`Invalid Version: ${version2}`); - } - this.raw = version2; - this.major = +m[1]; - this.minor = +m[2]; - this.patch = +m[3]; - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); - } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); - } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); - } - if (!m[4]) { - this.prerelease = []; - } else { - this.prerelease = m[4].split(".").map((id) => { - if (/^[0-9]+$/.test(id)) { - const num = +id; - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num; - } - } - return id; - }); - } - this.build = m[5] ? m[5].split(".") : []; - this.format(); - } - format() { - this.version = `${this.major}.${this.minor}.${this.patch}`; - if (this.prerelease.length) { - this.version += `-${this.prerelease.join(".")}`; - } - return this.version; - } - toString() { - return this.version; - } - compare(other) { - debug4("SemVer.compare", this.version, this.options, other); - if (!(other instanceof SemVer)) { - if (typeof other === "string" && other === this.version) { - return 0; - } - other = new SemVer(other, this.options); - } - if (other.version === this.version) { - return 0; - } - return this.compareMain(other) || this.comparePre(other); - } - compareMain(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); - } - return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); - } - comparePre(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); - } - if (this.prerelease.length && !other.prerelease.length) { - return -1; - } else if (!this.prerelease.length && other.prerelease.length) { - return 1; - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0; - } - let i = 0; - do { - const a = this.prerelease[i]; - const b = other.prerelease[i]; - debug4("prerelease compare", i, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i); - } - compareBuild(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); - } - let i = 0; - do { - const a = this.build[i]; - const b = other.build[i]; - debug4("build compare", i, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i); - } - inc(release, identifier, identifierBase) { - switch (release) { - case "premajor": - this.prerelease.length = 0; - this.patch = 0; - this.minor = 0; - this.major++; - this.inc("pre", identifier, identifierBase); - break; - case "preminor": - this.prerelease.length = 0; - this.patch = 0; - this.minor++; - this.inc("pre", identifier, identifierBase); - break; - case "prepatch": - this.prerelease.length = 0; - this.inc("patch", identifier, identifierBase); - this.inc("pre", identifier, identifierBase); - break; - case "prerelease": - if (this.prerelease.length === 0) { - this.inc("patch", identifier, identifierBase); - } - this.inc("pre", identifier, identifierBase); - break; - case "major": - if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { - this.major++; - } - this.minor = 0; - this.patch = 0; - this.prerelease = []; - break; - case "minor": - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++; - } - this.patch = 0; - this.prerelease = []; - break; - case "patch": - if (this.prerelease.length === 0) { - this.patch++; - } - this.prerelease = []; - break; - case "pre": { - const base = Number(identifierBase) ? 1 : 0; - if (!identifier && identifierBase === false) { - throw new Error("invalid increment argument: identifier is empty"); - } - if (this.prerelease.length === 0) { - this.prerelease = [base]; - } else { - let i = this.prerelease.length; - while (--i >= 0) { - if (typeof this.prerelease[i] === "number") { - this.prerelease[i]++; - i = -2; - } - } - if (i === -1) { - if (identifier === this.prerelease.join(".") && identifierBase === false) { - throw new Error("invalid increment argument: identifier already exists"); - } - this.prerelease.push(base); - } - } - if (identifier) { - let prerelease = [identifier, base]; - if (identifierBase === false) { - prerelease = [identifier]; - } - if (compareIdentifiers(this.prerelease[0], identifier) === 0) { - if (isNaN(this.prerelease[1])) { - this.prerelease = prerelease; - } - } else { - this.prerelease = prerelease; - } - } - break; - } - default: - throw new Error(`invalid increment argument: ${release}`); - } - this.raw = this.format(); - if (this.build.length) { - this.raw += `+${this.build.join(".")}`; - } - return this; - } - }; - module2.exports = SemVer; - } -}); - -// node_modules/semver/functions/parse.js -var require_parse = __commonJS({ - "node_modules/semver/functions/parse.js"(exports, module2) { - var SemVer = require_semver(); - var parse2 = (version2, options, throwErrors = false) => { - if (version2 instanceof SemVer) { - return version2; - } - try { - return new SemVer(version2, options); - } catch (er) { - if (!throwErrors) { - return null; - } - throw er; - } - }; - module2.exports = parse2; - } -}); - -// node_modules/semver/functions/valid.js -var require_valid = __commonJS({ - "node_modules/semver/functions/valid.js"(exports, module2) { - var parse2 = require_parse(); - var valid2 = (version2, options) => { - const v = parse2(version2, options); - return v ? v.version : null; - }; - module2.exports = valid2; - } -}); - -// node_modules/semver/functions/clean.js -var require_clean = __commonJS({ - "node_modules/semver/functions/clean.js"(exports, module2) { - var parse2 = require_parse(); - var clean = (version2, options) => { - const s = parse2(version2.trim().replace(/^[=v]+/, ""), options); - return s ? s.version : null; - }; - module2.exports = clean; - } -}); - -// node_modules/semver/functions/inc.js -var require_inc = __commonJS({ - "node_modules/semver/functions/inc.js"(exports, module2) { - var SemVer = require_semver(); - var inc = (version2, release, options, identifier, identifierBase) => { - if (typeof options === "string") { - identifierBase = identifier; - identifier = options; - options = void 0; - } - try { - return new SemVer(version2 instanceof SemVer ? version2.version : version2, options).inc(release, identifier, identifierBase).version; - } catch (er) { - return null; - } - }; - module2.exports = inc; - } -}); - -// node_modules/semver/functions/diff.js -var require_diff = __commonJS({ - "node_modules/semver/functions/diff.js"(exports, module2) { - var parse2 = require_parse(); - var diff = (version1, version2) => { - const v1 = parse2(version1, null, true); - const v2 = parse2(version2, null, true); - const comparison = v1.compare(v2); - if (comparison === 0) { - return null; - } - const v1Higher = comparison > 0; - const highVersion = v1Higher ? v1 : v2; - const lowVersion = v1Higher ? v2 : v1; - const highHasPre = !!highVersion.prerelease.length; - const lowHasPre = !!lowVersion.prerelease.length; - if (lowHasPre && !highHasPre) { - if (!lowVersion.patch && !lowVersion.minor) { - return "major"; - } - if (highVersion.patch) { - return "patch"; - } - if (highVersion.minor) { - return "minor"; - } - return "major"; - } - const prefix = highHasPre ? "pre" : ""; - if (v1.major !== v2.major) { - return prefix + "major"; - } - if (v1.minor !== v2.minor) { - return prefix + "minor"; - } - if (v1.patch !== v2.patch) { - return prefix + "patch"; - } - return "prerelease"; - }; - module2.exports = diff; - } -}); - -// node_modules/semver/functions/major.js -var require_major = __commonJS({ - "node_modules/semver/functions/major.js"(exports, module2) { - var SemVer = require_semver(); - var major = (a, loose) => new SemVer(a, loose).major; - module2.exports = major; - } -}); - -// node_modules/semver/functions/minor.js -var require_minor = __commonJS({ - "node_modules/semver/functions/minor.js"(exports, module2) { - var SemVer = require_semver(); - var minor = (a, loose) => new SemVer(a, loose).minor; - module2.exports = minor; - } -}); - -// node_modules/semver/functions/patch.js -var require_patch = __commonJS({ - "node_modules/semver/functions/patch.js"(exports, module2) { - var SemVer = require_semver(); - var patch = (a, loose) => new SemVer(a, loose).patch; - module2.exports = patch; - } -}); - -// node_modules/semver/functions/prerelease.js -var require_prerelease = __commonJS({ - "node_modules/semver/functions/prerelease.js"(exports, module2) { - var parse2 = require_parse(); - var prerelease = (version2, options) => { - const parsed = parse2(version2, options); - return parsed && parsed.prerelease.length ? parsed.prerelease : null; - }; - module2.exports = prerelease; - } -}); - -// node_modules/semver/functions/compare.js -var require_compare = __commonJS({ - "node_modules/semver/functions/compare.js"(exports, module2) { - var SemVer = require_semver(); - var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)); - module2.exports = compare; - } -}); - -// node_modules/semver/functions/rcompare.js -var require_rcompare = __commonJS({ - "node_modules/semver/functions/rcompare.js"(exports, module2) { - var compare = require_compare(); - var rcompare = (a, b, loose) => compare(b, a, loose); - module2.exports = rcompare; - } -}); - -// node_modules/semver/functions/compare-loose.js -var require_compare_loose = __commonJS({ - "node_modules/semver/functions/compare-loose.js"(exports, module2) { - var compare = require_compare(); - var compareLoose = (a, b) => compare(a, b, true); - module2.exports = compareLoose; - } -}); - -// node_modules/semver/functions/compare-build.js -var require_compare_build = __commonJS({ - "node_modules/semver/functions/compare-build.js"(exports, module2) { - var SemVer = require_semver(); - var compareBuild = (a, b, loose) => { - const versionA = new SemVer(a, loose); - const versionB = new SemVer(b, loose); - return versionA.compare(versionB) || versionA.compareBuild(versionB); - }; - module2.exports = compareBuild; - } -}); - -// node_modules/semver/functions/sort.js -var require_sort = __commonJS({ - "node_modules/semver/functions/sort.js"(exports, module2) { - var compareBuild = require_compare_build(); - var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)); - module2.exports = sort; - } -}); - -// node_modules/semver/functions/rsort.js -var require_rsort = __commonJS({ - "node_modules/semver/functions/rsort.js"(exports, module2) { - var compareBuild = require_compare_build(); - var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)); - module2.exports = rsort; - } -}); - -// node_modules/semver/functions/gt.js -var require_gt = __commonJS({ - "node_modules/semver/functions/gt.js"(exports, module2) { - var compare = require_compare(); - var gt2 = (a, b, loose) => compare(a, b, loose) > 0; - module2.exports = gt2; - } -}); - -// node_modules/semver/functions/lt.js -var require_lt = __commonJS({ - "node_modules/semver/functions/lt.js"(exports, module2) { - var compare = require_compare(); - var lt = (a, b, loose) => compare(a, b, loose) < 0; - module2.exports = lt; - } -}); - -// node_modules/semver/functions/eq.js -var require_eq = __commonJS({ - "node_modules/semver/functions/eq.js"(exports, module2) { - var compare = require_compare(); - var eq = (a, b, loose) => compare(a, b, loose) === 0; - module2.exports = eq; - } -}); - -// node_modules/semver/functions/neq.js -var require_neq = __commonJS({ - "node_modules/semver/functions/neq.js"(exports, module2) { - var compare = require_compare(); - var neq = (a, b, loose) => compare(a, b, loose) !== 0; - module2.exports = neq; - } -}); - -// node_modules/semver/functions/gte.js -var require_gte = __commonJS({ - "node_modules/semver/functions/gte.js"(exports, module2) { - var compare = require_compare(); - var gte = (a, b, loose) => compare(a, b, loose) >= 0; - module2.exports = gte; - } -}); - -// node_modules/semver/functions/lte.js -var require_lte = __commonJS({ - "node_modules/semver/functions/lte.js"(exports, module2) { - var compare = require_compare(); - var lte = (a, b, loose) => compare(a, b, loose) <= 0; - module2.exports = lte; - } -}); - -// node_modules/semver/functions/cmp.js -var require_cmp = __commonJS({ - "node_modules/semver/functions/cmp.js"(exports, module2) { - var eq = require_eq(); - var neq = require_neq(); - var gt2 = require_gt(); - var gte = require_gte(); - var lt = require_lt(); - var lte = require_lte(); - var cmp = (a, op, b, loose) => { - switch (op) { - case "===": - if (typeof a === "object") { - a = a.version; - } - if (typeof b === "object") { - b = b.version; - } - return a === b; - case "!==": - if (typeof a === "object") { - a = a.version; - } - if (typeof b === "object") { - b = b.version; - } - return a !== b; - case "": - case "=": - case "==": - return eq(a, b, loose); - case "!=": - return neq(a, b, loose); - case ">": - return gt2(a, b, loose); - case ">=": - return gte(a, b, loose); - case "<": - return lt(a, b, loose); - case "<=": - return lte(a, b, loose); - default: - throw new TypeError(`Invalid operator: ${op}`); - } - }; - module2.exports = cmp; - } -}); - -// node_modules/semver/functions/coerce.js -var require_coerce = __commonJS({ - "node_modules/semver/functions/coerce.js"(exports, module2) { - var SemVer = require_semver(); - var parse2 = require_parse(); - var { safeRe: re, t: t2 } = require_re(); - var coerce = (version2, options) => { - if (version2 instanceof SemVer) { - return version2; - } - if (typeof version2 === "number") { - version2 = String(version2); - } - if (typeof version2 !== "string") { - return null; - } - options = options || {}; - let match = null; - if (!options.rtl) { - match = version2.match(options.includePrerelease ? re[t2.COERCEFULL] : re[t2.COERCE]); - } else { - const coerceRtlRegex = options.includePrerelease ? re[t2.COERCERTLFULL] : re[t2.COERCERTL]; - let next; - while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) { - if (!match || next.index + next[0].length !== match.index + match[0].length) { - match = next; - } - coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length; - } - coerceRtlRegex.lastIndex = -1; - } - if (match === null) { - return null; - } - const major = match[2]; - const minor = match[3] || "0"; - const patch = match[4] || "0"; - const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ""; - const build = options.includePrerelease && match[6] ? `+${match[6]}` : ""; - return parse2(`${major}.${minor}.${patch}${prerelease}${build}`, options); - }; - module2.exports = coerce; - } -}); - -// node_modules/semver/internal/lrucache.js -var require_lrucache = __commonJS({ - "node_modules/semver/internal/lrucache.js"(exports, module2) { - var LRUCache = class { - constructor() { - this.max = 1e3; - this.map = /* @__PURE__ */ new Map(); - } - get(key) { - const value = this.map.get(key); - if (value === void 0) { - return void 0; - } else { - this.map.delete(key); - this.map.set(key, value); - return value; - } - } - delete(key) { - return this.map.delete(key); - } - set(key, value) { - const deleted = this.delete(key); - if (!deleted && value !== void 0) { - if (this.map.size >= this.max) { - const firstKey = this.map.keys().next().value; - this.delete(firstKey); - } - this.map.set(key, value); - } - return this; - } - }; - module2.exports = LRUCache; - } -}); - -// node_modules/semver/classes/range.js -var require_range = __commonJS({ - "node_modules/semver/classes/range.js"(exports, module2) { - var Range3 = class { - constructor(range, options) { - options = parseOptions(options); - if (range instanceof Range3) { - if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { - return range; - } else { - return new Range3(range.raw, options); - } - } - if (range instanceof Comparator) { - this.raw = range.value; - this.set = [[range]]; - this.format(); - return this; - } - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - this.raw = range.trim().split(/\s+/).join(" "); - this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length); - if (!this.set.length) { - throw new TypeError(`Invalid SemVer Range: ${this.raw}`); - } - if (this.set.length > 1) { - const first = this.set[0]; - this.set = this.set.filter((c) => !isNullSet(c[0])); - if (this.set.length === 0) { - this.set = [first]; - } else if (this.set.length > 1) { - for (const c of this.set) { - if (c.length === 1 && isAny(c[0])) { - this.set = [c]; - break; - } - } - } - } - this.format(); - } - format() { - this.range = this.set.map((comps) => comps.join(" ").trim()).join("||").trim(); - return this.range; - } - toString() { - return this.range; - } - parseRange(range) { - const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE); - const memoKey = memoOpts + ":" + range; - const cached = cache.get(memoKey); - if (cached) { - return cached; - } - const loose = this.options.loose; - const hr = loose ? re[t2.HYPHENRANGELOOSE] : re[t2.HYPHENRANGE]; - range = range.replace(hr, hyphenReplace(this.options.includePrerelease)); - debug4("hyphen replace", range); - range = range.replace(re[t2.COMPARATORTRIM], comparatorTrimReplace); - debug4("comparator trim", range); - range = range.replace(re[t2.TILDETRIM], tildeTrimReplace); - debug4("tilde trim", range); - range = range.replace(re[t2.CARETTRIM], caretTrimReplace); - debug4("caret trim", range); - let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options)); - if (loose) { - rangeList = rangeList.filter((comp) => { - debug4("loose invalid filter", comp, this.options); - return !!comp.match(re[t2.COMPARATORLOOSE]); - }); - } - debug4("range list", rangeList); - const rangeMap = /* @__PURE__ */ new Map(); - const comparators = rangeList.map((comp) => new Comparator(comp, this.options)); - for (const comp of comparators) { - if (isNullSet(comp)) { - return [comp]; - } - rangeMap.set(comp.value, comp); - } - if (rangeMap.size > 1 && rangeMap.has("")) { - rangeMap.delete(""); - } - const result = [...rangeMap.values()]; - cache.set(memoKey, result); - return result; - } - intersects(range, options) { - if (!(range instanceof Range3)) { - throw new TypeError("a Range is required"); - } - return this.set.some((thisComparators) => { - return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => { - return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => { - return rangeComparators.every((rangeComparator) => { - return thisComparator.intersects(rangeComparator, options); - }); - }); - }); - }); - } - test(version2) { - if (!version2) { - return false; - } - if (typeof version2 === "string") { - try { - version2 = new SemVer(version2, this.options); - } catch (er) { - return false; - } - } - for (let i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version2, this.options)) { - return true; - } - } - return false; - } - }; - module2.exports = Range3; - var LRU = require_lrucache(); - var cache = new LRU(); - var parseOptions = require_parse_options(); - var Comparator = require_comparator(); - var debug4 = require_debug(); - var SemVer = require_semver(); - var { - safeRe: re, - t: t2, - comparatorTrimReplace, - tildeTrimReplace, - caretTrimReplace - } = require_re(); - var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants(); - var isNullSet = (c) => c.value === "<0.0.0-0"; - var isAny = (c) => c.value === ""; - var isSatisfiable = (comparators, options) => { - let result = true; - const remainingComparators = comparators.slice(); - let testComparator = remainingComparators.pop(); - while (result && remainingComparators.length) { - result = remainingComparators.every((otherComparator) => { - return testComparator.intersects(otherComparator, options); - }); - testComparator = remainingComparators.pop(); - } - return result; - }; - var parseComparator = (comp, options) => { - debug4("comp", comp, options); - comp = replaceCarets(comp, options); - debug4("caret", comp); - comp = replaceTildes(comp, options); - debug4("tildes", comp); - comp = replaceXRanges(comp, options); - debug4("xrange", comp); - comp = replaceStars(comp, options); - debug4("stars", comp); - return comp; - }; - var isX = (id) => !id || id.toLowerCase() === "x" || id === "*"; - var replaceTildes = (comp, options) => { - return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" "); - }; - var replaceTilde = (comp, options) => { - const r = options.loose ? re[t2.TILDELOOSE] : re[t2.TILDE]; - return comp.replace(r, (_, M, m, p, pr) => { - debug4("tilde", comp, _, M, m, p, pr); - let ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = `>=${M}.0.0 <${+M + 1}.0.0-0`; - } else if (isX(p)) { - ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`; - } else if (pr) { - debug4("replaceTilde pr", pr); - ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; - } else { - ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`; - } - debug4("tilde return", ret); - return ret; - }); - }; - var replaceCarets = (comp, options) => { - return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" "); - }; - var replaceCaret = (comp, options) => { - debug4("caret", comp, options); - const r = options.loose ? re[t2.CARETLOOSE] : re[t2.CARET]; - const z = options.includePrerelease ? "-0" : ""; - return comp.replace(r, (_, M, m, p, pr) => { - debug4("caret", comp, _, M, m, p, pr); - let ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`; - } else if (isX(p)) { - if (M === "0") { - ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`; - } else { - ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`; - } - } else if (pr) { - debug4("replaceCaret pr", pr); - if (M === "0") { - if (m === "0") { - ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`; - } else { - ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; - } - } else { - ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`; - } - } else { - debug4("no pr"); - if (M === "0") { - if (m === "0") { - ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`; - } else { - ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`; - } - } else { - ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`; - } - } - debug4("caret return", ret); - return ret; - }); - }; - var replaceXRanges = (comp, options) => { - debug4("replaceXRanges", comp, options); - return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" "); - }; - var replaceXRange = (comp, options) => { - comp = comp.trim(); - const r = options.loose ? re[t2.XRANGELOOSE] : re[t2.XRANGE]; - return comp.replace(r, (ret, gtlt, M, m, p, pr) => { - debug4("xRange", comp, ret, gtlt, M, m, p, pr); - const xM = isX(M); - const xm = xM || isX(m); - const xp = xm || isX(p); - const anyX = xp; - if (gtlt === "=" && anyX) { - gtlt = ""; - } - pr = options.includePrerelease ? "-0" : ""; - if (xM) { - if (gtlt === ">" || gtlt === "<") { - ret = "<0.0.0-0"; - } else { - ret = "*"; - } - } else if (gtlt && anyX) { - if (xm) { - m = 0; - } - p = 0; - if (gtlt === ">") { - gtlt = ">="; - if (xm) { - M = +M + 1; - m = 0; - p = 0; - } else { - m = +m + 1; - p = 0; - } - } else if (gtlt === "<=") { - gtlt = "<"; - if (xm) { - M = +M + 1; - } else { - m = +m + 1; - } - } - if (gtlt === "<") { - pr = "-0"; - } - ret = `${gtlt + M}.${m}.${p}${pr}`; - } else if (xm) { - ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`; - } else if (xp) { - ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`; - } - debug4("xRange return", ret); - return ret; - }); - }; - var replaceStars = (comp, options) => { - debug4("replaceStars", comp, options); - return comp.trim().replace(re[t2.STAR], ""); - }; - var replaceGTE0 = (comp, options) => { - debug4("replaceGTE0", comp, options); - return comp.trim().replace(re[options.includePrerelease ? t2.GTE0PRE : t2.GTE0], ""); - }; - var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => { - if (isX(fM)) { - from = ""; - } else if (isX(fm)) { - from = `>=${fM}.0.0${incPr ? "-0" : ""}`; - } else if (isX(fp)) { - from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`; - } else if (fpr) { - from = `>=${from}`; - } else { - from = `>=${from}${incPr ? "-0" : ""}`; - } - if (isX(tM)) { - to = ""; - } else if (isX(tm)) { - to = `<${+tM + 1}.0.0-0`; - } else if (isX(tp)) { - to = `<${tM}.${+tm + 1}.0-0`; - } else if (tpr) { - to = `<=${tM}.${tm}.${tp}-${tpr}`; - } else if (incPr) { - to = `<${tM}.${tm}.${+tp + 1}-0`; - } else { - to = `<=${to}`; - } - return `${from} ${to}`.trim(); - }; - var testSet = (set, version2, options) => { - for (let i = 0; i < set.length; i++) { - if (!set[i].test(version2)) { - return false; - } - } - if (version2.prerelease.length && !options.includePrerelease) { - for (let i = 0; i < set.length; i++) { - debug4(set[i].semver); - if (set[i].semver === Comparator.ANY) { - continue; - } - if (set[i].semver.prerelease.length > 0) { - const allowed = set[i].semver; - if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) { - return true; - } - } - } - return false; - } - return true; - }; - } -}); - -// node_modules/semver/classes/comparator.js -var require_comparator = __commonJS({ - "node_modules/semver/classes/comparator.js"(exports, module2) { - var ANY = Symbol("SemVer ANY"); - var Comparator = class { - static get ANY() { - return ANY; - } - constructor(comp, options) { - options = parseOptions(options); - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp; - } else { - comp = comp.value; - } - } - comp = comp.trim().split(/\s+/).join(" "); - debug4("comparator", comp, options); - this.options = options; - this.loose = !!options.loose; - this.parse(comp); - if (this.semver === ANY) { - this.value = ""; - } else { - this.value = this.operator + this.semver.version; - } - debug4("comp", this); - } - parse(comp) { - const r = this.options.loose ? re[t2.COMPARATORLOOSE] : re[t2.COMPARATOR]; - const m = comp.match(r); - if (!m) { - throw new TypeError(`Invalid comparator: ${comp}`); - } - this.operator = m[1] !== void 0 ? m[1] : ""; - if (this.operator === "=") { - this.operator = ""; - } - if (!m[2]) { - this.semver = ANY; - } else { - this.semver = new SemVer(m[2], this.options.loose); - } - } - toString() { - return this.value; - } - test(version2) { - debug4("Comparator.test", version2, this.options.loose); - if (this.semver === ANY || version2 === ANY) { - return true; - } - if (typeof version2 === "string") { - try { - version2 = new SemVer(version2, this.options); - } catch (er) { - return false; - } - } - return cmp(version2, this.operator, this.semver, this.options); - } - intersects(comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError("a Comparator is required"); - } - if (this.operator === "") { - if (this.value === "") { - return true; - } - return new Range3(comp.value, options).test(this.value); - } else if (comp.operator === "") { - if (comp.value === "") { - return true; - } - return new Range3(this.value, options).test(comp.semver); - } - options = parseOptions(options); - if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) { - return false; - } - if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) { - return false; - } - if (this.operator.startsWith(">") && comp.operator.startsWith(">")) { - return true; - } - if (this.operator.startsWith("<") && comp.operator.startsWith("<")) { - return true; - } - if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) { - return true; - } - if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) { - return true; - } - if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) { - return true; - } - return false; - } - }; - module2.exports = Comparator; - var parseOptions = require_parse_options(); - var { safeRe: re, t: t2 } = require_re(); - var cmp = require_cmp(); - var debug4 = require_debug(); - var SemVer = require_semver(); - var Range3 = require_range(); - } -}); - -// node_modules/semver/functions/satisfies.js -var require_satisfies = __commonJS({ - "node_modules/semver/functions/satisfies.js"(exports, module2) { - var Range3 = require_range(); - var satisfies = (version2, range, options) => { - try { - range = new Range3(range, options); - } catch (er) { - return false; - } - return range.test(version2); - }; - module2.exports = satisfies; - } -}); - -// node_modules/semver/ranges/to-comparators.js -var require_to_comparators = __commonJS({ - "node_modules/semver/ranges/to-comparators.js"(exports, module2) { - var Range3 = require_range(); - var toComparators = (range, options) => new Range3(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" ")); - module2.exports = toComparators; - } -}); - -// node_modules/semver/ranges/max-satisfying.js -var require_max_satisfying = __commonJS({ - "node_modules/semver/ranges/max-satisfying.js"(exports, module2) { - var SemVer = require_semver(); - var Range3 = require_range(); - var maxSatisfying = (versions, range, options) => { - let max2 = null; - let maxSV = null; - let rangeObj = null; - try { - rangeObj = new Range3(range, options); - } catch (er) { - return null; - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - if (!max2 || maxSV.compare(v) === -1) { - max2 = v; - maxSV = new SemVer(max2, options); - } - } - }); - return max2; - }; - module2.exports = maxSatisfying; - } -}); - -// node_modules/semver/ranges/min-satisfying.js -var require_min_satisfying = __commonJS({ - "node_modules/semver/ranges/min-satisfying.js"(exports, module2) { - var SemVer = require_semver(); - var Range3 = require_range(); - var minSatisfying = (versions, range, options) => { - let min3 = null; - let minSV = null; - let rangeObj = null; - try { - rangeObj = new Range3(range, options); - } catch (er) { - return null; - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - if (!min3 || minSV.compare(v) === 1) { - min3 = v; - minSV = new SemVer(min3, options); - } - } - }); - return min3; - }; - module2.exports = minSatisfying; - } -}); - -// node_modules/semver/ranges/min-version.js -var require_min_version = __commonJS({ - "node_modules/semver/ranges/min-version.js"(exports, module2) { - var SemVer = require_semver(); - var Range3 = require_range(); - var gt2 = require_gt(); - var minVersion = (range, loose) => { - range = new Range3(range, loose); - let minver = new SemVer("0.0.0"); - if (range.test(minver)) { - return minver; - } - minver = new SemVer("0.0.0-0"); - if (range.test(minver)) { - return minver; - } - minver = null; - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i]; - let setMin = null; - comparators.forEach((comparator) => { - const compver = new SemVer(comparator.semver.version); - switch (comparator.operator) { - case ">": - if (compver.prerelease.length === 0) { - compver.patch++; - } else { - compver.prerelease.push(0); - } - compver.raw = compver.format(); - case "": - case ">=": - if (!setMin || gt2(compver, setMin)) { - setMin = compver; - } - break; - case "<": - case "<=": - break; - default: - throw new Error(`Unexpected operation: ${comparator.operator}`); - } - }); - if (setMin && (!minver || gt2(minver, setMin))) { - minver = setMin; - } - } - if (minver && range.test(minver)) { - return minver; - } - return null; - }; - module2.exports = minVersion; - } -}); - -// node_modules/semver/ranges/valid.js -var require_valid2 = __commonJS({ - "node_modules/semver/ranges/valid.js"(exports, module2) { - var Range3 = require_range(); - var validRange = (range, options) => { - try { - return new Range3(range, options).range || "*"; - } catch (er) { - return null; - } - }; - module2.exports = validRange; - } -}); - -// node_modules/semver/ranges/outside.js -var require_outside = __commonJS({ - "node_modules/semver/ranges/outside.js"(exports, module2) { - var SemVer = require_semver(); - var Comparator = require_comparator(); - var { ANY } = Comparator; - var Range3 = require_range(); - var satisfies = require_satisfies(); - var gt2 = require_gt(); - var lt = require_lt(); - var lte = require_lte(); - var gte = require_gte(); - var outside = (version2, range, hilo, options) => { - version2 = new SemVer(version2, options); - range = new Range3(range, options); - let gtfn, ltefn, ltfn, comp, ecomp; - switch (hilo) { - case ">": - gtfn = gt2; - ltefn = lte; - ltfn = lt; - comp = ">"; - ecomp = ">="; - break; - case "<": - gtfn = lt; - ltefn = gte; - ltfn = gt2; - comp = "<"; - ecomp = "<="; - break; - default: - throw new TypeError('Must provide a hilo val of "<" or ">"'); - } - if (satisfies(version2, range, options)) { - return false; - } - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i]; - let high = null; - let low = null; - comparators.forEach((comparator) => { - if (comparator.semver === ANY) { - comparator = new Comparator(">=0.0.0"); - } - high = high || comparator; - low = low || comparator; - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator; - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator; - } - }); - if (high.operator === comp || high.operator === ecomp) { - return false; - } - if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) { - return false; - } else if (low.operator === ecomp && ltfn(version2, low.semver)) { - return false; - } - } - return true; - }; - module2.exports = outside; - } -}); - -// node_modules/semver/ranges/gtr.js -var require_gtr = __commonJS({ - "node_modules/semver/ranges/gtr.js"(exports, module2) { - var outside = require_outside(); - var gtr = (version2, range, options) => outside(version2, range, ">", options); - module2.exports = gtr; - } -}); - -// node_modules/semver/ranges/ltr.js -var require_ltr = __commonJS({ - "node_modules/semver/ranges/ltr.js"(exports, module2) { - var outside = require_outside(); - var ltr = (version2, range, options) => outside(version2, range, "<", options); - module2.exports = ltr; - } -}); - -// node_modules/semver/ranges/intersects.js -var require_intersects = __commonJS({ - "node_modules/semver/ranges/intersects.js"(exports, module2) { - var Range3 = require_range(); - var intersects = (r1, r2, options) => { - r1 = new Range3(r1, options); - r2 = new Range3(r2, options); - return r1.intersects(r2, options); - }; - module2.exports = intersects; - } -}); - -// node_modules/semver/ranges/simplify.js -var require_simplify = __commonJS({ - "node_modules/semver/ranges/simplify.js"(exports, module2) { - var satisfies = require_satisfies(); - var compare = require_compare(); - module2.exports = (versions, range, options) => { - const set = []; - let first = null; - let prev = null; - const v = versions.sort((a, b) => compare(a, b, options)); - for (const version2 of v) { - const included = satisfies(version2, range, options); - if (included) { - prev = version2; - if (!first) { - first = version2; - } - } else { - if (prev) { - set.push([first, prev]); - } - prev = null; - first = null; - } - } - if (first) { - set.push([first, null]); - } - const ranges = []; - for (const [min3, max2] of set) { - if (min3 === max2) { - ranges.push(min3); - } else if (!max2 && min3 === v[0]) { - ranges.push("*"); - } else if (!max2) { - ranges.push(`>=${min3}`); - } else if (min3 === v[0]) { - ranges.push(`<=${max2}`); - } else { - ranges.push(`${min3} - ${max2}`); - } - } - const simplified = ranges.join(" || "); - const original = typeof range.raw === "string" ? range.raw : String(range); - return simplified.length < original.length ? simplified : range; - }; - } -}); - -// node_modules/semver/ranges/subset.js -var require_subset = __commonJS({ - "node_modules/semver/ranges/subset.js"(exports, module2) { - var Range3 = require_range(); - var Comparator = require_comparator(); - var { ANY } = Comparator; - var satisfies = require_satisfies(); - var compare = require_compare(); - var subset = (sub, dom, options = {}) => { - if (sub === dom) { - return true; - } - sub = new Range3(sub, options); - dom = new Range3(dom, options); - let sawNonNull = false; - OUTER: - for (const simpleSub of sub.set) { - for (const simpleDom of dom.set) { - const isSub = simpleSubset(simpleSub, simpleDom, options); - sawNonNull = sawNonNull || isSub !== null; - if (isSub) { - continue OUTER; - } - } - if (sawNonNull) { - return false; - } - } - return true; - }; - var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")]; - var minimumVersion = [new Comparator(">=0.0.0")]; - var simpleSubset = (sub, dom, options) => { - if (sub === dom) { - return true; - } - if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) { - return true; - } else if (options.includePrerelease) { - sub = minimumVersionWithPreRelease; - } else { - sub = minimumVersion; - } - } - if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) { - return true; - } else { - dom = minimumVersion; - } - } - const eqSet = /* @__PURE__ */ new Set(); - let gt2, lt; - for (const c of sub) { - if (c.operator === ">" || c.operator === ">=") { - gt2 = higherGT(gt2, c, options); - } else if (c.operator === "<" || c.operator === "<=") { - lt = lowerLT(lt, c, options); - } else { - eqSet.add(c.semver); - } - } - if (eqSet.size > 1) { - return null; - } - let gtltComp; - if (gt2 && lt) { - gtltComp = compare(gt2.semver, lt.semver, options); - if (gtltComp > 0) { - return null; - } else if (gtltComp === 0 && (gt2.operator !== ">=" || lt.operator !== "<=")) { - return null; - } - } - for (const eq of eqSet) { - if (gt2 && !satisfies(eq, String(gt2), options)) { - return null; - } - if (lt && !satisfies(eq, String(lt), options)) { - return null; - } - for (const c of dom) { - if (!satisfies(eq, String(c), options)) { - return false; - } - } - return true; - } - let higher, lower; - let hasDomLT, hasDomGT; - let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false; - let needDomGTPre = gt2 && !options.includePrerelease && gt2.semver.prerelease.length ? gt2.semver : false; - if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) { - needDomLTPre = false; - } - for (const c of dom) { - hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">="; - hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<="; - if (gt2) { - if (needDomGTPre) { - if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) { - needDomGTPre = false; - } - } - if (c.operator === ">" || c.operator === ">=") { - higher = higherGT(gt2, c, options); - if (higher === c && higher !== gt2) { - return false; - } - } else if (gt2.operator === ">=" && !satisfies(gt2.semver, String(c), options)) { - return false; - } - } - if (lt) { - if (needDomLTPre) { - if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) { - needDomLTPre = false; - } - } - if (c.operator === "<" || c.operator === "<=") { - lower = lowerLT(lt, c, options); - if (lower === c && lower !== lt) { - return false; - } - } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) { - return false; - } - } - if (!c.operator && (lt || gt2) && gtltComp !== 0) { - return false; - } - } - if (gt2 && hasDomLT && !lt && gtltComp !== 0) { - return false; - } - if (lt && hasDomGT && !gt2 && gtltComp !== 0) { - return false; - } - if (needDomGTPre || needDomLTPre) { - return false; - } - return true; - }; - var higherGT = (a, b, options) => { - if (!a) { - return b; - } - const comp = compare(a.semver, b.semver, options); - return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a; - }; - var lowerLT = (a, b, options) => { - if (!a) { - return b; - } - const comp = compare(a.semver, b.semver, options); - return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a; - }; - module2.exports = subset; - } -}); - -// node_modules/semver/index.js -var require_semver2 = __commonJS({ - "node_modules/semver/index.js"(exports, module2) { - var internalRe = require_re(); - var constants = require_constants(); - var SemVer = require_semver(); - var identifiers = require_identifiers(); - var parse2 = require_parse(); - var valid2 = require_valid(); - var clean = require_clean(); - var inc = require_inc(); - var diff = require_diff(); - var major = require_major(); - var minor = require_minor(); - var patch = require_patch(); - var prerelease = require_prerelease(); - var compare = require_compare(); - var rcompare = require_rcompare(); - var compareLoose = require_compare_loose(); - var compareBuild = require_compare_build(); - var sort = require_sort(); - var rsort = require_rsort(); - var gt2 = require_gt(); - var lt = require_lt(); - var eq = require_eq(); - var neq = require_neq(); - var gte = require_gte(); - var lte = require_lte(); - var cmp = require_cmp(); - var coerce = require_coerce(); - var Comparator = require_comparator(); - var Range3 = require_range(); - var satisfies = require_satisfies(); - var toComparators = require_to_comparators(); - var maxSatisfying = require_max_satisfying(); - var minSatisfying = require_min_satisfying(); - var minVersion = require_min_version(); - var validRange = require_valid2(); - var outside = require_outside(); - var gtr = require_gtr(); - var ltr = require_ltr(); - var intersects = require_intersects(); - var simplifyRange = require_simplify(); - var subset = require_subset(); - module2.exports = { - parse: parse2, - valid: valid2, - clean, - inc, - diff, - major, - minor, - patch, - prerelease, - compare, - rcompare, - compareLoose, - compareBuild, - sort, - rsort, - gt: gt2, - lt, - eq, - neq, - gte, - lte, - cmp, - coerce, - Comparator, - Range: Range3, - satisfies, - toComparators, - maxSatisfying, - minSatisfying, - minVersion, - validRange, - outside, - gtr, - ltr, - intersects, - simplifyRange, - subset, - SemVer, - re: internalRe.re, - src: internalRe.src, - tokens: internalRe.t, - SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, - RELEASE_TYPES: constants.RELEASE_TYPES, - compareIdentifiers: identifiers.compareIdentifiers, - rcompareIdentifiers: identifiers.rcompareIdentifiers - }; - } -}); - -// src/graphics/icons/write_default.svg -var require_write_default = __commonJS({ - "src/graphics/icons/write_default.svg"(exports, module2) { - module2.exports = '<svg\n viewBox="2 2 21 21"\n xmlns="http://www.w3.org/2000/svg"\n fill="currentcolor" \n >\n <g class="frame-children">\n <path d="M3.337,7.285C3.292,4.586,4.792,2.536,6.791,2.536C7.644,2.536,8.562,2.835,9.244,3.671C9.904,4.480,10.246,5.674,10.246,7.270C10.246,8.787,9.619,10.449,8.510,12.222C8.137,12.819,7.704,13.438,7.211,14.077C7.551,13.992,7.924,14.111,8.147,14.408C8.613,15.030,9.004,15.484,9.343,15.800C9.685,16.120,9.926,16.252,10.087,16.299C10.265,16.352,10.567,16.372,11.245,15.624C11.908,14.893,12.190,14.351,12.413,13.805C12.472,13.661,12.532,13.500,12.597,13.326C12.772,12.856,12.984,12.286,13.316,11.665C13.500,11.320,13.886,11.135,14.269,11.206C14.653,11.277,14.946,11.588,14.995,11.976C15.208,13.685,15.534,14.917,15.948,15.527C16.138,15.806,16.262,15.834,16.302,15.838C16.361,15.846,16.577,15.840,17.005,15.513C17.660,15.014,18.317,14.799,18.988,14.918C19.564,15.020,20.015,15.359,20.287,15.563C20.296,15.570,20.305,15.577,20.314,15.584C20.653,15.838,20.786,15.925,20.908,15.953C20.909,15.953,20.910,15.954,20.911,15.954C20.946,15.962,21.081,15.995,21.416,15.751C21.816,15.460,22.376,15.548,22.667,15.948C22.958,16.348,22.870,16.908,22.470,17.199C21.817,17.674,21.161,17.850,20.505,17.698C19.980,17.577,19.553,17.254,19.294,17.058C19.275,17.043,19.257,17.029,19.239,17.016C18.918,16.775,18.786,16.701,18.675,16.681C18.637,16.674,18.474,16.645,18.092,16.937C17.480,17.404,16.799,17.703,16.085,17.616C15.351,17.527,14.825,17.061,14.466,16.533C14.197,16.136,13.978,15.641,13.800,15.082C13.532,15.612,13.165,16.173,12.572,16.826C11.768,17.713,10.791,18.374,9.581,18.017C9.046,17.860,8.566,17.525,8.121,17.110C7.671,16.690,7.208,16.141,6.715,15.483C6.589,15.315,6.531,15.118,6.536,14.924C5.692,15.945,4.708,17.016,3.587,18.138C3.237,18.487,2.670,18.487,2.320,18.138C1.970,17.788,1.970,17.221,2.320,16.871C4.425,14.766,5.974,12.900,6.991,11.273C8.015,9.635,8.454,8.311,8.454,7.270C8.454,5.896,8.156,5.170,7.856,4.803C7.579,4.463,7.218,4.327,6.791,4.327C6.232,4.327,5.091,5.054,5.128,7.255C5.136,7.749,4.742,8.157,4.248,8.165C3.753,8.173,3.345,7.779,3.337,7.285ZZ"/>\n <path d="M4.218,6.374C4.712,6.366,5.120,6.760,5.128,7.255C5.147,8.373,5.612,9.795,6.256,11.172C6.890,12.532,7.648,13.742,8.147,14.408C8.444,14.804,8.364,15.366,7.968,15.662C7.572,15.959,7.011,15.879,6.714,15.483C6.137,14.713,5.317,13.395,4.633,11.930C3.957,10.484,3.362,8.786,3.337,7.285C3.329,6.790,3.723,6.383,4.218,6.374ZZ"/>\n <path d="M3.837,20.400C3.837,19.906,4.238,19.505,4.732,19.505L21.299,19.505C21.794,19.505,22.194,19.906,22.194,20.400C22.194,20.895,21.794,21.296,21.299,21.296L4.732,21.296C4.238,21.296,3.837,20.895,3.837,20.400ZZ"/>\n <ellipse cx="14.496" cy="8.705" rx="1.107" ry="1.107" transform="matrix(0.897379, -0.441262, 0.441262, 0.897379, -2.353381, 7.289870)" />\n </g>\n</svg>'; - } -}); - -// src/graphics/icons/write_existing.svg -var require_write_existing = __commonJS({ - "src/graphics/icons/write_existing.svg"(exports, module2) { - module2.exports = '<svg\n viewBox="2 2 21 21"\n xmlns="http://www.w3.org/2000/svg"\n fill="currentcolor" \n>\n <g class="frame-children">\n <path d="M7.522,11.373C7.941,11.111,8.494,11.239,8.756,11.658C8.952,11.972,9.202,12.364,9.312,12.511C9.609,12.906,9.528,13.468,9.133,13.764C8.737,14.061,8.176,13.981,7.879,13.585C7.713,13.363,7.417,12.896,7.237,12.607C6.975,12.188,7.103,11.635,7.522,11.373ZZ"/>\n <path d="M13.686,10.258C14.122,10.491,14.287,11.034,14.054,11.470C13.872,11.811,13.779,12.062,13.671,12.353C13.618,12.496,13.561,12.648,13.489,12.825C13.275,13.349,12.988,13.885,12.391,14.544C11.810,15.185,11.024,15.749,10.023,15.454C9.593,15.328,9.221,15.063,8.894,14.758C8.563,14.449,8.228,14.051,7.879,13.585C7.582,13.189,7.663,12.628,8.058,12.331C8.454,12.035,9.015,12.115,9.312,12.511C9.634,12.939,9.896,13.243,10.116,13.449C10.340,13.658,10.473,13.720,10.529,13.736C10.530,13.737,10.531,13.737,10.532,13.737C10.553,13.743,10.564,13.747,10.614,13.724C10.696,13.686,10.842,13.586,11.064,13.341C11.503,12.856,11.685,12.505,11.831,12.148C11.867,12.059,11.906,11.954,11.950,11.838C12.073,11.507,12.232,11.079,12.474,10.626C12.707,10.190,13.250,10.025,13.686,10.258ZZ"/>\n <path d="M13.153,10.160C13.644,10.098,14.091,10.446,14.153,10.937C14.302,12.134,14.526,12.936,14.775,13.303C14.807,13.350,14.832,13.379,14.849,13.396C14.893,13.381,14.984,13.341,15.129,13.231C15.673,12.815,16.258,12.673,16.840,12.838C17.285,12.965,17.641,13.260,17.831,13.418C17.845,13.429,17.858,13.440,17.870,13.450C17.938,13.506,17.990,13.547,18.029,13.576C18.040,13.564,18.052,13.550,18.066,13.535C18.387,13.159,18.953,13.116,19.328,13.437C19.704,13.759,19.747,14.325,19.425,14.700C19.021,15.173,18.484,15.519,17.819,15.412C17.335,15.335,16.950,15.015,16.768,14.863C16.755,14.852,16.743,14.842,16.733,14.834C16.495,14.638,16.412,14.583,16.363,14.565C16.343,14.572,16.294,14.594,16.215,14.655C15.760,15.002,15.214,15.256,14.616,15.183C13.998,15.108,13.569,14.716,13.294,14.309C12.777,13.549,12.524,12.349,12.375,11.159C12.314,10.668,12.662,10.221,13.153,10.160ZZM17.933,13.665C17.933,13.665,17.935,13.663,17.933,13.665ZC17.935,13.664,17.933,13.665,17.933,13.665ZZM14.876,13.419C14.876,13.419,14.874,13.418,14.876,13.419ZC14.874,13.417,14.876,13.418,14.876,13.419ZZ"/>\n <path d="M5.463,7.694C5.430,5.731,6.534,4.099,8.148,4.099C8.809,4.099,9.534,4.332,10.072,4.992C10.588,5.624,10.833,6.530,10.833,7.679C10.833,8.812,10.366,10.025,9.578,11.286C8.784,12.557,7.615,13.953,6.097,15.471C5.747,15.820,5.180,15.820,4.830,15.471C4.481,15.121,4.481,14.554,4.830,14.204C5.624,13.411,6.300,12.670,6.865,11.979C6.203,10.773,5.487,9.116,5.463,7.694ZZM8.047,10.357C8.051,10.350,8.055,10.343,8.047,10.357ZC8.763,9.211,9.042,8.336,9.042,7.679C9.042,6.751,8.840,6.315,8.684,6.124C8.551,5.961,8.382,5.890,8.148,5.890C7.973,5.890,7.229,6.200,7.254,7.664C7.267,8.428,7.601,9.416,8.047,10.357ZZ"/>\n <path d="M15.105,16.737C15.444,17.098,15.426,17.664,15.066,18.003C13.407,19.565,10.819,19.565,9.159,18.003C8.799,17.664,8.782,17.098,9.121,16.737C9.460,16.377,10.027,16.360,10.387,16.699C11.356,17.612,12.869,17.612,13.839,16.699C14.199,16.360,14.766,16.377,15.105,16.737ZZ"/>\n <ellipse cx="13.695" cy="8.395" rx=".965" ry=".965" transform="matrix(0.897379, -0.441262, 0.441262, 0.897379, -2.298862, 6.904515)" />\n </g>\n</svg>'; - } -}); - -// src/graphics/icons/write_paste.svg -var require_write_paste = __commonJS({ - "src/graphics/icons/write_paste.svg"(exports, module2) { - module2.exports = '<svg\n viewBox="2 2 21 21"\n xmlns="http://www.w3.org/2000/svg"\n fill="currentcolor" \n>\n <g class="frame-children">\n <path d="M15.954,3.315C15.954,2.821,16.355,2.420,16.850,2.420C19.968,2.420,22.495,4.947,22.495,8.065C22.495,8.559,22.094,8.960,21.599,8.960C21.105,8.960,20.704,8.559,20.704,8.065C20.704,5.936,18.978,4.211,16.850,4.211C16.355,4.211,15.954,3.810,15.954,3.315ZZ"/>\n <path d="M8.246,19.763C8.246,20.257,7.845,20.658,7.350,20.658C4.232,20.658,1.705,18.131,1.705,15.013C1.705,14.518,2.106,14.117,2.600,14.117C3.095,14.117,3.496,14.518,3.496,15.013C3.496,17.142,5.221,18.867,7.350,18.867C7.845,18.867,8.246,19.268,8.246,19.763ZZ"/>\n <path d="M21.599,14.117C22.094,14.117,22.495,14.518,22.495,15.013C22.495,18.131,19.968,20.658,16.850,20.658C16.355,20.658,15.954,20.257,15.954,19.763C15.954,19.268,16.355,18.867,16.850,18.867C18.978,18.867,20.704,17.142,20.704,15.013C20.704,14.518,21.105,14.117,21.599,14.117ZZ"/>\n <path d="M2.610,8.960C2.115,8.960,1.714,8.559,1.714,8.065C1.714,4.947,4.242,2.420,7.359,2.420C7.854,2.420,8.255,2.821,8.255,3.315C8.255,3.810,7.854,4.211,7.359,4.211C5.231,4.211,3.505,5.936,3.505,8.065C3.505,8.559,3.104,8.960,2.610,8.960ZZ"/>\n <ellipse cx="13.625" cy="9.567" rx=".965" ry=".965" transform="matrix(0.897379, -0.441262, 0.441262, 0.897379, -2.823144, 6.993809)"/>\n <path d="M7.522,12.684C7.941,12.421,8.494,12.549,8.756,12.969C8.952,13.282,9.202,13.674,9.312,13.821C9.609,14.216,9.528,14.778,9.133,15.074C8.737,15.371,8.176,15.291,7.879,14.895C7.713,14.674,7.417,14.206,7.237,13.917C6.975,13.498,7.103,12.946,7.522,12.684ZZ"/>\n <path d="M13.686,11.568C14.122,11.801,14.287,12.344,14.054,12.780C13.872,13.121,13.779,13.373,13.671,13.663C13.618,13.806,13.561,13.958,13.489,14.135C13.275,14.660,12.988,15.195,12.391,15.854C11.810,16.495,11.024,17.059,10.023,16.764C9.593,16.638,9.221,16.373,8.894,16.068C8.563,15.759,8.228,15.361,7.879,14.895C7.582,14.500,7.663,13.938,8.058,13.641C8.454,13.345,9.015,13.425,9.312,13.821C9.634,14.250,9.896,14.553,10.116,14.759C10.340,14.968,10.473,15.030,10.529,15.046C10.530,15.047,10.531,15.047,10.532,15.047C10.553,15.053,10.564,15.057,10.614,15.034C10.696,14.996,10.842,14.896,11.064,14.651C11.503,14.166,11.685,13.815,11.831,13.458C11.867,13.369,11.906,13.264,11.950,13.148C12.073,12.817,12.232,12.389,12.474,11.936C12.707,11.500,13.250,11.335,13.686,11.568ZZ"/>\n <path d="M13.153,11.470C13.644,11.408,14.091,11.757,14.153,12.247C14.302,13.444,14.526,14.246,14.775,14.613C14.807,14.660,14.832,14.689,14.849,14.706C14.893,14.691,14.984,14.651,15.129,14.541C15.673,14.126,16.258,13.983,16.840,14.149C17.285,14.275,17.641,14.570,17.831,14.728C17.845,14.740,17.858,14.750,17.870,14.760C17.938,14.816,17.990,14.857,18.029,14.886C18.040,14.874,18.052,14.860,18.066,14.845C18.387,14.469,18.953,14.426,19.328,14.748C19.704,15.069,19.747,15.635,19.425,16.010C19.021,16.483,18.484,16.829,17.819,16.722C17.335,16.645,16.950,16.325,16.768,16.173C16.755,16.162,16.743,16.152,16.733,16.144C16.495,15.949,16.412,15.893,16.363,15.875C16.343,15.883,16.294,15.904,16.215,15.965C15.760,16.312,15.214,16.566,14.616,16.493C13.998,16.418,13.569,16.026,13.294,15.619C12.777,14.859,12.524,13.659,12.375,12.469C12.314,11.978,12.662,11.531,13.153,11.470ZZM17.933,14.975C17.933,14.975,17.935,14.973,17.933,14.975ZC17.935,14.974,17.933,14.975,17.933,14.975ZZM14.876,14.729C14.876,14.729,14.874,14.728,14.876,14.729ZC14.874,14.727,14.876,14.728,14.876,14.729ZZ"/>\n <path d="M5.463,9.004C5.430,7.041,6.534,5.409,8.148,5.409C8.809,5.409,9.534,5.643,10.072,6.302C10.588,6.934,10.833,7.840,10.833,8.989C10.833,10.122,10.366,11.335,9.578,12.596C8.784,13.867,7.615,15.263,6.097,16.781C5.747,17.130,5.180,17.130,4.830,16.781C4.481,16.431,4.481,15.864,4.830,15.514C5.624,14.721,6.300,13.980,6.865,13.290C6.203,12.083,5.487,10.426,5.463,9.004ZZM8.047,11.667C8.051,11.660,8.055,11.653,8.047,11.667ZC8.763,10.521,9.042,9.646,9.042,8.989C9.042,8.062,8.840,7.625,8.684,7.434C8.551,7.271,8.382,7.200,8.148,7.200C7.973,7.200,7.229,7.510,7.254,8.974C7.267,9.738,7.601,10.726,8.047,11.667ZZ"/>\n </g>\n</svg>'; - } -}); - -// src/graphics/icons/draw_default.svg -var require_draw_default = __commonJS({ - "src/graphics/icons/draw_default.svg"(exports, module2) { - module2.exports = '<svg\n viewBox="2 2 21 21"\n xmlns="http://www.w3.org/2000/svg"\n fill="currentcolor" \n>\n <g >\n <path d="M19.771,17.456C20.266,17.456,20.667,17.857,20.667,18.351C20.667,20.003,19.328,21.341,17.677,21.341L11.960,21.341C11.465,21.341,11.064,20.940,11.064,20.446C11.064,19.951,11.465,19.550,11.960,19.550L17.677,19.550C18.339,19.550,18.876,19.013,18.876,18.351C18.876,17.857,19.277,17.456,19.771,17.456ZZ"/>\n <path d="M11.145,5.746C11.440,5.698,12.157,5.793,13.538,6.428C14.954,7.080,16.545,8.303,17.366,9.252C17.689,9.626,18.255,9.667,18.629,9.344C19.003,9.020,19.044,8.454,18.721,8.080C17.727,6.932,15.927,5.556,14.286,4.801C12.875,4.152,11.724,3.836,10.855,3.979C10.375,4.057,9.939,4.285,9.646,4.700C9.370,5.093,9.299,5.548,9.310,5.944C9.331,6.716,9.668,7.595,10.080,8.393C10.506,9.218,11.071,10.066,11.661,10.804C12.233,11.519,12.671,12.225,12.932,12.818C13.062,13.115,13.139,13.362,13.173,13.553C13.187,13.628,13.192,13.689,13.194,13.736C13.146,13.737,13.079,13.733,12.989,13.719C12.486,13.641,11.622,13.310,10.298,12.515C8.860,11.652,7.789,11.177,7.005,11.096C6.593,11.054,6.115,11.105,5.729,11.430C5.341,11.757,5.232,12.203,5.212,12.535C5.174,13.152,5.412,13.871,5.597,14.377C5.675,14.589,5.757,14.800,5.830,14.985C5.852,15.041,5.873,15.094,5.892,15.144C5.984,15.381,6.042,15.539,6.070,15.640C6.082,15.685,6.091,15.724,6.097,15.759C6.017,15.739,5.912,15.705,5.776,15.648C5.408,15.491,4.901,15.196,4.238,14.691C3.844,14.392,3.282,14.469,2.983,14.862C2.684,15.256,2.760,15.818,3.154,16.117C3.886,16.674,4.524,17.062,5.077,17.296C5.612,17.524,6.167,17.649,6.681,17.535C7.271,17.404,7.659,16.991,7.816,16.488C7.956,16.041,7.906,15.567,7.798,15.169C7.741,14.962,7.648,14.717,7.561,14.494C7.538,14.436,7.515,14.377,7.492,14.318C7.421,14.136,7.349,13.952,7.279,13.762C7.150,13.409,7.066,13.124,7.026,12.916C7.439,13.019,8.174,13.330,9.376,14.051C10.753,14.878,11.860,15.357,12.716,15.489C13.149,15.556,13.602,15.547,14.009,15.369C14.452,15.176,14.748,14.823,14.887,14.400C15.015,14.012,15.001,13.603,14.937,13.240C14.871,12.868,14.740,12.481,14.571,12.097C14.233,11.328,13.703,10.489,13.060,9.685C12.534,9.027,12.036,8.278,11.672,7.571C11.293,6.839,11.110,6.254,11.101,5.895C11.099,5.826,11.104,5.780,11.145,5.746ZC11.118,5.751,11.131,5.748,11.145,5.746ZZM11.077,5.764C11.077,5.764,11.078,5.763,11.077,5.764ZC11.077,5.763,11.076,5.764,11.077,5.764ZZM6.738,12.875C6.738,12.875,6.739,12.875,6.738,12.875ZZM7.001,12.625C7.002,12.624,7.002,12.623,7.001,12.625ZZ"/>\n </g>\n</svg>'; - } -}); - -// src/graphics/icons/draw_existing.svg -var require_draw_existing = __commonJS({ - "src/graphics/icons/draw_existing.svg"(exports, module2) { - module2.exports = '<svg\n viewBox="2 2 21 21"\n xmlns="http://www.w3.org/2000/svg"\n fill="currentcolor" \n>\n <g class="frame-children">\n <path d="M14.808,16.098C15.147,16.458,15.129,17.024,14.769,17.363C13.110,18.925,10.521,18.925,8.862,17.363C8.502,17.024,8.485,16.458,8.824,16.098C9.163,15.737,9.730,15.720,10.090,16.059C11.059,16.972,12.572,16.972,13.542,16.059C13.902,15.720,14.469,15.737,14.808,16.098ZZ"/>\n <path d="M12.576,6.218C12.819,6.242,13.279,6.354,14.047,6.707C15.069,7.177,16.224,8.066,16.811,8.745C17.135,9.119,17.700,9.160,18.074,8.837C18.448,8.513,18.489,7.948,18.166,7.573C17.406,6.695,16.043,5.654,14.795,5.080C13.744,4.596,12.833,4.333,12.114,4.451C11.709,4.517,11.324,4.713,11.065,5.081C10.821,5.428,10.765,5.820,10.773,6.144C10.791,6.770,11.060,7.461,11.371,8.062C11.695,8.690,12.123,9.333,12.570,9.891C12.985,10.410,13.299,10.917,13.482,11.335C13.534,11.453,13.573,11.557,13.600,11.647C13.248,11.555,12.684,11.316,11.856,10.820C10.788,10.178,9.954,9.800,9.316,9.734C8.977,9.699,8.549,9.738,8.196,10.035C7.842,10.334,7.748,10.737,7.731,11.018C7.699,11.531,7.895,12.108,8.030,12.479C8.089,12.639,8.152,12.799,8.206,12.937C8.217,12.966,8.228,12.993,8.238,13.019C8.012,12.898,7.727,12.716,7.377,12.450C6.983,12.150,6.421,12.227,6.122,12.621C5.823,13.014,5.899,13.576,6.293,13.876C6.846,14.295,7.336,14.596,7.770,14.780C8.187,14.956,8.652,15.070,9.102,14.970C9.627,14.853,9.975,14.482,10.115,14.036C10.237,13.647,10.190,13.246,10.103,12.927C10.058,12.760,9.984,12.567,9.920,12.403C9.903,12.358,9.885,12.314,9.868,12.270C9.815,12.135,9.763,12.002,9.713,11.864C9.689,11.799,9.667,11.737,9.647,11.677C9.667,11.685,9.689,11.694,9.711,11.704C10.020,11.838,10.421,12.047,10.934,12.355C11.964,12.973,12.817,13.349,13.498,13.453C13.843,13.506,14.228,13.504,14.586,13.348C14.978,13.176,15.241,12.861,15.364,12.489C15.476,12.151,15.461,11.805,15.409,11.515C15.356,11.216,15.252,10.910,15.122,10.614C14.861,10.020,14.455,9.380,13.968,8.772C13.586,8.293,13.225,7.750,12.962,7.240C12.732,6.795,12.613,6.446,12.576,6.218ZZM9.107,11.514C9.107,11.514,9.108,11.514,9.107,11.514ZC9.108,11.514,9.107,11.514,9.107,11.514ZZ"/>\n </g>\n</svg>'; - } -}); - -// src/graphics/icons/draw_paste.svg -var require_draw_paste = __commonJS({ - "src/graphics/icons/draw_paste.svg"(exports, module2) { - module2.exports = '<svg\n viewBox="2 2 21 21"\n xmlns="http://www.w3.org/2000/svg"\n fill="currentcolor" \n>\n <g class="frame-children">\n <path d="M16.298,3.315C16.298,2.821,16.699,2.420,17.194,2.420C20.312,2.420,22.839,4.947,22.839,8.065C22.839,8.559,22.438,8.960,21.943,8.960C21.449,8.960,21.048,8.559,21.048,8.065C21.048,5.936,19.322,4.211,17.194,4.211C16.699,4.211,16.298,3.810,16.298,3.315ZZ" />\n <path d="M8.590,19.763C8.590,20.257,8.189,20.658,7.694,20.658C4.576,20.658,2.049,18.131,2.049,15.013C2.049,14.518,2.450,14.117,2.944,14.117C3.439,14.117,3.840,14.518,3.840,15.013C3.840,17.142,5.565,18.867,7.694,18.867C8.189,18.867,8.590,19.268,8.590,19.763ZZ" />\n <path d="M21.943,14.117C22.438,14.117,22.839,14.518,22.839,15.013C22.839,18.131,20.312,20.658,17.194,20.658C16.699,20.658,16.298,20.257,16.298,19.763C16.298,19.268,16.699,18.867,17.194,18.867C19.322,18.867,21.048,17.142,21.048,15.013C21.048,14.518,21.449,14.117,21.943,14.117ZZ" />\n <path d="M2.954,8.960C2.459,8.960,2.058,8.559,2.058,8.065C2.058,4.947,4.586,2.420,7.703,2.420C8.198,2.420,8.599,2.821,8.599,3.315C8.599,3.810,8.198,4.211,7.703,4.211C5.575,4.211,3.849,5.936,3.849,8.065C3.849,8.559,3.448,8.960,2.954,8.960ZZ" />\n <path d="M13.216,8.168C13.459,8.192,13.919,8.304,14.686,8.657C15.709,9.127,16.863,10.016,17.451,10.695C17.774,11.069,18.340,11.110,18.714,10.787C19.088,10.463,19.129,9.898,18.806,9.523C18.046,8.645,16.683,7.604,15.435,7.030C14.383,6.546,13.472,6.283,12.753,6.401C12.349,6.468,11.964,6.663,11.705,7.031C11.461,7.378,11.404,7.770,11.413,8.095C11.430,8.720,11.700,9.411,12.011,10.013C12.335,10.640,12.763,11.283,13.209,11.841C13.625,12.360,13.938,12.868,14.122,13.285C14.174,13.403,14.212,13.507,14.240,13.597C13.887,13.505,13.323,13.266,12.496,12.770C11.428,12.128,10.593,11.750,9.956,11.684C9.617,11.649,9.189,11.688,8.836,11.985C8.481,12.284,8.388,12.688,8.370,12.968C8.339,13.481,8.534,14.058,8.670,14.429C8.728,14.589,8.791,14.749,8.846,14.888C8.857,14.916,8.867,14.943,8.877,14.969C8.652,14.848,8.367,14.666,8.017,14.400C7.623,14.100,7.061,14.177,6.762,14.571C6.462,14.965,6.539,15.526,6.933,15.826C7.485,16.245,7.976,16.546,8.410,16.730C8.826,16.906,9.292,17.020,9.742,16.920C10.267,16.803,10.615,16.432,10.754,15.986C10.876,15.597,10.830,15.196,10.743,14.877C10.697,14.710,10.623,14.517,10.560,14.353C10.542,14.309,10.525,14.264,10.508,14.220C10.455,14.085,10.403,13.953,10.352,13.814C10.328,13.749,10.306,13.687,10.286,13.627C10.307,13.635,10.328,13.644,10.350,13.654C10.660,13.788,11.061,13.997,11.574,14.305C12.603,14.923,13.457,15.299,14.138,15.403C14.483,15.456,14.868,15.454,15.225,15.298C15.618,15.126,15.881,14.811,16.004,14.440C16.115,14.101,16.100,13.755,16.049,13.465C15.995,13.166,15.892,12.860,15.761,12.564C15.500,11.970,15.095,11.331,14.608,10.722C14.225,10.243,13.865,9.700,13.602,9.191C13.372,8.745,13.253,8.396,13.216,8.168ZZM9.747,13.464C9.747,13.464,9.747,13.464,9.747,13.464ZC9.747,13.464,9.747,13.464,9.747,13.464ZZ" />\n </g>\n</svg>'; - } -}); - -// src/main.ts -var main_exports = {}; -__export(main_exports, { - default: () => InkPlugin, - inkPluginAtom: () => inkPluginAtom -}); -module.exports = __toCommonJS(main_exports); -var import_obsidian19 = require("obsidian"); - -// src/types/plugin-settings.ts -var DEFAULT_SETTINGS = { - onboardingTips: { - welcomeTipRead: false, - strokeLimitTipRead: false, - lastVersionTipRead: "" - }, - customAttachmentFolders: false, - noteAttachmentFolderLocation: "obsidian", - notelessAttachmentFolderLocation: "obsidian", - writingSubfolder: "Ink/Writing", - drawingSubfolder: "Ink/Drawing", - writingEnabled: true, - writingStrokeLimit: 200, - writingDynamicStrokeThickness: true, - writingSmoothing: false, - writingLinesWhenLocked: true, - writingBackgroundWhenLocked: true, - drawingEnabled: true, - drawingFrameWhenLocked: false, - drawingBackgroundWhenLocked: false -}; - -// src/components/dom-components/support-button-set.ts -var import_obsidian = require("obsidian"); -function createSupportButtonSet(containerEl) { - const supportBarEl = containerEl.createDiv("ddc_ink_support-btn-set"); - const settingEl = new import_obsidian.Setting(supportBarEl); - settingEl.infoEl.createEl("p").setText("Like Ink?"); - settingEl.addButton((btn) => { - btn.setClass("ddc_ink_secondary-button"); - btn.setTooltip("Bluesky"); - btn.setIcon("bluesky"); - btn.onClick((e) => { - window.open("https://bsky.app/profile/daledesilva.bsky.social", "_blank"); - }); - }); - settingEl.addButton((btn) => { - btn.setClass("ddc_ink_secondary-button"); - btn.setTooltip("Mastodon"); - btn.setIcon("mastodon"); - btn.onClick((e) => { - window.open("https://indieweb.social/@daledesilva", "_blank"); - }); - }); - settingEl.addButton((btn) => { - btn.setClass("ddc_ink_secondary-button"); - btn.setTooltip("X (Twitter)"); - btn.setIcon("twitter"); - btn.onClick((e) => { - window.open("https://twitter.com/daledesilva", "_blank"); - }); - }); - settingEl.addButton((btn) => { - btn.setClass("ddc_ink_primary-button"); - btn.setTooltip("Threads"); - btn.setIcon("threads"); - btn.onClick((e) => { - window.open("https://www.threads.net/@daledesilva", "_blank"); - }); - }); - settingEl.addButton((btn) => { - btn.setClass("ddc_ink_primary-button"); - btn.setTooltip("Support developer"); - btn.setIcon("heart"); - btn.onClick((e) => { - window.open("https://ko-fi.com/N4N3JLUCW", "_blank"); - }); - }); -} - -// src/tabs/settings-tab/settings-tab.ts -var import_obsidian5 = require("obsidian"); - -// src/modals/confirmation-modal/confirmation-modal.ts -var import_obsidian2 = require("obsidian"); -var ConfirmationModal = class extends import_obsidian2.Modal { - constructor(options) { - super(options.plugin.app); - this.title = "Confirmation"; - this.message = "Are you sure?"; - this.cancelLabel = "Cancel"; - this.cancelAction = () => { - }; - this.confirmLabel = "Yes"; - this.title = options.title || this.title; - this.message = options.message || this.message; - this.cancelLabel = options.cancelLabel || this.cancelLabel; - this.confirmLabel = options.confirmLabel || this.confirmLabel; - this.cancelAction = options.cancelAction || this.cancelAction; - this.confirmAction = options.confirmAction; - } - onOpen() { - const { titleEl, contentEl } = this; - titleEl.setText(this.title); - contentEl.createEl("p", { text: this.message }); - new import_obsidian2.Setting(contentEl).addButton((cancelBtn) => { - cancelBtn.setClass("uo_button"); - cancelBtn.setButtonText(this.cancelLabel); - cancelBtn.onClick(() => { - this.close(); - this.cancelAction(); - }); - }).addButton((confirmBtn) => { - confirmBtn.setClass("uo_button"); - confirmBtn.setWarning(); - confirmBtn.setButtonText(this.confirmLabel); - confirmBtn.onClick(() => { - this.close(); - this.confirmAction(); - }); - }); - } - onClose() { - const { titleEl, contentEl } = this; - titleEl.empty(); - contentEl.empty(); - } -}; - -// src/components/dom-components/notice-components.ts -var import_obsidian3 = require("obsidian"); -function createInkNoticeTemplate(noticeNumber, noticeTotal) { - const noticeBody = document.createDocumentFragment(); - createNoticeLabel(noticeBody, noticeNumber, noticeTotal); - return noticeBody; -} -function launchPersistentInkNotice(noticeBody) { - const notice = new import_obsidian3.Notice(noticeBody, 0); - notice.noticeEl.classList.add("ddc_ink_notice"); - notice.noticeEl.style.pointerEvents = "none"; - return notice; -} -function createNoticeLabel(noticeBody, noticeNumber, noticeTotal) { - const labelEl = noticeBody.createEl("p"); - let labelText = `Ink plugin`; - labelEl.setText(labelText); - labelEl.classList.add("ddc_ink_notice-label"); - return labelEl; -} -function createNoticeCtaBar(noticeBody, props) { - let primaryBtnEl = null; - let tertiaryBtnEl = null; - const ctaBarEl = noticeBody.createDiv("ddc_ink_notice-cta-bar"); - if (props.primaryLabel) { - primaryBtnEl = ctaBarEl.createEl("button"); - primaryBtnEl.setText(props.primaryLabel); - primaryBtnEl.classList.add("ddc_ink_primary-btn"); - primaryBtnEl.style.pointerEvents = "all"; - } - if (props.tertiaryLabel) { - tertiaryBtnEl = ctaBarEl.createEl("button"); - tertiaryBtnEl.setText(props.tertiaryLabel); - tertiaryBtnEl.classList.add("ddc_ink_tertiary-btn"); - tertiaryBtnEl.style.pointerEvents = "all"; - } - return { - ctaBarEl, - primaryBtnEl, - tertiaryBtnEl - }; -} - -// src/utils/isIpad.ts -function isIpad() { - const userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.includes("ipad")) { - return true; - } - if (userAgent.includes("mac") && navigator.maxTouchPoints > 2) { - return true; - } - return false; -} - -// src/notices/welcome-notice.ts -function showWelcomeTips_maybe(plugin) { - if (plugin.settings.onboardingTips.welcomeTipRead) - return false; - showWelcomeTips(plugin); - return true; -} -var tipsShowingOrDismissed = false; -async function showWelcomeTips(plugin) { - if (tipsShowingOrDismissed) - return; - tipsShowingOrDismissed = true; - const noticeBody = createInkNoticeTemplate(1, 3); - noticeBody.createEl("h1").setText(`Welcome to Ink`); - noticeBody.createEl("p").setText(`Ink is all about enabling stylus use directly in your markdown notes.`); - noticeBody.createEl("p").setText(`Here's a quick rundown to help you get started...`); - const { - primaryBtnEl, - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - primaryLabel: `Read now`, - tertiaryLabel: "Remind me later" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (tertiaryBtnEl) { - tertiaryBtnEl.addEventListener("click", () => { - notice.hide(); - }); - } - if (primaryBtnEl) { - primaryBtnEl.addEventListener("click", () => { - notice.hide(); - showHandwritingWelcomeTip(plugin); - }); - } -} -function showHandwritingWelcomeTip(plugin) { - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`Inserting handwriting sections...`); - noticeBody.createEl("p").setText(`In any markdown note, run the following command to begin writing where your cursor is.`); - noticeBody.createEl("blockquote").setText(`"Ink: New handwriting section"`); - noticeBody.createEl("p").setText(`( Cmd+P or swipe down )`); - const { - primaryBtnEl, - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - primaryLabel: "Continue", - tertiaryLabel: "Dismiss for now" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (primaryBtnEl) { - primaryBtnEl.addEventListener("click", () => { - notice.hide(); - showDrawingWelcomeTip(plugin); - }); - } -} -function showDrawingWelcomeTip(plugin) { - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`Drawing sections...`); - noticeBody.createEl("p").setText(`These can be added too and can be resized right in your markdown file.`); - noticeBody.createEl("blockquote").setText(`"Ink: New drawing"`); - const { - primaryBtnEl, - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - primaryLabel: "Continue", - tertiaryLabel: "Dismiss for now" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (primaryBtnEl) { - primaryBtnEl.addEventListener("click", () => { - notice.hide(); - if (isIpad()) { - showiPadWelcomeTip(plugin); - } else { - showSyncingWelcomeTip(plugin); - } - }); - } -} -function showiPadWelcomeTip(plugin) { - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`If you're using an iPad...`); - noticeBody.createEl("p").setText(`The 'Scribble' feature of the Apple Pencil can interfere with the ability to write in Ink embeds.`); - noticeBody.createEl("p").setText(`To use Ink you will need to turn off Scribble in your device settings.`); - const { - primaryBtnEl, - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - primaryLabel: "Continue", - tertiaryLabel: "Dismiss for now" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (primaryBtnEl) { - primaryBtnEl.addEventListener("click", () => { - notice.hide(); - showSyncingWelcomeTip(plugin); - }); - } -} -function showSyncingWelcomeTip(plugin) { - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`Syncing with your vault...`); - noticeBody.createEl("p").setText(`Ink files live in your vault and can sync with it to other devices.`); - noticeBody.createEl("p").setText(`If using Obsidian Sync, turn on "Sync all other types" in the Obsidian Sync settings.`); - const { - primaryBtnEl, - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - primaryLabel: "Continue", - tertiaryLabel: "Dismiss for now" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (primaryBtnEl) { - primaryBtnEl.addEventListener("click", () => { - notice.hide(); - showDevelopmentWelcomeTip(plugin); - }); - } -} -function showDevelopmentWelcomeTip(plugin) { - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`Get involved...`); - noticeBody.createEl("p").setText(`If you notice any bugs, please report them through the link in the settings.`); - noticeBody.createEl("p").setText(`You can also follow along with development and let me know which features are important to you at the links below.`); - const link1 = noticeBody.createEl("a"); - link1.setAttribute("href", "https://youtube.com/playlist?list=PLAiv7XV4xFx2NMRSCxdGiVombKO-TiMAL&si=GVp9ILvCAaRTwyYd"); - link1.setText(`View development diaries`); - link1.onClickEvent((e) => e.stopPropagation()); - noticeBody.createEl("br"); - const link2 = noticeBody.createEl("a"); - link2.setAttribute("href", "https://designdebt.club/socials"); - link2.setText(`Follow on socials`); - link2.onClickEvent((e) => e.stopPropagation()); - const { - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - tertiaryLabel: "Dismiss" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (tertiaryBtnEl) { - tertiaryBtnEl.addEventListener("click", () => { - notice.hide(); - tipsShowingOrDismissed = false; - plugin.settings.onboardingTips.welcomeTipRead = true; - plugin.settings.onboardingTips.lastVersionTipRead = plugin.manifest.version; - plugin.saveSettings(); - }); - } -} - -// src/components/dom-components/toggle-accordion-setting.ts -var import_obsidian4 = require("obsidian"); -var ToggleAccordionSetting = class { - constructor(containerEl) { - this.containerEl = containerEl; - this.sectionEl = this.containerEl.createDiv("ddc_ink_toggle-accordion"); - this.sectionHeaderEl = this.sectionEl.createDiv("ddc_ink_toggle-accordion-header"); - this.sectionContentEl = this.sectionEl.createDiv("ddc_ink_toggle-accordion-content"); - this.toggleSetting = new import_obsidian4.Setting(this.sectionHeaderEl).setClass("ddc_ink_setting").addToggle((toggle) => this.toggle = toggle); - return this; - } - setName(name) { - this.toggleSetting.setName(name); - return this; - } - setDesc(desc) { - this.toggleSetting.setDesc(desc); - return this; - } - setExpanded(expanded) { - this.toggle.setValue(expanded); - if (expanded) { - this.sectionEl.classList.add("ddc_ink_expanded"); - } else { - this.sectionEl.classList.remove("ddc_ink_expanded"); - } - return this; - } - onToggle(toggleHandler) { - this.toggle.onChange(toggleHandler); - return this; - } - setContent(contentHandler) { - contentHandler(this.sectionContentEl); - return this; - } -}; - -// src/tabs/settings-tab/settings-tab.ts -function registerSettingsTab(plugin) { - plugin.addSettingTab(new MySettingsTab(plugin.app, plugin)); -} -var MySettingsTab = class extends import_obsidian5.PluginSettingTab { - constructor(app, plugin) { - super(app, plugin); - this.plugin = plugin; - } - display() { - const { containerEl } = this; - containerEl.empty(); - containerEl.createEl("h1").setText("Ink"); - containerEl.createEl("p").setText("Hand write or draw directly between paragraphs in your notes."); - containerEl.createEl("hr"); - insertMoreInfoLinks(containerEl); - insertPrereleaseWarning(containerEl); - insertSetupGuide(this.plugin, containerEl); - insertHighLevelSettings(containerEl, this.plugin, () => this.display()); - insertSubfolderSettings(containerEl, this.plugin, () => this.display()); - containerEl.createEl("hr"); - if (this.plugin.settings.writingEnabled) - insertWritingSettings(containerEl, this.plugin, () => this.display()); - if (this.plugin.settings.drawingEnabled) - insertDrawingSettings(containerEl, this.plugin, () => this.display()); - new import_obsidian5.Setting(containerEl).addButton((button) => { - button.setButtonText("Reset settings"); - button.onClick(() => { - new ConfirmationModal({ - plugin: this.plugin, - title: "Please confirm", - message: "Revert to default settings for Ink plugin?", - confirmLabel: "Reset settings", - confirmAction: async () => { - await this.plugin.resetSettings(); - this.display(); - } - }).open(); - }); - }); - createSupportButtonSet(containerEl); - } -}; -function insertSetupGuide(plugin, containerEl) { - const sectionEl = containerEl.createDiv("ddc_ink_section ddc_ink_setup-guide-section"); - const accordionEl = sectionEl.createEl("details"); - accordionEl.createEl("summary", { text: `Expand setup tips` }); - new import_obsidian5.Setting(accordionEl).setClass("ddc_ink_setting").setName("Slash Commands").setDesc(`For a more intuitive experience, turn on "Slash commands" in "Obsidian Settings" / "Core Plugins" or install and set up the community plugin "Slash Commander".`); - new import_obsidian5.Setting(accordionEl).setClass("ddc_ink_setting").setName("Pen Scribble").setDesc(`If using an iPad, the Apple pencil "Scribble" setting can interfere with input in Ink sections. Disable it in iPadOS settings for a better experience.`); - new import_obsidian5.Setting(accordionEl).setClass("ddc_ink_setting").setName("Obsidian Sync").setDesc(`If using "Obsidian Sync", turn on "Sync all other types" in the Obsidian sync settings.`); - new import_obsidian5.Setting(accordionEl).addButton((btn) => { - btn.setButtonText("Rewatch welcome tips"); - btn.onClick(() => showWelcomeTips(plugin)); - btn.setCta(); - }); -} -function insertMoreInfoLinks(containerEl) { - const sectionEl = containerEl.createDiv("ddc_ink_section"); - sectionEl.createEl("p", { text: `For information on this plugin's development, visit the links below. Feel free to leave comments in the development diaries on YouTube.` }); - const list = sectionEl.createEl("ul"); - list.createEl("li").createEl("a", { - href: "https://github.com/daledesilva/obsidian_ink/releases", - text: "Latest Changes" - }); - list.createEl("li").createEl("a", { - href: "https://github.com/daledesilva/obsidian_ink", - text: "Roadmap" - }); - list.createEl("li").createEl("a", { - href: "https://www.youtube.com/playlist?list=PLAiv7XV4xFx2NMRSCxdGiVombKO-TiMAL", - text: "Development Diaries." - }); - list.createEl("li").createEl("a", { - href: "https://github.com/daledesilva/obsidian_ink/issues", - text: "Request feature / Report bug." - }); -} -function insertHighLevelSettings(containerEl, plugin, refresh) { - new import_obsidian5.Setting(containerEl).setClass("ddc_ink_setting").setName("Enable writing").setDesc("If disabled, you will not be able to add new writing embeds and those already embedded will appear as raw code. Existing writing files will be hidden in Obsidian but still exist on disk. Changing this setting will require a restart of Obsidian to take effect.").addToggle((toggle) => { - toggle.setValue(plugin.settings.writingEnabled); - toggle.onChange(async (value) => { - plugin.settings.writingEnabled = value; - await plugin.saveSettings(); - refresh(); - }); - }); - new import_obsidian5.Setting(containerEl).setClass("ddc_ink_setting").setName("Enable drawing").setDesc("If disabled, you will not be able to add new drawing embeds and those already embedded will appear as raw code. Existing drawing files will be hidden in Obsidian but still exist on disk. Changing this setting will require a restart of Obsidian to take effect.").addToggle((toggle) => { - toggle.setValue(plugin.settings.drawingEnabled); - toggle.onChange(async (value) => { - plugin.settings.drawingEnabled = value; - await plugin.saveSettings(); - refresh(); - }); - }); -} -function insertSubfolderSettings(containerEl, plugin, refresh) { - const saveWritingFolder = async (enteredValue) => { - const value = enteredValue || DEFAULT_SETTINGS.writingSubfolder; - plugin.settings.writingSubfolder = value.trim(); - await plugin.saveSettings(); - refresh(); - }; - const saveDrawingFolder = async (enteredValue) => { - const value = enteredValue || DEFAULT_SETTINGS.drawingSubfolder; - plugin.settings.drawingSubfolder = value.trim(); - await plugin.saveSettings(); - refresh(); - }; - const accordionSection = new ToggleAccordionSetting(containerEl).setName("Customise file organisation").setExpanded(plugin.settings.customAttachmentFolders).onToggle(async (value) => { - plugin.settings.customAttachmentFolders = value; - await plugin.saveSettings(); - refresh(); - }).setContent((container) => { - new import_obsidian5.Setting(container).setClass("ddc_ink_button-set").setName(`Where should Ink files be saved when created in a note?`).addButton((button) => { - button.setButtonText("Obsidian attachment folder"); - button.setClass("ddc_ink_left-most"); - if (plugin.settings.noteAttachmentFolderLocation === "obsidian") { - button.setCta(); - button.setDisabled(true); - } - button.onClick(async (e) => { - plugin.settings.noteAttachmentFolderLocation = "obsidian"; - await plugin.saveSettings(); - refresh(); - }); - }).addButton((button) => { - button.setButtonText("Vault root"); - button.setClass("ddc_ink_middle"); - if (plugin.settings.noteAttachmentFolderLocation === "root") { - button.setCta(); - button.setDisabled(true); - } - button.onClick(async (e) => { - plugin.settings.noteAttachmentFolderLocation = "root"; - await plugin.saveSettings(); - refresh(); - }); - }).addButton((button) => { - button.setButtonText("Next to the note"); - button.setClass("ddc_ink_right-most"); - if (plugin.settings.noteAttachmentFolderLocation === "note") { - button.setCta(); - button.setDisabled(true); - } - button.onClick(async (e) => { - plugin.settings.noteAttachmentFolderLocation = "note"; - await plugin.saveSettings(); - refresh(); - }); - }); - let inputSettingEl = new import_obsidian5.Setting(container).setClass("ddc_ink_setting").setName("Writing files subfolder").addText((textItem) => { - textItem.setValue(plugin.settings.writingSubfolder.toString()); - textItem.setPlaceholder(DEFAULT_SETTINGS.writingSubfolder.toString()); - textItem.inputEl.addEventListener("blur", async (ev) => { - saveWritingFolder(textItem.getValue()); - }); - textItem.inputEl.addEventListener("keypress", async (ev) => { - if (ev.key === "Enter") - saveWritingFolder(textItem.getValue()); - }); - }); - inputSettingEl.settingEl.classList.add("ddc_ink_input-medium"); - inputSettingEl = new import_obsidian5.Setting(container).setClass("ddc_ink_setting").setName("Drawing files subfolder").addText((textItem) => { - textItem.setValue(plugin.settings.drawingSubfolder.toString()); - textItem.setPlaceholder(DEFAULT_SETTINGS.drawingSubfolder.toString()); - textItem.inputEl.addEventListener("blur", async (ev) => { - saveDrawingFolder(textItem.getValue()); - }); - textItem.inputEl.addEventListener("keypress", async (ev) => { - if (ev.key === "Enter") - saveDrawingFolder(textItem.getValue()); - }); - }); - inputSettingEl.settingEl.classList.add("ddc_ink_input-medium"); - }); -} -function insertDrawingSettings(containerEl, plugin, refresh) { - const sectionEl = containerEl.createDiv("ddc_ink_section ddc_ink_controls-section"); - sectionEl.createEl("h2", { text: "Drawing" }); - sectionEl.createEl("p", { text: `While editing a Markdown file, run the action 'Insert new hand drawn section' to embed a drawing canvas.` }); - new import_obsidian5.Setting(sectionEl).setClass("ddc_ink_setting").setName("Show frame around drawing when not editing").addToggle((toggle) => { - toggle.setValue(plugin.settings.drawingFrameWhenLocked); - toggle.onChange(async (value) => { - plugin.settings.drawingFrameWhenLocked = value; - await plugin.saveSettings(); - refresh(); - }); - }); - new import_obsidian5.Setting(sectionEl).setClass("ddc_ink_setting").setName("Show background when not editing").addToggle((toggle) => { - toggle.setValue(plugin.settings.drawingBackgroundWhenLocked); - toggle.onChange(async (value) => { - plugin.settings.drawingBackgroundWhenLocked = value; - await plugin.saveSettings(); - refresh(); - }); - }); -} -function insertWritingSettings(containerEl, plugin, refresh) { - const saveWritingStrokeLimit = async (enteredValue) => { - const value = parseInt(enteredValue) || DEFAULT_SETTINGS.writingStrokeLimit; - plugin.settings.writingStrokeLimit = value; - await plugin.saveSettings(); - refresh(); - }; - const sectionEl = containerEl.createDiv("ddc_ink_section ddc_ink_controls-section"); - sectionEl.createEl("h2", { text: "Writing" }); - sectionEl.createEl("p", { text: `While editing a Markdown file, run the action 'Insert new handwriting section' to embed a section for writing with a stylus.` }); - new import_obsidian5.Setting(sectionEl).setClass("ddc_ink_setting").setName("Show ruled lines when not editing").addToggle((toggle) => { - toggle.setValue(plugin.settings.writingLinesWhenLocked); - toggle.onChange(async (value) => { - plugin.settings.writingLinesWhenLocked = value; - await plugin.saveSettings(); - refresh(); - }); - }); - new import_obsidian5.Setting(sectionEl).setClass("ddc_ink_setting").setName("Show background when not editing").addToggle((toggle) => { - toggle.setValue(plugin.settings.writingBackgroundWhenLocked); - toggle.onChange(async (value) => { - plugin.settings.writingBackgroundWhenLocked = value; - await plugin.saveSettings(); - refresh(); - }); - }); - new import_obsidian5.Setting(sectionEl).setClass("ddc_ink_setting").setName("Writing stroke limit").setDesc(`Too much writing in one embed can create a lag between your physical pen movement and the line appearing on screen. The stroke limit defines the maximum pen strokes before old strokes start becoming invisible until the embed is locked. Set this to a lower number if you're experiencing lag or jagged writing.`).addText((textItem) => { - textItem.setValue(plugin.settings.writingStrokeLimit.toString()); - textItem.setPlaceholder(DEFAULT_SETTINGS.writingStrokeLimit.toString()); - textItem.inputEl.addEventListener("blur", async (ev) => { - saveWritingStrokeLimit(textItem.getValue()); - }); - textItem.inputEl.addEventListener("keypress", async (ev) => { - if (ev.key === "Enter") - saveWritingStrokeLimit(textItem.getValue()); - }); - }); - insertWritingLimitations(sectionEl); -} -function insertWritingLimitations(containerEl) { -} -function insertPrereleaseWarning(containerEl) { - const sectionEl = containerEl.createDiv("ddc_ink_section ddc_ink_prerelease-warning-section"); - const accordion = sectionEl.createEl("details", { cls: "warning" }); - accordion.createEl("summary", { text: `This plugin is in an Alpha state (Expand for details)` }); - accordion.createEl("p", { text: `What does Alpha mean? Development of products like this plugin often involve moving through multiple different stages (e.g. Alpha, Beta, then Standard Release).` }); - accordion.createEl("p", { text: `Alpha, the current stage, means that this plugin is in early development and may undergo large changes that break or change previous functionality.` }); - accordion.createEl("p", { text: `While in Alpha, please exercise caution while using the plugin, however, note that I (The developer of this plugin) am proceeding with caution to help ensure any files created in this version will be compatible or converted to work with future versions (My own vaults depend on it as well).` }); -} - -// src/extensions/widgets/writing-embed-widget.tsx -var import_obsidian10 = require("obsidian"); -var React90 = __toESM(require_react()); -var import_client2 = __toESM(require_client()); - -// src/constants.ts -var manifest = require_manifest(); -var PLUGIN_VERSION = manifest.version; -var TLDRAW_VERSION = "2.4.3"; -var PLUGIN_KEY = "ddc_ink"; -var WRITE_FILE_EXT = "writing"; -var DRAW_FILE_EXT = "drawing"; -var WRITE_EMBED_KEY = "handwritten-ink"; -var DRAW_EMBED_KEY = "handdrawn-ink"; -var MENUBAR_HEIGHT_PX = 100; -var WRITE_SHORT_DELAY_MS = 500; -var WRITE_LONG_DELAY_MS = 2e3; -var DRAW_SHORT_DELAY_MS = 500; -var DRAW_LONG_DELAY_MS = 2e3; -var WRITING_PAGE_WIDTH = 2e3; -var WRITING_LINE_HEIGHT = 150; -var WRITING_MIN_PAGE_HEIGHT = WRITING_LINE_HEIGHT * 1.5; -var DRAWING_INITIAL_WIDTH = 500; -var DRAWING_INITIAL_ASPECT_RATIO = 1; -var DRAWING_INITIAL_HEIGHT = Math.round(DRAWING_INITIAL_WIDTH * DRAWING_INITIAL_ASPECT_RATIO); - -// src/utils/page-file.ts -var buildWritingFileData = (props) => { - return buildFileData(props); -}; -var buildDrawingFileData = (props) => { - return buildFileData(props); -}; -var buildFileData = (props) => { - const { - tlEditorSnapshot, - previewUri, - previewIsOutdated = false - } = props; - let pageData = { - meta: { - pluginVersion: PLUGIN_VERSION, - tldrawVersion: TLDRAW_VERSION - }, - tldraw: tlEditorSnapshot - }; - if (previewIsOutdated) - pageData.meta.previewIsOutdated = previewIsOutdated; - if (previewUri) - pageData.previewUri = previewUri; - return pageData; -}; -var stringifyPageData = (pageData) => { - return JSON.stringify(pageData, null, " "); -}; - -// src/utils/embed.ts -var buildWritingEmbed = (filepath, transcript) => { - let embedContent = { - versionAtEmbed: PLUGIN_VERSION, - filepath - }; - let embedStr = ""; - embedStr += "\n```" + WRITE_EMBED_KEY; - embedStr += "\n" + JSON.stringify(embedContent, null, " "); - embedStr += "\n```"; - embedStr += "\n"; - return embedStr; -}; -var buildDrawingEmbed = (filepath) => { - let embedContent = { - versionAtEmbed: PLUGIN_VERSION, - filepath, - width: DRAWING_INITIAL_WIDTH, - aspectRatio: DRAWING_INITIAL_ASPECT_RATIO - }; - let embedStr = ""; - embedStr += "\n```" + DRAW_EMBED_KEY; - embedStr += "\n" + JSON.stringify(embedContent, null, " "); - embedStr += "\n```"; - embedStr += "\n"; - return embedStr; -}; -function stringifyEmbedData(embedData) { - return JSON.stringify(embedData, null, " "); -} -function applyCommonAncestorStyling(embedEl) { - const parentEmbedBlockEl = embedEl.closest(".cm-embed-block"); - if (!parentEmbedBlockEl) - return; - parentEmbedBlockEl.classList.add("ddc_ink_embed-block"); - const parentPageScrollerEl = embedEl.closest(".cm-scroller"); - const scrollerStyle = window.getComputedStyle(parentPageScrollerEl); - const scrollerInlineStartMargin = scrollerStyle.paddingInlineStart; - const scrollerInlineEndMargin = scrollerStyle.paddingInlineEnd; - const scrollerMarginLeft = scrollerStyle.paddingLeft; - const scrollerMarginRight = scrollerStyle.paddingRight; - const pageHasScrollerInlineStartMargin = scrollerInlineStartMargin && scrollerInlineStartMargin !== "0" && scrollerInlineStartMargin !== "0px"; - if (pageHasScrollerInlineStartMargin) { - let style = parentEmbedBlockEl.getAttribute("style") ?? ""; - style += `; margin-inline-start: calc(-1 * ${scrollerInlineStartMargin} + 4px) !important`; - parentEmbedBlockEl.setAttribute("style", style); - } else { - } - const pageHasScrollerInlineEndMargin = scrollerInlineEndMargin && scrollerInlineEndMargin !== "0" && scrollerInlineEndMargin !== "0px"; - if (pageHasScrollerInlineEndMargin) { - let style = parentEmbedBlockEl.getAttribute("style") ?? ""; - style += `; margin-inline-end: calc(-1 * ${scrollerInlineEndMargin} + 4px) !important`; - parentEmbedBlockEl.setAttribute("style", style); - } else { - } -} -function removeEmbed(plugin, ctx, el) { - const cmEditor = plugin.app.workspace.activeEditor?.editor; - if (!cmEditor) - return; - const sectionInfo = ctx.getSectionInfo(el); - if (sectionInfo?.lineStart === void 0 || sectionInfo.lineEnd === void 0) - return; - const editorStart = { - line: sectionInfo.lineStart, - ch: 0 - }; - const editorEnd = { - line: sectionInfo.lineEnd + 1, - ch: 0 - }; - cmEditor.replaceRange("", editorStart, editorEnd); - cmEditor.setCursor(editorStart); -} - -// src/tldraw/writing/writing-embed.tsx -var React89 = __toESM(require_react()); -var import_react124 = __toESM(require_react()); - -// node_modules/@tldraw/editor/dist-esm/index.mjs -var import_at = __toESM(require_at2(), 1); -var import_flat_map = __toESM(require_flat_map2(), 1); -var import_flat = __toESM(require_flat2(), 1); -var import_at2 = __toESM(require_at4(), 1); -var import_replace_all = __toESM(require_replace_all2(), 1); - -// node_modules/@tldraw/state/dist-esm/lib/helpers.mjs -function isChild(x) { - return x && typeof x === "object" && "parents" in x; -} -function haveParentsChanged(child) { - for (let i = 0, n = child.parents.length; i < n; i++) { - child.parents[i].__unsafe__getWithoutCapture(true); - if (child.parents[i].lastChangedEpoch !== child.parentEpochs[i]) { - return true; - } - } - return false; -} -var detach = (parent, child) => { - if (!parent.children.remove(child)) { - return; - } - if (parent.children.isEmpty && isChild(parent)) { - for (let i = 0, n = parent.parents.length; i < n; i++) { - detach(parent.parents[i], parent); - } - } -}; -var attach = (parent, child) => { - if (!parent.children.add(child)) { - return; - } - if (isChild(parent)) { - for (let i = 0, n = parent.parents.length; i < n; i++) { - attach(parent.parents[i], parent); - } - } -}; -function equals(a, b) { - const shallowEquals = a === b || Object.is(a, b) || Boolean(a && b && typeof a.equals === "function" && a.equals(b)); - return shallowEquals; -} -function singleton(key, init) { - const symbol = Symbol.for(`com.tldraw.state/${key}`); - const global2 = globalThis; - global2[symbol] ?? (global2[symbol] = init()); - return global2[symbol]; -} -var EMPTY_ARRAY = singleton("empty_array", () => Object.freeze([])); - -// node_modules/@tldraw/state/dist-esm/lib/ArraySet.mjs -var ARRAY_SIZE_THRESHOLD = 8; -var ArraySet = class { - constructor() { - __publicField(this, "arraySize", 0); - __publicField(this, "array", Array(ARRAY_SIZE_THRESHOLD)); - __publicField(this, "set", null); - } - get isEmpty() { - if (this.array) { - return this.arraySize === 0; - } - if (this.set) { - return this.set.size === 0; - } - throw new Error("no set or array"); - } - add(elem) { - if (this.array) { - const idx = this.array.indexOf(elem); - if (idx !== -1) { - return false; - } - if (this.arraySize < ARRAY_SIZE_THRESHOLD) { - this.array[this.arraySize] = elem; - this.arraySize++; - return true; - } else { - this.set = new Set(this.array); - this.array = null; - this.set.add(elem); - return true; - } - } - if (this.set) { - if (this.set.has(elem)) { - return false; - } - this.set.add(elem); - return true; - } - throw new Error("no set or array"); - } - remove(elem) { - if (this.array) { - const idx = this.array.indexOf(elem); - if (idx === -1) { - return false; - } - this.array[idx] = void 0; - this.arraySize--; - if (idx !== this.arraySize) { - this.array[idx] = this.array[this.arraySize]; - this.array[this.arraySize] = void 0; - } - return true; - } - if (this.set) { - if (!this.set.has(elem)) { - return false; - } - this.set.delete(elem); - return true; - } - throw new Error("no set or array"); - } - visit(visitor) { - if (this.array) { - for (let i = 0; i < this.arraySize; i++) { - const elem = this.array[i]; - if (typeof elem !== "undefined") { - visitor(elem); - } - } - return; - } - if (this.set) { - this.set.forEach(visitor); - return; - } - throw new Error("no set or array"); - } - has(elem) { - if (this.array) { - return this.array.indexOf(elem) !== -1; - } else { - return this.set.has(elem); - } - } - clear() { - if (this.set) { - this.set.clear(); - } else { - this.arraySize = 0; - this.array = []; - } - } - size() { - if (this.set) { - return this.set.size; - } else { - return this.arraySize; - } - } -}; - -// node_modules/@tldraw/state/dist-esm/lib/types.mjs -var RESET_VALUE = Symbol.for("com.tldraw.state/RESET_VALUE"); - -// node_modules/@tldraw/state/dist-esm/lib/HistoryBuffer.mjs -var HistoryBuffer = class { - constructor(capacity) { - __publicField(this, "index", 0); - __publicField(this, "buffer"); - this.capacity = capacity; - this.buffer = new Array(capacity); - } - pushEntry(lastComputedEpoch, currentEpoch, diff) { - if (diff === void 0) { - return; - } - if (diff === RESET_VALUE) { - this.clear(); - return; - } - this.buffer[this.index] = [lastComputedEpoch, currentEpoch, diff]; - this.index = (this.index + 1) % this.capacity; - } - clear() { - this.index = 0; - this.buffer.fill(void 0); - } - getChangesSince(sinceEpoch) { - const { index: index2, capacity, buffer } = this; - for (let i = 0; i < capacity; i++) { - const offset4 = (index2 - 1 + capacity - i) % capacity; - const elem = buffer[offset4]; - if (!elem) { - return RESET_VALUE; - } - const [fromEpoch, toEpoch] = elem; - if (i === 0 && sinceEpoch >= toEpoch) { - return []; - } - if (fromEpoch <= sinceEpoch && sinceEpoch < toEpoch) { - const len = i + 1; - const result = new Array(len); - for (let j = 0; j < len; j++) { - result[j] = buffer[(offset4 + j) % capacity][2]; - } - return result; - } - } - return RESET_VALUE; - } -}; - -// node_modules/@tldraw/state/dist-esm/lib/capture.mjs -var CaptureStackFrame = class { - constructor(below, child) { - __publicField(this, "offset", 0); - __publicField(this, "maybeRemoved"); - this.below = below; - this.child = child; - } -}; -var inst = singleton("capture", () => ({ stack: null })); -function unsafe__withoutCapture(fn) { - const oldStack = inst.stack; - inst.stack = null; - try { - return fn(); - } finally { - inst.stack = oldStack; - } -} -function startCapturingParents(child) { - inst.stack = new CaptureStackFrame(inst.stack, child); - child.parentSet.clear(); -} -function stopCapturingParents() { - const frame2 = inst.stack; - inst.stack = frame2.below; - if (frame2.offset < frame2.child.parents.length) { - for (let i = frame2.offset; i < frame2.child.parents.length; i++) { - const maybeRemovedParent = frame2.child.parents[i]; - if (!frame2.child.parentSet.has(maybeRemovedParent)) { - detach(maybeRemovedParent, frame2.child); - } - } - frame2.child.parents.length = frame2.offset; - frame2.child.parentEpochs.length = frame2.offset; - } - if (frame2.maybeRemoved) { - for (let i = 0; i < frame2.maybeRemoved.length; i++) { - const maybeRemovedParent = frame2.maybeRemoved[i]; - if (!frame2.child.parentSet.has(maybeRemovedParent)) { - detach(maybeRemovedParent, frame2.child); - } - } - } -} -function maybeCaptureParent(p) { - if (inst.stack) { - const wasCapturedAlready = inst.stack.child.parentSet.has(p); - if (wasCapturedAlready) { - return; - } - inst.stack.child.parentSet.add(p); - if (inst.stack.child.isActivelyListening) { - attach(p, inst.stack.child); - } - if (inst.stack.offset < inst.stack.child.parents.length) { - const maybeRemovedParent = inst.stack.child.parents[inst.stack.offset]; - if (maybeRemovedParent !== p) { - if (!inst.stack.maybeRemoved) { - inst.stack.maybeRemoved = [maybeRemovedParent]; - } else { - inst.stack.maybeRemoved.push(maybeRemovedParent); - } - } - } - inst.stack.child.parents[inst.stack.offset] = p; - inst.stack.child.parentEpochs[inst.stack.offset] = p.lastChangedEpoch; - inst.stack.offset++; - } -} - -// node_modules/@tldraw/state/dist-esm/lib/constants.mjs -var GLOBAL_START_EPOCH = -1; - -// node_modules/@tldraw/state/dist-esm/lib/EffectScheduler.mjs -var __EffectScheduler__ = class { - constructor(name, runEffect, options) { - __publicField(this, "_isActivelyListening", false); - __publicField(this, "lastTraversedEpoch", GLOBAL_START_EPOCH); - __publicField(this, "lastReactedEpoch", GLOBAL_START_EPOCH); - __publicField(this, "_scheduleCount", 0); - __publicField(this, "parentSet", new ArraySet()); - __publicField(this, "parentEpochs", []); - __publicField(this, "parents", []); - __publicField(this, "_scheduleEffect"); - __publicField(this, "maybeExecute", () => { - if (!this._isActivelyListening) - return; - this.execute(); - }); - this.name = name; - this.runEffect = runEffect; - this._scheduleEffect = options?.scheduleEffect; - } - get isActivelyListening() { - return this._isActivelyListening; - } - get scheduleCount() { - return this._scheduleCount; - } - maybeScheduleEffect() { - if (!this._isActivelyListening) - return; - if (this.lastReactedEpoch === getGlobalEpoch()) - return; - if (this.parents.length && !haveParentsChanged(this)) { - this.lastReactedEpoch = getGlobalEpoch(); - return; - } - this.scheduleEffect(); - } - scheduleEffect() { - this._scheduleCount++; - if (this._scheduleEffect) { - this._scheduleEffect(this.maybeExecute); - } else { - this.execute(); - } - } - attach() { - this._isActivelyListening = true; - for (let i = 0, n = this.parents.length; i < n; i++) { - attach(this.parents[i], this); - } - } - detach() { - this._isActivelyListening = false; - for (let i = 0, n = this.parents.length; i < n; i++) { - detach(this.parents[i], this); - } - } - execute() { - try { - startCapturingParents(this); - const currentEpoch = getGlobalEpoch(); - const result = this.runEffect(this.lastReactedEpoch); - this.lastReactedEpoch = currentEpoch; - return result; - } finally { - stopCapturingParents(); - } - } -}; -var EffectScheduler = singleton("EffectScheduler", () => __EffectScheduler__); -function react(name, fn, options) { - const scheduler = new EffectScheduler(name, fn, options); - scheduler.attach(); - scheduler.scheduleEffect(); - return () => { - scheduler.detach(); - }; -} -function reactor(name, fn, options) { - const scheduler = new EffectScheduler(name, fn, options); - return { - scheduler, - start: (options2) => { - const force = options2?.force ?? false; - scheduler.attach(); - if (force) { - scheduler.scheduleEffect(); - } else { - scheduler.maybeScheduleEffect(); - } - }, - stop: () => { - scheduler.detach(); - } - }; -} - -// node_modules/@tldraw/state/dist-esm/lib/transactions.mjs -var Transaction = class { - constructor(parent) { - __publicField(this, "initialAtomValues", /* @__PURE__ */ new Map()); - this.parent = parent; - } - get isRoot() { - return this.parent === null; - } - commit() { - if (this.isRoot) { - flushChanges(this.initialAtomValues.keys()); - } else { - this.initialAtomValues.forEach((value, atom3) => { - if (!this.parent.initialAtomValues.has(atom3)) { - this.parent.initialAtomValues.set(atom3, value); - } - }); - } - } - abort() { - inst2.globalEpoch++; - this.initialAtomValues.forEach((value, atom3) => { - atom3.set(value); - atom3.historyBuffer?.clear(); - }); - this.commit(); - } -}; -var inst2 = singleton("transactions", () => ({ - globalEpoch: GLOBAL_START_EPOCH + 1, - globalIsReacting: false, - currentTransaction: null, - cleanupReactors: null, - reactionEpoch: GLOBAL_START_EPOCH + 1 -})); -function getReactionEpoch() { - return inst2.reactionEpoch; -} -function getGlobalEpoch() { - return inst2.globalEpoch; -} -function getIsReacting() { - return inst2.globalIsReacting; -} -function traverse(reactors, child) { - if (child.lastTraversedEpoch === inst2.globalEpoch) { - return; - } - child.lastTraversedEpoch = inst2.globalEpoch; - if (child instanceof EffectScheduler) { - reactors.add(child); - } else { - ; - child.children.visit((c) => traverse(reactors, c)); - } -} -function flushChanges(atoms) { - if (inst2.globalIsReacting) { - throw new Error("cannot change atoms during reaction cycle"); - } - try { - inst2.globalIsReacting = true; - inst2.reactionEpoch = inst2.globalEpoch; - const reactors = /* @__PURE__ */ new Set(); - for (const atom3 of atoms) { - atom3.children.visit((child) => traverse(reactors, child)); - } - for (const r of reactors) { - r.maybeScheduleEffect(); - } - let updateDepth = 0; - while (inst2.cleanupReactors?.size) { - if (updateDepth++ > 1e3) { - throw new Error("Reaction update depth limit exceeded"); - } - const reactors2 = inst2.cleanupReactors; - inst2.cleanupReactors = null; - for (const r of reactors2) { - r.maybeScheduleEffect(); - } - } - } finally { - inst2.cleanupReactors = null; - inst2.globalIsReacting = false; - } -} -function atomDidChange(atom3, previousValue) { - if (inst2.globalIsReacting) { - const rs = inst2.cleanupReactors ?? (inst2.cleanupReactors = /* @__PURE__ */ new Set()); - atom3.children.visit((child) => traverse(rs, child)); - } else if (!inst2.currentTransaction) { - flushChanges([atom3]); - } else if (!inst2.currentTransaction.initialAtomValues.has(atom3)) { - inst2.currentTransaction.initialAtomValues.set(atom3, previousValue); - } -} -function advanceGlobalEpoch() { - inst2.globalEpoch++; -} -function transaction(fn) { - const txn = new Transaction(inst2.currentTransaction); - inst2.currentTransaction = txn; - try { - let result = void 0; - let rollback = false; - try { - result = fn(() => rollback = true); - } catch (e) { - txn.abort(); - throw e; - } - if (rollback) { - txn.abort(); - } else { - txn.commit(); - } - return result; - } finally { - inst2.currentTransaction = inst2.currentTransaction.parent; - } -} -function transact(fn) { - if (inst2.currentTransaction) { - return fn(); - } - return transaction(fn); -} - -// node_modules/@tldraw/state/dist-esm/lib/Atom.mjs -var __Atom__ = class { - constructor(name, current, options) { - __publicField(this, "isEqual"); - __publicField(this, "computeDiff"); - __publicField(this, "lastChangedEpoch", getGlobalEpoch()); - __publicField(this, "children", new ArraySet()); - __publicField(this, "historyBuffer"); - this.name = name; - this.current = current; - this.isEqual = options?.isEqual ?? null; - if (!options) - return; - if (options.historyLength) { - this.historyBuffer = new HistoryBuffer(options.historyLength); - } - this.computeDiff = options.computeDiff; - } - __unsafe__getWithoutCapture(_ignoreErrors) { - return this.current; - } - get() { - maybeCaptureParent(this); - return this.current; - } - set(value, diff) { - if (this.isEqual?.(this.current, value) ?? equals(this.current, value)) { - return this.current; - } - advanceGlobalEpoch(); - if (this.historyBuffer) { - this.historyBuffer.pushEntry(this.lastChangedEpoch, getGlobalEpoch(), diff ?? this.computeDiff?.(this.current, value, this.lastChangedEpoch, getGlobalEpoch()) ?? RESET_VALUE); - } - this.lastChangedEpoch = getGlobalEpoch(); - const oldValue = this.current; - this.current = value; - atomDidChange(this, oldValue); - return value; - } - update(updater) { - return this.set(updater(this.current)); - } - getDiffSince(epoch) { - maybeCaptureParent(this); - if (epoch >= this.lastChangedEpoch) { - return EMPTY_ARRAY; - } - return this.historyBuffer?.getChangesSince(epoch) ?? RESET_VALUE; - } -}; -var _Atom = singleton("Atom", () => __Atom__); -function atom(name, initialValue, options) { - return new _Atom(name, initialValue, options); -} - -// node_modules/@tldraw/state/dist-esm/lib/warnings.mjs -var didWarnComputedGetter = false; -function logComputedGetterWarning() { - if (didWarnComputedGetter) - return; - didWarnComputedGetter = true; - console.warn(`Using \`@computed\` as a decorator for getters is deprecated and will be removed in the near future. Please refactor to use \`@computed\` as a decorator for methods. - -// Before -@computed -get foo() { - return 'foo' -} - -// After -@computed -getFoo() { - return 'foo' -} -`); -} - -// node_modules/@tldraw/state/dist-esm/lib/Computed.mjs -var UNINITIALIZED = Symbol.for("com.tldraw.state/UNINITIALIZED"); -var isUninitialized = (value) => { - return value === UNINITIALIZED; -}; -var WithDiff = singleton("WithDiff", () => class WithDiff { - constructor(value, diff) { - this.value = value; - this.diff = diff; - } -}); -function withDiff(value, diff) { - return new WithDiff(value, diff); -} -var __UNSAFE__Computed = class { - constructor(name, derive, options) { - __publicField(this, "lastChangedEpoch", GLOBAL_START_EPOCH); - __publicField(this, "lastTraversedEpoch", GLOBAL_START_EPOCH); - __publicField(this, "lastCheckedEpoch", GLOBAL_START_EPOCH); - __publicField(this, "parentSet", new ArraySet()); - __publicField(this, "parents", []); - __publicField(this, "parentEpochs", []); - __publicField(this, "children", new ArraySet()); - __publicField(this, "historyBuffer"); - __publicField(this, "state", UNINITIALIZED); - __publicField(this, "error", null); - __publicField(this, "computeDiff"); - __publicField(this, "isEqual"); - this.name = name; - this.derive = derive; - if (options?.historyLength) { - this.historyBuffer = new HistoryBuffer(options.historyLength); - } - this.computeDiff = options?.computeDiff; - this.isEqual = options?.isEqual ?? equals; - } - get isActivelyListening() { - return !this.children.isEmpty; - } - __unsafe__getWithoutCapture(ignoreErrors) { - const isNew = this.lastChangedEpoch === GLOBAL_START_EPOCH; - const globalEpoch = getGlobalEpoch(); - if (!isNew && (this.lastCheckedEpoch === globalEpoch || this.isActivelyListening && getIsReacting() && this.lastTraversedEpoch < getReactionEpoch() || !haveParentsChanged(this))) { - this.lastCheckedEpoch = globalEpoch; - if (this.error) { - if (!ignoreErrors) { - throw this.error.thrownValue; - } else { - return this.state; - } - } else { - return this.state; - } - } - try { - startCapturingParents(this); - const result = this.derive(this.state, this.lastCheckedEpoch); - const newState = result instanceof WithDiff ? result.value : result; - const isUninitialized2 = this.state === UNINITIALIZED; - if (isUninitialized2 || !this.isEqual(newState, this.state)) { - if (this.historyBuffer && !isUninitialized2) { - const diff = result instanceof WithDiff ? result.diff : void 0; - this.historyBuffer.pushEntry(this.lastChangedEpoch, getGlobalEpoch(), diff ?? this.computeDiff?.(this.state, newState, this.lastCheckedEpoch, getGlobalEpoch()) ?? RESET_VALUE); - } - this.lastChangedEpoch = getGlobalEpoch(); - this.state = newState; - } - this.error = null; - this.lastCheckedEpoch = getGlobalEpoch(); - return this.state; - } catch (e) { - if (this.state !== UNINITIALIZED) { - this.state = UNINITIALIZED; - this.lastChangedEpoch = getGlobalEpoch(); - } - this.lastCheckedEpoch = getGlobalEpoch(); - if (this.historyBuffer) { - this.historyBuffer.clear(); - } - this.error = { thrownValue: e }; - if (!ignoreErrors) - throw e; - return this.state; - } finally { - stopCapturingParents(); - } - } - get() { - try { - return this.__unsafe__getWithoutCapture(); - } finally { - maybeCaptureParent(this); - } - } - getDiffSince(epoch) { - this.__unsafe__getWithoutCapture(true); - maybeCaptureParent(this); - if (epoch >= this.lastChangedEpoch) { - return EMPTY_ARRAY; - } - return this.historyBuffer?.getChangesSince(epoch) ?? RESET_VALUE; - } -}; -var _Computed = singleton("Computed", () => __UNSAFE__Computed); -function computedMethodAnnotation(options = {}, _target, key, descriptor) { - const originalMethod = descriptor.value; - const derivationKey = Symbol.for("__@tldraw/state__computed__" + key); - descriptor.value = function() { - let d = this[derivationKey]; - if (!d) { - d = new _Computed(key, originalMethod.bind(this), options); - Object.defineProperty(this, derivationKey, { - enumerable: false, - configurable: false, - writable: false, - value: d - }); - } - return d.get(); - }; - descriptor.value[isComputedMethodKey] = true; - return descriptor; -} -function computedAnnotation(options = {}, _target, key, descriptor) { - if (descriptor.get) { - logComputedGetterWarning(); - return computedGetterAnnotation(options, _target, key, descriptor); - } else { - return computedMethodAnnotation(options, _target, key, descriptor); - } -} -function computedGetterAnnotation(options = {}, _target, key, descriptor) { - const originalMethod = descriptor.get; - const derivationKey = Symbol.for("__@tldraw/state__computed__" + key); - descriptor.get = function() { - let d = this[derivationKey]; - if (!d) { - d = new _Computed(key, originalMethod.bind(this), options); - Object.defineProperty(this, derivationKey, { - enumerable: false, - configurable: false, - writable: false, - value: d - }); - } - return d.get(); - }; - return descriptor; -} -var isComputedMethodKey = "@@__isComputedMethod__@@"; -function computed() { - if (arguments.length === 1) { - const options = arguments[0]; - return (target, key, descriptor) => computedAnnotation(options, target, key, descriptor); - } else if (typeof arguments[0] === "string") { - return new _Computed(arguments[0], arguments[1], arguments[2]); - } else { - return computedAnnotation(void 0, arguments[0], arguments[1], arguments[2]); - } -} - -// node_modules/@tldraw/state/dist-esm/index.mjs -var currentApiVersion = 1; -var actualApiVersion = singleton("apiVersion", () => currentApiVersion); -if (actualApiVersion !== currentApiVersion) { - throw new Error(`You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.`); -} - -// node_modules/@tldraw/utils/dist-esm/index.mjs -var import_lodash = __toESM(require_lodash(), 1); -var import_lodash2 = __toESM(require_lodash2(), 1); - -// node_modules/@tldraw/utils/dist-esm/lib/perf.mjs -var PERFORMANCE_COLORS = { - Good: "#40C057", - Mid: "#FFC078", - Poor: "#E03131" -}; -var PERFORMANCE_PREFIX_COLOR = PERFORMANCE_COLORS.Good; - -// node_modules/@tldraw/utils/dist-esm/lib/PerformanceTracker.mjs -var PerformanceTracker = class { - constructor() { - __publicField(this, "startTime", 0); - __publicField(this, "name", ""); - __publicField(this, "frames", 0); - __publicField(this, "started", false); - __publicField(this, "frame", null); - __publicField(this, "recordFrame", () => { - this.frames++; - if (!this.started) - return; - this.frame = requestAnimationFrame(this.recordFrame); - }); - } - start(name) { - this.name = name; - this.frames = 0; - this.started = true; - if (this.frame !== null) - cancelAnimationFrame(this.frame); - this.frame = requestAnimationFrame(this.recordFrame); - this.startTime = performance.now(); - } - stop() { - this.started = false; - if (this.frame !== null) - cancelAnimationFrame(this.frame); - const duration = (performance.now() - this.startTime) / 1e3; - const fps = duration === 0 ? 0 : Math.floor(this.frames / duration); - const background = fps > 55 ? PERFORMANCE_COLORS.Good : fps > 30 ? PERFORMANCE_COLORS.Mid : PERFORMANCE_COLORS.Poor; - const color = background === PERFORMANCE_COLORS.Mid ? "black" : "white"; - const capitalized = this.name[0].toUpperCase() + this.name.slice(1); - console.debug(`%cPerf%c ${capitalized} %c${fps}%c fps`, `color: white; background: ${PERFORMANCE_PREFIX_COLOR};padding: 2px;border-radius: 3px;`, "font-weight: normal", `font-weight: bold; padding: 2px; background: ${background};color: ${color};`, "font-weight: normal"); - } - isStarted() { - return this.started; - } -}; - -// node_modules/@tldraw/utils/dist-esm/lib/array.mjs -function dedupe(input, equals2) { - const result = []; - mainLoop: - for (const item of input) { - for (const existing of result) { - if (equals2 ? equals2(item, existing) : item === existing) { - continue mainLoop; - } - } - result.push(item); - } - return result; -} -function compact(arr) { - return arr.filter((i) => i !== void 0 && i !== null); -} -function last(arr) { - return arr[arr.length - 1]; -} -function minBy(arr, fn) { - let min3; - let minVal = Infinity; - for (const item of arr) { - const val = fn(item); - if (val < minVal) { - min3 = item; - minVal = val; - } - } - return min3; -} -function areArraysShallowEqual(arr1, arr2) { - if (arr1 === arr2) - return true; - if (arr1.length !== arr2.length) - return false; - for (let i = 0; i < arr1.length; i++) { - if (!Object.is(arr1[i], arr2[i])) { - return false; - } - } - return true; -} - -// node_modules/@tldraw/utils/dist-esm/lib/cache.mjs -var WeakCache = class { - constructor() { - __publicField(this, "items", /* @__PURE__ */ new WeakMap()); - } - get(item, cb) { - if (!this.items.has(item)) { - this.items.set(item, cb(item)); - } - return this.items.get(item); - } -}; - -// node_modules/@tldraw/utils/dist-esm/lib/function.mjs -function omitFromStackTrace(fn) { - const wrappedFn = (...args) => { - try { - return fn(...args); - } catch (error3) { - if (error3 instanceof Error && Error.captureStackTrace) { - Error.captureStackTrace(error3, wrappedFn); - } - throw error3; - } - }; - return wrappedFn; -} -var noop = () => { -}; - -// node_modules/@tldraw/utils/dist-esm/lib/control.mjs -var Result = { - ok(value) { - return { ok: true, value }; - }, - err(error3) { - return { ok: false, error: error3 }; - } -}; -function exhaustiveSwitchError(value, property) { - const debugValue = property && value && typeof value === "object" && property in value ? value[property] : value; - throw new Error(`Unknown switch case ${debugValue}`); -} -var assert = omitFromStackTrace((value, message) => { - if (!value) { - throw new Error(message || "Assertion Error"); - } -}); -var assertExists = omitFromStackTrace((value, message) => { - if (value == null) { - throw new Error(message ?? "value must be defined"); - } - return value; -}); - -// node_modules/@tldraw/utils/dist-esm/lib/debounce.mjs -function debounce(callback, wait) { - let state = void 0; - const fn = (...args) => { - if (!state) { - state = {}; - state.promise = new Promise((resolve, reject) => { - state.resolve = resolve; - state.reject = reject; - }); - } - clearTimeout(state.timeout); - state.latestArgs = args; - state.timeout = setTimeout(() => { - const s = state; - state = void 0; - try { - s.resolve(callback(...s.latestArgs)); - } catch (e) { - s.reject(e); - } - }, wait); - return state.promise; - }; - fn.cancel = () => { - if (!state) - return; - clearTimeout(state.timeout); - }; - return fn; -} - -// node_modules/@tldraw/utils/dist-esm/lib/error.mjs -var annotationsByError = /* @__PURE__ */ new WeakMap(); -function annotateError(error3, annotations) { - if (typeof error3 !== "object" || error3 === null) - return; - let currentAnnotations = annotationsByError.get(error3); - if (!currentAnnotations) { - currentAnnotations = { tags: {}, extras: {} }; - annotationsByError.set(error3, currentAnnotations); - } - if (annotations.tags) { - currentAnnotations.tags = { - ...currentAnnotations.tags, - ...annotations.tags - }; - } - if (annotations.extras) { - currentAnnotations.extras = { - ...currentAnnotations.extras, - ...annotations.extras - }; - } -} - -// node_modules/@tldraw/utils/dist-esm/lib/network.mjs -async function fetch2(input, init) { - return window.fetch(input, { - referrerPolicy: "strict-origin-when-cross-origin", - ...init - }); -} -var Image = (width, height) => { - const img = new window.Image(width, height); - img.referrerPolicy = "strict-origin-when-cross-origin"; - return img; -}; - -// node_modules/@tldraw/utils/dist-esm/lib/file.mjs -var FileHelpers = class { - static async dataUrlToArrayBuffer(dataURL) { - return fetch2(dataURL).then(function(result) { - return result.arrayBuffer(); - }); - } - static async blobToDataUrl(file) { - return await new Promise((resolve, reject) => { - if (file) { - const reader = new FileReader(); - reader.onload = () => resolve(reader.result); - reader.onerror = (error3) => reject(error3); - reader.onabort = (error3) => reject(error3); - reader.readAsDataURL(file); - } - }); - } - static async blobToText(file) { - return await new Promise((resolve, reject) => { - if (file) { - const reader = new FileReader(); - reader.onload = () => resolve(reader.result); - reader.onerror = (error3) => reject(error3); - reader.onabort = (error3) => reject(error3); - reader.readAsText(file); - } - }); - } -}; - -// node_modules/@tldraw/utils/dist-esm/lib/hash.mjs -function getHashForString(string2) { - let hash = 0; - for (let i = 0; i < string2.length; i++) { - hash = (hash << 5) - hash + string2.charCodeAt(i); - hash |= 0; - } - return hash + ""; -} - -// node_modules/@tldraw/utils/dist-esm/lib/media/apng.mjs -function isApngAnimated(buffer) { - const view = new Uint8Array(buffer); - if (!view || !(typeof Buffer !== "undefined" && Buffer.isBuffer(view) || view instanceof Uint8Array) || view.length < 16) { - return false; - } - const isPNG = view[0] === 137 && view[1] === 80 && view[2] === 78 && view[3] === 71 && view[4] === 13 && view[5] === 10 && view[6] === 26 && view[7] === 10; - if (!isPNG) { - return false; - } - function indexOfSubstring(haystack, needle, fromIndex, upToIndex, chunksize = 1024) { - if (!needle) { - return -1; - } - needle = new RegExp(needle, "g"); - const needle_length = needle.source.length; - const decoder = new TextDecoder(); - const full_haystack_length = haystack.length; - if (typeof upToIndex === "undefined") { - upToIndex = full_haystack_length; - } - if (fromIndex >= full_haystack_length || upToIndex <= 0 || fromIndex >= upToIndex) { - return -1; - } - haystack = haystack.subarray(fromIndex, upToIndex); - let position = -1; - let current_index = 0; - let full_length = 0; - let needle_buffer = ""; - outer: - while (current_index < haystack.length) { - const next_index = current_index + chunksize; - const chunk = haystack.subarray(current_index, next_index); - const decoded = decoder.decode(chunk, { stream: true }); - const text = needle_buffer + decoded; - let match; - let last_index = -1; - while ((match = needle.exec(text)) !== null) { - last_index = match.index - needle_buffer.length; - position = full_length + last_index; - break outer; - } - current_index = next_index; - full_length += decoded.length; - const needle_index = last_index > -1 ? last_index + needle_length : decoded.length - needle_length; - needle_buffer = decoded.slice(needle_index); - } - if (position >= 0) { - position += fromIndex >= 0 ? fromIndex : full_haystack_length + fromIndex; - } - return position; - } - const idatIdx = indexOfSubstring(view, "IDAT", 12); - if (idatIdx >= 12) { - const actlIdx = indexOfSubstring(view, "acTL", 8, idatIdx); - return actlIdx >= 8; - } - return false; -} - -// node_modules/@tldraw/utils/dist-esm/lib/media/avif.mjs -var isAvifAnimated = (buffer) => { - const view = new Uint8Array(buffer); - return view[3] === 44; -}; - -// node_modules/@tldraw/utils/dist-esm/lib/media/gif.mjs -function getDataBlocksLength(buffer, offset4) { - let length = 0; - while (buffer[offset4 + length]) { - length += buffer[offset4 + length] + 1; - } - return length + 1; -} -function isGIF(buffer) { - const enc = new TextDecoder("ascii"); - const header = enc.decode(buffer.slice(0, 3)); - return header === "GIF"; -} -function isGifAnimated(buffer) { - const view = new Uint8Array(buffer); - let hasColorTable, colorTableSize; - let offset4 = 0; - let imagesCount = 0; - if (!isGIF(buffer)) { - return false; - } - hasColorTable = view[10] & 128; - colorTableSize = view[10] & 7; - offset4 += 6; - offset4 += 7; - offset4 += hasColorTable ? 3 * Math.pow(2, colorTableSize + 1) : 0; - while (imagesCount < 2 && offset4 < view.length) { - switch (view[offset4]) { - case 44: - imagesCount += 1; - hasColorTable = view[offset4 + 9] & 128; - colorTableSize = view[offset4 + 9] & 7; - offset4 += 10; - offset4 += hasColorTable ? 3 * Math.pow(2, colorTableSize + 1) : 0; - offset4 += getDataBlocksLength(view, offset4 + 1) + 1; - break; - case 33: - offset4 += 2; - offset4 += getDataBlocksLength(view, offset4); - break; - case 59: - offset4 = view.length; - break; - default: - offset4 = view.length; - break; - } - } - return imagesCount > 1; -} - -// node_modules/@tldraw/utils/dist-esm/lib/media/png.mjs -var TABLE = [ - 0, - 1996959894, - 3993919788, - 2567524794, - 124634137, - 1886057615, - 3915621685, - 2657392035, - 249268274, - 2044508324, - 3772115230, - 2547177864, - 162941995, - 2125561021, - 3887607047, - 2428444049, - 498536548, - 1789927666, - 4089016648, - 2227061214, - 450548861, - 1843258603, - 4107580753, - 2211677639, - 325883990, - 1684777152, - 4251122042, - 2321926636, - 335633487, - 1661365465, - 4195302755, - 2366115317, - 997073096, - 1281953886, - 3579855332, - 2724688242, - 1006888145, - 1258607687, - 3524101629, - 2768942443, - 901097722, - 1119000684, - 3686517206, - 2898065728, - 853044451, - 1172266101, - 3705015759, - 2882616665, - 651767980, - 1373503546, - 3369554304, - 3218104598, - 565507253, - 1454621731, - 3485111705, - 3099436303, - 671266974, - 1594198024, - 3322730930, - 2970347812, - 795835527, - 1483230225, - 3244367275, - 3060149565, - 1994146192, - 31158534, - 2563907772, - 4023717930, - 1907459465, - 112637215, - 2680153253, - 3904427059, - 2013776290, - 251722036, - 2517215374, - 3775830040, - 2137656763, - 141376813, - 2439277719, - 3865271297, - 1802195444, - 476864866, - 2238001368, - 4066508878, - 1812370925, - 453092731, - 2181625025, - 4111451223, - 1706088902, - 314042704, - 2344532202, - 4240017532, - 1658658271, - 366619977, - 2362670323, - 4224994405, - 1303535960, - 984961486, - 2747007092, - 3569037538, - 1256170817, - 1037604311, - 2765210733, - 3554079995, - 1131014506, - 879679996, - 2909243462, - 3663771856, - 1141124467, - 855842277, - 2852801631, - 3708648649, - 1342533948, - 654459306, - 3188396048, - 3373015174, - 1466479909, - 544179635, - 3110523913, - 3462522015, - 1591671054, - 702138776, - 2966460450, - 3352799412, - 1504918807, - 783551873, - 3082640443, - 3233442989, - 3988292384, - 2596254646, - 62317068, - 1957810842, - 3939845945, - 2647816111, - 81470997, - 1943803523, - 3814918930, - 2489596804, - 225274430, - 2053790376, - 3826175755, - 2466906013, - 167816743, - 2097651377, - 4027552580, - 2265490386, - 503444072, - 1762050814, - 4150417245, - 2154129355, - 426522225, - 1852507879, - 4275313526, - 2312317920, - 282753626, - 1742555852, - 4189708143, - 2394877945, - 397917763, - 1622183637, - 3604390888, - 2714866558, - 953729732, - 1340076626, - 3518719985, - 2797360999, - 1068828381, - 1219638859, - 3624741850, - 2936675148, - 906185462, - 1090812512, - 3747672003, - 2825379669, - 829329135, - 1181335161, - 3412177804, - 3160834842, - 628085408, - 1382605366, - 3423369109, - 3138078467, - 570562233, - 1426400815, - 3317316542, - 2998733608, - 733239954, - 1555261956, - 3268935591, - 3050360625, - 752459403, - 1541320221, - 2607071920, - 3965973030, - 1969922972, - 40735498, - 2617837225, - 3943577151, - 1913087877, - 83908371, - 2512341634, - 3803740692, - 2075208622, - 213261112, - 2463272603, - 3855990285, - 2094854071, - 198958881, - 2262029012, - 4057260610, - 1759359992, - 534414190, - 2176718541, - 4139329115, - 1873836001, - 414664567, - 2282248934, - 4279200368, - 1711684554, - 285281116, - 2405801727, - 4167216745, - 1634467795, - 376229701, - 2685067896, - 3608007406, - 1308918612, - 956543938, - 2808555105, - 3495958263, - 1231636301, - 1047427035, - 2932959818, - 3654703836, - 1088359270, - 936918e3, - 2847714899, - 3736837829, - 1202900863, - 817233897, - 3183342108, - 3401237130, - 1404277552, - 615818150, - 3134207493, - 3453421203, - 1423857449, - 601450431, - 3009837614, - 3294710456, - 1567103746, - 711928724, - 3020668471, - 3272380065, - 1510334235, - 755167117 -]; -if (typeof Int32Array !== "undefined") { - TABLE = new Int32Array(TABLE); -} -var crc = (current, previous) => { - let crc2 = previous === 0 ? 0 : ~~previous ^ -1; - for (let index2 = 0; index2 < current.length; index2++) { - crc2 = TABLE[(crc2 ^ current[index2]) & 255] ^ crc2 >>> 8; - } - return crc2 ^ -1; -}; -var LEN_SIZE = 4; -var CRC_SIZE = 4; -var PngHelpers = class { - static isPng(view, offset4) { - if (view.getUint8(offset4 + 0) === 137 && view.getUint8(offset4 + 1) === 80 && view.getUint8(offset4 + 2) === 78 && view.getUint8(offset4 + 3) === 71 && view.getUint8(offset4 + 4) === 13 && view.getUint8(offset4 + 5) === 10 && view.getUint8(offset4 + 6) === 26 && view.getUint8(offset4 + 7) === 10) { - return true; - } - return false; - } - static getChunkType(view, offset4) { - return [ - String.fromCharCode(view.getUint8(offset4)), - String.fromCharCode(view.getUint8(offset4 + 1)), - String.fromCharCode(view.getUint8(offset4 + 2)), - String.fromCharCode(view.getUint8(offset4 + 3)) - ].join(""); - } - static readChunks(view, offset4 = 0) { - const chunks = {}; - if (!PngHelpers.isPng(view, offset4)) { - throw new Error("Not a PNG"); - } - offset4 += 8; - while (offset4 <= view.buffer.byteLength) { - const start = offset4; - const len = view.getInt32(offset4); - offset4 += 4; - const chunkType = PngHelpers.getChunkType(view, offset4); - if (chunkType === "IDAT" && chunks[chunkType]) { - offset4 += len + LEN_SIZE + CRC_SIZE; - continue; - } - if (chunkType === "IEND") { - break; - } - chunks[chunkType] = { - start, - dataOffset: offset4 + 4, - size: len - }; - offset4 += len + LEN_SIZE + CRC_SIZE; - } - return chunks; - } - static parsePhys(view, offset4) { - return { - ppux: view.getUint32(offset4), - ppuy: view.getUint32(offset4 + 4), - unit: view.getUint8(offset4 + 4) - }; - } - static findChunk(view, type) { - const chunks = PngHelpers.readChunks(view); - return chunks[type]; - } - static setPhysChunk(view, dpr = 1, options) { - let offset4 = 46; - let size4 = 0; - const res1 = PngHelpers.findChunk(view, "pHYs"); - if (res1) { - offset4 = res1.start; - size4 = res1.size; - } - const res2 = PngHelpers.findChunk(view, "IDAT"); - if (res2) { - offset4 = res2.start; - size4 = 0; - } - const pHYsData = new ArrayBuffer(21); - const pHYsDataView = new DataView(pHYsData); - pHYsDataView.setUint32(0, 9); - pHYsDataView.setUint8(4, "p".charCodeAt(0)); - pHYsDataView.setUint8(5, "H".charCodeAt(0)); - pHYsDataView.setUint8(6, "Y".charCodeAt(0)); - pHYsDataView.setUint8(7, "s".charCodeAt(0)); - const DPI_96 = 2835.5; - pHYsDataView.setInt32(8, DPI_96 * dpr); - pHYsDataView.setInt32(12, DPI_96 * dpr); - pHYsDataView.setInt8(16, 1); - const crcBit = new Uint8Array(pHYsData.slice(4, 17)); - pHYsDataView.setInt32(17, crc(crcBit)); - const startBuf = view.buffer.slice(0, offset4); - const endBuf = view.buffer.slice(offset4 + size4); - return new Blob([startBuf, pHYsData, endBuf], options); - } -}; - -// node_modules/@tldraw/utils/dist-esm/lib/media/webp.mjs -function isWebp(view) { - if (!view || view.length < 12) { - return false; - } - return view[8] === 87 && view[9] === 69 && view[10] === 66 && view[11] === 80; -} -function isWebpAnimated(buffer) { - const view = new Uint8Array(buffer); - if (!isWebp(view)) { - return false; - } - if (!view || view.length < 21) { - return false; - } - return (view[20] >> 1 & 1) === 1; -} - -// node_modules/@tldraw/utils/dist-esm/lib/media/media.mjs -var DEFAULT_SUPPORTED_VECTOR_IMAGE_TYPES = Object.freeze(["image/svg+xml"]); -var DEFAULT_SUPPORTED_STATIC_IMAGE_TYPES = Object.freeze([ - "image/jpeg", - "image/png", - "image/webp" -]); -var DEFAULT_SUPPORTED_ANIMATED_IMAGE_TYPES = Object.freeze([ - "image/gif", - "image/apng", - "image/avif" -]); -var DEFAULT_SUPPORTED_IMAGE_TYPES = Object.freeze([ - ...DEFAULT_SUPPORTED_STATIC_IMAGE_TYPES, - ...DEFAULT_SUPPORTED_VECTOR_IMAGE_TYPES, - ...DEFAULT_SUPPORTED_ANIMATED_IMAGE_TYPES -]); -var DEFAULT_SUPPORT_VIDEO_TYPES = Object.freeze([ - "video/mp4", - "video/webm", - "video/quicktime" -]); -var DEFAULT_SUPPORTED_MEDIA_TYPE_LIST = [ - ...DEFAULT_SUPPORTED_IMAGE_TYPES, - ...DEFAULT_SUPPORT_VIDEO_TYPES -].join(","); -var MediaHelpers = class { - static loadVideo(src) { - return new Promise((resolve, reject) => { - const video = document.createElement("video"); - video.onloadeddata = () => resolve(video); - video.onerror = (e) => { - console.error(e); - reject(new Error("Could not load video")); - }; - video.crossOrigin = "anonymous"; - video.src = src; - }); - } - static loadImage(src) { - return new Promise((resolve, reject) => { - const img = Image(); - img.onload = () => resolve(img); - img.onerror = (e) => { - console.error(e); - reject(new Error("Could not load image")); - }; - img.crossOrigin = "anonymous"; - img.referrerPolicy = "strict-origin-when-cross-origin"; - img.src = src; - }); - } - static async getVideoSize(blob) { - return MediaHelpers.usingObjectURL(blob, async (url) => { - const video = await MediaHelpers.loadVideo(url); - return { w: video.videoWidth, h: video.videoHeight }; - }); - } - static async getImageSize(blob) { - const image = await MediaHelpers.usingObjectURL(blob, MediaHelpers.loadImage); - try { - if (blob.type === "image/png") { - const view = new DataView(await blob.arrayBuffer()); - if (PngHelpers.isPng(view, 0)) { - const physChunk = PngHelpers.findChunk(view, "pHYs"); - if (physChunk) { - const physData = PngHelpers.parsePhys(view, physChunk.dataOffset); - if (physData.unit === 0 && physData.ppux === physData.ppuy) { - const pixelRatio = Math.max(physData.ppux / 2834.5, 1); - return { - w: Math.round(image.naturalWidth / pixelRatio), - h: Math.round(image.naturalHeight / pixelRatio) - }; - } - } - } - } - } catch (err) { - console.error(err); - return { w: image.naturalWidth, h: image.naturalHeight }; - } - return { w: image.naturalWidth, h: image.naturalHeight }; - } - static async isAnimated(file) { - if (file.type === "image/gif") { - return isGifAnimated(await file.arrayBuffer()); - } - if (file.type === "image/avif") { - return isAvifAnimated(await file.arrayBuffer()); - } - if (file.type === "image/webp") { - return isWebpAnimated(await file.arrayBuffer()); - } - if (file.type === "image/apng") { - return isApngAnimated(await file.arrayBuffer()); - } - return false; - } - static isAnimatedImageType(mimeType) { - return DEFAULT_SUPPORTED_ANIMATED_IMAGE_TYPES.includes(mimeType || ""); - } - static isStaticImageType(mimeType) { - return DEFAULT_SUPPORTED_STATIC_IMAGE_TYPES.includes(mimeType || ""); - } - static isVectorImageType(mimeType) { - return DEFAULT_SUPPORTED_VECTOR_IMAGE_TYPES.includes(mimeType || ""); - } - static isImageType(mimeType) { - return DEFAULT_SUPPORTED_IMAGE_TYPES.includes(mimeType); - } - static async usingObjectURL(blob, fn) { - const url = URL.createObjectURL(blob); - try { - return await fn(url); - } finally { - URL.revokeObjectURL(url); - } - } -}; - -// node_modules/@tldraw/utils/dist-esm/lib/number.mjs -function lerp(a, b, t2) { - return a + (b - a) * t2; -} -function rng(seed = "") { - let x = 0; - let y = 0; - let z = 0; - let w = 0; - function next() { - const t2 = x ^ x << 11; - x = y; - y = z; - z = w; - w ^= (w >>> 19 ^ t2 ^ t2 >>> 8) >>> 0; - return w / 4294967296 * 2; - } - for (let k = 0; k < seed.length + 64; k++) { - x ^= seed.charCodeAt(k) | 0; - next(); - } - return next; -} -function modulate(value, rangeA, rangeB, clamp4 = false) { - const [fromLow, fromHigh] = rangeA; - const [v0, v1] = rangeB; - const result = v0 + (value - fromLow) / (fromHigh - fromLow) * (v1 - v0); - return clamp4 ? v0 < v1 ? Math.max(Math.min(result, v1), v0) : Math.max(Math.min(result, v0), v1) : result; -} - -// node_modules/@tldraw/utils/dist-esm/lib/object.mjs -function hasOwnProperty(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); -} -function getOwnProperty(obj, key) { - if (!hasOwnProperty(obj, key)) { - return void 0; - } - return obj[key]; -} -function objectMapKeys(object2) { - return Object.keys(object2); -} -function objectMapValues(object2) { - return Object.values(object2); -} -function objectMapEntries(object2) { - return Object.entries(object2); -} -function objectMapFromEntries(entries) { - return Object.fromEntries(entries); -} -function filterEntries(object2, predicate) { - const result = {}; - let didChange = false; - for (const [key, value] of objectMapEntries(object2)) { - if (predicate(key, value)) { - result[key] = value; - } else { - didChange = true; - } - } - return didChange ? result : object2; -} -function mapObjectMapValues(object2, mapper) { - const result = {}; - for (const [key, value] of objectMapEntries(object2)) { - const newValue = mapper(key, value); - result[key] = newValue; - } - return result; -} -function areObjectsShallowEqual(obj1, obj2) { - if (obj1 === obj2) - return true; - const keys1 = new Set(Object.keys(obj1)); - const keys2 = new Set(Object.keys(obj2)); - if (keys1.size !== keys2.size) - return false; - for (const key of keys1) { - if (!keys2.has(key)) - return false; - if (!Object.is(obj1[key], obj2[key])) - return false; - } - return true; -} - -// node_modules/@tldraw/utils/dist-esm/lib/reordering/dgreensp/dgreensp.mjs -var DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -var INTEGER_ZERO = "a0"; -var SMALLEST_INTEGER = "A00000000000000000000000000"; -function getIntegerLength(head) { - if (head >= "a" && head <= "z") { - return head.charCodeAt(0) - "a".charCodeAt(0) + 2; - } else if (head >= "A" && head <= "Z") { - return "Z".charCodeAt(0) - head.charCodeAt(0) + 2; - } else { - throw new Error("Invalid index key head: " + head); - } -} -function validateInteger(int) { - if (int.length !== getIntegerLength(int.charAt(0))) { - throw new Error("invalid integer part of index key: " + int); - } -} -function isNotUndefined(n) { - if (n === void 0) - throw Error("n is undefined"); -} -function incrementInteger(x) { - validateInteger(x); - const [head, ...digs] = x.split(""); - let carry = true; - for (let i = digs.length - 1; carry && i >= 0; i--) { - const d = DIGITS.indexOf(digs[i]) + 1; - if (d === DIGITS.length) { - digs[i] = "0"; - } else { - digs[i] = DIGITS.charAt(d); - carry = false; - } - } - if (carry) { - if (head === "Z") - return "a0"; - if (head === "z") - return void 0; - const h = String.fromCharCode(head.charCodeAt(0) + 1); - if (h > "a") { - digs.push("0"); - } else { - digs.pop(); - } - return h + digs.join(""); - } else { - return head + digs.join(""); - } -} -function decrementInteger(x) { - validateInteger(x); - const [head, ...digs] = x.split(""); - let borrow = true; - for (let i = digs.length - 1; borrow && i >= 0; i--) { - const d = DIGITS.indexOf(digs[i]) - 1; - if (d === -1) { - digs[i] = DIGITS.slice(-1); - } else { - digs[i] = DIGITS.charAt(d); - borrow = false; - } - } - if (borrow) { - if (head === "a") - return "Z" + DIGITS.slice(-1); - if (head === "A") - return void 0; - const h = String.fromCharCode(head.charCodeAt(0) - 1); - if (h < "Z") { - digs.push(DIGITS.slice(-1)); - } else { - digs.pop(); - } - return h + digs.join(""); - } else { - return head + digs.join(""); - } -} -function midpoint(a, b) { - if (b !== void 0 && a >= b) { - throw new Error(a + " >= " + b); - } - if (a.slice(-1) === "0" || b && b.slice(-1) === "0") { - throw new Error("trailing zero"); - } - if (b) { - let n = 0; - while ((a.charAt(n) || "0") === b.charAt(n)) { - n++; - } - if (n > 0) { - return b.slice(0, n) + midpoint(a.slice(n), b.slice(n)); - } - } - const digitA = a ? DIGITS.indexOf(a.charAt(0)) : 0; - const digitB = b !== void 0 ? DIGITS.indexOf(b.charAt(0)) : DIGITS.length; - if (digitB - digitA > 1) { - const midDigit = Math.round(0.5 * (digitA + digitB)); - return DIGITS.charAt(midDigit); - } else { - if (b && b.length > 1) { - return b.slice(0, 1); - } else { - return DIGITS.charAt(digitA) + midpoint(a.slice(1), void 0); - } - } -} -function getIntegerPart(index2) { - const integerPartLength = getIntegerLength(index2.charAt(0)); - if (integerPartLength > index2.length) { - throw new Error("invalid index: " + index2); - } - return index2.slice(0, integerPartLength); -} -function validateOrder(index2) { - if (index2 === SMALLEST_INTEGER) { - throw new Error("invalid index: " + index2); - } - const i = getIntegerPart(index2); - const f = index2.slice(i.length); - if (f.slice(-1) === "0") { - throw new Error("invalid index: " + index2); - } -} -function generateKeyBetween(a, b) { - if (a !== void 0) - validateOrder(a); - if (b !== void 0) - validateOrder(b); - if (a !== void 0 && b !== void 0 && a >= b) { - throw new Error(a + " >= " + b); - } - if (a === void 0 && b === void 0) { - return INTEGER_ZERO; - } - if (a === void 0) { - if (b === void 0) - throw Error("b is undefined"); - const ib2 = getIntegerPart(b); - const fb2 = b.slice(ib2.length); - if (ib2 === SMALLEST_INTEGER) { - return ib2 + midpoint("", fb2); - } - if (ib2 < b) { - return ib2; - } - const ibl = decrementInteger(ib2); - isNotUndefined(ibl); - return ibl; - } - if (b === void 0) { - const ia2 = getIntegerPart(a); - const fa2 = a.slice(ia2.length); - const i2 = incrementInteger(ia2); - return i2 === void 0 ? ia2 + midpoint(fa2, void 0) : i2; - } - const ia = getIntegerPart(a); - const fa = a.slice(ia.length); - const ib = getIntegerPart(b); - const fb = b.slice(ib.length); - if (ia === ib) { - return ia + midpoint(fa, fb); - } - const i = incrementInteger(ia); - isNotUndefined(i); - return i < b ? i : ia + midpoint(fa, void 0); -} -function generateNKeysBetween(a, b, n) { - if (n === 0) - return []; - if (n === 1) - return [generateKeyBetween(a, b)]; - if (b === void 0) { - let c2 = generateKeyBetween(a, b); - const result = [c2]; - for (let i = 0; i < n - 1; i++) { - c2 = generateKeyBetween(c2, b); - result.push(c2); - } - return result; - } - if (a === void 0) { - let c2 = generateKeyBetween(a, b); - const result = [c2]; - for (let i = 0; i < n - 1; i++) { - c2 = generateKeyBetween(a, c2); - result.push(c2); - } - result.reverse(); - return result; - } - const mid = Math.floor(n / 2); - const c = generateKeyBetween(a, b); - return [...generateNKeysBetween(a, c, mid), c, ...generateNKeysBetween(c, b, n - mid - 1)]; -} - -// node_modules/@tldraw/utils/dist-esm/lib/reordering/reordering.mjs -var ZERO_INDEX_KEY = INTEGER_ZERO; -function validateIndexKey(key) { - validateOrder(key); -} -function getIndicesBetween(below, above, n) { - return generateNKeysBetween(below, above, n); -} -function getIndicesAbove(below, n) { - return generateNKeysBetween(below, void 0, n); -} -function getIndexBetween(below, above) { - return generateNKeysBetween(below, above, 1)[0]; -} -function getIndexAbove(below) { - return generateNKeysBetween(below, void 0, 1)[0]; -} -function getIndexBelow(above) { - return generateNKeysBetween(void 0, above, 1)[0]; -} -function getIndices(n, start = "a1") { - return [start, ...generateNKeysBetween(start, void 0, n)]; -} -function sortByIndex(a, b) { - if (a.index < b.index) { - return -1; - } else if (a.index > b.index) { - return 1; - } - return 0; -} - -// node_modules/@tldraw/utils/dist-esm/lib/sort.mjs -function sortById(a, b) { - return a.id > b.id ? 1 : -1; -} - -// node_modules/@tldraw/utils/dist-esm/lib/storage.mjs -function getFromLocalStorage(key) { - try { - return localStorage.getItem(key); - } catch { - return null; - } -} -function setInLocalStorage(key, value) { - try { - localStorage.setItem(key, value); - } catch { - } -} -function clearLocalStorage() { - try { - localStorage.clear(); - } catch { - } -} -function getFromSessionStorage(key) { - try { - return sessionStorage.getItem(key); - } catch { - return null; - } -} -function setInSessionStorage(key, value) { - try { - sessionStorage.setItem(key, value); - } catch { - } -} -function deleteFromSessionStorage(key) { - try { - sessionStorage.removeItem(key); - } catch { - } -} -function clearSessionStorage() { - try { - sessionStorage.clear(); - } catch { - } -} - -// node_modules/@tldraw/utils/dist-esm/lib/throttle.mjs -var isTest = () => typeof process !== "undefined" && false; -var fpsQueue = []; -var targetFps = 60; -var targetTimePerFrame = Math.ceil(1e3 / targetFps); -var frame; -var time = 0; -var last2 = 0; -var flush = () => { - const queue = fpsQueue.splice(0, fpsQueue.length); - for (const fn of queue) { - fn(); - } -}; -function tick() { - if (frame) { - return; - } - const now = Date.now(); - const elapsed = now - last2; - if (time + elapsed < targetTimePerFrame) { - frame = requestAnimationFrame(() => { - frame = void 0; - tick(); - }); - return; - } - frame = requestAnimationFrame(() => { - frame = void 0; - last2 = now; - time = Math.min(time + elapsed - targetTimePerFrame, targetTimePerFrame * 10); - flush(); - }); -} -var started = false; -function throttleToNextFrame(fn) { - if (isTest()) { - fn(); - return () => { - }; - } - if (!fpsQueue.includes(fn)) { - fpsQueue.push(fn); - if (!started) { - started = true; - last2 = Date.now() - targetTimePerFrame - 1; - } - tick(); - } - return () => { - const index2 = fpsQueue.indexOf(fn); - if (index2 > -1) { - fpsQueue.splice(index2, 1); - } - }; -} - -// node_modules/@tldraw/utils/dist-esm/lib/timers.mjs -var Timers = class { - constructor() { - __publicField(this, "timeouts", []); - __publicField(this, "intervals", []); - __publicField(this, "rafs", []); - } - setTimeout(handler, timeout, ...args) { - const id = window.setTimeout(handler, timeout, args); - this.timeouts.push(id); - return id; - } - setInterval(handler, timeout, ...args) { - const id = window.setInterval(handler, timeout, args); - this.intervals.push(id); - return id; - } - requestAnimationFrame(callback) { - const id = window.requestAnimationFrame(callback); - this.rafs.push(id); - return id; - } - dispose() { - this.timeouts.forEach((id) => clearTimeout(id)); - this.intervals.forEach((id) => clearInterval(id)); - this.rafs.forEach((id) => cancelAnimationFrame(id)); - this.timeouts.length = 0; - this.intervals.length = 0; - this.rafs.length = 0; - } -}; - -// node_modules/@tldraw/utils/dist-esm/lib/value.mjs -function isNonNull(value) { - return value !== null; -} -function getStructuredClone() { - if (typeof globalThis !== "undefined" && globalThis.structuredClone) { - return [globalThis.structuredClone, true]; - } - if (typeof global !== "undefined" && global.structuredClone) { - return [global.structuredClone, true]; - } - if (typeof window !== "undefined" && window.structuredClone) { - return [window.structuredClone, true]; - } - return [(i) => i ? JSON.parse(JSON.stringify(i)) : i, false]; -} -var _structuredClone = getStructuredClone(); -var structuredClone = _structuredClone[0]; -var isNativeStructuredClone = _structuredClone[1]; -var STRUCTURED_CLONE_OBJECT_PROTOTYPE = Object.getPrototypeOf(structuredClone({})); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/debug-flags.mjs -var featureFlags = { - enableLicensing: createFeatureFlag("enableLicensing", { - defaults: { all: true, production: false } - }) -}; -var pointerCaptureTrackingObject = createDebugValue("pointerCaptureTrackingObject", { - defaults: { all: /* @__PURE__ */ new Map() }, - shouldStoreForSession: false -}); -var debugFlags = { - logPreventDefaults: createDebugValue("logPreventDefaults", { - defaults: { all: false } - }), - logPointerCaptures: createDebugValue("logPointerCaptures", { - defaults: { all: false } - }), - logElementRemoves: createDebugValue("logElementRemoves", { - defaults: { all: false } - }), - debugSvg: createDebugValue("debugSvg", { - defaults: { all: false } - }), - showFps: createDebugValue("showFps", { - defaults: { all: false } - }), - measurePerformance: createDebugValue("measurePerformance", { defaults: { all: false } }), - throwToBlob: createDebugValue("throwToBlob", { - defaults: { all: false } - }), - reconnectOnPing: createDebugValue("reconnectOnPing", { - defaults: { all: false } - }), - debugCursors: createDebugValue("debugCursors", { - defaults: { all: false } - }), - forceSrgb: createDebugValue("forceSrgbColors", { defaults: { all: false } }), - debugGeometry: createDebugValue("debugGeometry", { defaults: { all: false } }), - hideShapes: createDebugValue("hideShapes", { defaults: { all: false } }), - editOnType: createDebugValue("editOnType", { defaults: { all: false } }) -}; -if (typeof Element !== "undefined") { - const nativeElementRemoveChild = Element.prototype.removeChild; - react("element removal logging", () => { - if (debugFlags.logElementRemoves.get()) { - Element.prototype.removeChild = function(child) { - console.warn("[tldraw] removing child:", child); - return nativeElementRemoveChild.call(this, child); - }; - } else { - Element.prototype.removeChild = nativeElementRemoveChild; - } - }); -} -function createDebugValue(name, { - defaults: defaults2, - shouldStoreForSession = true -}) { - return createDebugValueBase({ - name, - defaults: defaults2, - shouldStoreForSession - }); -} -function createFeatureFlag(name, { - defaults: defaults2, - shouldStoreForSession = true -}) { - return createDebugValueBase({ - name, - defaults: defaults2, - shouldStoreForSession - }); -} -function createDebugValueBase(def) { - const defaultValue = getDefaultValue(def); - const storedValue = def.shouldStoreForSession ? getStoredInitialValue(def.name) : null; - const valueAtom = atom(`debug:${def.name}`, storedValue ?? defaultValue); - if (typeof window !== "undefined") { - if (def.shouldStoreForSession) { - react(`debug:${def.name}`, () => { - const currentValue = valueAtom.get(); - if (currentValue === defaultValue) { - deleteFromSessionStorage(`tldraw_debug:${def.name}`); - } else { - setInSessionStorage(`tldraw_debug:${def.name}`, JSON.stringify(currentValue)); - } - }); - } - Object.defineProperty(window, `tldraw${def.name.replace(/^[a-z]/, (l) => l.toUpperCase())}`, { - get() { - return valueAtom.get(); - }, - set(newValue) { - valueAtom.set(newValue); - }, - configurable: true - }); - } - return Object.assign(valueAtom, def); -} -function getStoredInitialValue(name) { - try { - return JSON.parse(getFromSessionStorage(`tldraw_debug:${name}`) ?? "null"); - } catch (err) { - return null; - } -} -function readEnv(fn) { - try { - return fn(); - } catch { - return null; - } -} -function getDefaultValue(def) { - const env = readEnv(() => process.env.TLDRAW_ENV) ?? readEnv(() => process.env.VERCEL_PUBLIC_TLDRAW_ENV) ?? readEnv(() => process.env.NEXT_PUBLIC_TLDRAW_ENV) ?? "production"; - switch (env) { - case "production": - return def.defaults.production ?? def.defaults.all; - case "preview": - case "staging": - return def.defaults.staging ?? def.defaults.all; - default: - return def.defaults.development ?? def.defaults.all; - } -} - -// node_modules/@tldraw/store/dist-esm/lib/IncrementalSetConstructor.mjs -var IncrementalSetConstructor = class { - constructor(previousValue) { - __publicField(this, "nextValue"); - __publicField(this, "diff"); - this.previousValue = previousValue; - } - get() { - const numRemoved = this.diff?.removed?.size ?? 0; - const numAdded = this.diff?.added?.size ?? 0; - if (numRemoved === 0 && numAdded === 0) { - return void 0; - } - return { value: this.nextValue, diff: this.diff }; - } - _add(item, wasAlreadyPresent) { - var _a; - this.nextValue ?? (this.nextValue = new Set(this.previousValue)); - this.nextValue.add(item); - this.diff ?? (this.diff = {}); - if (wasAlreadyPresent) { - this.diff.removed?.delete(item); - } else { - (_a = this.diff).added ?? (_a.added = /* @__PURE__ */ new Set()); - this.diff.added.add(item); - } - } - add(item) { - const wasAlreadyPresent = this.previousValue.has(item); - if (wasAlreadyPresent) { - const wasRemoved = this.diff?.removed?.has(item); - if (!wasRemoved) - return; - return this._add(item, wasAlreadyPresent); - } - const isCurrentlyPresent = this.nextValue?.has(item); - if (isCurrentlyPresent) - return; - this._add(item, wasAlreadyPresent); - } - _remove(item, wasAlreadyPresent) { - var _a; - this.nextValue ?? (this.nextValue = new Set(this.previousValue)); - this.nextValue.delete(item); - this.diff ?? (this.diff = {}); - if (wasAlreadyPresent) { - (_a = this.diff).removed ?? (_a.removed = /* @__PURE__ */ new Set()); - this.diff.removed.add(item); - } else { - this.diff.added?.delete(item); - } - } - remove(item) { - const wasAlreadyPresent = this.previousValue.has(item); - if (!wasAlreadyPresent) { - const wasAdded = this.diff?.added?.has(item); - if (!wasAdded) - return; - return this._remove(item, wasAlreadyPresent); - } - const hasAlreadyBeenRemoved = this.diff?.removed?.has(item); - if (hasAlreadyBeenRemoved) - return; - this._remove(item, wasAlreadyPresent); - } -}; - -// node_modules/@tldraw/store/node_modules/nanoid/index.browser.js -var nanoid = (size4 = 21) => crypto.getRandomValues(new Uint8Array(size4)).reduce((id, byte) => { - byte &= 63; - if (byte < 36) { - id += byte.toString(36); - } else if (byte < 62) { - id += (byte - 26).toString(36).toUpperCase(); - } else if (byte > 62) { - id += "-"; - } else { - id += "_"; - } - return id; -}, ""); - -// node_modules/@tldraw/store/dist-esm/lib/RecordType.mjs -var RecordType = class { - constructor(typeName, config) { - __publicField(this, "createDefaultProperties"); - __publicField(this, "validator"); - __publicField(this, "ephemeralKeys"); - __publicField(this, "ephemeralKeySet"); - __publicField(this, "scope"); - __publicField(this, "isInstance", (record) => { - return record?.typeName === this.typeName; - }); - this.typeName = typeName; - this.createDefaultProperties = config.createDefaultProperties; - this.validator = config.validator ?? { validate: (r) => r }; - this.scope = config.scope ?? "document"; - this.ephemeralKeys = config.ephemeralKeys; - const ephemeralKeySet = /* @__PURE__ */ new Set(); - if (config.ephemeralKeys) { - for (const [key, isEphemeral] of objectMapEntries(config.ephemeralKeys)) { - if (isEphemeral) - ephemeralKeySet.add(key); - } - } - this.ephemeralKeySet = ephemeralKeySet; - } - create(properties) { - const result = { ...this.createDefaultProperties(), id: this.createId() }; - for (const [k, v] of Object.entries(properties)) { - if (v !== void 0) { - result[k] = v; - } - } - result.typeName = this.typeName; - return result; - } - clone(record) { - return { ...structuredClone(record), id: this.createId() }; - } - createId(customUniquePart) { - return this.typeName + ":" + (customUniquePart ?? nanoid()); - } - createCustomId(id) { - return this.typeName + ":" + id; - } - parseId(id) { - if (!this.isId(id)) { - throw new Error(`ID "${id}" is not a valid ID for type "${this.typeName}"`); - } - return id.slice(this.typeName.length + 1); - } - isId(id) { - if (!id) - return false; - for (let i = 0; i < this.typeName.length; i++) { - if (id[i] !== this.typeName[i]) - return false; - } - return id[this.typeName.length] === ":"; - } - withDefaultProperties(createDefaultProperties) { - return new RecordType(this.typeName, { - createDefaultProperties, - validator: this.validator, - scope: this.scope, - ephemeralKeys: this.ephemeralKeys - }); - } - validate(record, recordBefore) { - if (recordBefore && this.validator.validateUsingKnownGoodVersion) { - return this.validator.validateUsingKnownGoodVersion(recordBefore, record); - } - return this.validator.validate(record); - } -}; -function createRecordType(typeName, config) { - return new RecordType(typeName, { - createDefaultProperties: () => ({}), - validator: config.validator, - scope: config.scope, - ephemeralKeys: config.ephemeralKeys - }); -} - -// node_modules/@tldraw/store/dist-esm/lib/RecordsDiff.mjs -function createEmptyRecordsDiff() { - return { added: {}, updated: {}, removed: {} }; -} -function reverseRecordsDiff(diff) { - const result = { added: diff.removed, removed: diff.added, updated: {} }; - for (const [from, to] of Object.values(diff.updated)) { - result.updated[from.id] = [to, from]; - } - return result; -} -function isRecordsDiffEmpty(diff) { - return Object.keys(diff.added).length === 0 && Object.keys(diff.updated).length === 0 && Object.keys(diff.removed).length === 0; -} -function squashRecordDiffs(diffs) { - const result = { added: {}, removed: {}, updated: {} }; - squashRecordDiffsMutable(result, diffs); - return result; -} -function squashRecordDiffsMutable(target, diffs) { - for (const diff of diffs) { - for (const [id, value] of objectMapEntries(diff.added)) { - if (target.removed[id]) { - const original = target.removed[id]; - delete target.removed[id]; - if (original !== value) { - target.updated[id] = [original, value]; - } - } else { - target.added[id] = value; - } - } - for (const [id, [_from, to]] of objectMapEntries(diff.updated)) { - if (target.added[id]) { - target.added[id] = to; - delete target.updated[id]; - delete target.removed[id]; - continue; - } - if (target.updated[id]) { - target.updated[id] = [target.updated[id][0], to]; - delete target.removed[id]; - continue; - } - target.updated[id] = diff.updated[id]; - delete target.removed[id]; - } - for (const [id, value] of objectMapEntries(diff.removed)) { - if (target.added[id]) { - delete target.added[id]; - } else if (target.updated[id]) { - target.removed[id] = target.updated[id][0]; - delete target.updated[id]; - } else { - target.removed[id] = value; - } - } - } -} - -// node_modules/@tldraw/store/dist-esm/lib/StoreQueries.mjs -var import_lodash3 = __toESM(require_lodash3(), 1); - -// node_modules/@tldraw/store/dist-esm/lib/setUtils.mjs -function intersectSets(sets) { - if (sets.length === 0) - return /* @__PURE__ */ new Set(); - const first = sets[0]; - const rest = sets.slice(1); - const result = /* @__PURE__ */ new Set(); - for (const val of first) { - if (rest.every((set) => set.has(val))) { - result.add(val); - } - } - return result; -} -function diffSets(prev, next) { - const result = {}; - for (const val of next) { - if (!prev.has(val)) { - result.added ?? (result.added = /* @__PURE__ */ new Set()); - result.added.add(val); - } - } - for (const val of prev) { - if (!next.has(val)) { - result.removed ?? (result.removed = /* @__PURE__ */ new Set()); - result.removed.add(val); - } - } - return result.added || result.removed ? result : void 0; -} - -// node_modules/@tldraw/store/dist-esm/lib/executeQuery.mjs -function objectMatchesQuery(query, object2) { - for (const [key, _matcher] of Object.entries(query)) { - const matcher = _matcher; - const value = object2[key]; - if ("eq" in matcher && value !== matcher.eq) - return false; - if ("neq" in matcher && value === matcher.neq) - return false; - if ("gt" in matcher && (typeof value !== "number" || value <= matcher.gt)) - return false; - } - return true; -} -function executeQuery(store, typeName, query) { - const matchIds = Object.fromEntries(Object.keys(query).map((key) => [key, /* @__PURE__ */ new Set()])); - for (const [k, matcher] of Object.entries(query)) { - if ("eq" in matcher) { - const index2 = store.index(typeName, k); - const ids = index2.get().get(matcher.eq); - if (ids) { - for (const id of ids) { - matchIds[k].add(id); - } - } - } else if ("neq" in matcher) { - const index2 = store.index(typeName, k); - for (const [value, ids] of index2.get()) { - if (value !== matcher.neq) { - for (const id of ids) { - matchIds[k].add(id); - } - } - } - } else if ("gt" in matcher) { - const index2 = store.index(typeName, k); - for (const [value, ids] of index2.get()) { - if (value > matcher.gt) { - for (const id of ids) { - matchIds[k].add(id); - } - } - } - } - } - return intersectSets(Object.values(matchIds)); -} - -// node_modules/@tldraw/store/dist-esm/lib/StoreQueries.mjs -var StoreQueries = class { - constructor(atoms, history) { - __publicField(this, "indexCache", /* @__PURE__ */ new Map()); - __publicField(this, "historyCache", /* @__PURE__ */ new Map()); - this.atoms = atoms; - this.history = history; - } - filterHistory(typeName) { - if (this.historyCache.has(typeName)) { - return this.historyCache.get(typeName); - } - const filtered = computed("filterHistory:" + typeName, (lastValue, lastComputedEpoch) => { - if (isUninitialized(lastValue)) { - return this.history.get(); - } - const diff = this.history.getDiffSince(lastComputedEpoch); - if (diff === RESET_VALUE) - return this.history.get(); - const res = { added: {}, removed: {}, updated: {} }; - let numAdded = 0; - let numRemoved = 0; - let numUpdated = 0; - for (const changes of diff) { - for (const added of objectMapValues(changes.added)) { - if (added.typeName === typeName) { - if (res.removed[added.id]) { - const original = res.removed[added.id]; - delete res.removed[added.id]; - numRemoved--; - if (original !== added) { - res.updated[added.id] = [original, added]; - numUpdated++; - } - } else { - res.added[added.id] = added; - numAdded++; - } - } - } - for (const [from, to] of objectMapValues(changes.updated)) { - if (to.typeName === typeName) { - if (res.added[to.id]) { - res.added[to.id] = to; - } else if (res.updated[to.id]) { - res.updated[to.id] = [res.updated[to.id][0], to]; - } else { - res.updated[to.id] = [from, to]; - numUpdated++; - } - } - } - for (const removed of objectMapValues(changes.removed)) { - if (removed.typeName === typeName) { - if (res.added[removed.id]) { - delete res.added[removed.id]; - numAdded--; - } else if (res.updated[removed.id]) { - res.removed[removed.id] = res.updated[removed.id][0]; - delete res.updated[removed.id]; - numUpdated--; - numRemoved++; - } else { - res.removed[removed.id] = removed; - numRemoved++; - } - } - } - } - if (numAdded || numRemoved || numUpdated) { - return withDiff(this.history.get(), res); - } else { - return lastValue; - } - }, { historyLength: 100 }); - this.historyCache.set(typeName, filtered); - return filtered; - } - index(typeName, property) { - const cacheKey = typeName + ":" + property; - if (this.indexCache.has(cacheKey)) { - return this.indexCache.get(cacheKey); - } - const index2 = this.__uncached_createIndex(typeName, property); - this.indexCache.set(cacheKey, index2); - return index2; - } - __uncached_createIndex(typeName, property) { - const typeHistory = this.filterHistory(typeName); - const fromScratch = () => { - typeHistory.get(); - const res = /* @__PURE__ */ new Map(); - for (const atom3 of objectMapValues(this.atoms.get())) { - const record = atom3.get(); - if (record.typeName === typeName) { - const value = record[property]; - if (!res.has(value)) { - res.set(value, /* @__PURE__ */ new Set()); - } - res.get(value).add(record.id); - } - } - return res; - }; - return computed("index:" + typeName + ":" + property, (prevValue, lastComputedEpoch) => { - if (isUninitialized(prevValue)) - return fromScratch(); - const history = typeHistory.getDiffSince(lastComputedEpoch); - if (history === RESET_VALUE) { - return fromScratch(); - } - const setConstructors = /* @__PURE__ */ new Map(); - const add = (value, id) => { - let setConstructor = setConstructors.get(value); - if (!setConstructor) - setConstructor = new IncrementalSetConstructor(prevValue.get(value) ?? /* @__PURE__ */ new Set()); - setConstructor.add(id); - setConstructors.set(value, setConstructor); - }; - const remove2 = (value, id) => { - let set = setConstructors.get(value); - if (!set) - set = new IncrementalSetConstructor(prevValue.get(value) ?? /* @__PURE__ */ new Set()); - set.remove(id); - setConstructors.set(value, set); - }; - for (const changes of history) { - for (const record of objectMapValues(changes.added)) { - if (record.typeName === typeName) { - const value = record[property]; - add(value, record.id); - } - } - for (const [from, to] of objectMapValues(changes.updated)) { - if (to.typeName === typeName) { - const prev = from[property]; - const next = to[property]; - if (prev !== next) { - remove2(prev, to.id); - add(next, to.id); - } - } - } - for (const record of objectMapValues(changes.removed)) { - if (record.typeName === typeName) { - const value = record[property]; - remove2(value, record.id); - } - } - } - let nextValue = void 0; - let nextDiff = void 0; - for (const [value, setConstructor] of setConstructors) { - const result = setConstructor.get(); - if (!result) - continue; - if (!nextValue) - nextValue = new Map(prevValue); - if (!nextDiff) - nextDiff = /* @__PURE__ */ new Map(); - if (result.value.size === 0) { - nextValue.delete(value); - } else { - nextValue.set(value, result.value); - } - nextDiff.set(value, result.diff); - } - if (nextValue && nextDiff) { - return withDiff(nextValue, nextDiff); - } - return prevValue; - }, { historyLength: 100 }); - } - record(typeName, queryCreator = () => ({}), name = "record:" + typeName + (queryCreator ? ":" + queryCreator.toString() : "")) { - const ids = this.ids(typeName, queryCreator, name); - return computed(name, () => { - for (const id of ids.get()) { - return this.atoms.get()[id]?.get(); - } - return void 0; - }); - } - records(typeName, queryCreator = () => ({}), name = "records:" + typeName + (queryCreator ? ":" + queryCreator.toString() : "")) { - const ids = this.ids(typeName, queryCreator, "ids:" + name); - return computed(name, () => { - return [...ids.get()].map((id) => { - const atom3 = this.atoms.get()[id]; - if (!atom3) { - throw new Error("no atom found for record id: " + id); - } - return atom3.get(); - }); - }); - } - ids(typeName, queryCreator = () => ({}), name = "ids:" + typeName + (queryCreator ? ":" + queryCreator.toString() : "")) { - const typeHistory = this.filterHistory(typeName); - const fromScratch = () => { - typeHistory.get(); - const query = queryCreator(); - if (Object.keys(query).length === 0) { - return new Set(objectMapValues(this.atoms.get()).flatMap((v) => { - const r = v.get(); - if (r.typeName === typeName) { - return r.id; - } else { - return []; - } - })); - } - return executeQuery(this, typeName, query); - }; - const fromScratchWithDiff = (prevValue) => { - const nextValue = fromScratch(); - const diff = diffSets(prevValue, nextValue); - if (diff) { - return withDiff(nextValue, diff); - } else { - return prevValue; - } - }; - const cachedQuery = computed("ids_query:" + name, queryCreator, { - isEqual: import_lodash3.default - }); - return computed("query:" + name, (prevValue, lastComputedEpoch) => { - const query = cachedQuery.get(); - if (isUninitialized(prevValue)) { - return fromScratch(); - } - if (lastComputedEpoch < cachedQuery.lastChangedEpoch) { - return fromScratchWithDiff(prevValue); - } - const history = typeHistory.getDiffSince(lastComputedEpoch); - if (history === RESET_VALUE) { - return fromScratchWithDiff(prevValue); - } - const setConstructor = new IncrementalSetConstructor(prevValue); - for (const changes of history) { - for (const added of objectMapValues(changes.added)) { - if (added.typeName === typeName && objectMatchesQuery(query, added)) { - setConstructor.add(added.id); - } - } - for (const [_, updated] of objectMapValues(changes.updated)) { - if (updated.typeName === typeName) { - if (objectMatchesQuery(query, updated)) { - setConstructor.add(updated.id); - } else { - setConstructor.remove(updated.id); - } - } - } - for (const removed of objectMapValues(changes.removed)) { - if (removed.typeName === typeName) { - setConstructor.remove(removed.id); - } - } - } - const result = setConstructor.get(); - if (!result) { - return prevValue; - } - return withDiff(result.value, result.diff); - }, { historyLength: 50 }); - } - exec(typeName, query) { - const ids = executeQuery(this, typeName, query); - if (ids.size === 0) { - return EMPTY_ARRAY; - } - const atoms = this.atoms.get(); - return [...ids].map((id) => atoms[id].get()); - } -}; - -// node_modules/@tldraw/store/dist-esm/lib/StoreSideEffects.mjs -var StoreSideEffects = class { - constructor(store) { - __publicField(this, "_beforeCreateHandlers", {}); - __publicField(this, "_afterCreateHandlers", {}); - __publicField(this, "_beforeChangeHandlers", {}); - __publicField(this, "_afterChangeHandlers", {}); - __publicField(this, "_beforeDeleteHandlers", {}); - __publicField(this, "_afterDeleteHandlers", {}); - __publicField(this, "_operationCompleteHandlers", []); - __publicField(this, "_isEnabled", true); - this.store = store; - } - isEnabled() { - return this._isEnabled; - } - setIsEnabled(enabled) { - this._isEnabled = enabled; - } - handleBeforeCreate(record, source) { - if (!this._isEnabled) - return record; - const handlers = this._beforeCreateHandlers[record.typeName]; - if (handlers) { - let r = record; - for (const handler of handlers) { - r = handler(r, source); - } - return r; - } - return record; - } - handleAfterCreate(record, source) { - if (!this._isEnabled) - return; - const handlers = this._afterCreateHandlers[record.typeName]; - if (handlers) { - for (const handler of handlers) { - handler(record, source); - } - } - } - handleBeforeChange(prev, next, source) { - if (!this._isEnabled) - return next; - const handlers = this._beforeChangeHandlers[next.typeName]; - if (handlers) { - let r = next; - for (const handler of handlers) { - r = handler(prev, r, source); - } - return r; - } - return next; - } - handleAfterChange(prev, next, source) { - if (!this._isEnabled) - return; - const handlers = this._afterChangeHandlers[next.typeName]; - if (handlers) { - for (const handler of handlers) { - handler(prev, next, source); - } - } - } - handleBeforeDelete(record, source) { - if (!this._isEnabled) - return true; - const handlers = this._beforeDeleteHandlers[record.typeName]; - if (handlers) { - for (const handler of handlers) { - if (handler(record, source) === false) { - return false; - } - } - } - return true; - } - handleAfterDelete(record, source) { - if (!this._isEnabled) - return; - const handlers = this._afterDeleteHandlers[record.typeName]; - if (handlers) { - for (const handler of handlers) { - handler(record, source); - } - } - } - handleOperationComplete(source) { - if (!this._isEnabled) - return; - for (const handler of this._operationCompleteHandlers) { - handler(source); - } - } - register(handlersByType) { - const disposes = []; - for (const [type, handlers] of Object.entries(handlersByType)) { - if (handlers?.beforeCreate) { - disposes.push(this.registerBeforeCreateHandler(type, handlers.beforeCreate)); - } - if (handlers?.afterCreate) { - disposes.push(this.registerAfterCreateHandler(type, handlers.afterCreate)); - } - if (handlers?.beforeChange) { - disposes.push(this.registerBeforeChangeHandler(type, handlers.beforeChange)); - } - if (handlers?.afterChange) { - disposes.push(this.registerAfterChangeHandler(type, handlers.afterChange)); - } - if (handlers?.beforeDelete) { - disposes.push(this.registerBeforeDeleteHandler(type, handlers.beforeDelete)); - } - if (handlers?.afterDelete) { - disposes.push(this.registerAfterDeleteHandler(type, handlers.afterDelete)); - } - } - return () => { - for (const dispose of disposes) - dispose(); - }; - } - registerBeforeCreateHandler(typeName, handler) { - const handlers = this._beforeCreateHandlers[typeName]; - if (!handlers) - this._beforeCreateHandlers[typeName] = []; - this._beforeCreateHandlers[typeName].push(handler); - return () => remove(this._beforeCreateHandlers[typeName], handler); - } - registerAfterCreateHandler(typeName, handler) { - const handlers = this._afterCreateHandlers[typeName]; - if (!handlers) - this._afterCreateHandlers[typeName] = []; - this._afterCreateHandlers[typeName].push(handler); - return () => remove(this._afterCreateHandlers[typeName], handler); - } - registerBeforeChangeHandler(typeName, handler) { - const handlers = this._beforeChangeHandlers[typeName]; - if (!handlers) - this._beforeChangeHandlers[typeName] = []; - this._beforeChangeHandlers[typeName].push(handler); - return () => remove(this._beforeChangeHandlers[typeName], handler); - } - registerAfterChangeHandler(typeName, handler) { - const handlers = this._afterChangeHandlers[typeName]; - if (!handlers) - this._afterChangeHandlers[typeName] = []; - this._afterChangeHandlers[typeName].push(handler); - return () => remove(this._afterChangeHandlers[typeName], handler); - } - registerBeforeDeleteHandler(typeName, handler) { - const handlers = this._beforeDeleteHandlers[typeName]; - if (!handlers) - this._beforeDeleteHandlers[typeName] = []; - this._beforeDeleteHandlers[typeName].push(handler); - return () => remove(this._beforeDeleteHandlers[typeName], handler); - } - registerAfterDeleteHandler(typeName, handler) { - const handlers = this._afterDeleteHandlers[typeName]; - if (!handlers) - this._afterDeleteHandlers[typeName] = []; - this._afterDeleteHandlers[typeName].push(handler); - return () => remove(this._afterDeleteHandlers[typeName], handler); - } - registerOperationCompleteHandler(handler) { - this._operationCompleteHandlers.push(handler); - return () => remove(this._operationCompleteHandlers, handler); - } -}; -function remove(array2, item) { - const index2 = array2.indexOf(item); - if (index2 >= 0) { - array2.splice(index2, 1); - } -} - -// node_modules/@tldraw/store/dist-esm/lib/devFreeze.mjs -function devFreeze(object2) { - if (true) { - return object2; - } - const proto2 = Object.getPrototypeOf(object2); - if (proto2 && !(Array.isArray(object2) || proto2 === Object.prototype || proto2 === null || proto2 === STRUCTURED_CLONE_OBJECT_PROTOTYPE)) { - console.error("cannot include non-js data in a record", object2); - throw new Error("cannot include non-js data in a record"); - } - const propNames = Object.getOwnPropertyNames(object2); - for (const name of propNames) { - const value = object2[name]; - if (value && typeof value === "object") { - devFreeze(value); - } - } - return Object.freeze(object2); -} - -// node_modules/@tldraw/store/dist-esm/lib/Store.mjs -var Store = class { - constructor(config) { - __publicField(this, "id"); - __publicField(this, "atoms", atom("store_atoms", {})); - __publicField(this, "history", atom("history", 0, { - historyLength: 1e3 - })); - __publicField(this, "query", new StoreQueries(this.atoms, this.history)); - __publicField(this, "listeners", /* @__PURE__ */ new Set()); - __publicField(this, "historyAccumulator", new HistoryAccumulator()); - __publicField(this, "historyReactor"); - __publicField(this, "cancelHistoryReactor", () => { - }); - __publicField(this, "schema"); - __publicField(this, "props"); - __publicField(this, "scopedTypes"); - __publicField(this, "sideEffects", new StoreSideEffects(this)); - __publicField(this, "put", (records, phaseOverride) => { - this.atomic(() => { - const updates = {}; - const additions = {}; - const currentMap = this.atoms.__unsafe__getWithoutCapture(); - let map = null; - let record; - let didChange = false; - const source = this.isMergingRemoteChanges ? "remote" : "user"; - for (let i = 0, n = records.length; i < n; i++) { - record = records[i]; - const recordAtom = (map ?? currentMap)[record.id]; - if (recordAtom) { - const initialValue = recordAtom.__unsafe__getWithoutCapture(); - record = this.sideEffects.handleBeforeChange(initialValue, record, source); - const validated = this.schema.validateRecord(this, record, phaseOverride ?? "updateRecord", initialValue); - if (validated === initialValue) - continue; - recordAtom.set(devFreeze(record)); - didChange = true; - const updated = recordAtom.__unsafe__getWithoutCapture(); - updates[record.id] = [initialValue, updated]; - this.addDiffForAfterEvent(initialValue, updated); - } else { - record = this.sideEffects.handleBeforeCreate(record, source); - didChange = true; - record = this.schema.validateRecord(this, record, phaseOverride ?? "createRecord", null); - additions[record.id] = record; - this.addDiffForAfterEvent(null, record); - if (!map) { - map = { ...currentMap }; - } - map[record.id] = atom("atom:" + record.id, record); - } - } - if (map) { - this.atoms.set(map); - } - if (!didChange) - return; - this.updateHistory({ - added: additions, - updated: updates, - removed: {} - }); - }); - }); - __publicField(this, "remove", (ids) => { - this.atomic(() => { - const cancelled = /* @__PURE__ */ new Set(); - const source = this.isMergingRemoteChanges ? "remote" : "user"; - if (this.sideEffects.isEnabled()) { - for (const id of ids) { - const atom22 = this.atoms.__unsafe__getWithoutCapture()[id]; - if (!atom22) - continue; - if (this.sideEffects.handleBeforeDelete(atom22.get(), source) === false) { - cancelled.add(id); - } - } - } - let removed = void 0; - this.atoms.update((atoms) => { - let result = void 0; - for (const id of ids) { - if (cancelled.has(id)) - continue; - if (!(id in atoms)) - continue; - if (!result) - result = { ...atoms }; - if (!removed) - removed = {}; - delete result[id]; - const record = atoms[id].get(); - removed[id] = record; - this.addDiffForAfterEvent(record, null); - } - return result ?? atoms; - }); - if (!removed) - return; - this.updateHistory({ added: {}, updated: {}, removed }); - }); - }); - __publicField(this, "get", (id) => { - return this.atoms.get()[id]?.get(); - }); - __publicField(this, "unsafeGetWithoutCapture", (id) => { - return this.atoms.get()[id]?.__unsafe__getWithoutCapture(); - }); - __publicField(this, "serialize", (scope = "document") => { - const result = {}; - for (const [id, atom22] of objectMapEntries(this.atoms.get())) { - const record = atom22.get(); - if (scope === "all" || this.scopedTypes[scope].has(record.typeName)) { - result[id] = record; - } - } - return result; - }); - __publicField(this, "allRecords", () => { - return objectMapValues(this.atoms.get()).map((atom22) => atom22.get()); - }); - __publicField(this, "clear", () => { - this.remove(objectMapKeys(this.atoms.get())); - }); - __publicField(this, "update", (id, updater) => { - const atom22 = this.atoms.get()[id]; - if (!atom22) { - console.error(`Record ${id} not found. This is probably an error`); - return; - } - this.put([updater(atom22.__unsafe__getWithoutCapture())]); - }); - __publicField(this, "has", (id) => { - return !!this.atoms.get()[id]; - }); - __publicField(this, "listen", (onHistory, filters) => { - this._flushHistory(); - const listener = { - onHistory, - filters: { - source: filters?.source ?? "all", - scope: filters?.scope ?? "all" - } - }; - this.listeners.add(listener); - if (!this.historyReactor.scheduler.isActivelyListening) { - this.historyReactor.start(); - } - return () => { - this.listeners.delete(listener); - if (this.listeners.size === 0) { - this.historyReactor.stop(); - } - }; - }); - __publicField(this, "isMergingRemoteChanges", false); - __publicField(this, "mergeRemoteChanges", (fn) => { - if (this.isMergingRemoteChanges) { - return fn(); - } - if (this._isInAtomicOp) { - throw new Error("Cannot merge remote changes while in atomic operation"); - } - try { - this.isMergingRemoteChanges = true; - transact(fn); - } finally { - this.isMergingRemoteChanges = false; - } - }); - __publicField(this, "createComputedCache", (name, derive, isEqual2) => { - const cache = new WeakCache(); - return { - get: (id) => { - const atom22 = this.atoms.get()[id]; - if (!atom22) { - return void 0; - } - return cache.get(atom22, () => { - const recordSignal = isEqual2 ? computed(atom22.name + ":equals", () => atom22.get(), { isEqual: isEqual2 }) : atom22; - return computed(name + ":" + id, () => { - return derive(recordSignal.get()); - }); - }).get(); - } - }; - }); - __publicField(this, "createSelectedComputedCache", (name, selector, derive) => { - const cache = new WeakCache(); - return { - get: (id) => { - const atom22 = this.atoms.get()[id]; - if (!atom22) { - return void 0; - } - return cache.get(atom22, () => { - const d = computed(name + ":" + id + ":selector", () => selector(atom22.get())); - return computed(name + ":" + id, () => derive(d.get())); - }).get(); - } - }; - }); - __publicField(this, "_integrityChecker"); - __publicField(this, "_isPossiblyCorrupted", false); - __publicField(this, "pendingAfterEvents", null); - __publicField(this, "_isInAtomicOp", false); - const { initialData, schema, id } = config; - this.id = id ?? nanoid(); - this.schema = schema; - this.props = config.props; - if (initialData) { - this.atoms.set(objectMapFromEntries(objectMapEntries(initialData).map(([id2, record]) => [ - id2, - atom("atom:" + id2, devFreeze(this.schema.validateRecord(this, record, "initialize", null))) - ]))); - } - this.historyReactor = reactor("Store.historyReactor", () => { - this.history.get(); - this._flushHistory(); - }, { scheduleEffect: (cb) => this.cancelHistoryReactor = throttleToNextFrame(cb) }); - this.scopedTypes = { - document: new Set(objectMapValues(this.schema.types).filter((t2) => t2.scope === "document").map((t2) => t2.typeName)), - session: new Set(objectMapValues(this.schema.types).filter((t2) => t2.scope === "session").map((t2) => t2.typeName)), - presence: new Set(objectMapValues(this.schema.types).filter((t2) => t2.scope === "presence").map((t2) => t2.typeName)) - }; - } - _flushHistory() { - if (this.historyAccumulator.hasChanges()) { - const entries = this.historyAccumulator.flush(); - for (const { changes, source } of entries) { - let instanceChanges = null; - let documentChanges = null; - let presenceChanges = null; - for (const { onHistory, filters } of this.listeners) { - if (filters.source !== "all" && filters.source !== source) { - continue; - } - if (filters.scope !== "all") { - if (filters.scope === "document") { - documentChanges ?? (documentChanges = this.filterChangesByScope(changes, "document")); - if (!documentChanges) - continue; - onHistory({ changes: documentChanges, source }); - } else if (filters.scope === "session") { - instanceChanges ?? (instanceChanges = this.filterChangesByScope(changes, "session")); - if (!instanceChanges) - continue; - onHistory({ changes: instanceChanges, source }); - } else { - presenceChanges ?? (presenceChanges = this.filterChangesByScope(changes, "presence")); - if (!presenceChanges) - continue; - onHistory({ changes: presenceChanges, source }); - } - } else { - onHistory({ changes, source }); - } - } - } - } - } - dispose() { - this.cancelHistoryReactor(); - } - filterChangesByScope(change, scope) { - const result = { - added: filterEntries(change.added, (_, r) => this.scopedTypes[scope].has(r.typeName)), - updated: filterEntries(change.updated, (_, r) => this.scopedTypes[scope].has(r[1].typeName)), - removed: filterEntries(change.removed, (_, r) => this.scopedTypes[scope].has(r.typeName)) - }; - if (Object.keys(result.added).length === 0 && Object.keys(result.updated).length === 0 && Object.keys(result.removed).length === 0) { - return null; - } - return result; - } - updateHistory(changes) { - this.historyAccumulator.add({ - changes, - source: this.isMergingRemoteChanges ? "remote" : "user" - }); - if (this.listeners.size === 0) { - this.historyAccumulator.clear(); - } - this.history.set(this.history.get() + 1, changes); - } - validate(phase) { - this.allRecords().forEach((record) => this.schema.validateRecord(this, record, phase, null)); - } - getStoreSnapshot(scope = "document") { - return { - store: this.serialize(scope), - schema: this.schema.serialize() - }; - } - getSnapshot(scope = "document") { - console.warn("[tldraw] `Store.getSnapshot` is deprecated and will be removed in a future release. Use `getSnapshot` from the `tldraw` package instead."); - return this.getStoreSnapshot(scope); - } - migrateSnapshot(snapshot) { - const migrationResult = this.schema.migrateStoreSnapshot(snapshot); - if (migrationResult.type === "error") { - throw new Error(`Failed to migrate snapshot: ${migrationResult.reason}`); - } - return { - store: migrationResult.value, - schema: this.schema.serialize() - }; - } - loadStoreSnapshot(snapshot) { - const migrationResult = this.schema.migrateStoreSnapshot(snapshot); - if (migrationResult.type === "error") { - throw new Error(`Failed to migrate snapshot: ${migrationResult.reason}`); - } - const prevSideEffectsEnabled = this.sideEffects.isEnabled(); - try { - this.sideEffects.setIsEnabled(false); - this.atomic(() => { - this.clear(); - this.put(Object.values(migrationResult.value)); - this.ensureStoreIsUsable(); - }); - } finally { - this.sideEffects.setIsEnabled(prevSideEffectsEnabled); - } - } - loadSnapshot(snapshot) { - console.warn("[tldraw] `Store.loadSnapshot` is deprecated and will be removed in a future release. Use `loadSnapshot` from the 'tldraw' package instead."); - this.loadStoreSnapshot(snapshot); - } - extractingChanges(fn) { - const changes = []; - const dispose = this.historyAccumulator.addInterceptor((entry) => changes.push(entry.changes)); - try { - transact(fn); - return squashRecordDiffs(changes); - } finally { - dispose(); - } - } - applyDiff(diff, { - runCallbacks = true, - ignoreEphemeralKeys = false - } = {}) { - this.atomic(() => { - const toPut = objectMapValues(diff.added); - for (const [_from, to] of objectMapValues(diff.updated)) { - const type = this.schema.getType(to.typeName); - if (ignoreEphemeralKeys && type.ephemeralKeySet.size) { - const existing = this.get(to.id); - if (!existing) { - toPut.push(to); - continue; - } - let changed = null; - for (const [key, value] of Object.entries(to)) { - if (type.ephemeralKeySet.has(key) || Object.is(value, getOwnProperty(existing, key))) { - continue; - } - if (!changed) - changed = { ...existing }; - changed[key] = value; - } - if (changed) - toPut.push(changed); - } else { - toPut.push(to); - } - } - const toRemove = objectMapKeys(diff.removed); - if (toPut.length) { - this.put(toPut); - } - if (toRemove.length) { - this.remove(toRemove); - } - }, runCallbacks); - } - ensureStoreIsUsable() { - this.atomic(() => { - this._integrityChecker ?? (this._integrityChecker = this.schema.createIntegrityChecker(this)); - this._integrityChecker?.(); - }); - } - markAsPossiblyCorrupted() { - this._isPossiblyCorrupted = true; - } - isPossiblyCorrupted() { - return this._isPossiblyCorrupted; - } - addDiffForAfterEvent(before, after) { - assert(this.pendingAfterEvents, "must be in event operation"); - if (before === after) - return; - if (before && after) - assert(before.id === after.id); - if (!before && !after) - return; - const id = (before || after).id; - const existing = this.pendingAfterEvents.get(id); - if (existing) { - existing.after = after; - } else { - this.pendingAfterEvents.set(id, { before, after }); - } - } - flushAtomicCallbacks() { - let updateDepth = 0; - const source = this.isMergingRemoteChanges ? "remote" : "user"; - while (this.pendingAfterEvents) { - const events = this.pendingAfterEvents; - this.pendingAfterEvents = null; - if (!this.sideEffects.isEnabled()) - continue; - updateDepth++; - if (updateDepth > 100) { - throw new Error("Maximum store update depth exceeded, bailing out"); - } - for (const { before, after } of events.values()) { - if (before && after) { - this.sideEffects.handleAfterChange(before, after, source); - } else if (before && !after) { - this.sideEffects.handleAfterDelete(before, source); - } else if (!before && after) { - this.sideEffects.handleAfterCreate(after, source); - } - } - if (!this.pendingAfterEvents) { - this.sideEffects.handleOperationComplete(source); - } - } - } - atomic(fn, runCallbacks = true) { - return transact(() => { - if (this._isInAtomicOp) { - if (!this.pendingAfterEvents) - this.pendingAfterEvents = /* @__PURE__ */ new Map(); - return fn(); - } - this.pendingAfterEvents = /* @__PURE__ */ new Map(); - const prevSideEffectsEnabled = this.sideEffects.isEnabled(); - this.sideEffects.setIsEnabled(runCallbacks ?? prevSideEffectsEnabled); - this._isInAtomicOp = true; - try { - const result = fn(); - this.flushAtomicCallbacks(); - return result; - } finally { - this.pendingAfterEvents = null; - this.sideEffects.setIsEnabled(prevSideEffectsEnabled); - this._isInAtomicOp = false; - } - }); - } - addHistoryInterceptor(fn) { - return this.historyAccumulator.addInterceptor((entry) => fn(entry, this.isMergingRemoteChanges ? "remote" : "user")); - } -}; -function squashHistoryEntries(entries) { - if (entries.length === 0) - return []; - const chunked = []; - let chunk = [entries[0]]; - let entry; - for (let i = 1, n = entries.length; i < n; i++) { - entry = entries[i]; - if (chunk[0].source !== entry.source) { - chunked.push(chunk); - chunk = []; - } - chunk.push(entry); - } - chunked.push(chunk); - return devFreeze(chunked.map((chunk2) => ({ - source: chunk2[0].source, - changes: squashRecordDiffs(chunk2.map((e) => e.changes)) - }))); -} -var HistoryAccumulator = class { - constructor() { - __publicField(this, "_history", []); - __publicField(this, "_interceptors", /* @__PURE__ */ new Set()); - } - addInterceptor(fn) { - this._interceptors.add(fn); - return () => { - this._interceptors.delete(fn); - }; - } - add(entry) { - this._history.push(entry); - for (const interceptor of this._interceptors) { - interceptor(entry); - } - } - flush() { - const history = squashHistoryEntries(this._history); - this._history = []; - return history; - } - clear() { - this._history = []; - } - hasChanges() { - return this._history.length > 0; - } -}; -function createComputedCache(name, derive, isEqual2) { - const cache = new WeakCache(); - return { - get(context, id) { - const computedCache = cache.get(context, () => { - const store = context instanceof Store ? context : context.store; - return store.createComputedCache(name, (record) => derive(context, record), isEqual2); - }); - return computedCache.get(id); - } - }; -} - -// node_modules/@tldraw/store/dist-esm/lib/migrate.mjs -function squashDependsOn(sequence) { - const result = []; - for (let i = sequence.length - 1; i >= 0; i--) { - const elem = sequence[i]; - if (!("id" in elem)) { - const dependsOn = elem.dependsOn; - const prev = result[0]; - if (prev) { - result[0] = { - ...prev, - dependsOn: dependsOn.concat(prev.dependsOn ?? []) - }; - } - } else { - result.unshift(elem); - } - } - return result; -} -function createMigrationSequence({ - sequence, - sequenceId, - retroactive = true -}) { - const migrations = { - sequenceId, - retroactive, - sequence: squashDependsOn(sequence) - }; - validateMigrations(migrations); - return migrations; -} -function createMigrationIds(sequenceId, versions) { - return Object.fromEntries(objectMapEntries(versions).map(([key, version2]) => [key, `${sequenceId}/${version2}`])); -} -function createRecordMigrationSequence(opts) { - const sequenceId = opts.sequenceId; - return createMigrationSequence({ - sequenceId, - retroactive: opts.retroactive ?? true, - sequence: opts.sequence.map((m) => "id" in m ? { - ...m, - scope: "record", - filter: (r) => r.typeName === opts.recordType && (m.filter?.(r) ?? true) && (opts.filter?.(r) ?? true) - } : m) - }); -} -function sortMigrations(migrations) { - const byId = new Map(migrations.map((m) => [m.id, m])); - const isProcessing = /* @__PURE__ */ new Set(); - const result = []; - function process2(m) { - assert(!isProcessing.has(m.id), `Circular dependency in migrations: ${m.id}`); - isProcessing.add(m.id); - const { version: version2, sequenceId } = parseMigrationId(m.id); - const parent = byId.get(`${sequenceId}/${version2 - 1}`); - if (parent) { - process2(parent); - } - if (m.dependsOn) { - for (const dep of m.dependsOn) { - const depMigration = byId.get(dep); - if (depMigration) { - process2(depMigration); - } - } - } - byId.delete(m.id); - result.push(m); - } - for (const m of byId.values()) { - process2(m); - } - return result; -} -function parseMigrationId(id) { - const [sequenceId, version2] = id.split("/"); - return { sequenceId, version: parseInt(version2) }; -} -function validateMigrationId(id, expectedSequenceId) { - if (expectedSequenceId) { - assert(id.startsWith(expectedSequenceId + "/"), `Every migration in sequence '${expectedSequenceId}' must have an id starting with '${expectedSequenceId}/'. Got invalid id: '${id}'`); - } - assert(id.match(/^(.*?)\/(0|[1-9]\d*)$/), `Invalid migration id: '${id}'`); -} -function validateMigrations(migrations) { - assert(!migrations.sequenceId.includes("/"), `sequenceId cannot contain a '/', got ${migrations.sequenceId}`); - assert(migrations.sequenceId.length, "sequenceId must be a non-empty string"); - if (migrations.sequence.length === 0) { - return; - } - validateMigrationId(migrations.sequence[0].id, migrations.sequenceId); - let n = parseMigrationId(migrations.sequence[0].id).version; - assert(n === 1, `Expected the first migrationId to be '${migrations.sequenceId}/1' but got '${migrations.sequence[0].id}'`); - for (let i = 1; i < migrations.sequence.length; i++) { - const id = migrations.sequence[i].id; - validateMigrationId(id, migrations.sequenceId); - const m = parseMigrationId(id).version; - assert(m === n + 1, `Migration id numbers must increase in increments of 1, expected ${migrations.sequenceId}/${n + 1} but got '${migrations.sequence[i].id}'`); - n = m; - } -} -var MigrationFailureReason = /* @__PURE__ */ ((MigrationFailureReason2) => { - MigrationFailureReason2["IncompatibleSubtype"] = "incompatible-subtype"; - MigrationFailureReason2["UnknownType"] = "unknown-type"; - MigrationFailureReason2["TargetVersionTooNew"] = "target-version-too-new"; - MigrationFailureReason2["TargetVersionTooOld"] = "target-version-too-old"; - MigrationFailureReason2["MigrationError"] = "migration-error"; - MigrationFailureReason2["UnrecognizedSubtype"] = "unrecognized-subtype"; - return MigrationFailureReason2; -})(MigrationFailureReason || {}); - -// node_modules/@tldraw/store/dist-esm/lib/StoreSchema.mjs -function upgradeSchema(schema) { - if (schema.schemaVersion > 2 || schema.schemaVersion < 1) - return Result.err("Bad schema version"); - if (schema.schemaVersion === 2) - return Result.ok(schema); - const result = { - schemaVersion: 2, - sequences: {} - }; - for (const [typeName, recordVersion] of Object.entries(schema.recordVersions)) { - result.sequences[`com.tldraw.${typeName}`] = recordVersion.version; - if ("subTypeKey" in recordVersion) { - for (const [subType, version2] of Object.entries(recordVersion.subTypeVersions)) { - result.sequences[`com.tldraw.${typeName}.${subType}`] = version2; - } - } - } - return Result.ok(result); -} -var StoreSchema = class { - constructor(types, options) { - __publicField(this, "migrations", {}); - __publicField(this, "sortedMigrations"); - this.types = types; - this.options = options; - for (const m of options.migrations ?? []) { - assert(!this.migrations[m.sequenceId], `Duplicate migration sequenceId ${m.sequenceId}`); - validateMigrations(m); - this.migrations[m.sequenceId] = m; - } - const allMigrations = Object.values(this.migrations).flatMap((m) => m.sequence); - this.sortedMigrations = sortMigrations(allMigrations); - for (const migration of this.sortedMigrations) { - if (!migration.dependsOn?.length) - continue; - for (const dep of migration.dependsOn) { - const depMigration = allMigrations.find((m) => m.id === dep); - assert(depMigration, `Migration '${migration.id}' depends on missing migration '${dep}'`); - } - } - } - static create(types, options) { - return new StoreSchema(types, options ?? {}); - } - validateRecord(store, record, phase, recordBefore) { - try { - const recordType = getOwnProperty(this.types, record.typeName); - if (!recordType) { - throw new Error(`Missing definition for record type ${record.typeName}`); - } - return recordType.validate(record, recordBefore ?? void 0); - } catch (error3) { - if (this.options.onValidationFailure) { - return this.options.onValidationFailure({ - store, - record, - phase, - recordBefore, - error: error3 - }); - } else { - throw error3; - } - } - } - getMigrationsSince(persistedSchema) { - const upgradeResult = upgradeSchema(persistedSchema); - if (!upgradeResult.ok) { - return upgradeResult; - } - const schema = upgradeResult.value; - const sequenceIdsToInclude = new Set(Object.keys(schema.sequences).filter((sequenceId) => this.migrations[sequenceId])); - for (const sequenceId in this.migrations) { - if (schema.sequences[sequenceId] === void 0 && this.migrations[sequenceId].retroactive) { - sequenceIdsToInclude.add(sequenceId); - } - } - if (sequenceIdsToInclude.size === 0) { - return Result.ok([]); - } - const allMigrationsToInclude = /* @__PURE__ */ new Set(); - for (const sequenceId of sequenceIdsToInclude) { - const theirVersion = schema.sequences[sequenceId]; - if (typeof theirVersion !== "number" && this.migrations[sequenceId].retroactive || theirVersion === 0) { - for (const migration of this.migrations[sequenceId].sequence) { - allMigrationsToInclude.add(migration.id); - } - continue; - } - const theirVersionId = `${sequenceId}/${theirVersion}`; - const idx = this.migrations[sequenceId].sequence.findIndex((m) => m.id === theirVersionId); - if (idx === -1) { - return Result.err("Incompatible schema?"); - } - for (const migration of this.migrations[sequenceId].sequence.slice(idx + 1)) { - allMigrationsToInclude.add(migration.id); - } - } - return Result.ok(this.sortedMigrations.filter(({ id }) => allMigrationsToInclude.has(id))); - } - migratePersistedRecord(record, persistedSchema, direction = "up") { - const migrations = this.getMigrationsSince(persistedSchema); - if (!migrations.ok) { - console.error("Error migrating record", migrations.error); - return { type: "error", reason: MigrationFailureReason.MigrationError }; - } - let migrationsToApply = migrations.value; - if (migrationsToApply.length === 0) { - return { type: "success", value: record }; - } - if (migrationsToApply.some((m) => m.scope === "store")) { - return { - type: "error", - reason: direction === "down" ? MigrationFailureReason.TargetVersionTooOld : MigrationFailureReason.TargetVersionTooNew - }; - } - if (direction === "down") { - if (!migrationsToApply.every((m) => m.down)) { - return { - type: "error", - reason: MigrationFailureReason.TargetVersionTooOld - }; - } - migrationsToApply = migrationsToApply.slice().reverse(); - } - record = structuredClone(record); - try { - for (const migration of migrationsToApply) { - if (migration.scope === "store") - throw new Error(); - const shouldApply = migration.filter ? migration.filter(record) : true; - if (!shouldApply) - continue; - const result = migration[direction](record); - if (result) { - record = structuredClone(result); - } - } - } catch (e) { - console.error("Error migrating record", e); - return { type: "error", reason: MigrationFailureReason.MigrationError }; - } - return { type: "success", value: record }; - } - migrateStoreSnapshot(snapshot) { - let { store } = snapshot; - const migrations = this.getMigrationsSince(snapshot.schema); - if (!migrations.ok) { - console.error("Error migrating store", migrations.error); - return { type: "error", reason: MigrationFailureReason.MigrationError }; - } - const migrationsToApply = migrations.value; - if (migrationsToApply.length === 0) { - return { type: "success", value: store }; - } - store = structuredClone(store); - try { - for (const migration of migrationsToApply) { - if (migration.scope === "record") { - for (const [id, record] of Object.entries(store)) { - const shouldApply = migration.filter ? migration.filter(record) : true; - if (!shouldApply) - continue; - const result = migration.up(record); - if (result) { - store[id] = structuredClone(result); - } - } - } else if (migration.scope === "store") { - const result = migration.up(store); - if (result) { - store = structuredClone(result); - } - } else { - exhaustiveSwitchError(migration); - } - } - } catch (e) { - console.error("Error migrating store", e); - return { type: "error", reason: MigrationFailureReason.MigrationError }; - } - return { type: "success", value: store }; - } - createIntegrityChecker(store) { - return this.options.createIntegrityChecker?.(store) ?? void 0; - } - serialize() { - return { - schemaVersion: 2, - sequences: Object.fromEntries(Object.values(this.migrations).map(({ sequenceId, sequence }) => [ - sequenceId, - sequence.length ? parseMigrationId(sequence.at(-1).id).version : 0 - ])) - }; - } - serializeEarliestVersion() { - return { - schemaVersion: 2, - sequences: Object.fromEntries(Object.values(this.migrations).map(({ sequenceId }) => [sequenceId, 0])) - }; - } - getType(typeName) { - const type = getOwnProperty(this.types, typeName); - assert(type, "record type does not exists"); - return type; - } -}; - -// node_modules/@tldraw/validate/dist-esm/lib/validation.mjs -var validation_exports = {}; -__export(validation_exports, { - ArrayOfValidator: () => ArrayOfValidator, - DictValidator: () => DictValidator, - ObjectValidator: () => ObjectValidator, - UnionValidator: () => UnionValidator, - ValidationError: () => ValidationError, - Validator: () => Validator, - any: () => any, - array: () => array, - arrayOf: () => arrayOf, - bigint: () => bigint, - boolean: () => boolean, - dict: () => dict, - httpUrl: () => httpUrl, - indexKey: () => indexKey, - integer: () => integer, - jsonDict: () => jsonDict, - jsonValue: () => jsonValue, - linkUrl: () => linkUrl, - literal: () => literal, - literalEnum: () => literalEnum, - model: () => model, - nonZeroInteger: () => nonZeroInteger, - nonZeroNumber: () => nonZeroNumber, - nullable: () => nullable, - number: () => number, - numberUnion: () => numberUnion, - object: () => object, - optional: () => optional, - positiveInteger: () => positiveInteger, - positiveNumber: () => positiveNumber, - setEnum: () => setEnum, - srcUrl: () => srcUrl, - string: () => string, - union: () => union, - unknown: () => unknown, - unknownObject: () => unknownObject -}); -function formatPath(path) { - if (!path.length) { - return null; - } - let formattedPath = ""; - for (const item of path) { - if (typeof item === "number") { - formattedPath += `.${item}`; - } else if (item.startsWith("(")) { - if (formattedPath.endsWith(")")) { - formattedPath = `${formattedPath.slice(0, -1)}, ${item.slice(1)}`; - } else { - formattedPath += item; - } - } else { - formattedPath += `.${item}`; - } - } - formattedPath = formattedPath.replace(/id = [^,]+, /, "").replace(/id = [^)]+/, ""); - if (formattedPath.startsWith(".")) { - return formattedPath.slice(1); - } - return formattedPath; -} -var ValidationError = class extends Error { - constructor(rawMessage, path = []) { - const formattedPath = formatPath(path); - const indentedMessage = rawMessage.split("\n").map((line, i) => i === 0 ? line : ` ${line}`).join("\n"); - super(path ? `At ${formattedPath}: ${indentedMessage}` : indentedMessage); - __publicField(this, "name", "ValidationError"); - this.rawMessage = rawMessage; - this.path = path; - } -}; -function prefixError(path, fn) { - try { - return fn(); - } catch (err) { - if (err instanceof ValidationError) { - throw new ValidationError(err.rawMessage, [path, ...err.path]); - } - throw new ValidationError(err.toString(), [path]); - } -} -function typeToString(value) { - if (value === null) - return "null"; - if (Array.isArray(value)) - return "an array"; - const type = typeof value; - switch (type) { - case "bigint": - case "boolean": - case "function": - case "number": - case "string": - case "symbol": - return `a ${type}`; - case "object": - return `an ${type}`; - case "undefined": - return "undefined"; - default: - exhaustiveSwitchError(type); - } -} -var Validator = class { - constructor(validationFn, validateUsingKnownGoodVersionFn) { - this.validationFn = validationFn; - this.validateUsingKnownGoodVersionFn = validateUsingKnownGoodVersionFn; - } - validate(value) { - const validated = this.validationFn(value); - if (false) { - throw new ValidationError("Validator functions must return the same value they were passed"); - } - return validated; - } - validateUsingKnownGoodVersion(knownGoodValue, newValue) { - if (Object.is(knownGoodValue, newValue)) { - return knownGoodValue; - } - if (this.validateUsingKnownGoodVersionFn) { - return this.validateUsingKnownGoodVersionFn(knownGoodValue, newValue); - } - return this.validate(newValue); - } - isValid(value) { - try { - this.validate(value); - return true; - } catch { - return false; - } - } - nullable() { - return nullable(this); - } - optional() { - return optional(this); - } - refine(otherValidationFn) { - return new Validator((value) => { - return otherValidationFn(this.validate(value)); - }, (knownGoodValue, newValue) => { - const validated = this.validateUsingKnownGoodVersion(knownGoodValue, newValue); - if (Object.is(knownGoodValue, validated)) { - return knownGoodValue; - } - return otherValidationFn(validated); - }); - } - check(nameOrCheckFn, checkFn) { - if (typeof nameOrCheckFn === "string") { - return this.refine((value) => { - prefixError(`(check ${nameOrCheckFn})`, () => checkFn(value)); - return value; - }); - } else { - return this.refine((value) => { - nameOrCheckFn(value); - return value; - }); - } - } -}; -var ArrayOfValidator = class extends Validator { - constructor(itemValidator) { - super((value) => { - const arr = array.validate(value); - for (let i = 0; i < arr.length; i++) { - prefixError(i, () => itemValidator.validate(arr[i])); - } - return arr; - }, (knownGoodValue, newValue) => { - if (!itemValidator.validateUsingKnownGoodVersion) - return this.validate(newValue); - const arr = array.validate(newValue); - let isDifferent = knownGoodValue.length !== arr.length; - for (let i = 0; i < arr.length; i++) { - const item = arr[i]; - if (i >= knownGoodValue.length) { - isDifferent = true; - prefixError(i, () => itemValidator.validate(item)); - continue; - } - if (Object.is(knownGoodValue[i], item)) { - continue; - } - const checkedItem = prefixError(i, () => itemValidator.validateUsingKnownGoodVersion(knownGoodValue[i], item)); - if (!Object.is(checkedItem, knownGoodValue[i])) { - isDifferent = true; - } - } - return isDifferent ? newValue : knownGoodValue; - }); - this.itemValidator = itemValidator; - } - nonEmpty() { - return this.check((value) => { - if (value.length === 0) { - throw new ValidationError("Expected a non-empty array"); - } - }); - } - lengthGreaterThan1() { - return this.check((value) => { - if (value.length <= 1) { - throw new ValidationError("Expected an array with length greater than 1"); - } - }); - } -}; -var ObjectValidator = class extends Validator { - constructor(config, shouldAllowUnknownProperties = false) { - super((object2) => { - if (typeof object2 !== "object" || object2 === null) { - throw new ValidationError(`Expected object, got ${typeToString(object2)}`); - } - for (const [key, validator] of Object.entries(config)) { - prefixError(key, () => { - ; - validator.validate(getOwnProperty(object2, key)); - }); - } - if (!shouldAllowUnknownProperties) { - for (const key of Object.keys(object2)) { - if (!hasOwnProperty(config, key)) { - throw new ValidationError(`Unexpected property`, [key]); - } - } - } - return object2; - }, (knownGoodValue, newValue) => { - if (typeof newValue !== "object" || newValue === null) { - throw new ValidationError(`Expected object, got ${typeToString(newValue)}`); - } - let isDifferent = false; - for (const [key, validator] of Object.entries(config)) { - const prev = getOwnProperty(knownGoodValue, key); - const next = getOwnProperty(newValue, key); - if (Object.is(prev, next)) { - continue; - } - const checked = prefixError(key, () => { - const validatable = validator; - if (validatable.validateUsingKnownGoodVersion) { - return validatable.validateUsingKnownGoodVersion(prev, next); - } else { - return validatable.validate(next); - } - }); - if (!Object.is(checked, prev)) { - isDifferent = true; - } - } - if (!shouldAllowUnknownProperties) { - for (const key of Object.keys(newValue)) { - if (!hasOwnProperty(config, key)) { - throw new ValidationError(`Unexpected property`, [key]); - } - } - } - for (const key of Object.keys(knownGoodValue)) { - if (!hasOwnProperty(newValue, key)) { - isDifferent = true; - break; - } - } - return isDifferent ? newValue : knownGoodValue; - }); - this.config = config; - this.shouldAllowUnknownProperties = shouldAllowUnknownProperties; - } - allowUnknownProperties() { - return new ObjectValidator(this.config, true); - } - extend(extension) { - return new ObjectValidator({ ...this.config, ...extension }); - } -}; -var UnionValidator = class extends Validator { - constructor(key, config, unknownValueValidation, useNumberKeys) { - super((input) => { - this.expectObject(input); - const { matchingSchema, variant } = this.getMatchingSchemaAndVariant(input); - if (matchingSchema === void 0) { - return this.unknownValueValidation(input, variant); - } - return prefixError(`(${key} = ${variant})`, () => matchingSchema.validate(input)); - }, (prevValue, newValue) => { - this.expectObject(newValue); - this.expectObject(prevValue); - const { matchingSchema, variant } = this.getMatchingSchemaAndVariant(newValue); - if (matchingSchema === void 0) { - return this.unknownValueValidation(newValue, variant); - } - if (getOwnProperty(prevValue, key) !== getOwnProperty(newValue, key)) { - return prefixError(`(${key} = ${variant})`, () => matchingSchema.validate(newValue)); - } - return prefixError(`(${key} = ${variant})`, () => { - if (matchingSchema.validateUsingKnownGoodVersion) { - return matchingSchema.validateUsingKnownGoodVersion(prevValue, newValue); - } else { - return matchingSchema.validate(newValue); - } - }); - }); - this.key = key; - this.config = config; - this.unknownValueValidation = unknownValueValidation; - this.useNumberKeys = useNumberKeys; - } - expectObject(value) { - if (typeof value !== "object" || value === null) { - throw new ValidationError(`Expected an object, got ${typeToString(value)}`, []); - } - } - getMatchingSchemaAndVariant(object2) { - const variant = getOwnProperty(object2, this.key); - if (!this.useNumberKeys && typeof variant !== "string") { - throw new ValidationError(`Expected a string for key "${this.key}", got ${typeToString(variant)}`); - } else if (this.useNumberKeys && !Number.isFinite(Number(variant))) { - throw new ValidationError(`Expected a number for key "${this.key}", got "${variant}"`); - } - const matchingSchema = hasOwnProperty(this.config, variant) ? this.config[variant] : void 0; - return { matchingSchema, variant }; - } - validateUnknownVariants(unknownValueValidation) { - return new UnionValidator(this.key, this.config, unknownValueValidation, this.useNumberKeys); - } -}; -var DictValidator = class extends Validator { - constructor(keyValidator, valueValidator) { - super((object2) => { - if (typeof object2 !== "object" || object2 === null) { - throw new ValidationError(`Expected object, got ${typeToString(object2)}`); - } - for (const [key, value] of Object.entries(object2)) { - prefixError(key, () => { - keyValidator.validate(key); - valueValidator.validate(value); - }); - } - return object2; - }, (knownGoodValue, newValue) => { - if (typeof newValue !== "object" || newValue === null) { - throw new ValidationError(`Expected object, got ${typeToString(newValue)}`); - } - let isDifferent = false; - for (const [key, value] of Object.entries(newValue)) { - if (!hasOwnProperty(knownGoodValue, key)) { - isDifferent = true; - prefixError(key, () => { - keyValidator.validate(key); - valueValidator.validate(value); - }); - continue; - } - const prev = getOwnProperty(knownGoodValue, key); - const next = value; - if (Object.is(prev, next)) { - continue; - } - const checked = prefixError(key, () => { - if (valueValidator.validateUsingKnownGoodVersion) { - return valueValidator.validateUsingKnownGoodVersion(prev, next); - } else { - return valueValidator.validate(next); - } - }); - if (!Object.is(checked, prev)) { - isDifferent = true; - } - } - for (const key of Object.keys(knownGoodValue)) { - if (!hasOwnProperty(newValue, key)) { - isDifferent = true; - break; - } - } - return isDifferent ? newValue : knownGoodValue; - }); - this.keyValidator = keyValidator; - this.valueValidator = valueValidator; - } -}; -function typeofValidator(type) { - return new Validator((value) => { - if (typeof value !== type) { - throw new ValidationError(`Expected ${type}, got ${typeToString(value)}`); - } - return value; - }); -} -var unknown = new Validator((value) => value); -var any = new Validator((value) => value); -var string = typeofValidator("string"); -var number = typeofValidator("number").check((number2) => { - if (Number.isNaN(number2)) { - throw new ValidationError("Expected a number, got NaN"); - } - if (!Number.isFinite(number2)) { - throw new ValidationError(`Expected a finite number, got ${number2}`); - } -}); -var positiveNumber = number.check((value) => { - if (value < 0) - throw new ValidationError(`Expected a positive number, got ${value}`); -}); -var nonZeroNumber = number.check((value) => { - if (value <= 0) - throw new ValidationError(`Expected a non-zero positive number, got ${value}`); -}); -var integer = number.check((value) => { - if (!Number.isInteger(value)) - throw new ValidationError(`Expected an integer, got ${value}`); -}); -var positiveInteger = integer.check((value) => { - if (value < 0) - throw new ValidationError(`Expected a positive integer, got ${value}`); -}); -var nonZeroInteger = integer.check((value) => { - if (value <= 0) - throw new ValidationError(`Expected a non-zero positive integer, got ${value}`); -}); -var boolean = typeofValidator("boolean"); -var bigint = typeofValidator("bigint"); -function literal(expectedValue) { - return new Validator((actualValue) => { - if (actualValue !== expectedValue) { - throw new ValidationError(`Expected ${expectedValue}, got ${JSON.stringify(actualValue)}`); - } - return expectedValue; - }); -} -var array = new Validator((value) => { - if (!Array.isArray(value)) { - throw new ValidationError(`Expected an array, got ${typeToString(value)}`); - } - return value; -}); -function arrayOf(itemValidator) { - return new ArrayOfValidator(itemValidator); -} -var unknownObject = new Validator((value) => { - if (typeof value !== "object" || value === null) { - throw new ValidationError(`Expected object, got ${typeToString(value)}`); - } - return value; -}); -function object(config) { - return new ObjectValidator(config); -} -function isPlainObject(value) { - return typeof value === "object" && value !== null && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null || Object.getPrototypeOf(value) === STRUCTURED_CLONE_OBJECT_PROTOTYPE); -} -function isValidJson(value) { - if (value === null || typeof value === "number" || typeof value === "string" || typeof value === "boolean") { - return true; - } - if (Array.isArray(value)) { - return value.every(isValidJson); - } - if (isPlainObject(value)) { - return Object.values(value).every(isValidJson); - } - return false; -} -var jsonValue = new Validator((value) => { - if (isValidJson(value)) { - return value; - } - throw new ValidationError(`Expected json serializable value, got ${typeof value}`); -}, (knownGoodValue, newValue) => { - if (Array.isArray(knownGoodValue) && Array.isArray(newValue)) { - let isDifferent = knownGoodValue.length !== newValue.length; - for (let i = 0; i < newValue.length; i++) { - if (i >= knownGoodValue.length) { - isDifferent = true; - jsonValue.validate(newValue[i]); - continue; - } - const prev = knownGoodValue[i]; - const next = newValue[i]; - if (Object.is(prev, next)) { - continue; - } - const checked = jsonValue.validateUsingKnownGoodVersion(prev, next); - if (!Object.is(checked, prev)) { - isDifferent = true; - } - } - return isDifferent ? newValue : knownGoodValue; - } else if (isPlainObject(knownGoodValue) && isPlainObject(newValue)) { - let isDifferent = false; - for (const key of Object.keys(newValue)) { - if (!hasOwnProperty(knownGoodValue, key)) { - isDifferent = true; - jsonValue.validate(newValue[key]); - continue; - } - const prev = knownGoodValue[key]; - const next = newValue[key]; - if (Object.is(prev, next)) { - continue; - } - const checked = jsonValue.validateUsingKnownGoodVersion(prev, next); - if (!Object.is(checked, prev)) { - isDifferent = true; - } - } - for (const key of Object.keys(knownGoodValue)) { - if (!hasOwnProperty(newValue, key)) { - isDifferent = true; - break; - } - } - return isDifferent ? newValue : knownGoodValue; - } else { - return jsonValue.validate(newValue); - } -}); -function jsonDict() { - return dict(string, jsonValue); -} -function dict(keyValidator, valueValidator) { - return new DictValidator(keyValidator, valueValidator); -} -function union(key, config) { - return new UnionValidator(key, config, (unknownValue, unknownVariant) => { - throw new ValidationError(`Expected one of ${Object.keys(config).map((key2) => JSON.stringify(key2)).join(" or ")}, got ${JSON.stringify(unknownVariant)}`, [key]); - }, false); -} -function numberUnion(key, config) { - return new UnionValidator(key, config, (unknownValue, unknownVariant) => { - throw new ValidationError(`Expected one of ${Object.keys(config).map((key2) => JSON.stringify(key2)).join(" or ")}, got ${JSON.stringify(unknownVariant)}`, [key]); - }, true); -} -function model(name, validator) { - return new Validator((value) => { - return prefixError(name, () => validator.validate(value)); - }, (prevValue, newValue) => { - return prefixError(name, () => { - if (validator.validateUsingKnownGoodVersion) { - return validator.validateUsingKnownGoodVersion(prevValue, newValue); - } else { - return validator.validate(newValue); - } - }); - }); -} -function setEnum(values) { - return new Validator((value) => { - if (!values.has(value)) { - const valuesString = Array.from(values, (value2) => JSON.stringify(value2)).join(" or "); - throw new ValidationError(`Expected ${valuesString}, got ${value}`); - } - return value; - }); -} -function optional(validator) { - return new Validator((value) => { - if (value === void 0) - return void 0; - return validator.validate(value); - }, (knownGoodValue, newValue) => { - if (knownGoodValue === void 0 && newValue === void 0) - return void 0; - if (newValue === void 0) - return void 0; - if (validator.validateUsingKnownGoodVersion && knownGoodValue !== void 0) { - return validator.validateUsingKnownGoodVersion(knownGoodValue, newValue); - } - return validator.validate(newValue); - }); -} -function nullable(validator) { - return new Validator((value) => { - if (value === null) - return null; - return validator.validate(value); - }, (knownGoodValue, newValue) => { - if (newValue === null) - return null; - if (validator.validateUsingKnownGoodVersion && knownGoodValue !== null) { - return validator.validateUsingKnownGoodVersion(knownGoodValue, newValue); - } - return validator.validate(newValue); - }); -} -function literalEnum(...values) { - return setEnum(new Set(values)); -} -function parseUrl(str) { - try { - return new URL(str); - } catch (error3) { - if (str.startsWith("/") || str.startsWith("./")) { - try { - return new URL(str, "http://example.com"); - } catch (error22) { - throw new ValidationError(`Expected a valid url, got ${JSON.stringify(str)}`); - } - } - throw new ValidationError(`Expected a valid url, got ${JSON.stringify(str)}`); - } -} -var validLinkProtocols = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]); -var linkUrl = string.check((value) => { - if (value === "") - return; - const url = parseUrl(value); - if (!validLinkProtocols.has(url.protocol.toLowerCase())) { - throw new ValidationError(`Expected a valid url, got ${JSON.stringify(value)} (invalid protocol)`); - } -}); -var validSrcProtocols = /* @__PURE__ */ new Set(["http:", "https:", "data:", "asset:"]); -var srcUrl = string.check((value) => { - if (value === "") - return; - const url = parseUrl(value); - if (!validSrcProtocols.has(url.protocol.toLowerCase())) { - throw new ValidationError(`Expected a valid url, got ${JSON.stringify(value)} (invalid protocol)`); - } -}); -var httpUrl = string.check((value) => { - if (value === "") - return; - const url = parseUrl(value); - if (!url.protocol.toLowerCase().match(/^https?:$/)) { - throw new ValidationError(`Expected a valid url, got ${JSON.stringify(value)} (invalid protocol)`); - } -}); -var indexKey = string.refine((key) => { - try { - validateIndexKey(key); - return key; - } catch { - throw new ValidationError(`Expected an index key, got ${JSON.stringify(key)}`); - } -}); - -// node_modules/@tldraw/tlschema/dist-esm/misc/id-validator.mjs -function idValidator(prefix) { - return validation_exports.string.refine((id) => { - if (!id.startsWith(`${prefix}:`)) { - throw new Error(`${prefix} ID must start with "${prefix}:"`); - } - return id; - }); -} - -// node_modules/@tldraw/tlschema/dist-esm/assets/TLBaseAsset.mjs -var assetIdValidator = idValidator("asset"); -function createAssetValidator(type, props) { - return validation_exports.object({ - id: assetIdValidator, - typeName: validation_exports.literal("asset"), - type: validation_exports.literal(type), - props, - meta: validation_exports.jsonValue - }); -} - -// node_modules/@tldraw/tlschema/dist-esm/misc/geometry-types.mjs -var vecModelValidator = validation_exports.object({ - x: validation_exports.number, - y: validation_exports.number, - z: validation_exports.number.optional() -}); -var boxModelValidator = validation_exports.object({ - x: validation_exports.number, - y: validation_exports.number, - w: validation_exports.number, - h: validation_exports.number -}); - -// node_modules/@tldraw/tlschema/node_modules/nanoid/index.browser.js -var nanoid2 = (size4 = 21) => crypto.getRandomValues(new Uint8Array(size4)).reduce((id, byte) => { - byte &= 63; - if (byte < 36) { - id += byte.toString(36); - } else if (byte < 62) { - id += (byte - 26).toString(36).toUpperCase(); - } else if (byte > 62) { - id += "-"; - } else { - id += "_"; - } - return id; -}, ""); - -// node_modules/@tldraw/tlschema/dist-esm/misc/TLOpacity.mjs -var opacityValidator = validation_exports.number.check((n) => { - if (n < 0 || n > 1) { - throw new validation_exports.ValidationError("Opacity must be between 0 and 1"); - } -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLBaseShape.mjs -var parentIdValidator = validation_exports.string.refine((id) => { - if (!id.startsWith("page:") && !id.startsWith("shape:")) { - throw new Error('Parent ID must start with "page:" or "shape:"'); - } - return id; -}); -var shapeIdValidator = idValidator("shape"); -function createShapeValidator(type, props, meta) { - return validation_exports.object({ - id: shapeIdValidator, - typeName: validation_exports.literal("shape"), - x: validation_exports.number, - y: validation_exports.number, - rotation: validation_exports.number, - index: validation_exports.indexKey, - parentId: parentIdValidator, - type: validation_exports.literal(type), - isLocked: validation_exports.boolean, - opacity: opacityValidator, - props: props ? validation_exports.object(props) : validation_exports.jsonValue, - meta: meta ? validation_exports.object(meta) : validation_exports.jsonValue - }); -} - -// node_modules/@tldraw/tlschema/dist-esm/bindings/TLBaseBinding.mjs -var bindingIdValidator = idValidator("binding"); -function createBindingValidator(type, props, meta) { - return validation_exports.object({ - id: bindingIdValidator, - typeName: validation_exports.literal("binding"), - type: validation_exports.literal(type), - fromId: shapeIdValidator, - toId: shapeIdValidator, - props: props ? validation_exports.object(props) : validation_exports.jsonValue, - meta: meta ? validation_exports.object(meta) : validation_exports.jsonValue - }); -} - -// node_modules/@tldraw/tlschema/dist-esm/records/TLBinding.mjs -var rootBindingVersions = createMigrationIds("com.tldraw.binding", {}); -var rootBindingMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.binding", - recordType: "binding", - sequence: [] -}); -function createBindingId(id) { - return `binding:${id ?? nanoid2()}`; -} -function createBindingPropsMigrationSequence(migrations) { - return migrations; -} -function createBindingRecordType(bindings) { - return createRecordType("binding", { - scope: "document", - validator: validation_exports.model("binding", validation_exports.union("type", mapObjectMapValues(bindings, (type, { props, meta }) => createBindingValidator(type, props, meta)))) - }).withDefaultProperties(() => ({ - meta: {} - })); -} - -// node_modules/@tldraw/tlschema/dist-esm/styles/StyleProp.mjs -var StyleProp = class { - constructor(id, defaultValue, type) { - this.id = id; - this.defaultValue = defaultValue; - this.type = type; - } - static define(uniqueId2, options) { - const { defaultValue, type = validation_exports.any } = options; - return new StyleProp(uniqueId2, defaultValue, type); - } - static defineEnum(uniqueId2, options) { - const { defaultValue, values } = options; - return new EnumStyleProp(uniqueId2, defaultValue, values); - } - setDefaultValue(value) { - this.defaultValue = value; - } - validate(value) { - return this.type.validate(value); - } - validateUsingKnownGoodVersion(prevValue, newValue) { - if (this.type.validateUsingKnownGoodVersion) { - return this.type.validateUsingKnownGoodVersion(prevValue, newValue); - } else { - return this.validate(newValue); - } - } -}; -var EnumStyleProp = class extends StyleProp { - constructor(id, defaultValue, values) { - super(id, defaultValue, validation_exports.literalEnum(...values)); - this.values = values; - } -}; - -// node_modules/@tldraw/tlschema/dist-esm/records/TLShape.mjs -var rootShapeVersions = createMigrationIds("com.tldraw.shape", { - AddIsLocked: 1, - HoistOpacity: 2, - AddMeta: 3, - AddWhite: 4 -}); -var rootShapeMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.shape", - recordType: "shape", - sequence: [ - { - id: rootShapeVersions.AddIsLocked, - up: (record) => { - record.isLocked = false; - }, - down: (record) => { - delete record.isLocked; - } - }, - { - id: rootShapeVersions.HoistOpacity, - up: (record) => { - record.opacity = Number(record.props.opacity ?? "1"); - delete record.props.opacity; - }, - down: (record) => { - const opacity = record.opacity; - delete record.opacity; - record.props.opacity = opacity < 0.175 ? "0.1" : opacity < 0.375 ? "0.25" : opacity < 0.625 ? "0.5" : opacity < 0.875 ? "0.75" : "1"; - } - }, - { - id: rootShapeVersions.AddMeta, - up: (record) => { - record.meta = {}; - } - }, - { - id: rootShapeVersions.AddWhite, - up: (_record) => { - }, - down: (record) => { - if (record.props.color === "white") { - record.props.color = "black"; - } - } - } - ] -}); -function isShape(record) { - if (!record) - return false; - return record.typeName === "shape"; -} -function isShapeId(id) { - if (!id) - return false; - return id.startsWith("shape:"); -} -function createShapeId(id) { - return `shape:${id ?? nanoid2()}`; -} -function getShapePropKeysByStyle(props) { - const propKeysByStyle = /* @__PURE__ */ new Map(); - for (const [key, prop] of Object.entries(props)) { - if (prop instanceof StyleProp) { - if (propKeysByStyle.has(prop)) { - throw new Error(`Duplicate style prop ${prop.id}. Each style prop can only be used once within a shape.`); - } - propKeysByStyle.set(prop, key); - } - } - return propKeysByStyle; -} -function createShapePropsMigrationSequence(migrations) { - return migrations; -} -function createShapePropsMigrationIds(shapeType, ids) { - return mapObjectMapValues(ids, (_k, v) => `com.tldraw.shape.${shapeType}/${v}`); -} -function createShapeRecordType(shapes) { - return createRecordType("shape", { - scope: "document", - validator: validation_exports.model("shape", validation_exports.union("type", mapObjectMapValues(shapes, (type, { props, meta }) => createShapeValidator(type, props, meta)))) - }).withDefaultProperties(() => ({ - x: 0, - y: 0, - rotation: 0, - isLocked: false, - opacity: 1, - meta: {} - })); -} - -// node_modules/@tldraw/tlschema/dist-esm/recordsWithProps.mjs -function processPropsMigrations(typeName, records) { - const result = []; - for (const [subType, { migrations }] of Object.entries(records)) { - const sequenceId = `com.tldraw.${typeName}.${subType}`; - if (!migrations) { - result.push(createMigrationSequence({ - sequenceId, - retroactive: false, - sequence: [] - })); - } else if ("sequenceId" in migrations) { - assert(sequenceId === migrations.sequenceId, `sequenceId mismatch for ${subType} ${RecordType} migrations. Expected '${sequenceId}', got '${migrations.sequenceId}'`); - result.push(migrations); - } else if ("sequence" in migrations) { - result.push(createMigrationSequence({ - sequenceId, - retroactive: false, - sequence: migrations.sequence.map((m) => "id" in m ? createPropsMigration(typeName, subType, m) : m) - })); - } else { - result.push(createMigrationSequence({ - sequenceId, - retroactive: false, - sequence: Object.keys(migrations.migrators).map((k) => Number(k)).sort((a, b) => a - b).map((version2) => ({ - id: `${sequenceId}/${version2}`, - scope: "record", - filter: (r) => r.typeName === typeName && r.type === subType, - up: (record) => { - const result2 = migrations.migrators[version2].up(record); - if (result2) { - return result2; - } - }, - down: (record) => { - const result2 = migrations.migrators[version2].down(record); - if (result2) { - return result2; - } - } - })) - })); - } - } - return result; -} -function createPropsMigration(typeName, subType, m) { - return { - id: m.id, - dependsOn: m.dependsOn, - scope: "record", - filter: (r) => r.typeName === typeName && r.type === subType, - up: (record) => { - const result = m.up(record.props); - if (result) { - record.props = result; - } - }, - down: typeof m.down === "function" ? (record) => { - const result = m.down(record.props); - if (result) { - record.props = result; - } - } : void 0 - }; -} - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLColorStyle.mjs -var defaultColorNames = [ - "black", - "grey", - "light-violet", - "violet", - "blue", - "light-blue", - "yellow", - "orange", - "green", - "light-green", - "light-red", - "red", - "white" -]; -var DefaultColorThemePalette = { - lightMode: { - id: "light", - text: "#000000", - background: "rgb(249, 250, 251)", - solid: "#fcfffe", - black: { - solid: "#1d1d1d", - fill: "#1d1d1d", - note: { - fill: "#FCE19C", - text: "#000000" - }, - semi: "#e8e8e8", - pattern: "#494949", - highlight: { - srgb: "#fddd00", - p3: "color(display-p3 0.972 0.8705 0.05)" - } - }, - blue: { - solid: "#4465e9", - fill: "#4465e9", - note: { - fill: "#8AA3FF", - text: "#000000" - }, - semi: "#dce1f8", - pattern: "#6681ee", - highlight: { - srgb: "#10acff", - p3: "color(display-p3 0.308 0.6632 0.9996)" - } - }, - green: { - solid: "#099268", - fill: "#099268", - note: { - fill: "#6FC896", - text: "#000000" - }, - semi: "#d3e9e3", - pattern: "#39a785", - highlight: { - srgb: "#00ffc8", - p3: "color(display-p3 0.2536 0.984 0.7981)" - } - }, - grey: { - solid: "#9fa8b2", - fill: "#9fa8b2", - note: { - fill: "#C0CAD3", - text: "#000000" - }, - semi: "#eceef0", - pattern: "#bcc3c9", - highlight: { - srgb: "#cbe7f1", - p3: "color(display-p3 0.8163 0.9023 0.9416)" - } - }, - "light-blue": { - solid: "#4ba1f1", - fill: "#4ba1f1", - note: { - fill: "#9BC4FD", - text: "#000000" - }, - semi: "#ddedfa", - pattern: "#6fbbf8", - highlight: { - srgb: "#00f4ff", - p3: "color(display-p3 0.1512 0.9414 0.9996)" - } - }, - "light-green": { - solid: "#4cb05e", - fill: "#4cb05e", - note: { - fill: "#98D08A", - text: "#000000" - }, - semi: "#dbf0e0", - pattern: "#65cb78", - highlight: { - srgb: "#65f641", - p3: "color(display-p3 0.563 0.9495 0.3857)" - } - }, - "light-red": { - solid: "#f87777", - fill: "#f87777", - note: { - fill: "#F7A5A1", - text: "#000000" - }, - semi: "#f4dadb", - pattern: "#fe9e9e", - highlight: { - srgb: "#ff7fa3", - p3: "color(display-p3 0.9988 0.5301 0.6397)" - } - }, - "light-violet": { - solid: "#e085f4", - fill: "#e085f4", - note: { - fill: "#DFB0F9", - text: "#000000" - }, - semi: "#f5eafa", - pattern: "#e9acf8", - highlight: { - srgb: "#ff88ff", - p3: "color(display-p3 0.9676 0.5652 0.9999)" - } - }, - orange: { - solid: "#e16919", - fill: "#e16919", - note: { - fill: "#FAA475", - text: "#000000" - }, - semi: "#f8e2d4", - pattern: "#f78438", - highlight: { - srgb: "#ffa500", - p3: "color(display-p3 0.9988 0.6905 0.266)" - } - }, - red: { - solid: "#e03131", - fill: "#e03131", - note: { - fill: "#FC8282", - text: "#000000" - }, - semi: "#f4dadb", - pattern: "#e55959", - highlight: { - srgb: "#ff636e", - p3: "color(display-p3 0.9992 0.4376 0.45)" - } - }, - violet: { - solid: "#ae3ec9", - fill: "#ae3ec9", - note: { - fill: "#DB91FD", - text: "#000000" - }, - semi: "#ecdcf2", - pattern: "#bd63d3", - highlight: { - srgb: "#c77cff", - p3: "color(display-p3 0.7469 0.5089 0.9995)" - } - }, - yellow: { - solid: "#f1ac4b", - fill: "#f1ac4b", - note: { - fill: "#FED49A", - text: "#000000" - }, - semi: "#f9f0e6", - pattern: "#fecb92", - highlight: { - srgb: "#fddd00", - p3: "color(display-p3 0.972 0.8705 0.05)" - } - }, - white: { - solid: "#FFFFFF", - fill: "#FFFFFF", - semi: "#f5f5f5", - pattern: "#f9f9f9", - note: { - fill: "#FFFFFF", - text: "#000000" - }, - highlight: { - srgb: "#ffffff", - p3: "color(display-p3 1 1 1)" - } - } - }, - darkMode: { - id: "dark", - text: "hsl(210, 17%, 98%)", - background: "hsl(240, 5%, 6.5%)", - solid: "#010403", - black: { - solid: "#f2f2f2", - fill: "#f2f2f2", - note: { - fill: "#2c2c2c", - text: "#f2f2f2" - }, - semi: "#2c3036", - pattern: "#989898", - highlight: { - srgb: "#d2b700", - p3: "color(display-p3 0.8078 0.7225 0.0312)" - } - }, - blue: { - solid: "#4f72fc", - fill: "#4f72fc", - note: { - fill: "#2A3F98", - text: "#f2f2f2" - }, - semi: "#262d40", - pattern: "#3a4b9e", - highlight: { - srgb: "#0079d2", - p3: "color(display-p3 0.0032 0.4655 0.7991)" - } - }, - green: { - solid: "#099268", - fill: "#099268", - note: { - fill: "#014429", - text: "#f2f2f2" - }, - semi: "#253231", - pattern: "#366a53", - highlight: { - srgb: "#009774", - p3: "color(display-p3 0.0085 0.582 0.4604)" - } - }, - grey: { - solid: "#9398b0", - fill: "#9398b0", - note: { - fill: "#56595F", - text: "#f2f2f2" - }, - semi: "#33373c", - pattern: "#7c8187", - highlight: { - srgb: "#9cb4cb", - p3: "color(display-p3 0.6299 0.7012 0.7856)" - } - }, - "light-blue": { - solid: "#4dabf7", - fill: "#4dabf7", - note: { - fill: "#1F5495", - text: "#f2f2f2" - }, - semi: "#2a3642", - pattern: "#4d7aa9", - highlight: { - srgb: "#00bdc8", - p3: "color(display-p3 0.0023 0.7259 0.7735)" - } - }, - "light-green": { - solid: "#40c057", - fill: "#40c057", - note: { - fill: "#21581D", - text: "#f2f2f2" - }, - semi: "#2a3830", - pattern: "#4e874e", - highlight: { - srgb: "#00a000", - p3: "color(display-p3 0.2711 0.6172 0.0195)" - } - }, - "light-red": { - solid: "#ff8787", - fill: "#ff8787", - note: { - fill: "#923632", - text: "#f2f2f2" - }, - semi: "#3b3235", - pattern: "#a56767", - highlight: { - srgb: "#db005b", - p3: "color(display-p3 0.7849 0.0585 0.3589)" - } - }, - "light-violet": { - solid: "#e599f7", - fill: "#e599f7", - note: { - fill: "#762F8E", - text: "#f2f2f2" - }, - semi: "#383442", - pattern: "#9770a9", - highlight: { - srgb: "#c400c7", - p3: "color(display-p3 0.7024 0.0403 0.753)" - } - }, - orange: { - solid: "#f76707", - fill: "#f76707", - note: { - fill: "#843906", - text: "#f2f2f2" - }, - semi: "#3a2e2a", - pattern: "#9f552d", - highlight: { - srgb: "#d07a00", - p3: "color(display-p3 0.7699 0.4937 0.0085)" - } - }, - red: { - solid: "#e03131", - fill: "#e03131", - note: { - fill: "#89231A", - text: "#f2f2f2" - }, - semi: "#36292b", - pattern: "#8f3734", - highlight: { - srgb: "#de002c", - p3: "color(display-p3 0.7978 0.0509 0.2035)" - } - }, - violet: { - solid: "#ae3ec9", - fill: "#ae3ec9", - note: { - fill: "#681683", - text: "#f2f2f2" - }, - semi: "#31293c", - pattern: "#763a8b", - highlight: { - srgb: "#9e00ee", - p3: "color(display-p3 0.5651 0.0079 0.8986)" - } - }, - yellow: { - solid: "#ffc034", - fill: "#ffc034", - note: { - fill: "#98571B", - text: "#f2f2f2" - }, - semi: "#3c3934", - pattern: "#fecb92", - highlight: { - srgb: "#d2b700", - p3: "color(display-p3 0.8078 0.7225 0.0312)" - } - }, - white: { - solid: "#f3f3f3", - fill: "#f3f3f3", - semi: "#f5f5f5", - pattern: "#f9f9f9", - note: { - fill: "#eaeaea", - text: "#1d1d1d" - }, - highlight: { - srgb: "#ffffff", - p3: "color(display-p3 1 1 1)" - } - } - } -}; -function getDefaultColorTheme(opts) { - return opts.isDarkMode ? DefaultColorThemePalette.darkMode : DefaultColorThemePalette.lightMode; -} -var DefaultColorStyle = StyleProp.defineEnum("tldraw:color", { - defaultValue: "black", - values: defaultColorNames -}); -var DefaultLabelColorStyle = StyleProp.defineEnum("tldraw:labelColor", { - defaultValue: "black", - values: defaultColorNames -}); - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLDashStyle.mjs -var DefaultDashStyle = StyleProp.defineEnum("tldraw:dash", { - defaultValue: "draw", - values: ["draw", "solid", "dashed", "dotted"] -}); - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLFillStyle.mjs -var DefaultFillStyle = StyleProp.defineEnum("tldraw:fill", { - defaultValue: "none", - values: ["none", "semi", "solid", "pattern", "fill"] -}); - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLFontStyle.mjs -var DefaultFontStyle = StyleProp.defineEnum("tldraw:font", { - defaultValue: "draw", - values: ["draw", "sans", "serif", "mono"] -}); -var DefaultFontFamilies = { - draw: "'tldraw_draw', sans-serif", - sans: "'tldraw_sans', sans-serif", - serif: "'tldraw_serif', serif", - mono: "'tldraw_mono', monospace" -}; - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLSizeStyle.mjs -var DefaultSizeStyle = StyleProp.defineEnum("tldraw:size", { - defaultValue: "m", - values: ["s", "m", "l", "xl"] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLArrowShape.mjs -var arrowheadTypes = [ - "arrow", - "triangle", - "square", - "dot", - "pipe", - "diamond", - "inverted", - "bar", - "none" -]; -var ArrowShapeArrowheadStartStyle = StyleProp.defineEnum("tldraw:arrowheadStart", { - defaultValue: "none", - values: arrowheadTypes -}); -var ArrowShapeArrowheadEndStyle = StyleProp.defineEnum("tldraw:arrowheadEnd", { - defaultValue: "arrow", - values: arrowheadTypes -}); -var arrowShapeProps = { - labelColor: DefaultLabelColorStyle, - color: DefaultColorStyle, - fill: DefaultFillStyle, - dash: DefaultDashStyle, - size: DefaultSizeStyle, - arrowheadStart: ArrowShapeArrowheadStartStyle, - arrowheadEnd: ArrowShapeArrowheadEndStyle, - font: DefaultFontStyle, - start: vecModelValidator, - end: vecModelValidator, - bend: validation_exports.number, - text: validation_exports.string, - labelPosition: validation_exports.number, - scale: validation_exports.nonZeroNumber -}; -var arrowShapeVersions = createShapePropsMigrationIds("arrow", { - AddLabelColor: 1, - AddIsPrecise: 2, - AddLabelPosition: 3, - ExtractBindings: 4, - AddScale: 5 -}); -function propsMigration(migration) { - return createPropsMigration("shape", "arrow", migration); -} -var arrowShapeMigrations = createMigrationSequence({ - sequenceId: "com.tldraw.shape.arrow", - retroactive: false, - sequence: [ - propsMigration({ - id: arrowShapeVersions.AddLabelColor, - up: (props) => { - props.labelColor = "black"; - }, - down: "retired" - }), - propsMigration({ - id: arrowShapeVersions.AddIsPrecise, - up: ({ start, end }) => { - if (start.type === "binding") { - start.isPrecise = !(start.normalizedAnchor.x === 0.5 && start.normalizedAnchor.y === 0.5); - } - if (end.type === "binding") { - end.isPrecise = !(end.normalizedAnchor.x === 0.5 && end.normalizedAnchor.y === 0.5); - } - }, - down: ({ start, end }) => { - if (start.type === "binding") { - if (!start.isPrecise) { - start.normalizedAnchor = { x: 0.5, y: 0.5 }; - } - delete start.isPrecise; - } - if (end.type === "binding") { - if (!end.isPrecise) { - end.normalizedAnchor = { x: 0.5, y: 0.5 }; - } - delete end.isPrecise; - } - } - }), - propsMigration({ - id: arrowShapeVersions.AddLabelPosition, - up: (props) => { - props.labelPosition = 0.5; - }, - down: (props) => { - delete props.labelPosition; - } - }), - { - id: arrowShapeVersions.ExtractBindings, - scope: "store", - up: (oldStore) => { - const arrows = Object.values(oldStore).filter((r) => r.typeName === "shape" && r.type === "arrow"); - for (const arrow4 of arrows) { - const { start, end } = arrow4.props; - if (start.type === "binding") { - const id = createBindingId(); - const binding = { - typeName: "binding", - id, - type: "arrow", - fromId: arrow4.id, - toId: start.boundShapeId, - meta: {}, - props: { - terminal: "start", - normalizedAnchor: start.normalizedAnchor, - isExact: start.isExact, - isPrecise: start.isPrecise - } - }; - oldStore[id] = binding; - arrow4.props.start = { x: 0, y: 0 }; - } else { - delete arrow4.props.start.type; - } - if (end.type === "binding") { - const id = createBindingId(); - const binding = { - typeName: "binding", - id, - type: "arrow", - fromId: arrow4.id, - toId: end.boundShapeId, - meta: {}, - props: { - terminal: "end", - normalizedAnchor: end.normalizedAnchor, - isExact: end.isExact, - isPrecise: end.isPrecise - } - }; - oldStore[id] = binding; - arrow4.props.end = { x: 0, y: 0 }; - } else { - delete arrow4.props.end.type; - } - } - } - }, - propsMigration({ - id: arrowShapeVersions.AddScale, - up: (props) => { - props.scale = 1; - }, - down: (props) => { - delete props.scale; - } - }) - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/bindings/TLArrowBinding.mjs -var arrowBindingProps = { - terminal: validation_exports.literalEnum("start", "end"), - normalizedAnchor: vecModelValidator, - isExact: validation_exports.boolean, - isPrecise: validation_exports.boolean -}; -var arrowBindingMigrations = createBindingPropsMigrationSequence({ - sequence: [{ dependsOn: [arrowShapeVersions.ExtractBindings] }] -}); - -// node_modules/@tldraw/tlschema/dist-esm/records/TLCamera.mjs -var cameraValidator = validation_exports.model("camera", validation_exports.object({ - typeName: validation_exports.literal("camera"), - id: idValidator("camera"), - x: validation_exports.number, - y: validation_exports.number, - z: validation_exports.number, - meta: validation_exports.jsonValue -})); -var cameraVersions = createMigrationIds("com.tldraw.camera", { - AddMeta: 1 -}); -var cameraMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.camera", - recordType: "camera", - sequence: [ - { - id: cameraVersions.AddMeta, - up: (record) => { - ; - record.meta = {}; - } - } - ] -}); -var CameraRecordType = createRecordType("camera", { - validator: cameraValidator, - scope: "session" -}).withDefaultProperties(() => ({ - x: 0, - y: 0, - z: 1, - meta: {} -})); - -// node_modules/@tldraw/tlschema/dist-esm/misc/TLCursor.mjs -var TL_CURSOR_TYPES = /* @__PURE__ */ new Set([ - "none", - "default", - "pointer", - "cross", - "grab", - "rotate", - "grabbing", - "resize-edge", - "resize-corner", - "text", - "move", - "ew-resize", - "ns-resize", - "nesw-resize", - "nwse-resize", - "nesw-rotate", - "nwse-rotate", - "swne-rotate", - "senw-rotate", - "zoom-in", - "zoom-out" -]); -var cursorTypeValidator = validation_exports.setEnum(TL_CURSOR_TYPES); -var cursorValidator = validation_exports.object({ - type: cursorTypeValidator, - rotation: validation_exports.number -}); - -// node_modules/@tldraw/tlschema/dist-esm/misc/TLColor.mjs -var TL_CANVAS_UI_COLOR_TYPES = /* @__PURE__ */ new Set([ - "accent", - "white", - "black", - "selection-stroke", - "selection-fill", - "laser", - "muted-1" -]); -var canvasUiColorTypeValidator = validation_exports.setEnum(TL_CANVAS_UI_COLOR_TYPES); - -// node_modules/@tldraw/tlschema/dist-esm/misc/TLScribble.mjs -var TL_SCRIBBLE_STATES = /* @__PURE__ */ new Set(["starting", "paused", "active", "stopping"]); -var scribbleValidator = validation_exports.object({ - id: validation_exports.string, - points: validation_exports.arrayOf(vecModelValidator), - size: validation_exports.positiveNumber, - color: canvasUiColorTypeValidator, - opacity: validation_exports.number, - state: validation_exports.setEnum(TL_SCRIBBLE_STATES), - delay: validation_exports.number, - shrink: validation_exports.number, - taper: validation_exports.boolean -}); - -// node_modules/@tldraw/tlschema/dist-esm/records/TLPage.mjs -var pageIdValidator = idValidator("page"); -var pageValidator = validation_exports.model("page", validation_exports.object({ - typeName: validation_exports.literal("page"), - id: pageIdValidator, - name: validation_exports.string, - index: validation_exports.indexKey, - meta: validation_exports.jsonValue -})); -var pageVersions = createMigrationIds("com.tldraw.page", { - AddMeta: 1 -}); -var pageMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.page", - recordType: "page", - sequence: [ - { - id: pageVersions.AddMeta, - up: (record) => { - record.meta = {}; - } - } - ] -}); -var PageRecordType = createRecordType("page", { - validator: pageValidator, - scope: "document" -}).withDefaultProperties(() => ({ - meta: {} -})); -function isPageId(id) { - return PageRecordType.isId(id); -} - -// node_modules/@tldraw/tlschema/dist-esm/records/TLInstance.mjs -var shouldKeyBePreservedBetweenSessions = { - id: false, - typeName: false, - currentPageId: false, - opacityForNextShape: false, - stylesForNextShape: false, - followingUserId: false, - highlightedUserIds: false, - brush: false, - cursor: false, - scribbles: false, - isFocusMode: true, - isDebugMode: true, - isToolLocked: true, - exportBackground: true, - screenBounds: true, - insets: true, - zoomBrush: false, - chatMessage: false, - isChatting: false, - isPenMode: false, - isGridMode: true, - isFocused: true, - devicePixelRatio: true, - isCoarsePointer: true, - isHoveringCanvas: false, - openMenus: false, - isChangingStyle: false, - isReadonly: true, - meta: false, - duplicateProps: false -}; -var pluckPreservingValues = (val) => val ? filterEntries(val, (key) => { - return shouldKeyBePreservedBetweenSessions[key]; -}) : null; -var instanceIdValidator = idValidator("instance"); -function createInstanceRecordType(stylesById) { - const stylesForNextShapeValidators = {}; - for (const [id, style] of stylesById) { - stylesForNextShapeValidators[id] = validation_exports.optional(style); - } - const instanceTypeValidator = validation_exports.model("instance", validation_exports.object({ - typeName: validation_exports.literal("instance"), - id: idValidator("instance"), - currentPageId: pageIdValidator, - followingUserId: validation_exports.string.nullable(), - brush: boxModelValidator.nullable(), - opacityForNextShape: opacityValidator, - stylesForNextShape: validation_exports.object(stylesForNextShapeValidators), - cursor: cursorValidator, - scribbles: validation_exports.arrayOf(scribbleValidator), - isFocusMode: validation_exports.boolean, - isDebugMode: validation_exports.boolean, - isToolLocked: validation_exports.boolean, - exportBackground: validation_exports.boolean, - screenBounds: boxModelValidator, - insets: validation_exports.arrayOf(validation_exports.boolean), - zoomBrush: boxModelValidator.nullable(), - isPenMode: validation_exports.boolean, - isGridMode: validation_exports.boolean, - chatMessage: validation_exports.string, - isChatting: validation_exports.boolean, - highlightedUserIds: validation_exports.arrayOf(validation_exports.string), - isFocused: validation_exports.boolean, - devicePixelRatio: validation_exports.number, - isCoarsePointer: validation_exports.boolean, - isHoveringCanvas: validation_exports.boolean.nullable(), - openMenus: validation_exports.arrayOf(validation_exports.string), - isChangingStyle: validation_exports.boolean, - isReadonly: validation_exports.boolean, - meta: validation_exports.jsonValue, - duplicateProps: validation_exports.object({ - shapeIds: validation_exports.arrayOf(idValidator("shape")), - offset: validation_exports.object({ - x: validation_exports.number, - y: validation_exports.number - }) - }).nullable() - })); - return createRecordType("instance", { - validator: instanceTypeValidator, - scope: "session", - ephemeralKeys: { - currentPageId: false, - meta: false, - followingUserId: true, - opacityForNextShape: true, - stylesForNextShape: true, - brush: true, - cursor: true, - scribbles: true, - isFocusMode: true, - isDebugMode: true, - isToolLocked: true, - exportBackground: true, - screenBounds: true, - insets: true, - zoomBrush: true, - isPenMode: true, - isGridMode: true, - chatMessage: true, - isChatting: true, - highlightedUserIds: true, - isFocused: true, - devicePixelRatio: true, - isCoarsePointer: true, - isHoveringCanvas: true, - openMenus: true, - isChangingStyle: true, - isReadonly: true, - duplicateProps: true - } - }).withDefaultProperties(() => ({ - followingUserId: null, - opacityForNextShape: 1, - stylesForNextShape: {}, - brush: null, - scribbles: [], - cursor: { - type: "default", - rotation: 0 - }, - isFocusMode: false, - exportBackground: false, - isDebugMode: false, - isToolLocked: false, - screenBounds: { x: 0, y: 0, w: 1080, h: 720 }, - insets: [false, false, false, false], - zoomBrush: null, - isGridMode: false, - isPenMode: false, - chatMessage: "", - isChatting: false, - highlightedUserIds: [], - isFocused: false, - devicePixelRatio: typeof window === "undefined" ? 1 : window.devicePixelRatio, - isCoarsePointer: false, - isHoveringCanvas: null, - openMenus: [], - isChangingStyle: false, - isReadonly: false, - meta: {}, - duplicateProps: null - })); -} -var instanceVersions = createMigrationIds("com.tldraw.instance", { - AddTransparentExportBgs: 1, - RemoveDialog: 2, - AddToolLockMode: 3, - RemoveExtraPropsForNextShape: 4, - AddLabelColor: 5, - AddFollowingUserId: 6, - RemoveAlignJustify: 7, - AddZoom: 8, - AddVerticalAlign: 9, - AddScribbleDelay: 10, - RemoveUserId: 11, - AddIsPenModeAndIsGridMode: 12, - HoistOpacity: 13, - AddChat: 14, - AddHighlightedUserIds: 15, - ReplacePropsForNextShapeWithStylesForNextShape: 16, - AddMeta: 17, - RemoveCursorColor: 18, - AddLonelyProperties: 19, - ReadOnlyReadonly: 20, - AddHoveringCanvas: 21, - AddScribbles: 22, - AddInset: 23, - AddDuplicateProps: 24, - RemoveCanMoveCamera: 25 -}); -var instanceMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.instance", - recordType: "instance", - sequence: [ - { - id: instanceVersions.AddTransparentExportBgs, - up: (instance) => { - return { ...instance, exportBackground: true }; - } - }, - { - id: instanceVersions.RemoveDialog, - up: ({ dialog: _, ...instance }) => { - return instance; - } - }, - { - id: instanceVersions.AddToolLockMode, - up: (instance) => { - return { ...instance, isToolLocked: false }; - } - }, - { - id: instanceVersions.RemoveExtraPropsForNextShape, - up: ({ propsForNextShape, ...instance }) => { - return { - ...instance, - propsForNextShape: Object.fromEntries(Object.entries(propsForNextShape).filter(([key]) => [ - "color", - "labelColor", - "dash", - "fill", - "size", - "font", - "align", - "verticalAlign", - "icon", - "geo", - "arrowheadStart", - "arrowheadEnd", - "spline" - ].includes(key))) - }; - } - }, - { - id: instanceVersions.AddLabelColor, - up: ({ propsForNextShape, ...instance }) => { - return { - ...instance, - propsForNextShape: { - ...propsForNextShape, - labelColor: "black" - } - }; - } - }, - { - id: instanceVersions.AddFollowingUserId, - up: (instance) => { - return { ...instance, followingUserId: null }; - } - }, - { - id: instanceVersions.RemoveAlignJustify, - up: (instance) => { - let newAlign = instance.propsForNextShape.align; - if (newAlign === "justify") { - newAlign = "start"; - } - return { - ...instance, - propsForNextShape: { - ...instance.propsForNextShape, - align: newAlign - } - }; - } - }, - { - id: instanceVersions.AddZoom, - up: (instance) => { - return { ...instance, zoomBrush: null }; - } - }, - { - id: instanceVersions.AddVerticalAlign, - up: (instance) => { - return { - ...instance, - propsForNextShape: { - ...instance.propsForNextShape, - verticalAlign: "middle" - } - }; - } - }, - { - id: instanceVersions.AddScribbleDelay, - up: (instance) => { - if (instance.scribble !== null) { - return { ...instance, scribble: { ...instance.scribble, delay: 0 } }; - } - return { ...instance }; - } - }, - { - id: instanceVersions.RemoveUserId, - up: ({ userId: _, ...instance }) => { - return instance; - } - }, - { - id: instanceVersions.AddIsPenModeAndIsGridMode, - up: (instance) => { - return { ...instance, isPenMode: false, isGridMode: false }; - } - }, - { - id: instanceVersions.HoistOpacity, - up: ({ propsForNextShape: { opacity, ...propsForNextShape }, ...instance }) => { - return { ...instance, opacityForNextShape: Number(opacity ?? "1"), propsForNextShape }; - } - }, - { - id: instanceVersions.AddChat, - up: (instance) => { - return { ...instance, chatMessage: "", isChatting: false }; - } - }, - { - id: instanceVersions.AddHighlightedUserIds, - up: (instance) => { - return { ...instance, highlightedUserIds: [] }; - } - }, - { - id: instanceVersions.ReplacePropsForNextShapeWithStylesForNextShape, - up: ({ propsForNextShape: _, ...instance }) => { - return { ...instance, stylesForNextShape: {} }; - } - }, - { - id: instanceVersions.AddMeta, - up: (record) => { - return { - ...record, - meta: {} - }; - } - }, - { - id: instanceVersions.RemoveCursorColor, - up: (record) => { - const { color: _, ...cursor } = record.cursor; - return { - ...record, - cursor - }; - } - }, - { - id: instanceVersions.AddLonelyProperties, - up: (record) => { - return { - ...record, - canMoveCamera: true, - isFocused: false, - devicePixelRatio: 1, - isCoarsePointer: false, - openMenus: [], - isChangingStyle: false, - isReadOnly: false - }; - } - }, - { - id: instanceVersions.ReadOnlyReadonly, - up: ({ isReadOnly: _isReadOnly, ...record }) => { - return { - ...record, - isReadonly: _isReadOnly - }; - } - }, - { - id: instanceVersions.AddHoveringCanvas, - up: (record) => { - return { - ...record, - isHoveringCanvas: null - }; - } - }, - { - id: instanceVersions.AddScribbles, - up: ({ scribble: _, ...record }) => { - return { - ...record, - scribbles: [] - }; - } - }, - { - id: instanceVersions.AddInset, - up: (record) => { - return { - ...record, - insets: [false, false, false, false] - }; - }, - down: ({ insets: _, ...record }) => { - return { - ...record - }; - } - }, - { - id: instanceVersions.AddDuplicateProps, - up: (record) => { - return { - ...record, - duplicateProps: null - }; - }, - down: ({ duplicateProps: _, ...record }) => { - return { - ...record - }; - } - }, - { - id: instanceVersions.RemoveCanMoveCamera, - up: ({ canMoveCamera: _, ...record }) => { - return { - ...record - }; - }, - down: (instance) => { - return { ...instance, canMoveCamera: true }; - } - } - ] -}); -var TLINSTANCE_ID = "instance:instance"; - -// node_modules/@tldraw/tlschema/dist-esm/records/TLPageState.mjs -var instancePageStateValidator = validation_exports.model("instance_page_state", validation_exports.object({ - typeName: validation_exports.literal("instance_page_state"), - id: idValidator("instance_page_state"), - pageId: pageIdValidator, - selectedShapeIds: validation_exports.arrayOf(shapeIdValidator), - hintingShapeIds: validation_exports.arrayOf(shapeIdValidator), - erasingShapeIds: validation_exports.arrayOf(shapeIdValidator), - hoveredShapeId: shapeIdValidator.nullable(), - editingShapeId: shapeIdValidator.nullable(), - croppingShapeId: shapeIdValidator.nullable(), - focusedGroupId: shapeIdValidator.nullable(), - meta: validation_exports.jsonValue -})); -var instancePageStateVersions = createMigrationIds("com.tldraw.instance_page_state", { - AddCroppingId: 1, - RemoveInstanceIdAndCameraId: 2, - AddMeta: 3, - RenameProperties: 4, - RenamePropertiesAgain: 5 -}); -var instancePageStateMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.instance_page_state", - recordType: "instance_page_state", - sequence: [ - { - id: instancePageStateVersions.AddCroppingId, - up(instance) { - instance.croppingShapeId = null; - } - }, - { - id: instancePageStateVersions.RemoveInstanceIdAndCameraId, - up(instance) { - delete instance.instanceId; - delete instance.cameraId; - } - }, - { - id: instancePageStateVersions.AddMeta, - up: (record) => { - record.meta = {}; - } - }, - { - id: instancePageStateVersions.RenameProperties, - up: (_record) => { - }, - down: (_record) => { - } - }, - { - id: instancePageStateVersions.RenamePropertiesAgain, - up: (record) => { - record.selectedShapeIds = record.selectedIds; - delete record.selectedIds; - record.hintingShapeIds = record.hintingIds; - delete record.hintingIds; - record.erasingShapeIds = record.erasingIds; - delete record.erasingIds; - record.hoveredShapeId = record.hoveredId; - delete record.hoveredId; - record.editingShapeId = record.editingId; - delete record.editingId; - record.croppingShapeId = record.croppingShapeId ?? record.croppingId ?? null; - delete record.croppingId; - record.focusedGroupId = record.focusLayerId; - delete record.focusLayerId; - }, - down: (record) => { - record.selectedIds = record.selectedShapeIds; - delete record.selectedShapeIds; - record.hintingIds = record.hintingShapeIds; - delete record.hintingShapeIds; - record.erasingIds = record.erasingShapeIds; - delete record.erasingShapeIds; - record.hoveredId = record.hoveredShapeId; - delete record.hoveredShapeId; - record.editingId = record.editingShapeId; - delete record.editingShapeId; - record.croppingId = record.croppingShapeId; - delete record.croppingShapeId; - record.focusLayerId = record.focusedGroupId; - delete record.focusedGroupId; - } - } - ] -}); -var InstancePageStateRecordType = createRecordType("instance_page_state", { - validator: instancePageStateValidator, - scope: "session", - ephemeralKeys: { - pageId: false, - selectedShapeIds: false, - editingShapeId: false, - croppingShapeId: false, - meta: false, - hintingShapeIds: true, - erasingShapeIds: true, - hoveredShapeId: true, - focusedGroupId: true - } -}).withDefaultProperties(() => ({ - editingShapeId: null, - croppingShapeId: null, - selectedShapeIds: [], - hoveredShapeId: null, - erasingShapeIds: [], - hintingShapeIds: [], - focusedGroupId: null, - meta: {} -})); - -// node_modules/@tldraw/tlschema/dist-esm/records/TLPointer.mjs -var pointerValidator = validation_exports.model("pointer", validation_exports.object({ - typeName: validation_exports.literal("pointer"), - id: idValidator("pointer"), - x: validation_exports.number, - y: validation_exports.number, - lastActivityTimestamp: validation_exports.number, - meta: validation_exports.jsonValue -})); -var pointerVersions = createMigrationIds("com.tldraw.pointer", { - AddMeta: 1 -}); -var pointerMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.pointer", - recordType: "pointer", - sequence: [ - { - id: pointerVersions.AddMeta, - up: (record) => { - record.meta = {}; - } - } - ] -}); -var PointerRecordType = createRecordType("pointer", { - validator: pointerValidator, - scope: "session" -}).withDefaultProperties(() => ({ - x: 0, - y: 0, - lastActivityTimestamp: 0, - meta: {} -})); -var TLPOINTER_ID = PointerRecordType.createId("pointer"); - -// node_modules/@tldraw/tlschema/dist-esm/records/TLPresence.mjs -var instancePresenceValidator = validation_exports.model("instance_presence", validation_exports.object({ - typeName: validation_exports.literal("instance_presence"), - id: idValidator("instance_presence"), - userId: validation_exports.string, - userName: validation_exports.string, - lastActivityTimestamp: validation_exports.number, - followingUserId: validation_exports.string.nullable(), - cursor: validation_exports.object({ - x: validation_exports.number, - y: validation_exports.number, - type: cursorTypeValidator, - rotation: validation_exports.number - }), - color: validation_exports.string, - camera: validation_exports.object({ - x: validation_exports.number, - y: validation_exports.number, - z: validation_exports.number - }), - screenBounds: boxModelValidator, - selectedShapeIds: validation_exports.arrayOf(idValidator("shape")), - currentPageId: idValidator("page"), - brush: boxModelValidator.nullable(), - scribbles: validation_exports.arrayOf(scribbleValidator), - chatMessage: validation_exports.string, - meta: validation_exports.jsonValue -})); -var instancePresenceVersions = createMigrationIds("com.tldraw.instance_presence", { - AddScribbleDelay: 1, - RemoveInstanceId: 2, - AddChatMessage: 3, - AddMeta: 4, - RenameSelectedShapeIds: 5 -}); -var instancePresenceMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.instance_presence", - recordType: "instance_presence", - sequence: [ - { - id: instancePresenceVersions.AddScribbleDelay, - up: (instance) => { - if (instance.scribble !== null) { - instance.scribble.delay = 0; - } - } - }, - { - id: instancePresenceVersions.RemoveInstanceId, - up: (instance) => { - delete instance.instanceId; - } - }, - { - id: instancePresenceVersions.AddChatMessage, - up: (instance) => { - instance.chatMessage = ""; - } - }, - { - id: instancePresenceVersions.AddMeta, - up: (record) => { - record.meta = {}; - } - }, - { - id: instancePresenceVersions.RenameSelectedShapeIds, - up: (_record) => { - } - } - ] -}); -var InstancePresenceRecordType = createRecordType("instance_presence", { - validator: instancePresenceValidator, - scope: "presence" -}).withDefaultProperties(() => ({ - lastActivityTimestamp: 0, - followingUserId: null, - color: "#FF0000", - camera: { - x: 0, - y: 0, - z: 1 - }, - cursor: { - x: 0, - y: 0, - type: "default", - rotation: 0 - }, - screenBounds: { - x: 0, - y: 0, - w: 1, - h: 1 - }, - selectedShapeIds: [], - brush: null, - scribbles: [], - chatMessage: "", - meta: {} -})); - -// node_modules/@tldraw/tlschema/dist-esm/records/TLDocument.mjs -var documentValidator = validation_exports.model("document", validation_exports.object({ - typeName: validation_exports.literal("document"), - id: validation_exports.literal("document:document"), - gridSize: validation_exports.number, - name: validation_exports.string, - meta: validation_exports.jsonValue -})); -var documentVersions = createMigrationIds("com.tldraw.document", { - AddName: 1, - AddMeta: 2 -}); -var documentMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.document", - recordType: "document", - sequence: [ - { - id: documentVersions.AddName, - up: (document2) => { - ; - document2.name = ""; - }, - down: (document2) => { - delete document2.name; - } - }, - { - id: documentVersions.AddMeta, - up: (record) => { - ; - record.meta = {}; - } - } - ] -}); -var DocumentRecordType = createRecordType("document", { - validator: documentValidator, - scope: "document" -}).withDefaultProperties(() => ({ - gridSize: 10, - name: "", - meta: {} -})); -var TLDOCUMENT_ID = DocumentRecordType.createId("document"); - -// node_modules/@tldraw/tlschema/dist-esm/TLStore.mjs -function sortByIndex2(a, b) { - if (a.index < b.index) { - return -1; - } else if (a.index > b.index) { - return 1; - } - return 0; -} -function redactRecordForErrorReporting(record) { - if (record.typeName === "asset") { - if ("src" in record) { - record.src = "<redacted>"; - } - if ("src" in record.props) { - record.props.src = "<redacted>"; - } - } -} -var onValidationFailure = ({ error: error3, phase, record, recordBefore }) => { - const isExistingValidationIssue = phase === "initialize"; - annotateError(error3, { - tags: { - origin: "store.validateRecord", - storePhase: phase, - isExistingValidationIssue - }, - extras: { - recordBefore: recordBefore ? redactRecordForErrorReporting(structuredClone(recordBefore)) : void 0, - recordAfter: redactRecordForErrorReporting(structuredClone(record)) - } - }); - throw error3; -}; -function getDefaultPages() { - return [ - PageRecordType.create({ - id: "page:page", - name: "Page 1", - index: "a1", - meta: {} - }) - ]; -} -function createIntegrityChecker(store) { - const $pageIds = store.query.ids("page"); - const ensureStoreIsUsable = () => { - if (!store.has(TLDOCUMENT_ID)) { - store.put([DocumentRecordType.create({ id: TLDOCUMENT_ID, name: store.props.defaultName })]); - return ensureStoreIsUsable(); - } - if (!store.has(TLPOINTER_ID)) { - store.put([PointerRecordType.create({ id: TLPOINTER_ID })]); - return ensureStoreIsUsable(); - } - const pageIds = $pageIds.get(); - if (pageIds.size === 0) { - store.put(getDefaultPages()); - return ensureStoreIsUsable(); - } - const getFirstPageId = () => [...pageIds].map((id) => store.get(id)).sort(sortByIndex2)[0].id; - const instanceState = store.get(TLINSTANCE_ID); - if (!instanceState) { - store.put([ - store.schema.types.instance.create({ - id: TLINSTANCE_ID, - currentPageId: getFirstPageId(), - exportBackground: true - }) - ]); - return ensureStoreIsUsable(); - } else if (!pageIds.has(instanceState.currentPageId)) { - store.put([{ ...instanceState, currentPageId: getFirstPageId() }]); - return ensureStoreIsUsable(); - } - const missingPageStateIds = /* @__PURE__ */ new Set(); - const missingCameraIds = /* @__PURE__ */ new Set(); - for (const id of pageIds) { - const pageStateId = InstancePageStateRecordType.createId(id); - if (!store.has(pageStateId)) { - missingPageStateIds.add(pageStateId); - } - const cameraId = CameraRecordType.createId(id); - if (!store.has(cameraId)) { - missingCameraIds.add(cameraId); - } - } - if (missingPageStateIds.size > 0) { - store.put([...missingPageStateIds].map((id) => InstancePageStateRecordType.create({ - id, - pageId: InstancePageStateRecordType.parseId(id) - }))); - } - if (missingCameraIds.size > 0) { - store.put([...missingCameraIds].map((id) => CameraRecordType.create({ id }))); - } - }; - return ensureStoreIsUsable; -} - -// node_modules/@tldraw/tlschema/dist-esm/assets/TLBookmarkAsset.mjs -var bookmarkAssetValidator = createAssetValidator("bookmark", validation_exports.object({ - title: validation_exports.string, - description: validation_exports.string, - image: validation_exports.string, - favicon: validation_exports.string, - src: validation_exports.srcUrl.nullable() -})); -var Versions = createMigrationIds("com.tldraw.asset.bookmark", { - MakeUrlsValid: 1, - AddFavicon: 2 -}); -var bookmarkAssetMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.asset.bookmark", - recordType: "asset", - filter: (asset) => asset.type === "bookmark", - sequence: [ - { - id: Versions.MakeUrlsValid, - up: (asset) => { - if (!validation_exports.srcUrl.isValid(asset.props.src)) { - asset.props.src = ""; - } - }, - down: (_asset) => { - } - }, - { - id: Versions.AddFavicon, - up: (asset) => { - if (!validation_exports.srcUrl.isValid(asset.props.favicon)) { - asset.props.favicon = ""; - } - }, - down: (asset) => { - delete asset.props.favicon; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/assets/TLImageAsset.mjs -var imageAssetValidator = createAssetValidator("image", validation_exports.object({ - w: validation_exports.number, - h: validation_exports.number, - name: validation_exports.string, - isAnimated: validation_exports.boolean, - mimeType: validation_exports.string.nullable(), - src: validation_exports.srcUrl.nullable(), - fileSize: validation_exports.nonZeroNumber.optional() -})); -var Versions2 = createMigrationIds("com.tldraw.asset.image", { - AddIsAnimated: 1, - RenameWidthHeight: 2, - MakeUrlsValid: 3, - AddFileSize: 4, - MakeFileSizeOptional: 5 -}); -var imageAssetMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.asset.image", - recordType: "asset", - filter: (asset) => asset.type === "image", - sequence: [ - { - id: Versions2.AddIsAnimated, - up: (asset) => { - asset.props.isAnimated = false; - }, - down: (asset) => { - delete asset.props.isAnimated; - } - }, - { - id: Versions2.RenameWidthHeight, - up: (asset) => { - asset.props.w = asset.props.width; - asset.props.h = asset.props.height; - delete asset.props.width; - delete asset.props.height; - }, - down: (asset) => { - asset.props.width = asset.props.w; - asset.props.height = asset.props.h; - delete asset.props.w; - delete asset.props.h; - } - }, - { - id: Versions2.MakeUrlsValid, - up: (asset) => { - if (!validation_exports.srcUrl.isValid(asset.props.src)) { - asset.props.src = ""; - } - }, - down: (_asset) => { - } - }, - { - id: Versions2.AddFileSize, - up: (asset) => { - asset.props.fileSize = -1; - }, - down: (asset) => { - delete asset.props.fileSize; - } - }, - { - id: Versions2.MakeFileSizeOptional, - up: (asset) => { - if (asset.props.fileSize === -1) { - asset.props.fileSize = void 0; - } - }, - down: (asset) => { - if (asset.props.fileSize === void 0) { - asset.props.fileSize = -1; - } - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/assets/TLVideoAsset.mjs -var videoAssetValidator = createAssetValidator("video", validation_exports.object({ - w: validation_exports.number, - h: validation_exports.number, - name: validation_exports.string, - isAnimated: validation_exports.boolean, - mimeType: validation_exports.string.nullable(), - src: validation_exports.srcUrl.nullable(), - fileSize: validation_exports.number.optional() -})); -var Versions3 = createMigrationIds("com.tldraw.asset.video", { - AddIsAnimated: 1, - RenameWidthHeight: 2, - MakeUrlsValid: 3, - AddFileSize: 4, - MakeFileSizeOptional: 5 -}); -var videoAssetMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.asset.video", - recordType: "asset", - filter: (asset) => asset.type === "video", - sequence: [ - { - id: Versions3.AddIsAnimated, - up: (asset) => { - asset.props.isAnimated = false; - }, - down: (asset) => { - delete asset.props.isAnimated; - } - }, - { - id: Versions3.RenameWidthHeight, - up: (asset) => { - asset.props.w = asset.props.width; - asset.props.h = asset.props.height; - delete asset.props.width; - delete asset.props.height; - }, - down: (asset) => { - asset.props.width = asset.props.w; - asset.props.height = asset.props.h; - delete asset.props.w; - delete asset.props.h; - } - }, - { - id: Versions3.MakeUrlsValid, - up: (asset) => { - if (!validation_exports.srcUrl.isValid(asset.props.src)) { - asset.props.src = ""; - } - }, - down: (_asset) => { - } - }, - { - id: Versions3.AddFileSize, - up: (asset) => { - asset.props.fileSize = -1; - }, - down: (asset) => { - delete asset.props.fileSize; - } - }, - { - id: Versions3.MakeFileSizeOptional, - up: (asset) => { - if (asset.props.fileSize === -1) { - asset.props.fileSize = void 0; - } - }, - down: (asset) => { - if (asset.props.fileSize === void 0) { - asset.props.fileSize = -1; - } - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/records/TLAsset.mjs -var assetValidator = validation_exports.model("asset", validation_exports.union("type", { - image: imageAssetValidator, - video: videoAssetValidator, - bookmark: bookmarkAssetValidator -})); -var assetVersions = createMigrationIds("com.tldraw.asset", { - AddMeta: 1 -}); -var assetMigrations = createRecordMigrationSequence({ - sequenceId: "com.tldraw.asset", - recordType: "asset", - sequence: [ - { - id: assetVersions.AddMeta, - up: (record) => { - ; - record.meta = {}; - } - } - ] -}); -var AssetRecordType = createRecordType("asset", { - validator: assetValidator, - scope: "document" -}).withDefaultProperties(() => ({ - meta: {} -})); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLBookmarkShape.mjs -var bookmarkShapeProps = { - w: validation_exports.nonZeroNumber, - h: validation_exports.nonZeroNumber, - assetId: assetIdValidator.nullable(), - url: validation_exports.linkUrl -}; -var Versions4 = createShapePropsMigrationIds("bookmark", { - NullAssetId: 1, - MakeUrlsValid: 2 -}); -var bookmarkShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions4.NullAssetId, - up: (props) => { - if (props.assetId === void 0) { - props.assetId = null; - } - }, - down: "retired" - }, - { - id: Versions4.MakeUrlsValid, - up: (props) => { - if (!validation_exports.linkUrl.isValid(props.url)) { - props.url = ""; - } - }, - down: (_props) => { - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLDrawShape.mjs -var DrawShapeSegment = validation_exports.object({ - type: validation_exports.literalEnum("free", "straight"), - points: validation_exports.arrayOf(vecModelValidator) -}); -var drawShapeProps = { - color: DefaultColorStyle, - fill: DefaultFillStyle, - dash: DefaultDashStyle, - size: DefaultSizeStyle, - segments: validation_exports.arrayOf(DrawShapeSegment), - isComplete: validation_exports.boolean, - isClosed: validation_exports.boolean, - isPen: validation_exports.boolean, - scale: validation_exports.nonZeroNumber -}; -var Versions5 = createShapePropsMigrationIds("draw", { - AddInPen: 1, - AddScale: 2 -}); -var drawShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions5.AddInPen, - up: (props) => { - const { points } = props.segments[0]; - if (points.length === 0) { - props.isPen = false; - return; - } - let isPen = !(points[0].z === 0 || points[0].z === 0.5); - if (points[1]) { - isPen = isPen && !(points[1].z === 0 || points[1].z === 0.5); - } - props.isPen = isPen; - }, - down: "retired" - }, - { - id: Versions5.AddScale, - up: (props) => { - props.scale = 1; - }, - down: (props) => { - delete props.scale; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLEmbedShape.mjs -var TLDRAW_APP_RE = /(^\/r\/[^/]+\/?$)/; -var safeParseUrl = (url) => { - try { - return new URL(url); - } catch (err) { - return; - } -}; -var EMBED_DEFINITIONS = [ - { - type: "tldraw", - title: "tldraw", - hostnames: ["beta.tldraw.com", "tldraw.com", "localhost:3000"], - minWidth: 300, - minHeight: 300, - width: 720, - height: 500, - doesResize: true, - overridePermissions: { - "allow-top-navigation": true - }, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) { - return url; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) { - return url; - } - return; - } - }, - { - type: "figma", - title: "Figma", - hostnames: ["figma.com"], - width: 720, - height: 500, - doesResize: true, - toEmbedUrl: (url) => { - if (!!url.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/) && !url.includes("figma.com/embed")) { - return `https://www.figma.com/embed?embed_host=share&url=${url}`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/embed\/?$/)) { - const outUrl = urlObj.searchParams.get("url"); - if (outUrl) { - return outUrl; - } - } - return; - } - }, - { - type: "google_maps", - title: "Google Maps", - hostnames: ["google.*"], - width: 720, - height: 500, - doesResize: true, - overridePermissions: { - "allow-presentation": true - }, - toEmbedUrl: (url) => { - if (url.includes("/maps/")) { - const match = url.match(/@(.*),(.*),(.*)z/); - let result; - if (match) { - const [, lat, lng, z] = match; - const host = new URL(url).host.replace("www.", ""); - result = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}¢er=${lat},${lng}&zoom=${z}`; - } else { - result = ""; - } - return result; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (!urlObj) - return; - const matches = urlObj.pathname.match(/^\/maps\/embed\/v1\/view\/?$/); - if (matches && urlObj.searchParams.has("center") && urlObj.searchParams.get("zoom")) { - const zoom = urlObj.searchParams.get("zoom"); - const [lat, lon] = urlObj.searchParams.get("center").split(","); - return `https://www.google.com/maps/@${lat},${lon},${zoom}z`; - } - return; - } - }, - { - type: "val_town", - title: "Val Town", - hostnames: ["val.town"], - minWidth: 260, - minHeight: 100, - width: 720, - height: 500, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - const matches = urlObj && urlObj.pathname.match(/\/v\/(.+)\/?/); - if (matches) { - return `https://www.val.town/embed/${matches[1]}`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - const matches = urlObj && urlObj.pathname.match(/\/embed\/(.+)\/?/); - if (matches) { - return `https://www.val.town/v/${matches[1]}`; - } - return; - } - }, - { - type: "codesandbox", - title: "CodeSandbox", - hostnames: ["codesandbox.io"], - minWidth: 300, - minHeight: 300, - width: 720, - height: 500, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - const matches = urlObj && urlObj.pathname.match(/\/s\/([^/]+)\/?/); - if (matches) { - return `https://codesandbox.io/embed/${matches[1]}`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - const matches = urlObj && urlObj.pathname.match(/\/embed\/([^/]+)\/?/); - if (matches) { - return `https://codesandbox.io/s/${matches[1]}`; - } - return; - } - }, - { - type: "codepen", - title: "Codepen", - hostnames: ["codepen.io"], - minWidth: 300, - minHeight: 300, - width: 520, - height: 400, - doesResize: true, - toEmbedUrl: (url) => { - const CODEPEN_URL_REGEXP = /https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/; - const matches = url.match(CODEPEN_URL_REGEXP); - if (matches) { - const [_, user, id] = matches; - return `https://codepen.io/${user}/embed/${id}`; - } - return; - }, - fromEmbedUrl: (url) => { - const CODEPEN_EMBED_REGEXP = /https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/; - const matches = url.match(CODEPEN_EMBED_REGEXP); - if (matches) { - const [_, user, id] = matches; - return `https://codepen.io/${user}/pen/${id}`; - } - return; - } - }, - { - type: "scratch", - title: "Scratch", - hostnames: ["scratch.mit.edu"], - width: 520, - height: 400, - doesResize: false, - toEmbedUrl: (url) => { - const SCRATCH_URL_REGEXP = /https?:\/\/scratch.mit.edu\/projects\/([^/]+)/; - const matches = url.match(SCRATCH_URL_REGEXP); - if (matches) { - const [_, id] = matches; - return `https://scratch.mit.edu/projects/embed/${id}`; - } - return; - }, - fromEmbedUrl: (url) => { - const SCRATCH_EMBED_REGEXP = /https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/; - const matches = url.match(SCRATCH_EMBED_REGEXP); - if (matches) { - const [_, id] = matches; - return `https://scratch.mit.edu/projects/${id}`; - } - return; - } - }, - { - type: "youtube", - title: "YouTube", - hostnames: ["*.youtube.com", "youtube.com", "youtu.be"], - width: 800, - height: 450, - doesResize: true, - overridePermissions: { - "allow-presentation": true, - "allow-popups-to-escape-sandbox": true - }, - isAspectRatioLocked: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (!urlObj) - return; - const hostname = urlObj.hostname.replace(/^www./, ""); - if (hostname === "youtu.be") { - const videoId = urlObj.pathname.split("/").filter(Boolean)[0]; - return `https://www.youtube.com/embed/${videoId}`; - } else if ((hostname === "youtube.com" || hostname === "m.youtube.com") && urlObj.pathname.match(/^\/watch/)) { - const videoId = urlObj.searchParams.get("v"); - return `https://www.youtube.com/embed/${videoId}`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (!urlObj) - return; - const hostname = urlObj.hostname.replace(/^www./, ""); - if (hostname === "youtube.com") { - const matches = urlObj.pathname.match(/^\/embed\/([^/]+)\/?/); - if (matches) { - return `https://www.youtube.com/watch?v=${matches[1]}`; - } - } - return; - } - }, - { - type: "google_calendar", - title: "Google Calendar", - hostnames: ["calendar.google.*"], - width: 720, - height: 500, - minWidth: 460, - minHeight: 360, - doesResize: true, - instructionLink: "https://support.google.com/calendar/answer/41207?hl=en", - overridePermissions: { - "allow-popups-to-escape-sandbox": true - }, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - const cidQs = urlObj?.searchParams.get("cid"); - if (urlObj?.pathname.match(/\/calendar\/u\/0/) && cidQs) { - urlObj.pathname = "/calendar/embed"; - const keys = Array.from(urlObj.searchParams.keys()); - for (const key of keys) { - urlObj.searchParams.delete(key); - } - urlObj.searchParams.set("src", cidQs); - return urlObj.href; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - const srcQs = urlObj?.searchParams.get("src"); - if (urlObj?.pathname.match(/\/calendar\/embed/) && srcQs) { - urlObj.pathname = "/calendar/u/0"; - const keys = Array.from(urlObj.searchParams.keys()); - for (const key of keys) { - urlObj.searchParams.delete(key); - } - urlObj.searchParams.set("cid", srcQs); - return urlObj.href; - } - return; - } - }, - { - type: "google_slides", - title: "Google Slides", - hostnames: ["docs.google.*"], - width: 720, - height: 500, - minWidth: 460, - minHeight: 360, - doesResize: true, - overridePermissions: { - "allow-popups-to-escape-sandbox": true - }, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj?.pathname.match(/^\/presentation/) && urlObj?.pathname.match(/\/pub\/?$/)) { - urlObj.pathname = urlObj.pathname.replace(/\/pub$/, "/embed"); - const keys = Array.from(urlObj.searchParams.keys()); - for (const key of keys) { - urlObj.searchParams.delete(key); - } - return urlObj.href; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj?.pathname.match(/^\/presentation/) && urlObj?.pathname.match(/\/embed\/?$/)) { - urlObj.pathname = urlObj.pathname.replace(/\/embed$/, "/pub"); - const keys = Array.from(urlObj.searchParams.keys()); - for (const key of keys) { - urlObj.searchParams.delete(key); - } - return urlObj.href; - } - return; - } - }, - { - type: "github_gist", - title: "GitHub Gist", - hostnames: ["gist.github.com"], - width: 720, - height: 500, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/\/([^/]+)\/([^/]+)/)) { - if (!url.split("/").pop()) - return; - return url; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/\/([^/]+)\/([^/]+)/)) { - if (!url.split("/").pop()) - return; - return url; - } - return; - } - }, - { - type: "replit", - title: "Replit", - hostnames: ["replit.com"], - width: 720, - height: 500, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/\/@([^/]+)\/([^/]+)/)) { - return `${url}?embed=true`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/\/@([^/]+)\/([^/]+)/) && urlObj.searchParams.has("embed")) { - urlObj.searchParams.delete("embed"); - return urlObj.href; - } - return; - } - }, - { - type: "felt", - title: "Felt", - hostnames: ["felt.com"], - width: 720, - height: 500, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/map\//)) { - return urlObj.origin + "/embed" + urlObj.pathname; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/embed\/map\//)) { - urlObj.pathname = urlObj.pathname.replace(/^\/embed/, ""); - return urlObj.href; - } - return; - } - }, - { - type: "spotify", - title: "Spotify", - hostnames: ["open.spotify.com"], - width: 720, - height: 500, - minHeight: 500, - overrideOutlineRadius: 12, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/(artist|album)\//)) { - return urlObj.origin + "/embed" + urlObj.pathname; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/embed\/(artist|album)\//)) { - return urlObj.origin + urlObj.pathname.replace(/^\/embed/, ""); - } - return; - } - }, - { - type: "vimeo", - title: "Vimeo", - hostnames: ["vimeo.com", "player.vimeo.com"], - width: 640, - height: 360, - doesResize: true, - isAspectRatioLocked: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.hostname === "vimeo.com") { - if (urlObj.pathname.match(/^\/[0-9]+/)) { - return "https://player.vimeo.com/video/" + urlObj.pathname.split("/")[1] + "?title=0&byline=0"; - } - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.hostname === "player.vimeo.com") { - const matches = urlObj.pathname.match(/^\/video\/([^/]+)\/?$/); - if (matches) { - return "https://vimeo.com/" + matches[1]; - } - } - return; - } - }, - { - type: "excalidraw", - title: "Excalidraw", - hostnames: ["excalidraw.com"], - width: 720, - height: 500, - doesResize: true, - isAspectRatioLocked: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.hash.match(/#room=/)) { - return url; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.hash.match(/#room=/)) { - return url; - } - return; - } - }, - { - type: "observable", - title: "Observable", - hostnames: ["observablehq.com"], - width: 720, - height: 500, - doesResize: true, - isAspectRatioLocked: false, - backgroundColor: "#fff", - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/)) { - return `${urlObj.origin}/embed${urlObj.pathname}?cell=*`; - } - if (urlObj && urlObj.pathname.match(/^\/d\/([^/]+)\/?$/)) { - const pathName = urlObj.pathname.replace(/^\/d/, ""); - return `${urlObj.origin}/embed${pathName}?cell=*`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/)) { - return `${urlObj.origin}${urlObj.pathname.replace("/embed", "")}#cell-*`; - } - if (urlObj && urlObj.pathname.match(/^\/embed\/([^/]+)\/?$/)) { - return `${urlObj.origin}${urlObj.pathname.replace("/embed", "/d")}#cell-*`; - } - return; - } - }, - { - type: "desmos", - title: "Desmos", - hostnames: ["desmos.com"], - width: 700, - height: 450, - doesResize: true, - toEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.hostname === "www.desmos.com" && urlObj.pathname.match(/^\/calculator\/([^/]+)\/?$/) && urlObj.search === "" && urlObj.hash === "") { - return `${url}?embed`; - } - return; - }, - fromEmbedUrl: (url) => { - const urlObj = safeParseUrl(url); - if (urlObj && urlObj.hostname === "www.desmos.com" && urlObj.pathname.match(/^\/calculator\/([^/]+)\/?$/) && urlObj.search === "?embed" && urlObj.hash === "") { - return url.replace("?embed", ""); - } - return; - } - } -]; -var embedShapePermissionDefaults = { - "allow-downloads-without-user-activation": false, - "allow-downloads": false, - "allow-modals": false, - "allow-orientation-lock": false, - "allow-pointer-lock": false, - "allow-popups": true, - "allow-popups-to-escape-sandbox": false, - "allow-presentation": false, - "allow-storage-access-by-user-activation": false, - "allow-top-navigation": false, - "allow-top-navigation-by-user-activation": false, - "allow-scripts": true, - "allow-same-origin": true, - "allow-forms": true -}; -var embedShapeProps = { - w: validation_exports.nonZeroNumber, - h: validation_exports.nonZeroNumber, - url: validation_exports.string -}; -var Versions6 = createShapePropsMigrationIds("embed", { - GenOriginalUrlInEmbed: 1, - RemoveDoesResize: 2, - RemoveTmpOldUrl: 3, - RemovePermissionOverrides: 4 -}); -var embedShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions6.GenOriginalUrlInEmbed, - up: (props) => { - try { - const url = props.url; - const host = new URL(url).host.replace("www.", ""); - let originalUrl; - for (const localEmbedDef of EMBED_DEFINITIONS) { - if (localEmbedDef.hostnames.includes(host)) { - try { - originalUrl = localEmbedDef.fromEmbedUrl(url); - } catch (err) { - console.warn(err); - } - } - } - props.tmpOldUrl = props.url; - props.url = originalUrl ?? ""; - } catch (e) { - props.url = ""; - props.tmpOldUrl = props.url; - } - }, - down: "retired" - }, - { - id: Versions6.RemoveDoesResize, - up: (props) => { - delete props.doesResize; - }, - down: "retired" - }, - { - id: Versions6.RemoveTmpOldUrl, - up: (props) => { - delete props.tmpOldUrl; - }, - down: "retired" - }, - { - id: Versions6.RemovePermissionOverrides, - up: (props) => { - delete props.overridePermissions; - }, - down: "retired" - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLFrameShape.mjs -var frameShapeProps = { - w: validation_exports.nonZeroNumber, - h: validation_exports.nonZeroNumber, - name: validation_exports.string -}; -var frameShapeMigrations = createShapePropsMigrationSequence({ - sequence: [] -}); - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLHorizontalAlignStyle.mjs -var DefaultHorizontalAlignStyle = StyleProp.defineEnum("tldraw:horizontalAlign", { - defaultValue: "middle", - values: ["start", "middle", "end", "start-legacy", "end-legacy", "middle-legacy"] -}); - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLVerticalAlignStyle.mjs -var DefaultVerticalAlignStyle = StyleProp.defineEnum("tldraw:verticalAlign", { - defaultValue: "middle", - values: ["start", "middle", "end"] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLGeoShape.mjs -var GeoShapeGeoStyle = StyleProp.defineEnum("tldraw:geo", { - defaultValue: "rectangle", - values: [ - "cloud", - "rectangle", - "ellipse", - "triangle", - "diamond", - "pentagon", - "hexagon", - "octagon", - "star", - "rhombus", - "rhombus-2", - "oval", - "trapezoid", - "arrow-right", - "arrow-left", - "arrow-up", - "arrow-down", - "x-box", - "check-box", - "heart" - ] -}); -var geoShapeProps = { - geo: GeoShapeGeoStyle, - labelColor: DefaultLabelColorStyle, - color: DefaultColorStyle, - fill: DefaultFillStyle, - dash: DefaultDashStyle, - size: DefaultSizeStyle, - font: DefaultFontStyle, - align: DefaultHorizontalAlignStyle, - verticalAlign: DefaultVerticalAlignStyle, - url: validation_exports.linkUrl, - w: validation_exports.nonZeroNumber, - h: validation_exports.nonZeroNumber, - growY: validation_exports.positiveNumber, - text: validation_exports.string, - scale: validation_exports.nonZeroNumber -}; -var geoShapeVersions = createShapePropsMigrationIds("geo", { - AddUrlProp: 1, - AddLabelColor: 2, - RemoveJustify: 3, - AddCheckBox: 4, - AddVerticalAlign: 5, - MigrateLegacyAlign: 6, - AddCloud: 7, - MakeUrlsValid: 8, - AddScale: 9 -}); -var geoShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: geoShapeVersions.AddUrlProp, - up: (props) => { - props.url = ""; - }, - down: "retired" - }, - { - id: geoShapeVersions.AddLabelColor, - up: (props) => { - props.labelColor = "black"; - }, - down: "retired" - }, - { - id: geoShapeVersions.RemoveJustify, - up: (props) => { - if (props.align === "justify") { - props.align = "start"; - } - }, - down: "retired" - }, - { - id: geoShapeVersions.AddCheckBox, - up: (_props) => { - }, - down: "retired" - }, - { - id: geoShapeVersions.AddVerticalAlign, - up: (props) => { - props.verticalAlign = "middle"; - }, - down: "retired" - }, - { - id: geoShapeVersions.MigrateLegacyAlign, - up: (props) => { - let newAlign; - switch (props.align) { - case "start": - newAlign = "start-legacy"; - break; - case "end": - newAlign = "end-legacy"; - break; - default: - newAlign = "middle-legacy"; - break; - } - props.align = newAlign; - }, - down: "retired" - }, - { - id: geoShapeVersions.AddCloud, - up: (_props) => { - }, - down: "retired" - }, - { - id: geoShapeVersions.MakeUrlsValid, - up: (props) => { - if (!validation_exports.linkUrl.isValid(props.url)) { - props.url = ""; - } - }, - down: (_props) => { - } - }, - { - id: geoShapeVersions.AddScale, - up: (props) => { - props.scale = 1; - }, - down: (props) => { - delete props.scale; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLGroupShape.mjs -var groupShapeProps = {}; -var groupShapeMigrations = createShapePropsMigrationSequence({ sequence: [] }); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLHighlightShape.mjs -var highlightShapeProps = { - color: DefaultColorStyle, - size: DefaultSizeStyle, - segments: validation_exports.arrayOf(DrawShapeSegment), - isComplete: validation_exports.boolean, - isPen: validation_exports.boolean, - scale: validation_exports.nonZeroNumber -}; -var Versions7 = createShapePropsMigrationIds("highlight", { - AddScale: 1 -}); -var highlightShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions7.AddScale, - up: (props) => { - props.scale = 1; - }, - down: (props) => { - delete props.scale; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLImageShape.mjs -var ImageShapeCrop = validation_exports.object({ - topLeft: vecModelValidator, - bottomRight: vecModelValidator -}); -var imageShapeProps = { - w: validation_exports.nonZeroNumber, - h: validation_exports.nonZeroNumber, - playing: validation_exports.boolean, - url: validation_exports.linkUrl, - assetId: assetIdValidator.nullable(), - crop: ImageShapeCrop.nullable(), - flipX: validation_exports.boolean, - flipY: validation_exports.boolean -}; -var Versions8 = createShapePropsMigrationIds("image", { - AddUrlProp: 1, - AddCropProp: 2, - MakeUrlsValid: 3, - AddFlipProps: 4 -}); -var imageShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions8.AddUrlProp, - up: (props) => { - props.url = ""; - }, - down: "retired" - }, - { - id: Versions8.AddCropProp, - up: (props) => { - props.crop = null; - }, - down: (props) => { - delete props.crop; - } - }, - { - id: Versions8.MakeUrlsValid, - up: (props) => { - if (!validation_exports.linkUrl.isValid(props.url)) { - props.url = ""; - } - }, - down: (_props) => { - } - }, - { - id: Versions8.AddFlipProps, - up: (props) => { - props.flipX = false; - props.flipY = false; - }, - down: (props) => { - delete props.flipX; - delete props.flipY; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLLineShape.mjs -var LineShapeSplineStyle = StyleProp.defineEnum("tldraw:spline", { - defaultValue: "line", - values: ["cubic", "line"] -}); -var lineShapePointValidator = validation_exports.object({ - id: validation_exports.string, - index: validation_exports.indexKey, - x: validation_exports.number, - y: validation_exports.number -}); -var lineShapeProps = { - color: DefaultColorStyle, - dash: DefaultDashStyle, - size: DefaultSizeStyle, - spline: LineShapeSplineStyle, - points: validation_exports.dict(validation_exports.string, lineShapePointValidator), - scale: validation_exports.nonZeroNumber -}; -var lineShapeVersions = createShapePropsMigrationIds("line", { - AddSnapHandles: 1, - RemoveExtraHandleProps: 2, - HandlesToPoints: 3, - PointIndexIds: 4, - AddScale: 5 -}); -var lineShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: lineShapeVersions.AddSnapHandles, - up: (props) => { - for (const handle of Object.values(props.handles)) { - ; - handle.canSnap = true; - } - }, - down: "retired" - }, - { - id: lineShapeVersions.RemoveExtraHandleProps, - up: (props) => { - props.handles = objectMapFromEntries(Object.values(props.handles).map((handle) => [ - handle.index, - { - x: handle.x, - y: handle.y - } - ])); - }, - down: (props) => { - const handles = Object.entries(props.handles).map(([index2, handle]) => ({ index: index2, ...handle })).sort(sortByIndex); - props.handles = Object.fromEntries(handles.map((handle, i) => { - const id = i === 0 ? "start" : i === handles.length - 1 ? "end" : `handle:${handle.index}`; - return [ - id, - { - id, - type: "vertex", - canBind: false, - canSnap: true, - index: handle.index, - x: handle.x, - y: handle.y - } - ]; - })); - } - }, - { - id: lineShapeVersions.HandlesToPoints, - up: (props) => { - const sortedHandles = Object.entries(props.handles).map(([index2, { x, y }]) => ({ x, y, index: index2 })).sort(sortByIndex); - props.points = sortedHandles.map(({ x, y }) => ({ x, y })); - delete props.handles; - }, - down: (props) => { - const indices = getIndices(props.points.length); - props.handles = Object.fromEntries(props.points.map((handle, i) => { - const index2 = indices[i]; - return [ - index2, - { - x: handle.x, - y: handle.y - } - ]; - })); - delete props.points; - } - }, - { - id: lineShapeVersions.PointIndexIds, - up: (props) => { - const indices = getIndices(props.points.length); - props.points = Object.fromEntries(props.points.map((point, i) => { - const id = indices[i]; - return [ - id, - { - id, - index: id, - x: point.x, - y: point.y - } - ]; - })); - }, - down: (props) => { - const sortedHandles = Object.values(props.points).sort(sortByIndex); - props.points = sortedHandles.map(({ x, y }) => ({ x, y })); - } - }, - { - id: lineShapeVersions.AddScale, - up: (props) => { - props.scale = 1; - }, - down: (props) => { - delete props.scale; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLNoteShape.mjs -var noteShapeProps = { - color: DefaultColorStyle, - size: DefaultSizeStyle, - font: DefaultFontStyle, - fontSizeAdjustment: validation_exports.positiveNumber, - align: DefaultHorizontalAlignStyle, - verticalAlign: DefaultVerticalAlignStyle, - growY: validation_exports.positiveNumber, - url: validation_exports.linkUrl, - text: validation_exports.string, - scale: validation_exports.nonZeroNumber -}; -var Versions9 = createShapePropsMigrationIds("note", { - AddUrlProp: 1, - RemoveJustify: 2, - MigrateLegacyAlign: 3, - AddVerticalAlign: 4, - MakeUrlsValid: 5, - AddFontSizeAdjustment: 6, - AddScale: 7 -}); -var noteShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions9.AddUrlProp, - up: (props) => { - props.url = ""; - }, - down: "retired" - }, - { - id: Versions9.RemoveJustify, - up: (props) => { - if (props.align === "justify") { - props.align = "start"; - } - }, - down: "retired" - }, - { - id: Versions9.MigrateLegacyAlign, - up: (props) => { - switch (props.align) { - case "start": - props.align = "start-legacy"; - return; - case "end": - props.align = "end-legacy"; - return; - default: - props.align = "middle-legacy"; - return; - } - }, - down: "retired" - }, - { - id: Versions9.AddVerticalAlign, - up: (props) => { - props.verticalAlign = "middle"; - }, - down: "retired" - }, - { - id: Versions9.MakeUrlsValid, - up: (props) => { - if (!validation_exports.linkUrl.isValid(props.url)) { - props.url = ""; - } - }, - down: (_props) => { - } - }, - { - id: Versions9.AddFontSizeAdjustment, - up: (props) => { - props.fontSizeAdjustment = 0; - }, - down: (props) => { - delete props.fontSizeAdjustment; - } - }, - { - id: Versions9.AddScale, - up: (props) => { - props.scale = 1; - }, - down: (props) => { - delete props.scale; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/styles/TLTextAlignStyle.mjs -var DefaultTextAlignStyle = StyleProp.defineEnum("tldraw:textAlign", { - defaultValue: "start", - values: ["start", "middle", "end"] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLTextShape.mjs -var textShapeProps = { - color: DefaultColorStyle, - size: DefaultSizeStyle, - font: DefaultFontStyle, - textAlign: DefaultTextAlignStyle, - w: validation_exports.nonZeroNumber, - text: validation_exports.string, - scale: validation_exports.nonZeroNumber, - autoSize: validation_exports.boolean -}; -var Versions10 = createShapePropsMigrationIds("text", { - RemoveJustify: 1, - AddTextAlign: 2 -}); -var textShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions10.RemoveJustify, - up: (props) => { - if (props.align === "justify") { - props.align = "start"; - } - }, - down: "retired" - }, - { - id: Versions10.AddTextAlign, - up: (props) => { - props.textAlign = props.align; - delete props.align; - }, - down: (props) => { - props.align = props.textAlign; - delete props.textAlign; - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/shapes/TLVideoShape.mjs -var videoShapeProps = { - w: validation_exports.nonZeroNumber, - h: validation_exports.nonZeroNumber, - time: validation_exports.number, - playing: validation_exports.boolean, - url: validation_exports.linkUrl, - assetId: assetIdValidator.nullable() -}; -var Versions11 = createShapePropsMigrationIds("video", { - AddUrlProp: 1, - MakeUrlsValid: 2 -}); -var videoShapeMigrations = createShapePropsMigrationSequence({ - sequence: [ - { - id: Versions11.AddUrlProp, - up: (props) => { - props.url = ""; - }, - down: "retired" - }, - { - id: Versions11.MakeUrlsValid, - up: (props) => { - if (!validation_exports.linkUrl.isValid(props.url)) { - props.url = ""; - } - }, - down: (_props) => { - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/store-migrations.mjs -var Versions12 = createMigrationIds("com.tldraw.store", { - RemoveCodeAndIconShapeTypes: 1, - AddInstancePresenceType: 2, - RemoveTLUserAndPresenceAndAddPointer: 3, - RemoveUserDocument: 4 -}); -var storeMigrations = createMigrationSequence({ - sequenceId: "com.tldraw.store", - retroactive: false, - sequence: [ - { - id: Versions12.RemoveCodeAndIconShapeTypes, - scope: "store", - up: (store) => { - for (const [id, record] of objectMapEntries(store)) { - if (record.typeName === "shape" && (record.type === "icon" || record.type === "code")) { - delete store[id]; - } - } - } - }, - { - id: Versions12.AddInstancePresenceType, - scope: "store", - up(_store) { - } - }, - { - id: Versions12.RemoveTLUserAndPresenceAndAddPointer, - scope: "store", - up: (store) => { - for (const [id, record] of objectMapEntries(store)) { - if (record.typeName.match(/^(user|user_presence)$/)) { - delete store[id]; - } - } - } - }, - { - id: Versions12.RemoveUserDocument, - scope: "store", - up: (store) => { - for (const [id, record] of objectMapEntries(store)) { - if (record.typeName.match("user_document")) { - delete store[id]; - } - } - } - } - ] -}); - -// node_modules/@tldraw/tlschema/dist-esm/createTLSchema.mjs -var defaultShapeSchemas = { - arrow: { migrations: arrowShapeMigrations, props: arrowShapeProps }, - bookmark: { migrations: bookmarkShapeMigrations, props: bookmarkShapeProps }, - draw: { migrations: drawShapeMigrations, props: drawShapeProps }, - embed: { migrations: embedShapeMigrations, props: embedShapeProps }, - frame: { migrations: frameShapeMigrations, props: frameShapeProps }, - geo: { migrations: geoShapeMigrations, props: geoShapeProps }, - group: { migrations: groupShapeMigrations, props: groupShapeProps }, - highlight: { migrations: highlightShapeMigrations, props: highlightShapeProps }, - image: { migrations: imageShapeMigrations, props: imageShapeProps }, - line: { migrations: lineShapeMigrations, props: lineShapeProps }, - note: { migrations: noteShapeMigrations, props: noteShapeProps }, - text: { migrations: textShapeMigrations, props: textShapeProps }, - video: { migrations: videoShapeMigrations, props: videoShapeProps } -}; -var defaultBindingSchemas = { - arrow: { migrations: arrowBindingMigrations, props: arrowBindingProps } -}; -function createTLSchema({ - shapes = defaultShapeSchemas, - bindings = defaultBindingSchemas, - migrations -} = {}) { - const stylesById = /* @__PURE__ */ new Map(); - for (const shape of objectMapValues(shapes)) { - for (const style of getShapePropKeysByStyle(shape.props ?? {}).keys()) { - if (stylesById.has(style.id) && stylesById.get(style.id) !== style) { - throw new Error(`Multiple StyleProp instances with the same id: ${style.id}`); - } - stylesById.set(style.id, style); - } - } - const ShapeRecordType = createShapeRecordType(shapes); - const BindingRecordType = createBindingRecordType(bindings); - const InstanceRecordType = createInstanceRecordType(stylesById); - return StoreSchema.create({ - asset: AssetRecordType, - binding: BindingRecordType, - camera: CameraRecordType, - document: DocumentRecordType, - instance: InstanceRecordType, - instance_page_state: InstancePageStateRecordType, - page: PageRecordType, - instance_presence: InstancePresenceRecordType, - pointer: PointerRecordType, - shape: ShapeRecordType - }, { - migrations: [ - storeMigrations, - assetMigrations, - cameraMigrations, - documentMigrations, - instanceMigrations, - instancePageStateMigrations, - pageMigrations, - instancePresenceMigrations, - pointerMigrations, - rootShapeMigrations, - bookmarkAssetMigrations, - imageAssetMigrations, - videoAssetMigrations, - ...processPropsMigrations("shape", shapes), - ...processPropsMigrations("binding", bindings), - ...migrations ?? [] - ], - onValidationFailure, - createIntegrityChecker - }); -} - -// node_modules/@tldraw/tlschema/dist-esm/translations/languages.mjs -var LANGUAGES = [ - { locale: "id", label: "Bahasa Indonesia" }, - { locale: "ca", label: "Catal\xE0" }, - { locale: "cs", label: "\u010Ce\u0161tina" }, - { locale: "da", label: "Danish" }, - { locale: "de", label: "Deutsch" }, - { locale: "en", label: "English" }, - { locale: "es", label: "Espa\xF1ol" }, - { locale: "fr", label: "Fran\xE7ais" }, - { locale: "gl", label: "Galego" }, - { locale: "hr", label: "Hrvatski" }, - { locale: "it", label: "Italiano" }, - { locale: "hu", label: "Magyar" }, - { locale: "no", label: "Norwegian" }, - { locale: "pl", label: "Polski" }, - { locale: "pt-br", label: "Portugu\xEAs - Brasil" }, - { locale: "pt-pt", label: "Portugu\xEAs - Europeu" }, - { locale: "ro", label: "Rom\xE2n\u0103" }, - { locale: "ru", label: "Russian" }, - { locale: "sl", label: "Sloven\u0161\u010Dina" }, - { locale: "fi", label: "Suomi" }, - { locale: "sv", label: "Svenska" }, - { locale: "vi", label: "Ti\u1EBFng Vi\u1EC7t" }, - { locale: "tr", label: "T\xFCrk\xE7e" }, - { locale: "uk", label: "Ukrainian" }, - { locale: "he", label: "\u05E2\u05D1\u05E8\u05D9\u05EA" }, - { locale: "ar", label: "\u0639\u0631\u0628\u064A" }, - { locale: "fa", label: "\u0641\u0627\u0631\u0633\u06CC" }, - { locale: "ku", label: "\u06A9\u0648\u0631\u062F\u06CC" }, - { locale: "ne", label: "\u0928\u0947\u092A\u093E\u0932\u0940" }, - { locale: "hi-in", label: "\u0939\u093F\u0928\u094D\u0926\u0940" }, - { locale: "te", label: "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41" }, - { locale: "th", label: "\u0E20\u0E32\u0E29\u0E32\u0E44\u0E17\u0E22" }, - { locale: "my", label: "\u1019\u103C\u1014\u103A\u1019\u102C\u1005\u102C" }, - { locale: "ko-kr", label: "\uD55C\uAD6D\uC5B4" }, - { locale: "ja", label: "\u65E5\u672C\u8A9E" }, - { locale: "zh-cn", label: "\u7B80\u4F53\u4E2D\u6587" }, - { locale: "zh-tw", label: "\u7E41\u9AD4\u4E2D\u6587 (\u53F0\u7063)" } -]; - -// node_modules/@tldraw/tlschema/dist-esm/translations/translations.mjs -function getDefaultTranslationLocale() { - const locales = typeof window !== "undefined" ? window.navigator.languages ?? ["en"] : ["en"]; - return _getDefaultTranslationLocale(locales); -} -function _getDefaultTranslationLocale(locales) { - for (const locale of locales) { - const supportedLocale = getSupportedLocale(locale); - if (supportedLocale) { - return supportedLocale; - } - } - return "en"; -} -var DEFAULT_LOCALE_REGIONS = { - zh: "zh-cn", - pt: "pt-br", - ko: "ko-kr", - hi: "hi-in" -}; -function getSupportedLocale(locale) { - const exactMatch = LANGUAGES.find((t2) => t2.locale === locale.toLowerCase()); - if (exactMatch) { - return exactMatch.locale; - } - const [language, region] = locale.split(/[-_]/).map((s) => s.toLowerCase()); - if (region) { - const languageMatch = LANGUAGES.find((t2) => t2.locale === language); - if (languageMatch) { - return languageMatch.locale; - } - } - if (language in DEFAULT_LOCALE_REGIONS) { - return DEFAULT_LOCALE_REGIONS[language]; - } - return null; -} - -// node_modules/@tldraw/state-react/dist-esm/lib/track.mjs -var import_react2 = __toESM(require_react(), 1); - -// node_modules/@tldraw/state-react/dist-esm/lib/useStateTracking.mjs -var import_react = __toESM(require_react(), 1); -function useStateTracking(name, render) { - const renderRef = import_react.default.useRef(render); - renderRef.current = render; - const [scheduler, subscribe, getSnapshot2] = import_react.default.useMemo(() => { - let scheduleUpdate = null; - const subscribe2 = (cb) => { - scheduleUpdate = cb; - return () => { - scheduleUpdate = null; - }; - }; - const scheduler2 = new EffectScheduler(`useStateTracking(${name})`, () => renderRef.current?.(), { - scheduleEffect() { - scheduleUpdate?.(); - } - }); - const getSnapshot22 = () => scheduler2.scheduleCount; - return [scheduler2, subscribe2, getSnapshot22]; - }, [name]); - import_react.default.useSyncExternalStore(subscribe, getSnapshot2, getSnapshot2); - import_react.default.useEffect(() => { - scheduler.attach(); - scheduler.maybeScheduleEffect(); - return () => { - scheduler.detach(); - }; - }, [scheduler]); - return scheduler.execute(); -} - -// node_modules/@tldraw/state-react/dist-esm/lib/track.mjs -var ProxyHandlers = { - apply(Component2, thisArg, argumentsList) { - return useStateTracking(Component2.displayName ?? Component2.name ?? "tracked(???)", () => Component2.apply(thisArg, argumentsList)); - } -}; -var ReactMemoSymbol = Symbol.for("react.memo"); -var ReactForwardRefSymbol = Symbol.for("react.forward_ref"); -function track(baseComponent) { - let compare = null; - const $$typeof = baseComponent["$$typeof"]; - if ($$typeof === ReactMemoSymbol) { - baseComponent = baseComponent.type; - compare = baseComponent.compare; - } - if ($$typeof === ReactForwardRefSymbol) { - return (0, import_react2.memo)((0, import_react2.forwardRef)(new Proxy(baseComponent.render, ProxyHandlers))); - } - return (0, import_react2.memo)(new Proxy(baseComponent, ProxyHandlers), compare); -} - -// node_modules/@tldraw/state-react/dist-esm/lib/useAtom.mjs -var import_react3 = __toESM(require_react(), 1); - -// node_modules/@tldraw/state-react/dist-esm/lib/useComputed.mjs -var import_react4 = __toESM(require_react(), 1); -function useComputed() { - const name = arguments[0]; - const compute = arguments[1]; - const opts = arguments.length === 3 ? void 0 : arguments[2]; - const deps = arguments.length === 3 ? arguments[2] : arguments[3]; - return (0, import_react4.useMemo)(() => computed(`useComputed(${name})`, compute, opts), deps); -} - -// node_modules/@tldraw/state-react/dist-esm/lib/useQuickReactor.mjs -var import_react5 = __toESM(require_react(), 1); -function useQuickReactor(name, reactFn, deps = EMPTY_ARRAY) { - (0, import_react5.useEffect)(() => { - const scheduler = new EffectScheduler(name, reactFn); - scheduler.attach(); - scheduler.execute(); - return () => { - scheduler.detach(); - }; - }, deps); -} - -// node_modules/@tldraw/state-react/dist-esm/lib/useReactor.mjs -var import_react6 = __toESM(require_react(), 1); - -// node_modules/@tldraw/state-react/dist-esm/lib/useValue.mjs -var import_react7 = __toESM(require_react(), 1); -function useValue() { - const args = arguments; - const deps = args.length === 3 ? args[2] : [args[0]]; - const name = args.length === 3 ? args[0] : `useValue(${args[0].name})`; - const isInRender = (0, import_react7.useRef)(true); - isInRender.current = true; - const $val = (0, import_react7.useMemo)(() => { - if (args.length === 1) { - return args[0]; - } - return computed(name, () => { - if (isInRender.current) { - return args[1](); - } else { - try { - return args[1](); - } catch { - return {}; - } - } - }); - }, deps); - try { - const { subscribe, getSnapshot: getSnapshot2 } = (0, import_react7.useMemo)(() => { - return { - subscribe: (listen) => { - return react(`useValue(${name})`, () => { - $val.get(); - listen(); - }); - }, - getSnapshot: () => $val.get() - }; - }, [$val]); - return (0, import_react7.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2); - } finally { - isInRender.current = false; - } -} - -// node_modules/@tldraw/editor/dist-esm/lib/TldrawEditor.mjs -var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); -var import_react42 = __toESM(require_react(), 1); -var import_classnames11 = __toESM(require_classnames(), 1); - -// node_modules/@tldraw/editor/dist-esm/version.mjs -var version = "2.4.3"; -var publishDates = { - major: "2024-06-28T10:56:07.893Z", - minor: "2024-07-22T16:42:50.301Z", - patch: "2024-07-31T13:08:03.152Z" -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/ErrorBoundary.mjs -var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); -var React2 = __toESM(require_react(), 1); -var initialState = { error: null }; -var ErrorBoundary = class extends React2.Component { - constructor() { - super(...arguments); - __publicField(this, "state", initialState); - } - static getDerivedStateFromError(error3) { - return { error: error3 }; - } - componentDidCatch(error3) { - this.props.onError?.(error3); - } - render() { - const { error: error3 } = this.state; - if (error3 !== null) { - const { fallback: Fallback } = this.props; - return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fallback, { error: error3 }); - } - return this.props.children; - } -}; -function OptionalErrorBoundary({ - children, - fallback, - ...props -}) { - if (fallback === null) { - return children; - } - return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, { fallback, ...props, children }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs -var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); -var import_classnames9 = __toESM(require_classnames(), 1); -var import_react31 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useEditor.mjs -var import_react8 = __toESM(require_react(), 1); -var EditorContext = (0, import_react8.createContext)(null); -function useEditor() { - const editor = import_react8.default.useContext(EditorContext); - if (!editor) { - throw new Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components"); - } - return editor; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useEditorComponents.mjs -var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); -var import_react30 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultBackground.mjs -var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); -function DefaultBackground() { - return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tl-background" }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultBrush.mjs -var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); -var import_react10 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useTransform.mjs -var import_react9 = __toESM(require_react(), 1); -function useTransform(ref, x, y, scale, rotate, additionalOffset) { - (0, import_react9.useLayoutEffect)(() => { - const elm = ref.current; - if (!elm) - return; - if (x === void 0) - return; - let trans = `translate(${x}px, ${y}px)`; - if (scale !== void 0) { - trans += ` scale(${scale})`; - } - if (rotate !== void 0) { - trans += ` rotate(${rotate}rad)`; - } - if (additionalOffset) { - trans += ` translate(${additionalOffset.x}px, ${additionalOffset.y}px)`; - } - elm.style.transform = trans; - }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/easings.mjs -var EASINGS = { - linear: (t2) => t2, - easeInQuad: (t2) => t2 * t2, - easeOutQuad: (t2) => t2 * (2 - t2), - easeInOutQuad: (t2) => t2 < 0.5 ? 2 * t2 * t2 : -1 + (4 - 2 * t2) * t2, - easeInCubic: (t2) => t2 * t2 * t2, - easeOutCubic: (t2) => --t2 * t2 * t2 + 1, - easeInOutCubic: (t2) => t2 < 0.5 ? 4 * t2 * t2 * t2 : (t2 - 1) * (2 * t2 - 2) * (2 * t2 - 2) + 1, - easeInQuart: (t2) => t2 * t2 * t2 * t2, - easeOutQuart: (t2) => 1 - --t2 * t2 * t2 * t2, - easeInOutQuart: (t2) => t2 < 0.5 ? 8 * t2 * t2 * t2 * t2 : 1 - 8 * --t2 * t2 * t2 * t2, - easeInQuint: (t2) => t2 * t2 * t2 * t2 * t2, - easeOutQuint: (t2) => 1 + --t2 * t2 * t2 * t2 * t2, - easeInOutQuint: (t2) => t2 < 0.5 ? 16 * t2 * t2 * t2 * t2 * t2 : 1 + 16 * --t2 * t2 * t2 * t2 * t2, - easeInSine: (t2) => 1 - Math.cos(t2 * Math.PI / 2), - easeOutSine: (t2) => Math.sin(t2 * Math.PI / 2), - easeInOutSine: (t2) => -(Math.cos(Math.PI * t2) - 1) / 2, - easeInExpo: (t2) => t2 <= 0 ? 0 : Math.pow(2, 10 * t2 - 10), - easeOutExpo: (t2) => t2 >= 1 ? 1 : 1 - Math.pow(2, -10 * t2), - easeInOutExpo: (t2) => t2 <= 0 ? 0 : t2 >= 1 ? 1 : t2 < 0.5 ? Math.pow(2, 20 * t2 - 10) / 2 : (2 - Math.pow(2, -20 * t2 + 10)) / 2 -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/Vec.mjs -var Vec = class { - constructor(x = 0, y = 0, z = 1) { - this.x = x; - this.y = y; - this.z = z; - } - get pressure() { - return this.z; - } - set(x = this.x, y = this.y, z = this.z) { - this.x = x; - this.y = y; - this.z = z; - return this; - } - setTo({ x = 0, y = 0, z = 1 }) { - this.x = x; - this.y = y; - this.z = z; - return this; - } - rot(r) { - if (r === 0) - return this; - const { x, y } = this; - const s = Math.sin(r); - const c = Math.cos(r); - this.x = x * c - y * s; - this.y = x * s + y * c; - return this; - } - rotWith(C, r) { - if (r === 0) - return this; - const x = this.x - C.x; - const y = this.y - C.y; - const s = Math.sin(r); - const c = Math.cos(r); - this.x = C.x + (x * c - y * s); - this.y = C.y + (x * s + y * c); - return this; - } - clone() { - const { x, y, z } = this; - return new Vec(x, y, z); - } - sub(V) { - this.x -= V.x; - this.y -= V.y; - return this; - } - subXY(x, y) { - this.x -= x; - this.y -= y; - return this; - } - subScalar(n) { - this.x -= n; - this.y -= n; - return this; - } - add(V) { - this.x += V.x; - this.y += V.y; - return this; - } - addXY(x, y) { - this.x += x; - this.y += y; - return this; - } - addScalar(n) { - this.x += n; - this.y += n; - return this; - } - clamp(min3, max2) { - this.x = Math.max(this.x, min3); - this.y = Math.max(this.y, min3); - if (max2 !== void 0) { - this.x = Math.min(this.x, max2); - this.y = Math.min(this.y, max2); - } - return this; - } - div(t2) { - this.x /= t2; - this.y /= t2; - return this; - } - divV(V) { - this.x /= V.x; - this.y /= V.y; - return this; - } - mul(t2) { - this.x *= t2; - this.y *= t2; - return this; - } - mulV(V) { - this.x *= V.x; - this.y *= V.y; - return this; - } - abs() { - this.x = Math.abs(this.x); - this.y = Math.abs(this.y); - return this; - } - nudge(B, distance) { - const tan = Vec.Tan(B, this); - return this.add(tan.mul(distance)); - } - neg() { - this.x *= -1; - this.y *= -1; - return this; - } - cross(V) { - this.x = this.y * V.z - this.z * V.y; - this.y = this.z * V.x - this.x * V.z; - return this; - } - dpr(V) { - return Vec.Dpr(this, V); - } - cpr(V) { - return Vec.Cpr(this, V); - } - len2() { - return Vec.Len2(this); - } - len() { - return Vec.Len(this); - } - pry(V) { - return Vec.Pry(this, V); - } - per() { - const { x, y } = this; - this.x = y; - this.y = -x; - return this; - } - uni() { - return Vec.Uni(this); - } - tan(V) { - return Vec.Tan(this, V); - } - dist(V) { - return Vec.Dist(this, V); - } - distanceToLineSegment(A, B) { - return Vec.DistanceToLineSegment(A, B, this); - } - slope(B) { - return Vec.Slope(this, B); - } - snapToGrid(gridSize) { - this.x = Math.round(this.x / gridSize) * gridSize; - this.y = Math.round(this.y / gridSize) * gridSize; - return this; - } - angle(B) { - return Vec.Angle(this, B); - } - toAngle() { - return Vec.ToAngle(this); - } - lrp(B, t2) { - this.x = this.x + (B.x - this.x) * t2; - this.y = this.y + (B.y - this.y) * t2; - return this; - } - equals(B) { - return Vec.Equals(this, B); - } - equalsXY(x, y) { - return Vec.EqualsXY(this, x, y); - } - norm() { - const l = this.len(); - this.x = l === 0 ? 0 : this.x / l; - this.y = l === 0 ? 0 : this.y / l; - return this; - } - toFixed() { - return Vec.ToFixed(this); - } - toString() { - return Vec.ToString(Vec.ToFixed(this)); - } - toJson() { - return Vec.ToJson(this); - } - toArray() { - return Vec.ToArray(this); - } - static Add(A, B) { - return new Vec(A.x + B.x, A.y + B.y); - } - static AddXY(A, x, y) { - return new Vec(A.x + x, A.y + y); - } - static Sub(A, B) { - return new Vec(A.x - B.x, A.y - B.y); - } - static SubXY(A, x, y) { - return new Vec(A.x - x, A.y - y); - } - static AddScalar(A, n) { - return new Vec(A.x + n, A.y + n); - } - static SubScalar(A, n) { - return new Vec(A.x - n, A.y - n); - } - static Div(A, t2) { - return new Vec(A.x / t2, A.y / t2); - } - static Mul(A, t2) { - return new Vec(A.x * t2, A.y * t2); - } - static DivV(A, B) { - return new Vec(A.x / B.x, A.y / B.y); - } - static MulV(A, B) { - return new Vec(A.x * B.x, A.y * B.y); - } - static Neg(A) { - return new Vec(-A.x, -A.y); - } - static Per(A) { - return new Vec(A.y, -A.x); - } - static Abs(A) { - return new Vec(Math.abs(A.x), Math.abs(A.y)); - } - static Dist(A, B) { - return ((A.y - B.y) ** 2 + (A.x - B.x) ** 2) ** 0.5; - } - static DistMin(A, B, n) { - return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y) < n ** 2; - } - static Dist2(A, B) { - return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y); - } - static Dpr(A, B) { - return A.x * B.x + A.y * B.y; - } - static Cross(A, V) { - return new Vec(A.y * V.z - A.z * V.y, A.z * V.x - A.x * V.z); - } - static Cpr(A, B) { - return A.x * B.y - B.x * A.y; - } - static Len2(A) { - return A.x * A.x + A.y * A.y; - } - static Len(A) { - return (A.x * A.x + A.y * A.y) ** 0.5; - } - static Pry(A, B) { - return Vec.Dpr(A, B) / Vec.Len(B); - } - static Uni(A) { - return Vec.Div(A, Vec.Len(A)); - } - static Tan(A, B) { - return Vec.Uni(Vec.Sub(A, B)); - } - static Min(A, B) { - return new Vec(Math.min(A.x, B.x), Math.min(A.y, B.y)); - } - static Max(A, B) { - return new Vec(Math.max(A.x, B.x), Math.max(A.y, B.y)); - } - static From({ x, y, z = 1 }) { - return new Vec(x, y, z); - } - static FromArray(v) { - return new Vec(v[0], v[1]); - } - static Rot(A, r = 0) { - const s = Math.sin(r); - const c = Math.cos(r); - return new Vec(A.x * c - A.y * s, A.x * s + A.y * c); - } - static RotWith(A, C, r) { - const x = A.x - C.x; - const y = A.y - C.y; - const s = Math.sin(r); - const c = Math.cos(r); - return new Vec(C.x + (x * c - y * s), C.y + (x * s + y * c)); - } - static NearestPointOnLineThroughPoint(A, u, P) { - return Vec.Mul(u, Vec.Sub(P, A).pry(u)).add(A); - } - static NearestPointOnLineSegment(A, B, P, clamp4 = true) { - if (Vec.Equals(A, P)) - return Vec.From(P); - if (Vec.Equals(B, P)) - return Vec.From(P); - const u = Vec.Tan(B, A); - const C = Vec.Add(A, Vec.Mul(u, Vec.Sub(P, A).pry(u))); - if (clamp4) { - if (C.x < Math.min(A.x, B.x)) - return Vec.Cast(A.x < B.x ? A : B); - if (C.x > Math.max(A.x, B.x)) - return Vec.Cast(A.x > B.x ? A : B); - if (C.y < Math.min(A.y, B.y)) - return Vec.Cast(A.y < B.y ? A : B); - if (C.y > Math.max(A.y, B.y)) - return Vec.Cast(A.y > B.y ? A : B); - } - return C; - } - static DistanceToLineThroughPoint(A, u, P) { - return Vec.Dist(P, Vec.NearestPointOnLineThroughPoint(A, u, P)); - } - static DistanceToLineSegment(A, B, P, clamp4 = true) { - return Vec.Dist(P, Vec.NearestPointOnLineSegment(A, B, P, clamp4)); - } - static Snap(A, step = 1) { - return new Vec(Math.round(A.x / step) * step, Math.round(A.y / step) * step); - } - static Cast(A) { - if (A instanceof Vec) - return A; - return Vec.From(A); - } - static Slope(A, B) { - if (A.x === B.y) - return NaN; - return (A.y - B.y) / (A.x - B.x); - } - static IsNaN(A) { - return isNaN(A.x) || isNaN(A.y); - } - static Angle(A, B) { - return Math.atan2(B.y - A.y, B.x - A.x); - } - static Lrp(A, B, t2) { - return Vec.Sub(B, A).mul(t2).add(A); - } - static Med(A, B) { - return new Vec((A.x + B.x) / 2, (A.y + B.y) / 2); - } - static Equals(A, B) { - return Math.abs(A.x - B.x) < 1e-4 && Math.abs(A.y - B.y) < 1e-4; - } - static EqualsXY(A, x, y) { - return A.x === x && A.y === y; - } - static Clockwise(A, B, C) { - return (C.x - A.x) * (B.y - A.y) - (B.x - A.x) * (C.y - A.y) < 0; - } - static Rescale(A, n) { - const l = Vec.Len(A); - return new Vec(n * A.x / l, n * A.y / l); - } - static ScaleWithOrigin(A, scale, origin) { - return Vec.Sub(A, origin).mul(scale).add(origin); - } - static ToFixed(A) { - return new Vec(toFixed(A.x), toFixed(A.y)); - } - static ToInt(A) { - return new Vec(parseInt(A.x.toFixed(0)), parseInt(A.y.toFixed(0)), parseInt((A.z ?? 0).toFixed(0))); - } - static ToCss(A) { - return `${A.x},${A.y}`; - } - static Nudge(A, B, distance) { - return Vec.Add(A, Vec.Tan(B, A).mul(distance)); - } - static ToString(A) { - return `${A.x}, ${A.y}`; - } - static ToAngle(A) { - let r = Math.atan2(A.y, A.x); - if (r < 0) - r += Math.PI * 2; - return r; - } - static FromAngle(r, length = 1) { - return new Vec(Math.cos(r) * length, Math.sin(r) * length); - } - static ToArray(A) { - return [A.x, A.y, A.z]; - } - static ToJson(A) { - const { x, y, z } = A; - return { x, y, z }; - } - static Average(arr) { - const len = arr.length; - const avg = new Vec(0, 0); - if (len === 0) { - return avg; - } - for (let i = 0; i < len; i++) { - avg.add(arr[i]); - } - return avg.div(len); - } - static Clamp(A, min3, max2) { - if (max2 === void 0) { - return new Vec(Math.min(Math.max(A.x, min3)), Math.min(Math.max(A.y, min3))); - } - return new Vec(Math.min(Math.max(A.x, min3), max2), Math.min(Math.max(A.y, min3), max2)); - } - static PointsBetween(A, B, steps = 6) { - const results = []; - for (let i = 0; i < steps; i++) { - const t2 = EASINGS.easeInQuad(i / (steps - 1)); - const point = Vec.Lrp(A, B, t2); - point.z = Math.min(1, 0.5 + Math.abs(0.5 - ease(t2)) * 0.65); - results.push(point); - } - return results; - } - static SnapToGrid(A, gridSize = 8) { - return new Vec(Math.round(A.x / gridSize) * gridSize, Math.round(A.y / gridSize) * gridSize); - } -}; -var ease = (t2) => t2 < 0.5 ? 2 * t2 * t2 : -1 + (4 - 2 * t2) * t2; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/utils.mjs -function precise(A) { - return `${toDomPrecision(A.x)},${toDomPrecision(A.y)} `; -} -function average(A, B) { - return `${toDomPrecision((A.x + B.x) / 2)},${toDomPrecision((A.y + B.y) / 2)} `; -} -var PI = Math.PI; -var HALF_PI = PI / 2; -var PI2 = PI * 2; -var SIN = Math.sin; -function clamp(n, min3, max2) { - return Math.max(min3, typeof max2 !== "undefined" ? Math.min(n, max2) : n); -} -function toPrecision(n, precision = 1e10) { - if (!n) - return 0; - return Math.round(n * precision) / precision; -} -function approximately(a, b, precision = 1e-6) { - return Math.abs(a - b) <= precision; -} -function perimeterOfEllipse(rx, ry) { - const h = Math.pow(rx - ry, 2) / Math.pow(rx + ry, 2); - return PI * (rx + ry) * (1 + 3 * h / (10 + Math.sqrt(4 - 3 * h))); -} -function canonicalizeRotation(a) { - a = a % PI2; - if (a < 0) { - a = a + PI2; - } else if (a === 0) { - a = 0; - } - return a; -} -function clockwiseAngleDist(a0, a1) { - a0 = canonicalizeRotation(a0); - a1 = canonicalizeRotation(a1); - if (a0 > a1) { - a1 += PI2; - } - return a1 - a0; -} -function counterClockwiseAngleDist(a0, a1) { - return PI2 - clockwiseAngleDist(a0, a1); -} -function shortAngleDist(a0, a1) { - const da = (a1 - a0) % PI2; - return 2 * da % PI2 - da; -} -function clampRadians(r) { - return (PI2 + r) % PI2; -} -function snapAngle(r, segments) { - const seg = PI2 / segments; - let ang = Math.floor((clampRadians(r) + seg / 2) / seg) * seg % PI2; - if (ang < PI) - ang += PI2; - if (ang > PI) - ang -= PI2; - return ang; -} -function areAnglesCompatible(a, b) { - return a === b || approximately(a % (Math.PI / 2) - b % (Math.PI / 2), 0); -} -function degreesToRadians(d) { - return d * PI / 180; -} -function radiansToDegrees(r) { - return r * 180 / PI; -} -function getPointOnCircle(center, r, a) { - return new Vec(center.x, center.y).add(Vec.FromAngle(a, r)); -} -function getPolygonVertices(width, height, sides2) { - const cx = width / 2; - const cy = height / 2; - const pointsOnPerimeter = []; - let minX = Infinity; - let maxX = -Infinity; - let minY = Infinity; - let maxY = -Infinity; - for (let i = 0; i < sides2; i++) { - const step = PI2 / sides2; - const t2 = -HALF_PI + i * step; - const x = cx + cx * Math.cos(t2); - const y = cy + cy * Math.sin(t2); - if (x < minX) - minX = x; - if (y < minY) - minY = y; - if (x > maxX) - maxX = x; - if (y > maxY) - maxY = y; - pointsOnPerimeter.push(new Vec(x, y)); - } - const w = maxX - minX; - const h = maxY - minY; - const dx = width - w; - const dy = height - h; - if (dx !== 0 || dy !== 0) { - for (let i = 0; i < pointsOnPerimeter.length; i++) { - const pt = pointsOnPerimeter[i]; - pt.x = (pt.x - minX) / w * width; - pt.y = (pt.y - minY) / h * height; - } - } - return pointsOnPerimeter; -} -function rangesOverlap(a0, a1, b0, b1) { - return a0 < b1 && b0 < a1; -} -function rangeIntersection(a0, a1, b0, b1) { - const min3 = Math.max(a0, b0); - const max2 = Math.min(a1, b1); - if (min3 <= max2) { - return [min3, max2]; - } - return null; -} -function cross(x, y, z) { - return (y.x - x.x) * (z.y - x.y) - (z.x - x.x) * (y.y - x.y); -} -function pointInPolygon(A, points) { - let windingNumber = 0; - let a; - let b; - for (let i = 0; i < points.length; i++) { - a = points[i]; - if (a.x === A.x && a.y === A.y) - return true; - b = points[(i + 1) % points.length]; - if (Vec.Dist(A, a) + Vec.Dist(A, b) === Vec.Dist(a, b)) - return true; - if (a.y <= A.y) { - if (b.y > A.y && cross(a, b, A) > 0) { - windingNumber += 1; - } - } else if (b.y <= A.y && cross(a, b, A) < 0) { - windingNumber -= 1; - } - } - return windingNumber !== 0; -} -function toDomPrecision(v) { - return Math.round(v * 1e4) / 1e4; -} -function toFixed(v) { - return Math.round(v * 100) / 100; -} -var isSafeFloat = (n) => { - return Math.abs(n) < Number.MAX_SAFE_INTEGER; -}; -function angleDistance(fromAngle, toAngle, direction) { - const dist = direction < 0 ? clockwiseAngleDist(fromAngle, toAngle) : counterClockwiseAngleDist(fromAngle, toAngle); - return dist; -} -function getPointInArcT(mAB, A, B, P) { - let mAP; - if (Math.abs(mAB) > PI) { - mAP = shortAngleDist(A, P); - const mPB = shortAngleDist(P, B); - if (Math.abs(mAP) < Math.abs(mPB)) { - return mAP / mAB; - } else { - return (mAB - mPB) / mAB; - } - } else { - mAP = shortAngleDist(A, P); - const t2 = mAP / mAB; - if (Math.sign(mAP) !== Math.sign(mAB)) { - return Math.abs(t2) > 0.5 ? 1 : 0; - } - return t2; - } -} -function getArcMeasure(A, B, sweepFlag, largeArcFlag) { - const m = 2 * ((B - A) % PI2) % PI2 - (B - A) % PI2; - if (!largeArcFlag) - return m; - return (PI2 - Math.abs(m)) * (sweepFlag ? 1 : -1); -} -function centerOfCircleFromThreePoints(a, b, c) { - const u = -2 * (a.x * (b.y - c.y) - a.y * (b.x - c.x) + b.x * c.y - c.x * b.y); - return new Vec(((a.x * a.x + a.y * a.y) * (c.y - b.y) + (b.x * b.x + b.y * b.y) * (a.y - c.y) + (c.x * c.x + c.y * c.y) * (b.y - a.y)) / u, ((a.x * a.x + a.y * a.y) * (b.x - c.x) + (b.x * b.x + b.y * b.y) * (c.x - a.x) + (c.x * c.x + c.y * c.y) * (a.x - b.x)) / u); -} -function getPointsOnArc(startPoint, endPoint, center, radius, numPoints) { - if (center === null) { - return [Vec.From(startPoint), Vec.From(endPoint)]; - } - const results = []; - const startAngle = Vec.Angle(center, startPoint); - const endAngle = Vec.Angle(center, endPoint); - const l = clockwiseAngleDist(startAngle, endAngle); - for (let i = 0; i < numPoints; i++) { - const t2 = i / (numPoints - 1); - const angle = startAngle + l * t2; - const point = getPointOnCircle(center, radius, angle); - results.push(point); - } - return results; -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultBrush.mjs -var DefaultBrush = ({ brush, color, opacity, className }) => { - const rSvg = (0, import_react10.useRef)(null); - useTransform(rSvg, brush.x, brush.y); - const w = toDomPrecision(Math.max(1, brush.w)); - const h = toDomPrecision(Math.max(1, brush.h)); - return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className: "tl-overlays__item", ref: rSvg, children: color ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("g", { className: "tl-brush", opacity, children: [ - /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { width: w, height: h, fill: color, opacity: 0.75 }), - /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { width: w, height: h, fill: "none", stroke: color, opacity: 0.1 }) - ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { className: `tl-brush tl-brush__default ${className}`, width: w, height: h }) }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultCanvas.mjs -var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); -var import_classnames = __toESM(require_classnames(), 1); -var import_react22 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useCanvasEvents.mjs -var import_react11 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/constants.mjs -var DEFAULT_CAMERA_OPTIONS = { - isLocked: false, - wheelBehavior: "pan", - panSpeed: 1, - zoomSpeed: 1, - zoomSteps: [0.1, 0.25, 0.5, 1, 2, 4, 8] -}; -var DEFAULT_ANIMATION_OPTIONS = { - duration: 0, - easing: EASINGS.easeInOutCubic -}; -var INTERNAL_POINTER_IDS = { - CAMERA_MOVE: -10 -}; -var SIDES = ["top", "right", "bottom", "left"]; -var LEFT_MOUSE_BUTTON = 0; -var RIGHT_MOUSE_BUTTON = 2; -var MIDDLE_MOUSE_BUTTON = 1; -var STYLUS_ERASER_BUTTON = 5; -var ZOOM_TO_FIT_PADDING = 128; - -// node_modules/@tldraw/editor/dist-esm/lib/utils/dom.mjs -function loopToHtmlElement(elm) { - if (elm instanceof HTMLElement) - return elm; - if (elm.parentElement) - return loopToHtmlElement(elm.parentElement); - else - throw Error("Could not find a parent element of an HTML type!"); -} -function preventDefault(event) { - event.preventDefault(); - if (debugFlags.logPreventDefaults.get()) { - console.warn("preventDefault called on event:", event); - } -} -function setPointerCapture(element, event) { - element.setPointerCapture(event.pointerId); - if (debugFlags.logPointerCaptures.get()) { - const trackingObj = pointerCaptureTrackingObject.get(); - trackingObj.set(element, (trackingObj.get(element) ?? 0) + 1); - console.warn("setPointerCapture called on element:", element, event); - } -} -function releasePointerCapture(element, event) { - if (!element.hasPointerCapture(event.pointerId)) { - return; - } - element.releasePointerCapture(event.pointerId); - if (debugFlags.logPointerCaptures.get()) { - const trackingObj = pointerCaptureTrackingObject.get(); - if (trackingObj.get(element) === 1) { - trackingObj.delete(element); - } else if (trackingObj.has(element)) { - trackingObj.set(element, trackingObj.get(element) - 1); - } else { - console.warn("Release without capture"); - } - console.warn("releasePointerCapture called on element:", element, event); - } -} -var stopEventPropagation = (e) => e.stopPropagation(); -var setStyleProperty = (elm, property, value) => { - if (!elm) - return; - elm.style.setProperty(property, value); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/utils/getPointerInfo.mjs -function getPointerInfo(e) { - ; - e.isKilled = true; - return { - point: { - x: e.clientX, - y: e.clientY, - z: e.pressure - }, - shiftKey: e.shiftKey, - altKey: e.altKey, - ctrlKey: e.metaKey || e.ctrlKey, - pointerId: e.pointerId, - button: e.button, - isPen: e.pointerType === "pen" - }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useCanvasEvents.mjs -function useCanvasEvents() { - const editor = useEditor(); - const events = (0, import_react11.useMemo)(function canvasEvents() { - let lastX, lastY; - function onPointerDown(e) { - if (e.isKilled) - return; - if (e.button === RIGHT_MOUSE_BUTTON) { - editor.dispatch({ - type: "pointer", - target: "canvas", - name: "right_click", - ...getPointerInfo(e) - }); - return; - } - if (e.button !== 0 && e.button !== 1 && e.button !== 5) - return; - setPointerCapture(e.currentTarget, e); - editor.dispatch({ - type: "pointer", - target: "canvas", - name: "pointer_down", - ...getPointerInfo(e) - }); - } - function onPointerMove(e) { - if (e.isKilled) - return; - if (e.clientX === lastX && e.clientY === lastY) - return; - lastX = e.clientX; - lastY = e.clientY; - editor.dispatch({ - type: "pointer", - target: "canvas", - name: "pointer_move", - ...getPointerInfo(e) - }); - } - function onPointerUp(e) { - if (e.isKilled) - return; - if (e.button !== 0 && e.button !== 1 && e.button !== 2 && e.button !== 5) - return; - lastX = e.clientX; - lastY = e.clientY; - releasePointerCapture(e.currentTarget, e); - editor.dispatch({ - type: "pointer", - target: "canvas", - name: "pointer_up", - ...getPointerInfo(e) - }); - } - function onPointerEnter(e) { - if (e.isKilled) - return; - if (editor.getInstanceState().isPenMode && e.pointerType !== "pen") - return; - const canHover = e.pointerType === "mouse" || e.pointerType === "pen"; - editor.updateInstanceState({ isHoveringCanvas: canHover ? true : null }); - } - function onPointerLeave(e) { - if (e.isKilled) - return; - if (editor.getInstanceState().isPenMode && e.pointerType !== "pen") - return; - const canHover = e.pointerType === "mouse" || e.pointerType === "pen"; - editor.updateInstanceState({ isHoveringCanvas: canHover ? false : null }); - } - function onTouchStart(e) { - ; - e.isKilled = true; - preventDefault(e); - } - function onTouchEnd(e) { - ; - e.isKilled = true; - if (!(e.target instanceof HTMLElement)) - return; - if (e.target.tagName !== "A" && e.target.tagName !== "TEXTAREA" && !(editor.getEditingShape() && e.target.className.includes("tl-text-content"))) { - preventDefault(e); - } - } - function onDragOver(e) { - preventDefault(e); - } - async function onDrop(e) { - preventDefault(e); - if (!e.dataTransfer?.files?.length) - return; - const files = Array.from(e.dataTransfer.files); - await editor.putExternalContent({ - type: "files", - files, - point: editor.screenToPage({ x: e.clientX, y: e.clientY }), - ignoreParent: false - }); - } - function onClick(e) { - stopEventPropagation(e); - } - return { - onPointerDown, - onPointerMove, - onPointerUp, - onPointerEnter, - onPointerLeave, - onDragOver, - onDrop, - onTouchStart, - onTouchEnd, - onClick - }; - }, [editor]); - return events; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useCoarsePointer.mjs -var import_react12 = __toESM(require_react(), 1); -function useCoarsePointer() { - const editor = useEditor(); - (0, import_react12.useEffect)(() => { - let isCoarse = editor.getInstanceState().isCoarsePointer; - const handlePointerDown = (e) => { - const isCoarseEvent = e.pointerType !== "mouse"; - if (isCoarse === isCoarseEvent) - return; - isCoarse = isCoarseEvent; - editor.updateInstanceState({ isCoarsePointer: isCoarseEvent }); - }; - window.addEventListener("pointerdown", handlePointerDown, { capture: true }); - const mql = window.matchMedia && window.matchMedia("(any-pointer: coarse)"); - const isForcedFinePointer = editor.environment.isFirefox && !editor.environment.isAndroid && !editor.environment.isIos; - const handleMediaQueryChange = () => { - const next = isForcedFinePointer ? false : mql.matches; - if (isCoarse !== next) - return; - isCoarse = next; - editor.updateInstanceState({ isCoarsePointer: next }); - }; - if (mql) { - mql.addEventListener("change", handleMediaQueryChange); - handleMediaQueryChange(); - } - return () => { - window.removeEventListener("pointerdown", handlePointerDown, { capture: true }); - if (mql) { - mql.removeEventListener("change", handleMediaQueryChange); - } - }; - }, [editor]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useContainer.mjs -var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); -var import_react13 = __toESM(require_react(), 1); -var ContainerContext = (0, import_react13.createContext)(null); -function ContainerProvider({ - container, - children -}) { - return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ContainerContext.Provider, { value: container, children }); -} -function useContainer() { - return assertExists((0, import_react13.useContext)(ContainerContext), "useContainer used outside of <Tldraw />"); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useDocumentEvents.mjs -var import_react14 = __toESM(require_react(), 1); -function useDocumentEvents() { - const editor = useEditor(); - const container = useContainer(); - const isAppFocused = useValue("isFocused", () => editor.getIsFocused(), [editor]); - (0, import_react14.useEffect)(() => { - if (typeof window === "undefined" || !("matchMedia" in window)) - return; - let remove2 = null; - const updatePixelRatio = () => { - if (remove2 != null) { - remove2(); - } - const mqString = `(resolution: ${window.devicePixelRatio}dppx)`; - const media = matchMedia(mqString); - const safariCb = (ev) => { - if (ev.type === "change") { - updatePixelRatio(); - } - }; - if (media.addEventListener) { - media.addEventListener("change", updatePixelRatio); - } else if (media.addListener) { - media.addListener(safariCb); - } - remove2 = () => { - if (media.removeEventListener) { - media.removeEventListener("change", updatePixelRatio); - } else if (media.removeListener) { - media.removeListener(safariCb); - } - }; - editor.updateInstanceState({ devicePixelRatio: window.devicePixelRatio }); - }; - updatePixelRatio(); - return () => { - remove2?.(); - }; - }, [editor]); - (0, import_react14.useEffect)(() => { - if (!isAppFocused) - return; - const handleKeyDown = (e) => { - if (e.altKey && (editor.isIn("zoom") || !editor.getPath().endsWith(".idle")) && !isFocusingInput()) { - preventDefault(e); - } - if (e.isKilled) - return; - e.isKilled = true; - switch (e.key) { - case "=": - case "-": - case "0": { - if (e.metaKey || e.ctrlKey) { - preventDefault(e); - return; - } - break; - } - case "Tab": { - if (isFocusingInput() || editor.getIsMenuOpen()) { - return; - } - break; - } - case ",": { - return; - } - case "Escape": { - if (editor.getEditingShape() || editor.getSelectedShapeIds().length > 0) { - e.preventDefault(); - } - if (editor.getOpenMenus().length > 0) - return; - if (!editor.inputs.keys.has("Escape")) { - editor.inputs.keys.add("Escape"); - editor.cancel(); - editor.focus(); - } - return; - } - default: { - if (isFocusingInput() || editor.getIsMenuOpen()) { - return; - } - } - } - const info2 = { - type: "keyboard", - name: e.repeat ? "key_repeat" : "key_down", - key: e.key, - code: e.code, - shiftKey: e.shiftKey, - altKey: e.altKey, - ctrlKey: e.metaKey || e.ctrlKey - }; - editor.dispatch(info2); - }; - const handleKeyUp = (e) => { - if (e.isKilled) - return; - e.isKilled = true; - if (isFocusingInput() || editor.getIsMenuOpen()) { - return; - } - if (e.key === ",") { - return; - } - const info2 = { - type: "keyboard", - name: "key_up", - key: e.key, - code: e.code, - shiftKey: e.shiftKey, - altKey: e.altKey, - ctrlKey: e.metaKey || e.ctrlKey - }; - editor.dispatch(info2); - }; - function handleTouchStart(e) { - if (container.contains(e.target)) { - const touchXPosition = e.touches[0].pageX; - const touchXRadius = e.touches[0].radiusX || 0; - if (touchXPosition - touchXRadius < 10 || touchXPosition + touchXRadius > editor.getViewportScreenBounds().width - 10) { - if (e.target?.tagName === "BUTTON") { - ; - e.target?.click(); - } - preventDefault(e); - } - } - } - const handleWheel = (e) => { - if (container.contains(e.target) && (e.ctrlKey || e.metaKey)) { - preventDefault(e); - } - }; - container.addEventListener("touchstart", handleTouchStart, { passive: false }); - container.addEventListener("wheel", handleWheel, { passive: false }); - document.addEventListener("gesturestart", preventDefault); - document.addEventListener("gesturechange", preventDefault); - document.addEventListener("gestureend", preventDefault); - container.addEventListener("keydown", handleKeyDown); - container.addEventListener("keyup", handleKeyUp); - return () => { - container.removeEventListener("touchstart", handleTouchStart); - container.removeEventListener("wheel", handleWheel); - document.removeEventListener("gesturestart", preventDefault); - document.removeEventListener("gesturechange", preventDefault); - document.removeEventListener("gestureend", preventDefault); - container.removeEventListener("keydown", handleKeyDown); - container.removeEventListener("keyup", handleKeyUp); - }; - }, [editor, container, isAppFocused]); -} -var INPUTS = ["input", "select", "button", "textarea"]; -function isFocusingInput() { - const { activeElement } = document; - if (activeElement && (activeElement.getAttribute("contenteditable") || INPUTS.indexOf(activeElement.tagName.toLowerCase()) > -1)) { - return true; - } - return false; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs -var import_react15 = __toESM(require_react(), 1); -var IGNORED_TAGS = ["textarea", "input"]; -function useFixSafariDoubleTapZoomPencilEvents(ref) { - const editor = useEditor(); - (0, import_react15.useEffect)(() => { - const elm = ref.current; - if (!elm) - return; - const handleEvent = (e) => { - if (e instanceof PointerEvent && e.pointerType === "pen") { - ; - e.isKilled = true; - const { target } = e; - if (IGNORED_TAGS.includes(target.tagName?.toLocaleLowerCase()) || editor.isIn("select.editing_shape")) { - return; - } - preventDefault(e); - } - }; - elm.addEventListener("touchstart", handleEvent); - elm.addEventListener("touchend", handleEvent); - return () => { - elm.removeEventListener("touchstart", handleEvent); - elm.removeEventListener("touchend", handleEvent); - }; - }, [editor, ref]); -} - -// node_modules/@use-gesture/react/dist/use-gesture-react.esm.js -var use_gesture_react_esm_exports = {}; -__export(use_gesture_react_esm_exports, { - createUseGesture: () => createUseGesture, - useDrag: () => useDrag, - useGesture: () => useGesture, - useHover: () => useHover, - useMove: () => useMove, - usePinch: () => usePinch, - useScroll: () => useScroll, - useWheel: () => useWheel -}); -var import_actions = __toESM(require_use_gesture_core_actions_cjs()); -__reExport(use_gesture_react_esm_exports, __toESM(require_use_gesture_core_actions_cjs())); -var import_react16 = __toESM(require_react()); -var import_core = __toESM(require_use_gesture_core_cjs()); -__reExport(use_gesture_react_esm_exports, __toESM(require_use_gesture_core_utils_cjs())); -__reExport(use_gesture_react_esm_exports, __toESM(require_use_gesture_core_types_cjs())); -function useRecognizers(handlers, config = {}, gestureKey, nativeHandlers) { - const ctrl = import_react16.default.useMemo(() => new import_core.Controller(handlers), []); - ctrl.applyHandlers(handlers, nativeHandlers); - ctrl.applyConfig(config, gestureKey); - import_react16.default.useEffect(ctrl.effect.bind(ctrl)); - import_react16.default.useEffect(() => { - return ctrl.clean.bind(ctrl); - }, []); - if (config.target === void 0) { - return ctrl.bind.bind(ctrl); - } - return void 0; -} -function useDrag(handler, config) { - (0, import_actions.registerAction)(import_actions.dragAction); - return useRecognizers({ - drag: handler - }, config || {}, "drag"); -} -function usePinch(handler, config) { - (0, import_actions.registerAction)(import_actions.pinchAction); - return useRecognizers({ - pinch: handler - }, config || {}, "pinch"); -} -function useWheel(handler, config) { - (0, import_actions.registerAction)(import_actions.wheelAction); - return useRecognizers({ - wheel: handler - }, config || {}, "wheel"); -} -function useScroll(handler, config) { - (0, import_actions.registerAction)(import_actions.scrollAction); - return useRecognizers({ - scroll: handler - }, config || {}, "scroll"); -} -function useMove(handler, config) { - (0, import_actions.registerAction)(import_actions.moveAction); - return useRecognizers({ - move: handler - }, config || {}, "move"); -} -function useHover(handler, config) { - (0, import_actions.registerAction)(import_actions.hoverAction); - return useRecognizers({ - hover: handler - }, config || {}, "hover"); -} -function createUseGesture(actions) { - actions.forEach(import_actions.registerAction); - return function useGesture3(_handlers2, _config) { - const { - handlers, - nativeHandlers, - config - } = (0, import_core.parseMergedHandlers)(_handlers2, _config || {}); - return useRecognizers(handlers, config, void 0, nativeHandlers); - }; -} -function useGesture(handlers, config) { - const hook = createUseGesture([import_actions.dragAction, import_actions.pinchAction, import_actions.scrollAction, import_actions.wheelAction, import_actions.moveAction, import_actions.hoverAction]); - return hook(handlers, config || {}); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useGestureEvents.mjs -var React5 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/normalizeWheel.mjs -var MAX_ZOOM_STEP = 10; -var IS_DARWIN = /Mac|iPod|iPhone|iPad/.test(typeof window === "undefined" ? "node" : window.navigator.platform); -function normalizeWheel(event) { - let { deltaY, deltaX } = event; - let deltaZ = 0; - if (event.ctrlKey || event.altKey || event.metaKey) { - deltaZ = (Math.abs(deltaY) > MAX_ZOOM_STEP ? MAX_ZOOM_STEP * Math.sign(deltaY) : deltaY) / 100; - } else { - if (event.shiftKey && !IS_DARWIN) { - deltaX = deltaY; - deltaY = 0; - } - } - return { x: -deltaX, y: -deltaY, z: -deltaZ }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useGestureEvents.mjs -var useGesture2 = createUseGesture([use_gesture_react_esm_exports.wheelAction, use_gesture_react_esm_exports.pinchAction]); -var lastWheelTime = void 0; -var isWheelEndEvent = (time2) => { - if (lastWheelTime === void 0) { - lastWheelTime = time2; - return false; - } - if (time2 - lastWheelTime > 120 && time2 - lastWheelTime < 160) { - lastWheelTime = time2; - return true; - } - lastWheelTime = time2; - return false; -}; -function useGestureEvents(ref) { - const editor = useEditor(); - const events = React5.useMemo(() => { - let pinchState = "not sure"; - const onWheel = ({ event }) => { - if (!editor.getInstanceState().isFocused) { - return; - } - pinchState = "not sure"; - if (isWheelEndEvent(Date.now())) { - return; - } - const editingShapeId = editor.getEditingShapeId(); - if (editingShapeId) { - const shape = editor.getShape(editingShapeId); - if (shape) { - const util = editor.getShapeUtil(shape); - if (util.canScroll(shape)) { - const bounds = editor.getShapePageBounds(editingShapeId); - if (bounds?.containsPoint(editor.inputs.currentPagePoint)) { - return; - } - } - } - } - preventDefault(event); - stopEventPropagation(event); - const delta = normalizeWheel(event); - if (delta.x === 0 && delta.y === 0) - return; - const info2 = { - type: "wheel", - name: "wheel", - delta, - point: new Vec(event.clientX, event.clientY), - shiftKey: event.shiftKey, - altKey: event.altKey, - ctrlKey: event.metaKey || event.ctrlKey - }; - editor.dispatch(info2); - }; - let initDistanceBetweenFingers = 1; - let initZoom = 1; - let currZoom = 1; - let currDistanceBetweenFingers = 0; - const initPointBetweenFingers = new Vec(); - const prevPointBetweenFingers = new Vec(); - const onPinchStart = (gesture) => { - const elm = ref.current; - pinchState = "not sure"; - const { event, origin, da } = gesture; - if (event instanceof WheelEvent) - return; - if (!(event.target === elm || elm?.contains(event.target))) - return; - prevPointBetweenFingers.x = origin[0]; - prevPointBetweenFingers.y = origin[1]; - initPointBetweenFingers.x = origin[0]; - initPointBetweenFingers.y = origin[1]; - initDistanceBetweenFingers = da[0]; - initZoom = editor.getZoomLevel(); - editor.dispatch({ - type: "pinch", - name: "pinch_start", - point: { x: origin[0], y: origin[1], z: editor.getZoomLevel() }, - delta: { x: 0, y: 0 }, - shiftKey: event.shiftKey, - altKey: event.altKey, - ctrlKey: event.metaKey || event.ctrlKey - }); - }; - const updatePinchState = (isSafariTrackpadPinch) => { - if (isSafariTrackpadPinch) { - pinchState = "zooming"; - } - if (pinchState === "zooming") { - return; - } - const touchDistance = Math.abs(currDistanceBetweenFingers - initDistanceBetweenFingers); - const originDistance = Vec.Dist(initPointBetweenFingers, prevPointBetweenFingers); - switch (pinchState) { - case "not sure": { - if (touchDistance > 24) { - pinchState = "zooming"; - } else if (originDistance > 16) { - pinchState = "panning"; - } - break; - } - case "panning": { - if (touchDistance > 64) { - pinchState = "zooming"; - } - break; - } - } - }; - const onPinch = (gesture) => { - const elm = ref.current; - const { event, origin, offset: offset4, da } = gesture; - if (event instanceof WheelEvent) - return; - if (!(event.target === elm || elm?.contains(event.target))) - return; - const isSafariTrackpadPinch = gesture.type === "gesturechange" || gesture.type === "gestureend"; - currDistanceBetweenFingers = da[0]; - const dx = origin[0] - prevPointBetweenFingers.x; - const dy = origin[1] - prevPointBetweenFingers.y; - prevPointBetweenFingers.x = origin[0]; - prevPointBetweenFingers.y = origin[1]; - updatePinchState(isSafariTrackpadPinch); - switch (pinchState) { - case "zooming": { - currZoom = offset4[0]; - editor.dispatch({ - type: "pinch", - name: "pinch", - point: { x: origin[0], y: origin[1], z: currZoom }, - delta: { x: dx, y: dy }, - shiftKey: event.shiftKey, - altKey: event.altKey, - ctrlKey: event.metaKey || event.ctrlKey - }); - break; - } - case "panning": { - editor.dispatch({ - type: "pinch", - name: "pinch", - point: { x: origin[0], y: origin[1], z: initZoom }, - delta: { x: dx, y: dy }, - shiftKey: event.shiftKey, - altKey: event.altKey, - ctrlKey: event.metaKey || event.ctrlKey - }); - break; - } - } - }; - const onPinchEnd = (gesture) => { - const elm = ref.current; - const { event, origin, offset: offset4 } = gesture; - if (event instanceof WheelEvent) - return; - if (!(event.target === elm || elm?.contains(event.target))) - return; - const scale = offset4[0]; - pinchState = "not sure"; - editor.timers.requestAnimationFrame(() => { - editor.dispatch({ - type: "pinch", - name: "pinch_end", - point: { x: origin[0], y: origin[1], z: scale }, - delta: { x: origin[0], y: origin[1] }, - shiftKey: event.shiftKey, - altKey: event.altKey, - ctrlKey: event.metaKey || event.ctrlKey - }); - }); - }; - return { - onWheel, - onPinchStart, - onPinchEnd, - onPinch - }; - }, [editor, ref]); - useGesture2(events, { - target: ref, - eventOptions: { passive: false }, - pinch: { - from: () => [editor.getZoomLevel(), 0], - scaleBounds: () => { - return { from: editor.getZoomLevel(), max: 8, min: 0.05 }; - } - } - }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useHandleEvents.mjs -var React6 = __toESM(require_react(), 1); -function getHandle(editor, id, handleId) { - const shape = editor.getShape(id); - const handles = editor.getShapeHandles(shape); - return { shape, handle: handles.find((h) => h.id === handleId) }; -} -function useHandleEvents(id, handleId) { - const editor = useEditor(); - return React6.useMemo(() => { - const onPointerDown = (e) => { - if (e.isKilled) - return; - const target = loopToHtmlElement(e.currentTarget); - setPointerCapture(target, e); - const { shape, handle } = getHandle(editor, id, handleId); - if (!handle) - return; - editor.dispatch({ - type: "pointer", - target: "handle", - handle, - shape, - name: "pointer_down", - ...getPointerInfo(e) - }); - }; - let lastX, lastY; - const onPointerMove = (e) => { - if (e.isKilled) - return; - if (e.clientX === lastX && e.clientY === lastY) - return; - lastX = e.clientX; - lastY = e.clientY; - const { shape, handle } = getHandle(editor, id, handleId); - if (!handle) - return; - editor.dispatch({ - type: "pointer", - target: "handle", - handle, - shape, - name: "pointer_move", - ...getPointerInfo(e) - }); - }; - const onPointerUp = (e) => { - if (e.isKilled) - return; - const target = loopToHtmlElement(e.currentTarget); - releasePointerCapture(target, e); - const { shape, handle } = getHandle(editor, id, handleId); - if (!handle) - return; - editor.dispatch({ - type: "pointer", - target: "handle", - handle, - shape, - name: "pointer_up", - ...getPointerInfo(e) - }); - }; - return { - onPointerDown, - onPointerMove, - onPointerUp - }; - }, [editor, id, handleId]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useScreenBounds.mjs -var import_react18 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/Box.mjs -var _Box = class { - constructor(x = 0, y = 0, w = 0, h = 0) { - __publicField(this, "x", 0); - __publicField(this, "y", 0); - __publicField(this, "w", 0); - __publicField(this, "h", 0); - this.x = x; - this.y = y; - this.w = w; - this.h = h; - } - get point() { - return new Vec(this.x, this.y); - } - set point(val) { - this.x = val.x; - this.y = val.y; - } - get minX() { - return this.x; - } - set minX(n) { - this.x = n; - } - get midX() { - return this.x + this.w / 2; - } - get maxX() { - return this.x + this.w; - } - get minY() { - return this.y; - } - set minY(n) { - this.y = n; - } - get midY() { - return this.y + this.h / 2; - } - get maxY() { - return this.y + this.h; - } - get width() { - return this.w; - } - set width(n) { - this.w = n; - } - get height() { - return this.h; - } - set height(n) { - this.h = n; - } - get aspectRatio() { - return this.width / this.height; - } - get center() { - return new Vec(this.midX, this.midY); - } - set center(v) { - this.minX = v.x - this.width / 2; - this.minY = v.y - this.height / 2; - } - get corners() { - return [ - new Vec(this.minX, this.minY), - new Vec(this.maxX, this.minY), - new Vec(this.maxX, this.maxY), - new Vec(this.minX, this.maxY) - ]; - } - get cornersAndCenter() { - return [ - new Vec(this.minX, this.minY), - new Vec(this.maxX, this.minY), - new Vec(this.maxX, this.maxY), - new Vec(this.minX, this.maxY), - this.center - ]; - } - get sides() { - const { corners } = this; - return [ - [corners[0], corners[1]], - [corners[1], corners[2]], - [corners[2], corners[3]], - [corners[3], corners[0]] - ]; - } - get size() { - return new Vec(this.w, this.h); - } - toFixed() { - this.x = toPrecision(this.x); - this.y = toPrecision(this.y); - this.w = toPrecision(this.w); - this.h = toPrecision(this.h); - return this; - } - setTo(B) { - this.x = B.x; - this.y = B.y; - this.w = B.w; - this.h = B.h; - return this; - } - set(x = 0, y = 0, w = 0, h = 0) { - this.x = x; - this.y = y; - this.w = w; - this.h = h; - return this; - } - expand(A) { - const minX = Math.min(this.minX, A.minX); - const minY = Math.min(this.minY, A.minY); - const maxX = Math.max(this.maxX, A.maxX); - const maxY = Math.max(this.maxY, A.maxY); - this.x = minX; - this.y = minY; - this.w = maxX - minX; - this.h = maxY - minY; - return this; - } - expandBy(n) { - this.x -= n; - this.y -= n; - this.w += n * 2; - this.h += n * 2; - return this; - } - scale(n) { - this.x /= n; - this.y /= n; - this.w /= n; - this.h /= n; - return this; - } - clone() { - const { x, y, w, h } = this; - return new _Box(x, y, w, h); - } - translate(delta) { - this.x += delta.x; - this.y += delta.y; - return this; - } - snapToGrid(size4) { - const minX = Math.round(this.minX / size4) * size4; - const minY = Math.round(this.minY / size4) * size4; - const maxX = Math.round(this.maxX / size4) * size4; - const maxY = Math.round(this.maxY / size4) * size4; - this.minX = minX; - this.minY = minY; - this.width = Math.max(1, maxX - minX); - this.height = Math.max(1, maxY - minY); - } - collides(B) { - return _Box.Collides(this, B); - } - contains(B) { - return _Box.Contains(this, B); - } - includes(B) { - return _Box.Includes(this, B); - } - containsPoint(V, margin = 0) { - return _Box.ContainsPoint(this, V, margin); - } - getHandlePoint(handle) { - switch (handle) { - case "top_left": - return new Vec(this.minX, this.minY); - case "top_right": - return new Vec(this.maxX, this.minY); - case "bottom_left": - return new Vec(this.minX, this.maxY); - case "bottom_right": - return new Vec(this.maxX, this.maxY); - case "top": - return new Vec(this.midX, this.minY); - case "right": - return new Vec(this.maxX, this.midY); - case "bottom": - return new Vec(this.midX, this.maxY); - case "left": - return new Vec(this.minX, this.midY); - } - } - toJson() { - return { x: this.minX, y: this.minY, w: this.w, h: this.h }; - } - resize(handle, dx, dy) { - const { minX: a0x, minY: a0y, maxX: a1x, maxY: a1y } = this; - let { minX: b0x, minY: b0y, maxX: b1x, maxY: b1y } = this; - switch (handle) { - case "left": - case "top_left": - case "bottom_left": { - b0x += dx; - break; - } - case "right": - case "top_right": - case "bottom_right": { - b1x += dx; - break; - } - } - switch (handle) { - case "top": - case "top_left": - case "top_right": { - b0y += dy; - break; - } - case "bottom": - case "bottom_left": - case "bottom_right": { - b1y += dy; - break; - } - } - const scaleX = (b1x - b0x) / (a1x - a0x); - const scaleY = (b1y - b0y) / (a1y - a0y); - const flipX = scaleX < 0; - const flipY = scaleY < 0; - if (flipX) { - const t2 = b1x; - b1x = b0x; - b0x = t2; - } - if (flipY) { - const t2 = b1y; - b1y = b0y; - b0y = t2; - } - this.minX = b0x; - this.minY = b0y; - this.width = Math.abs(b1x - b0x); - this.height = Math.abs(b1y - b0y); - } - union(box) { - const minX = Math.min(this.minX, box.x); - const minY = Math.min(this.minY, box.y); - const maxX = Math.max(this.maxX, box.w + box.x); - const maxY = Math.max(this.maxY, box.h + box.y); - this.x = minX; - this.y = minY; - this.width = maxX - minX; - this.height = maxY - minY; - return this; - } - static From(box) { - return new _Box(box.x, box.y, box.w, box.h); - } - static FromCenter(center, size4) { - return new _Box(center.x - size4.x / 2, center.y - size4.y / 2, size4.x, size4.y); - } - static FromPoints(points) { - if (points.length === 0) - return new _Box(); - let minX = Infinity; - let minY = Infinity; - let maxX = -Infinity; - let maxY = -Infinity; - let point; - for (let i = 0, n = points.length; i < n; i++) { - point = points[i]; - minX = Math.min(point.x, minX); - minY = Math.min(point.y, minY); - maxX = Math.max(point.x, maxX); - maxY = Math.max(point.y, maxY); - } - return new _Box(minX, minY, maxX - minX, maxY - minY); - } - static Expand(A, B) { - const minX = Math.min(B.minX, A.minX); - const minY = Math.min(B.minY, A.minY); - const maxX = Math.max(B.maxX, A.maxX); - const maxY = Math.max(B.maxY, A.maxY); - return new _Box(minX, minY, maxX - minX, maxY - minY); - } - static ExpandBy(A, n) { - return new _Box(A.minX - n, A.minY - n, A.width + n * 2, A.height + n * 2); - } - static Resize(box, handle, dx, dy, isAspectRatioLocked = false) { - const { minX: a0x, minY: a0y, maxX: a1x, maxY: a1y } = box; - let { minX: b0x, minY: b0y, maxX: b1x, maxY: b1y } = box; - switch (handle) { - case "left": - case "top_left": - case "bottom_left": { - b0x += dx; - break; - } - case "right": - case "top_right": - case "bottom_right": { - b1x += dx; - break; - } - } - switch (handle) { - case "top": - case "top_left": - case "top_right": { - b0y += dy; - break; - } - case "bottom": - case "bottom_left": - case "bottom_right": { - b1y += dy; - break; - } - } - const scaleX = (b1x - b0x) / (a1x - a0x); - const scaleY = (b1y - b0y) / (a1y - a0y); - const flipX = scaleX < 0; - const flipY = scaleY < 0; - if (isAspectRatioLocked) { - const aspectRatio = (a1x - a0x) / (a1y - a0y); - const bw = Math.abs(b1x - b0x); - const bh = Math.abs(b1y - b0y); - const tw = bw * (scaleY < 0 ? 1 : -1) * (1 / aspectRatio); - const th = bh * (scaleX < 0 ? 1 : -1) * aspectRatio; - const isTall = aspectRatio < bw / bh; - switch (handle) { - case "top_left": { - if (isTall) - b0y = b1y + tw; - else - b0x = b1x + th; - break; - } - case "top_right": { - if (isTall) - b0y = b1y + tw; - else - b1x = b0x - th; - break; - } - case "bottom_right": { - if (isTall) - b1y = b0y - tw; - else - b1x = b0x - th; - break; - } - case "bottom_left": { - if (isTall) - b1y = b0y - tw; - else - b0x = b1x + th; - break; - } - case "bottom": - case "top": { - const m = (b0x + b1x) / 2; - const w = bh * aspectRatio; - b0x = m - w / 2; - b1x = m + w / 2; - break; - } - case "left": - case "right": { - const m = (b0y + b1y) / 2; - const h = bw / aspectRatio; - b0y = m - h / 2; - b1y = m + h / 2; - break; - } - } - } - if (flipX) { - const t2 = b1x; - b1x = b0x; - b0x = t2; - } - if (flipY) { - const t2 = b1y; - b1y = b0y; - b0y = t2; - } - const final = new _Box(b0x, b0y, Math.abs(b1x - b0x), Math.abs(b1y - b0y)); - return { - box: final, - scaleX: +(final.width / box.width * (scaleX > 0 ? 1 : -1)).toFixed(5), - scaleY: +(final.height / box.height * (scaleY > 0 ? 1 : -1)).toFixed(5) - }; - } - equals(other) { - return _Box.Equals(this, other); - } - static Equals(a, b) { - return b.x === a.x && b.y === a.y && b.w === a.w && b.h === a.h; - } - zeroFix() { - this.w = Math.max(1, this.w); - this.h = Math.max(1, this.h); - return this; - } - static ZeroFix(other) { - return new _Box(other.x, other.y, Math.max(1, other.w), Math.max(1, other.h)); - } -}; -var Box = _Box; -__publicField(Box, "Collides", (A, B) => { - return !(A.maxX < B.minX || A.minX > B.maxX || A.maxY < B.minY || A.minY > B.maxY); -}); -__publicField(Box, "Contains", (A, B) => { - return A.minX < B.minX && A.minY < B.minY && A.maxY > B.maxY && A.maxX > B.maxX; -}); -__publicField(Box, "Includes", (A, B) => { - return _Box.Collides(A, B) || _Box.Contains(A, B); -}); -__publicField(Box, "ContainsPoint", (A, B, margin = 0) => { - return !(B.x < A.minX - margin || B.y < A.minY - margin || B.x > A.maxX + margin || B.y > A.maxY + margin); -}); -__publicField(Box, "Common", (boxes) => { - let minX = Infinity; - let minY = Infinity; - let maxX = -Infinity; - let maxY = -Infinity; - for (let i = 0; i < boxes.length; i++) { - const B = boxes[i]; - minX = Math.min(minX, B.minX); - minY = Math.min(minY, B.minY); - maxX = Math.max(maxX, B.maxX); - maxY = Math.max(maxY, B.maxY); - } - return new _Box(minX, minY, maxX - minX, maxY - minY); -}); -__publicField(Box, "Sides", (A, inset = 0) => { - const { corners } = A; - if (inset) { - } - return [ - [corners[0], corners[1]], - [corners[1], corners[2]], - [corners[2], corners[3]], - [corners[3], corners[0]] - ]; -}); -function flipSelectionHandleY(handle) { - switch (handle) { - case "top": - return "bottom"; - case "bottom": - return "top"; - case "top_left": - return "bottom_left"; - case "top_right": - return "bottom_right"; - case "bottom_left": - return "top_left"; - case "bottom_right": - return "top_right"; - default: - return handle; - } -} -function flipSelectionHandleX(handle) { - switch (handle) { - case "left": - return "right"; - case "right": - return "left"; - case "top_left": - return "top_right"; - case "top_right": - return "top_left"; - case "bottom_left": - return "bottom_right"; - case "bottom_right": - return "bottom_left"; - default: - return handle; - } -} -function isSelectionCorner(selection) { - return selection === "top_left" || selection === "top_right" || selection === "bottom_right" || selection === "bottom_left"; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useScreenBounds.mjs -function useScreenBounds(ref) { - const editor = useEditor(); - (0, import_react18.useLayoutEffect)(() => { - let prevBounds = new Box(); - function updateScreenBounds() { - const container2 = ref.current; - if (!container2) - return null; - const rect = container2.getBoundingClientRect(); - const next = new Box(rect.left || rect.x, rect.top || rect.y, Math.max(rect.width, 1), Math.max(rect.height, 1)); - if (prevBounds.equals(next)) - return; - editor.updateViewportScreenBounds(next); - prevBounds = next; - } - updateScreenBounds(); - const updateBounds = (0, import_lodash.default)(updateScreenBounds, 200, { - trailing: true - }); - const interval = editor.timers.setInterval(updateBounds, 1e3); - window.addEventListener("resize", updateBounds); - const resizeObserver = new ResizeObserver((entries) => { - if (!entries[0].contentRect) - return; - updateBounds(); - }); - const container = ref.current; - let scrollingParent = null; - if (container) { - resizeObserver.observe(container); - scrollingParent = getNearestScrollableContainer(container); - scrollingParent.addEventListener("scroll", updateBounds); - } - return () => { - clearInterval(interval); - window.removeEventListener("resize", updateBounds); - resizeObserver.disconnect(); - scrollingParent?.removeEventListener("scroll", updateBounds); - updateBounds.cancel(); - }; - }, [editor, ref]); -} -var getNearestScrollableContainer = (element) => { - let parent = element.parentElement; - while (parent) { - if (parent === document.body) { - return document; - } - const { overflowY } = window.getComputedStyle(parent); - const hasScrollableContent = parent.scrollHeight > parent.clientHeight; - if (hasScrollableContent && (overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay")) { - return parent; - } - parent = parent.parentElement; - } - return document; -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/Mat.mjs -var _Mat = class { - constructor(a, b, c, d, e, f) { - __publicField(this, "a", 1); - __publicField(this, "b", 0); - __publicField(this, "c", 0); - __publicField(this, "d", 1); - __publicField(this, "e", 0); - __publicField(this, "f", 0); - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.e = e; - this.f = f; - } - equals(m) { - return this === m || this.a === m.a && this.b === m.b && this.c === m.c && this.d === m.d && this.e === m.e && this.f === m.f; - } - identity() { - this.a = 1; - this.b = 0; - this.c = 0; - this.d = 1; - this.e = 0; - this.f = 0; - return this; - } - multiply(m) { - const m2 = m; - const { a, b, c, d, e, f } = this; - this.a = a * m2.a + c * m2.b; - this.c = a * m2.c + c * m2.d; - this.e = a * m2.e + c * m2.f + e; - this.b = b * m2.a + d * m2.b; - this.d = b * m2.c + d * m2.d; - this.f = b * m2.e + d * m2.f + f; - return this; - } - rotate(r, cx, cy) { - if (r === 0) - return this; - if (cx === void 0) - return this.multiply(_Mat.Rotate(r)); - return this.translate(cx, cy).multiply(_Mat.Rotate(r)).translate(-cx, -cy); - } - translate(x, y) { - return this.multiply(_Mat.Translate(x, y)); - } - scale(x, y) { - return this.multiply(_Mat.Scale(x, y)); - } - invert() { - const { a, b, c, d, e, f } = this; - const denom = a * d - b * c; - this.a = d / denom; - this.b = b / -denom; - this.c = c / -denom; - this.d = a / denom; - this.e = (d * e - c * f) / -denom; - this.f = (b * e - a * f) / denom; - return this; - } - applyToPoint(point) { - return _Mat.applyToPoint(this, point); - } - applyToPoints(points) { - return _Mat.applyToPoints(this, points); - } - rotation() { - return _Mat.Rotation(this); - } - point() { - return _Mat.Point(this); - } - decomposed() { - return _Mat.Decompose(this); - } - toCssString() { - return _Mat.toCssString(this); - } - setTo(model2) { - Object.assign(this, model2); - return this; - } - decompose() { - return _Mat.Decompose(this); - } - clone() { - return new _Mat(this.a, this.b, this.c, this.d, this.e, this.f); - } - static Identity() { - return new _Mat(1, 0, 0, 1, 0, 0); - } - static Translate(x, y) { - return new _Mat(1, 0, 0, 1, x, y); - } - static Rotate(r, cx, cy) { - if (r === 0) - return _Mat.Identity(); - const cosAngle = Math.cos(r); - const sinAngle = Math.sin(r); - const rotationMatrix = new _Mat(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0); - if (cx === void 0) - return rotationMatrix; - return _Mat.Compose(_Mat.Translate(cx, cy), rotationMatrix, _Mat.Translate(-cx, -cy)); - } - static Multiply(m1, m2) { - return { - a: m1.a * m2.a + m1.c * m2.b, - c: m1.a * m2.c + m1.c * m2.d, - e: m1.a * m2.e + m1.c * m2.f + m1.e, - b: m1.b * m2.a + m1.d * m2.b, - d: m1.b * m2.c + m1.d * m2.d, - f: m1.b * m2.e + m1.d * m2.f + m1.f - }; - } - static Inverse(m) { - const denom = m.a * m.d - m.b * m.c; - return { - a: m.d / denom, - b: m.b / -denom, - c: m.c / -denom, - d: m.a / denom, - e: (m.d * m.e - m.c * m.f) / -denom, - f: (m.b * m.e - m.a * m.f) / denom - }; - } - static Absolute(m) { - const denom = m.a * m.d - m.b * m.c; - return { - a: m.d / denom, - b: m.b / -denom, - c: m.c / -denom, - d: m.a / denom, - e: (m.d * m.e - m.c * m.f) / denom, - f: (m.b * m.e - m.a * m.f) / -denom - }; - } - static Compose(...matrices) { - const matrix = _Mat.Identity(); - for (let i = 0, n = matrices.length; i < n; i++) { - matrix.multiply(matrices[i]); - } - return matrix; - } - static Point(m) { - return new Vec(m.e, m.f); - } - static Rotation(m) { - let rotation; - if (m.a !== 0 || m.c !== 0) { - const hypotAc = (m.a * m.a + m.c * m.c) ** 0.5; - rotation = Math.acos(m.a / hypotAc) * (m.c > 0 ? -1 : 1); - } else if (m.b !== 0 || m.d !== 0) { - const hypotBd = (m.b * m.b + m.d * m.d) ** 0.5; - rotation = HALF_PI + Math.acos(m.b / hypotBd) * (m.d > 0 ? -1 : 1); - } else { - rotation = 0; - } - return clampRadians(rotation); - } - static Decompose(m) { - let scaleX, scaleY, rotation; - if (m.a !== 0 || m.c !== 0) { - const hypotAc = (m.a * m.a + m.c * m.c) ** 0.5; - scaleX = hypotAc; - scaleY = (m.a * m.d - m.b * m.c) / hypotAc; - rotation = Math.acos(m.a / hypotAc) * (m.c > 0 ? -1 : 1); - } else if (m.b !== 0 || m.d !== 0) { - const hypotBd = (m.b * m.b + m.d * m.d) ** 0.5; - scaleX = (m.a * m.d - m.b * m.c) / hypotBd; - scaleY = hypotBd; - rotation = HALF_PI + Math.acos(m.b / hypotBd) * (m.d > 0 ? -1 : 1); - } else { - scaleX = 0; - scaleY = 0; - rotation = 0; - } - return { - x: m.e, - y: m.f, - scaleX, - scaleY, - rotation: clampRadians(rotation) - }; - } - static Smooth(m, precision = 1e10) { - m.a = Math.round(m.a * precision) / precision; - m.b = Math.round(m.b * precision) / precision; - m.c = Math.round(m.c * precision) / precision; - m.d = Math.round(m.d * precision) / precision; - m.e = Math.round(m.e * precision) / precision; - m.f = Math.round(m.f * precision) / precision; - return m; - } - static toCssString(m) { - return `matrix(${toDomPrecision(m.a)}, ${toDomPrecision(m.b)}, ${toDomPrecision(m.c)}, ${toDomPrecision(m.d)}, ${toDomPrecision(m.e)}, ${toDomPrecision(m.f)})`; - } - static applyToPoint(m, point) { - return new Vec(m.a * point.x + m.c * point.y + m.e, m.b * point.x + m.d * point.y + m.f, point.z); - } - static applyToXY(m, x, y) { - return [m.a * x + m.c * y + m.e, m.b * x + m.d * y + m.f]; - } - static applyToPoints(m, points) { - return points.map((point) => new Vec(m.a * point.x + m.c * point.y + m.e, m.b * point.x + m.d * point.y + m.f, point.z)); - } - static applyToBounds(m, box) { - return new Box(m.e + box.minX, m.f + box.minY, box.width, box.height); - } - static From(m) { - return new _Mat(m.a, m.b, m.c, m.d, m.e, m.f); - } - static Cast(m) { - return m instanceof _Mat ? m : _Mat.From(m); - } -}; -var Mat = _Mat; -__publicField(Mat, "Scale", (x, y, cx, cy) => { - const scaleMatrix = new _Mat(x, 0, 0, y, 0, 0); - if (cx === void 0) - return scaleMatrix; - return _Mat.Compose(_Mat.Translate(cx, cy), scaleMatrix, _Mat.Translate(-cx, -cy)); -}); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/nearestMultiple.mjs -function gcd(a, b) { - return b === 0 ? a : gcd(b, a % b); -} -function nearestMultiple(float) { - const decimal = float.toString().split(".")[1]; - if (!decimal) - return 1; - const denominator = Math.pow(10, decimal.length); - const numerator = parseInt(decimal, 10); - return denominator / gcd(numerator, denominator); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/GeometryDebuggingView.mjs -var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); -var import_react19 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Geometry2d.mjs -var Geometry2d = class { - constructor(opts) { - __publicField(this, "isFilled", false); - __publicField(this, "isClosed", true); - __publicField(this, "isLabel", false); - __publicField(this, "debugColor"); - __publicField(this, "ignore"); - __publicField(this, "_vertices"); - __publicField(this, "_bounds"); - __publicField(this, "_area"); - __publicField(this, "_length"); - this.isFilled = opts.isFilled; - this.isClosed = opts.isClosed; - this.isLabel = opts.isLabel ?? false; - this.debugColor = opts.debugColor; - this.ignore = opts.ignore; - } - hitTestPoint(point, margin = 0, hitInside = false) { - if (this.isClosed && (this.isFilled || hitInside) && pointInPolygon(point, this.vertices)) { - return true; - } - return Vec.Dist2(point, this.nearestPoint(point)) <= margin * margin; - } - distanceToPoint(point, hitInside = false) { - return point.dist(this.nearestPoint(point)) * (this.isClosed && (this.isFilled || hitInside) && pointInPolygon(point, this.vertices) ? -1 : 1); - } - distanceToLineSegment(A, B) { - if (A.equals(B)) - return this.distanceToPoint(A); - const { vertices } = this; - let nearest; - let dist = Infinity; - let d, p, q; - for (let i = 0; i < vertices.length; i++) { - p = vertices[i]; - q = Vec.NearestPointOnLineSegment(A, B, p, true); - d = Vec.Dist2(p, q); - if (d < dist) { - dist = d; - nearest = q; - } - } - if (!nearest) - throw Error("nearest point not found"); - return this.isClosed && this.isFilled && pointInPolygon(nearest, this.vertices) ? -dist : dist; - } - hitTestLineSegment(A, B, distance = 0) { - return this.distanceToLineSegment(A, B) <= distance; - } - nearestPointOnLineSegment(A, B) { - const { vertices } = this; - let nearest; - let dist = Infinity; - let d, p, q; - for (let i = 0; i < vertices.length; i++) { - p = vertices[i]; - q = Vec.NearestPointOnLineSegment(A, B, p, true); - d = Vec.Dist2(p, q); - if (d < dist) { - dist = d; - nearest = q; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - isPointInBounds(point, margin = 0) { - const { bounds } = this; - return !(point.x < bounds.minX - margin || point.y < bounds.minY - margin || point.x > bounds.maxX + margin || point.y > bounds.maxY + margin); - } - get vertices() { - if (!this._vertices) { - this._vertices = this.getVertices(); - } - return this._vertices; - } - getBounds() { - return Box.FromPoints(this.vertices); - } - get bounds() { - if (!this._bounds) { - this._bounds = this.getBounds(); - } - return this._bounds; - } - get center() { - return this.bounds.center; - } - get area() { - if (!this._area) { - this._area = this.getArea(); - } - return this._area; - } - getArea() { - if (!this.isClosed) { - return 0; - } - const { vertices } = this; - let area = 0; - for (let i = 0, n = vertices.length; i < n; i++) { - const curr = vertices[i]; - const next = vertices[(i + 1) % n]; - area += curr.x * next.y - next.x * curr.y; - } - return area / 2; - } - toSimpleSvgPath() { - let path = ""; - const { vertices } = this; - const n = vertices.length; - if (n === 0) - return path; - path += `M${vertices[0].x},${vertices[0].y}`; - for (let i = 1; i < n; i++) { - path += `L${vertices[i].x},${vertices[i].y}`; - } - if (this.isClosed) { - path += "Z"; - } - return path; - } - get length() { - if (this._length) - return this._length; - this._length = this.getLength(); - return this._length; - } - getLength() { - const { vertices } = this; - let n1, p1 = vertices[0], length = 0; - for (let i = 1; i < vertices.length; i++) { - n1 = vertices[i]; - length += Vec.Dist2(p1, n1); - p1 = n1; - } - return Math.sqrt(length); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Group2d.mjs -var Group2d = class extends Geometry2d { - constructor(config) { - super({ ...config, isClosed: true, isFilled: false }); - __publicField(this, "children", []); - __publicField(this, "ignoredChildren", []); - for (const child of config.children) { - if (child.ignore) { - this.ignoredChildren.push(child); - } else { - this.children.push(child); - } - } - if (this.children.length === 0) - throw Error("Group2d must have at least one child"); - } - getVertices() { - return this.children.filter((c) => !c.isLabel).flatMap((c) => c.vertices); - } - nearestPoint(point) { - let dist = Infinity; - let nearest; - const { children } = this; - if (children.length === 0) { - throw Error("no children"); - } - let p; - let d; - for (const child of children) { - p = child.nearestPoint(point); - d = Vec.Dist2(p, point); - if (d < dist) { - dist = d; - nearest = p; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - distanceToPoint(point, hitInside = false) { - return Math.min(...this.children.map((c, i) => c.distanceToPoint(point, hitInside || i > 0))); - } - hitTestPoint(point, margin, hitInside) { - return !!this.children.filter((c) => !c.isLabel).find((c) => c.hitTestPoint(point, margin, hitInside)); - } - hitTestLineSegment(A, B, zoom) { - return !!this.children.filter((c) => !c.isLabel).find((c) => c.hitTestLineSegment(A, B, zoom)); - } - getArea() { - return this.children[0].area; - } - toSimpleSvgPath() { - let path = ""; - for (const child of this.children) { - path += child.toSimpleSvgPath(); - } - const corners = Box.FromPoints(this.vertices).corners; - for (let i = 0, n = corners.length; i < n; i++) { - const corner = corners[i]; - const prevCorner = corners[(i - 1 + n) % n]; - const prevDist = corner.dist(prevCorner); - const nextCorner = corners[(i + 1) % n]; - const nextDist = corner.dist(nextCorner); - const A = corner.clone().lrp(prevCorner, 4 / prevDist); - const B = corner; - const C = corner.clone().lrp(nextCorner, 4 / nextDist); - path += `M${A.x},${A.y} L${B.x},${B.y} L${C.x},${C.y} `; - } - return path; - } - getLength() { - return this.children.reduce((a, c) => c.isLabel ? a : a + c.length, 0); - } - getSvgPathData() { - return this.children.map((c, i) => c.isLabel ? "" : c.getSvgPathData(i === 0)).join(" "); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/GeometryDebuggingView.mjs -function useTick(isEnabled = true) { - const [_, setTick] = (0, import_react19.useState)(0); - const editor = useEditor(); - (0, import_react19.useEffect)(() => { - if (!isEnabled) - return; - const update = () => setTick((tick2) => tick2 + 1); - editor.on("tick", update); - return () => { - editor.off("tick", update); - }; - }, [editor, isEnabled]); -} -var GeometryDebuggingView = track(function GeometryDebuggingView2({ - showStroke = true, - showVertices = true, - showClosestPointOnOutline = true -}) { - const editor = useEditor(); - useTick(showClosestPointOnOutline); - const zoomLevel = editor.getZoomLevel(); - const renderingShapes = editor.getRenderingShapes(); - const { - inputs: { currentPagePoint } - } = editor; - return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { - style: { - position: "absolute", - pointerEvents: "none", - zIndex: 999999999, - top: 0, - left: 0, - overflow: "visible" - }, - children: renderingShapes.map((result) => { - const shape = editor.getShape(result.id); - if (shape.type === "group") - return null; - const geometry = editor.getShapeGeometry(shape); - const pageTransform = editor.getShapePageTransform(shape); - const pointInShapeSpace = editor.getPointInShapeSpace(shape, currentPagePoint); - const nearestPointOnShape = geometry.nearestPoint(pointInShapeSpace); - const distanceToPoint = geometry.distanceToPoint(pointInShapeSpace, true); - const dist = Math.abs(distanceToPoint) * zoomLevel; - const hitInside = distanceToPoint < 0; - const { vertices } = geometry; - return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("g", { - transform: pageTransform.toCssString(), - strokeLinecap: "round", - strokeLinejoin: "round", - children: [ - showStroke && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { - stroke: geometry.debugColor ?? "red", - opacity: "1", - strokeWidth: 2 / zoomLevel, - fill: "none", - children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GeometryStroke, { geometry }) - }), - showVertices && vertices.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { - cx: v.x, - cy: v.y, - r: 2 / zoomLevel, - fill: `hsl(${modulate(i, [0, vertices.length - 1], [120, 200])}, 100%, 50%)`, - stroke: "black", - strokeWidth: 1 / zoomLevel - }, `v${i}`)), - showClosestPointOnOutline && dist < 150 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", { - x1: nearestPointOnShape.x, - y1: nearestPointOnShape.y, - x2: pointInShapeSpace.x, - y2: pointInShapeSpace.y, - opacity: 1 - dist / 150, - stroke: hitInside ? "goldenrod" : "dodgerblue", - strokeWidth: 2 / zoomLevel - }) - ] - }, result.id + "_outline"); - }) - }); -}); -function GeometryStroke({ geometry }) { - if (geometry instanceof Group2d) { - return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: [...geometry.children, ...geometry.ignoredChildren].map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GeometryStroke, { geometry: child }, i)) }); - } - return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: geometry.toSimpleSvgPath() }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/LiveCollaborators.mjs -var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); -var import_react20 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/uniq.mjs -function uniq(array2) { - return (0, import_lodash2.default)(array2); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/usePeerIds.mjs -function usePeerIds() { - const editor = useEditor(); - const $userIds = useComputed("userIds", () => uniq(editor.getCollaborators().map((p) => p.userId)).sort(), { isEqual: (a, b) => a.join(",") === b.join?.(",") }, [editor]); - return useValue($userIds); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/usePresence.mjs -function usePresence(userId) { - const editor = useEditor(); - const latestPresence = useValue(`latestPresence:${userId}`, () => { - return editor.getCollaborators().find((c) => c.userId === userId); - }, [editor, userId]); - return latestPresence ?? null; -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/LiveCollaborators.mjs -var LiveCollaborators = track(function Collaborators() { - const peerIds = usePeerIds(); - return peerIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollaboratorGuard, { collaboratorId: id }, id)); -}); -var CollaboratorGuard = track(function CollaboratorGuard2({ - collaboratorId -}) { - const editor = useEditor(); - const presence = usePresence(collaboratorId); - const collaboratorState = useCollaboratorState(editor, presence); - if (!(presence && presence.currentPageId === editor.getCurrentPageId())) { - return null; - } - switch (collaboratorState) { - case "inactive": { - const { followingUserId, highlightedUserIds } = editor.getInstanceState(); - if (!(followingUserId === presence.userId || highlightedUserIds.includes(presence.userId))) { - return null; - } - break; - } - case "idle": { - const { highlightedUserIds } = editor.getInstanceState(); - if (presence.followingUserId === editor.user.getId() && !(presence.chatMessage || highlightedUserIds.includes(presence.userId))) { - return null; - } - break; - } - case "active": { - break; - } - } - return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Collaborator, { latestPresence: presence }); -}); -var Collaborator = track(function Collaborator2({ - latestPresence -}) { - const editor = useEditor(); - const { - CollaboratorBrush, - CollaboratorScribble, - CollaboratorCursor, - CollaboratorHint, - CollaboratorShapeIndicator - } = useEditorComponents(); - const zoomLevel = editor.getZoomLevel(); - const viewportPageBounds = editor.getViewportPageBounds(); - const { userId, chatMessage, brush, scribbles, selectedShapeIds, userName, cursor, color } = latestPresence; - const isCursorInViewport = !(cursor.x < viewportPageBounds.minX - 12 / zoomLevel || cursor.y < viewportPageBounds.minY - 16 / zoomLevel || cursor.x > viewportPageBounds.maxX - 12 / zoomLevel || cursor.y > viewportPageBounds.maxY - 16 / zoomLevel); - return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [ - brush && CollaboratorBrush ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollaboratorBrush, { - className: "tl-collaborator__brush", - brush, - color, - opacity: 0.1 - }, userId + "_brush") : null, - isCursorInViewport && CollaboratorCursor ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollaboratorCursor, { - className: "tl-collaborator__cursor", - point: cursor, - color, - zoom: zoomLevel, - name: userName !== "New User" ? userName : null, - chatMessage - }, userId + "_cursor") : CollaboratorHint ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollaboratorHint, { - className: "tl-collaborator__cursor-hint", - point: cursor, - color, - zoom: zoomLevel, - viewport: viewportPageBounds - }, userId + "_cursor_hint") : null, - CollaboratorScribble && scribbles.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: scribbles.map((scribble) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollaboratorScribble, { - className: "tl-collaborator__scribble", - scribble, - color, - zoom: zoomLevel, - opacity: scribble.color === "laser" ? 0.5 : 0.1 - }, userId + "_scribble_" + scribble.id)) }) : null, - CollaboratorShapeIndicator && selectedShapeIds.map((shapeId) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollaboratorShapeIndicator, { - className: "tl-collaborator__shape-indicator", - shapeId, - color, - opacity: 0.5 - }, userId + "_" + shapeId)) - ] }); -}); -function getStateFromElapsedTime(editor, elapsed) { - return elapsed > editor.options.collaboratorInactiveTimeoutMs ? "inactive" : elapsed > editor.options.collaboratorIdleTimeoutMs ? "idle" : "active"; -} -function useCollaboratorState(editor, latestPresence) { - const rLastActivityTimestamp = (0, import_react20.useRef)(latestPresence?.lastActivityTimestamp ?? -1); - const [state, setState] = (0, import_react20.useState)(() => getStateFromElapsedTime(editor, Date.now() - rLastActivityTimestamp.current)); - (0, import_react20.useEffect)(() => { - const interval = editor.timers.setInterval(() => { - setState(getStateFromElapsedTime(editor, Date.now() - rLastActivityTimestamp.current)); - }, editor.options.collaboratorCheckIntervalMs); - return () => clearInterval(interval); - }, [editor]); - if (latestPresence) { - rLastActivityTimestamp.current = latestPresence.lastActivityTimestamp; - } - return state; -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/Shape.mjs -var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); -var import_react21 = __toESM(require_react(), 1); -var Shape = (0, import_react21.memo)(function Shape2({ - id, - shape, - util, - index: index2, - backgroundIndex, - opacity, - dprMultiple -}) { - const editor = useEditor(); - const { ShapeErrorFallback } = useEditorComponents(); - const containerRef = (0, import_react21.useRef)(null); - const bgContainerRef = (0, import_react21.useRef)(null); - const memoizedStuffRef = (0, import_react21.useRef)({ - transform: "", - clipPath: "none", - width: 0, - height: 0, - x: 0, - y: 0, - isCulled: false - }); - useQuickReactor("set shape stuff", () => { - const shape2 = editor.getShape(id); - if (!shape2) - return; - const prev = memoizedStuffRef.current; - const clipPath = editor.getShapeClipPath(id) ?? "none"; - if (clipPath !== prev.clipPath) { - setStyleProperty(containerRef.current, "clip-path", clipPath); - setStyleProperty(bgContainerRef.current, "clip-path", clipPath); - prev.clipPath = clipPath; - } - const pageTransform = editor.getShapePageTransform(id); - const transform = Mat.toCssString(pageTransform); - const bounds = editor.getShapeGeometry(shape2).bounds; - if (transform !== prev.transform) { - setStyleProperty(containerRef.current, "transform", transform); - setStyleProperty(bgContainerRef.current, "transform", transform); - prev.transform = transform; - } - const widthRemainder = bounds.w % dprMultiple; - const heightRemainder = bounds.h % dprMultiple; - const width = widthRemainder === 0 ? bounds.w : bounds.w + (dprMultiple - widthRemainder); - const height = heightRemainder === 0 ? bounds.h : bounds.h + (dprMultiple - heightRemainder); - if (width !== prev.width || height !== prev.height) { - setStyleProperty(containerRef.current, "width", Math.max(width, dprMultiple) + "px"); - setStyleProperty(containerRef.current, "height", Math.max(height, dprMultiple) + "px"); - setStyleProperty(bgContainerRef.current, "width", Math.max(width, dprMultiple) + "px"); - setStyleProperty(bgContainerRef.current, "height", Math.max(height, dprMultiple) + "px"); - prev.width = width; - prev.height = height; - } - }, [editor]); - useQuickReactor("set opacity and z-index", () => { - const container = containerRef.current; - const bgContainer = bgContainerRef.current; - setStyleProperty(container, "opacity", opacity); - setStyleProperty(bgContainer, "opacity", opacity); - setStyleProperty(container, "z-index", index2); - setStyleProperty(bgContainer, "z-index", backgroundIndex); - }, [opacity, index2, backgroundIndex]); - useQuickReactor("set display", () => { - const shape2 = editor.getShape(id); - if (!shape2) - return; - const culledShapes = editor.getCulledShapes(); - const isCulled = culledShapes.has(id); - if (isCulled !== memoizedStuffRef.current.isCulled) { - setStyleProperty(containerRef.current, "display", isCulled ? "none" : "block"); - setStyleProperty(bgContainerRef.current, "display", isCulled ? "none" : "block"); - memoizedStuffRef.current.isCulled = isCulled; - } - }, [editor]); - const annotateError2 = (0, import_react21.useCallback)((error3) => editor.annotateError(error3, { origin: "shape", willCrashApp: false }), [editor]); - if (!shape) - return null; - const isFilledShape = "fill" in shape.props && shape.props.fill !== "none"; - return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [ - util.backgroundComponent && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { - ref: bgContainerRef, - className: "tl-shape tl-shape-background", - "data-shape-type": shape.type, - draggable: false, - children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OptionalErrorBoundary, { fallback: ShapeErrorFallback, onError: annotateError2, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InnerShapeBackground, { shape, util }) }) - }), - /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { - ref: containerRef, - className: "tl-shape", - "data-shape-type": shape.type, - "data-shape-is-filled": isFilledShape, - draggable: false, - children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OptionalErrorBoundary, { fallback: ShapeErrorFallback, onError: annotateError2, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InnerShape, { shape, util }) }) - }) - ] }); -}); -var InnerShape = (0, import_react21.memo)(function InnerShape2({ shape, util }) { - return useStateTracking("InnerShape:" + shape.type, () => util.component(util.editor.store.unsafeGetWithoutCapture(shape.id))); -}, (prev, next) => prev.shape.props === next.shape.props && prev.shape.meta === next.shape.meta); -var InnerShapeBackground = (0, import_react21.memo)(function InnerShapeBackground2({ - shape, - util -}) { - return useStateTracking("InnerShape:" + shape.type, () => util.backgroundComponent?.(util.editor.store.unsafeGetWithoutCapture(shape.id))); -}, (prev, next) => prev.shape.props === next.shape.props && prev.shape.meta === next.shape.meta); - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultCanvas.mjs -function DefaultCanvas({ className }) { - const editor = useEditor(); - const { Background, SvgDefs, ShapeIndicators } = useEditorComponents(); - const rCanvas = (0, import_react22.useRef)(null); - const rHtmlLayer = (0, import_react22.useRef)(null); - const rHtmlLayer2 = (0, import_react22.useRef)(null); - const container = useContainer(); - useScreenBounds(rCanvas); - useDocumentEvents(); - useCoarsePointer(); - useGestureEvents(rCanvas); - useFixSafariDoubleTapZoomPencilEvents(rCanvas); - const rMemoizedStuff = (0, import_react22.useRef)({ lodDisableTextOutline: false, allowTextOutline: true }); - useQuickReactor("position layers", function positionLayersWhenCameraMoves() { - const { x, y, z } = editor.getCamera(); - if (rMemoizedStuff.current.allowTextOutline && editor.environment.isSafari) { - container.style.setProperty("--tl-text-outline", "none"); - rMemoizedStuff.current.allowTextOutline = false; - } - if (rMemoizedStuff.current.allowTextOutline && z < editor.options.textShadowLod !== rMemoizedStuff.current.lodDisableTextOutline) { - const lodDisableTextOutline = z < editor.options.textShadowLod; - container.style.setProperty("--tl-text-outline", lodDisableTextOutline ? "none" : `var(--tl-text-outline-reference)`); - rMemoizedStuff.current.lodDisableTextOutline = lodDisableTextOutline; - } - const offset4 = z >= 1 ? modulate(z, [1, 8], [0.125, 0.5], true) : modulate(z, [0.1, 1], [-2, 0.125], true); - const transform = `scale(${toDomPrecision(z)}) translate(${toDomPrecision(x + offset4)}px,${toDomPrecision(y + offset4)}px)`; - setStyleProperty(rHtmlLayer.current, "transform", transform); - setStyleProperty(rHtmlLayer2.current, "transform", transform); - }, [editor, container]); - const events = useCanvasEvents(); - const shapeSvgDefs = useValue("shapeSvgDefs", () => { - const shapeSvgDefsByKey = /* @__PURE__ */ new Map(); - for (const util of objectMapValues(editor.shapeUtils)) { - if (!util) - return; - const defs = util.getCanvasSvgDefs(); - for (const { key, component: Component2 } of defs) { - if (shapeSvgDefsByKey.has(key)) - continue; - shapeSvgDefsByKey.set(key, /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Component2, {}, key)); - } - } - return [...shapeSvgDefsByKey.values()]; - }, [editor]); - const hideShapes = useValue("debug_shapes", () => debugFlags.hideShapes.get(), [debugFlags]); - const debugSvg = useValue("debug_svg", () => debugFlags.debugSvg.get(), [debugFlags]); - const debugGeometry = useValue("debug_geometry", () => debugFlags.debugGeometry.get(), [ - debugFlags - ]); - const isEditingAnything = useValue("isEditingAnything", () => editor.getEditingShapeId() !== null, [editor]); - const isSelectingAnything = useValue("isSelectingAnything", () => !!editor.getSelectedShapeIds().length, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { - ref: rCanvas, - draggable: false, - "data-iseditinganything": isEditingAnything, - "data-isselectinganything": isSelectingAnything, - className: (0, import_classnames.default)("tl-canvas", className), - "data-testid": "canvas", - ...events, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { className: "tl-svg-context", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("defs", { children: [ - shapeSvgDefs, - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CursorDef, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CollaboratorHintDef, {}), - SvgDefs && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SvgDefs, {}) - ] }) }), - Background && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "tl-background__wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Background, {}) }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GridWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: rHtmlLayer, className: "tl-html-layer tl-shapes", draggable: false, children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OnTheCanvasWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SelectionBackgroundWrapper, {}), - hideShapes ? null : debugSvg ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ShapesWithSVGs, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ShapesToDisplay, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "tl-overlays", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: rHtmlLayer2, className: "tl-html-layer", children: [ - debugGeometry ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GeometryDebuggingView, {}) : null, - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HandlesWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BrushWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ScribbleWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ZoomBrushWrapper, {}), - ShapeIndicators && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ShapeIndicators, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HintedShapeIndicator, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SnapIndicatorWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SelectionForegroundWrapper, {}), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LiveCollaborators, {}) - ] }) }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MovingCameraHitTestBlocker, {}) - ] - }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InFrontOfTheCanvasWrapper, {}) - ] }); -} -function InFrontOfTheCanvasWrapper() { - const { InFrontOfTheCanvas } = useEditorComponents(); - if (!InFrontOfTheCanvas) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InFrontOfTheCanvas, {}); -} -function GridWrapper() { - const editor = useEditor(); - const gridSize = useValue("gridSize", () => editor.getDocumentSettings().gridSize, [editor]); - const { x, y, z } = useValue("camera", () => editor.getCamera(), [editor]); - const isGridMode = useValue("isGridMode", () => editor.getInstanceState().isGridMode, [editor]); - const { Grid } = useEditorComponents(); - if (!(Grid && isGridMode)) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Grid, { x, y, z, size: gridSize }); -} -function ScribbleWrapper() { - const editor = useEditor(); - const scribbles = useValue("scribbles", () => editor.getInstanceState().scribbles, [editor]); - const zoomLevel = useValue("zoomLevel", () => editor.getZoomLevel(), [editor]); - const { Scribble } = useEditorComponents(); - if (!(Scribble && scribbles.length)) - return null; - return scribbles.map((scribble) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Scribble, { className: "tl-user-scribble", scribble, zoom: zoomLevel }, scribble.id)); -} -function BrushWrapper() { - const editor = useEditor(); - const brush = useValue("brush", () => editor.getInstanceState().brush, [editor]); - const { Brush } = useEditorComponents(); - if (!(Brush && brush)) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Brush, { className: "tl-user-brush", brush }); -} -function ZoomBrushWrapper() { - const editor = useEditor(); - const zoomBrush = useValue("zoomBrush", () => editor.getInstanceState().zoomBrush, [editor]); - const { ZoomBrush } = useEditorComponents(); - if (!(ZoomBrush && zoomBrush)) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ZoomBrush, { className: "tl-user-brush tl-zoom-brush", brush: zoomBrush }); -} -function SnapIndicatorWrapper() { - const editor = useEditor(); - const lines = useValue("snapLines", () => editor.snaps.getIndicators(), [editor]); - const zoomLevel = useValue("zoomLevel", () => editor.getZoomLevel(), [editor]); - const { SnapIndicator } = useEditorComponents(); - if (!(SnapIndicator && lines.length > 0)) - return null; - return lines.map((line) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SnapIndicator, { className: "tl-user-snapline", line, zoom: zoomLevel }, line.id)); -} -function HandlesWrapper() { - const editor = useEditor(); - const shapeIdWithHandles = useValue("handles shapeIdWithHandles", () => { - const { isReadonly, isChangingStyle } = editor.getInstanceState(); - if (isReadonly || isChangingStyle) - return false; - const onlySelectedShape = editor.getOnlySelectedShape(); - if (!onlySelectedShape) - return false; - const handles = editor.getShapeHandles(onlySelectedShape); - if (!handles) - return false; - return onlySelectedShape.id; - }, [editor]); - if (!shapeIdWithHandles) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HandlesWrapperInner, { shapeId: shapeIdWithHandles }); -} -function HandlesWrapperInner({ shapeId }) { - const editor = useEditor(); - const { Handles } = useEditorComponents(); - const zoomLevel = useValue("zoomLevel", () => editor.getZoomLevel(), [editor]); - const isCoarse = useValue("coarse pointer", () => editor.getInstanceState().isCoarsePointer, [ - editor - ]); - const transform = useValue("handles transform", () => editor.getShapePageTransform(shapeId), [ - editor, - shapeId - ]); - const handles = useValue("handles", () => { - const handles2 = editor.getShapeHandles(shapeId); - if (!handles2) - return null; - const minDistBetweenVirtualHandlesAndRegularHandles = (isCoarse ? editor.options.coarseHandleRadius : editor.options.handleRadius) / zoomLevel * 2; - return handles2.filter((handle) => handle.type !== "virtual" || !handles2.some((h) => h !== handle && h.type === "vertex" && Vec.Dist(handle, h) < minDistBetweenVirtualHandlesAndRegularHandles)).sort((a) => a.type === "vertex" ? 1 : -1); - }, [editor, zoomLevel, isCoarse, shapeId]); - if (!Handles || !handles || !transform) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Handles, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("g", { transform: Mat.toCssString(transform), children: handles.map((handle) => { - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HandleWrapper, { - shapeId, - handle, - zoom: zoomLevel, - isCoarse - }, handle.id); - }) }) }); -} -function HandleWrapper({ - shapeId, - handle, - zoom, - isCoarse -}) { - const events = useHandleEvents(shapeId, handle.id); - const { Handle } = useEditorComponents(); - if (!Handle) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("g", { "aria-label": "handle", transform: `translate(${handle.x}, ${handle.y})`, ...events, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Handle, { shapeId, handle, zoom, isCoarse }) }); -} -function ShapesWithSVGs() { - const editor = useEditor(); - const renderingShapes = useValue("rendering shapes", () => editor.getRenderingShapes(), [editor]); - const dprMultiple = useValue("dpr multiple", () => nearestMultiple(Math.floor(editor.getInstanceState().devicePixelRatio * 100) / 100), [editor]); - return renderingShapes.map((result) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react22.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shape, { ...result, dprMultiple }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DebugSvgCopy, { id: result.id }) - ] }, result.id + "_fragment")); -} -function ReflowIfNeeded() { - const editor = useEditor(); - const culledShapesRef = (0, import_react22.useRef)(/* @__PURE__ */ new Set()); - useQuickReactor("reflow for culled shapes", () => { - const culledShapes = editor.getCulledShapes(); - if (culledShapesRef.current.size === culledShapes.size && [...culledShapes].every((id) => culledShapesRef.current.has(id))) - return; - culledShapesRef.current = culledShapes; - const canvas = document.getElementsByClassName("tl-canvas"); - if (canvas.length === 0) - return; - const _height = canvas[0].offsetHeight; - }, [editor]); - return null; -} -function ShapesToDisplay() { - const editor = useEditor(); - const renderingShapes = useValue("rendering shapes", () => editor.getRenderingShapes(), [editor]); - const dprMultiple = useValue("dpr multiple", () => nearestMultiple(Math.floor(editor.getInstanceState().devicePixelRatio * 100) / 100), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [ - renderingShapes.map((result) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shape, { ...result, dprMultiple }, result.id + "_shape")), - editor.environment.isSafari && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ReflowIfNeeded, {}) - ] }); -} -function HintedShapeIndicator() { - const editor = useEditor(); - const { ShapeIndicator } = useEditorComponents(); - const ids = useValue("hinting shape ids", () => dedupe(editor.getHintingShapeIds()), [editor]); - if (!ids.length) - return null; - if (!ShapeIndicator) - return null; - return ids.map((id) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ShapeIndicator, { className: "tl-user-indicator__hint", shapeId: id }, id + "_hinting")); -} -function CursorDef() { - return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("g", { id: "cursor", children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("g", { fill: "rgba(0,0,0,.2)", transform: "translate(-11,-11)", children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("g", { fill: "white", transform: "translate(-12,-12)", children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("g", { fill: "currentColor", transform: "translate(-12,-12)", children: [ - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z" }), - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m13 10.814v11.188l2.969-2.866.428-.139h4.768z" }) - ] }) - ] }); -} -function CollaboratorHintDef() { - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { id: "cursor_hint", fill: "currentColor", d: "M -2,-5 2,0 -2,5 Z" }); -} -function DebugSvgCopy({ id }) { - const editor = useEditor(); - const [image, setImage] = (0, import_react22.useState)(null); - const isInRoot = useValue("is in root", () => { - const shape = editor.getShape(id); - return shape?.parentId === editor.getCurrentPageId(); - }, [editor, id]); - (0, import_react22.useEffect)(() => { - if (!isInRoot) - return; - let latest = null; - const unsubscribe = react("shape to svg", async () => { - const renderId = Math.random(); - latest = renderId; - const isSingleFrame = editor.isShapeOfType(id, "frame"); - const padding = isSingleFrame ? 0 : 10; - let bounds = editor.getShapePageBounds(id); - if (!bounds) - return; - bounds = bounds.clone().expandBy(padding); - const result = await editor.getSvgString([id], { - padding, - background: editor.getInstanceState().exportBackground - }); - if (latest !== renderId || !result) - return; - const svgDataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(result.svg)}`; - setImage({ src: svgDataUrl, bounds }); - }); - return () => { - latest = null; - unsubscribe(); - }; - }, [editor, id, isInRoot]); - if (!isInRoot || !image) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { - src: image.src, - width: image.bounds.width, - height: image.bounds.height, - referrerPolicy: "no-referrer", - style: { - position: "absolute", - top: 0, - left: 0, - transform: `translate(${image.bounds.x}px, ${image.bounds.maxY + 12}px)`, - outline: "1px solid black", - maxWidth: "none" - } - }); -} -function SelectionForegroundWrapper() { - const editor = useEditor(); - const selectionRotation = useValue("selection rotation", () => editor.getSelectionRotation(), [ - editor - ]); - const selectionBounds = useValue("selection bounds", () => editor.getSelectionRotatedPageBounds(), [editor]); - const { SelectionForeground } = useEditorComponents(); - if (!selectionBounds || !SelectionForeground) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SelectionForeground, { bounds: selectionBounds, rotation: selectionRotation }); -} -function SelectionBackgroundWrapper() { - const editor = useEditor(); - const selectionRotation = useValue("selection rotation", () => editor.getSelectionRotation(), [ - editor - ]); - const selectionBounds = useValue("selection bounds", () => editor.getSelectionRotatedPageBounds(), [editor]); - const { SelectionBackground } = useEditorComponents(); - if (!selectionBounds || !SelectionBackground) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SelectionBackground, { bounds: selectionBounds, rotation: selectionRotation }); -} -function OnTheCanvasWrapper() { - const { OnTheCanvas } = useEditorComponents(); - if (!OnTheCanvas) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OnTheCanvas, {}); -} -function MovingCameraHitTestBlocker() { - const editor = useEditor(); - const cameraState = useValue("camera state", () => editor.getCameraState(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { - className: (0, import_classnames.default)("tl-hit-test-blocker", { - "tl-hit-test-blocker__hidden": cameraState === "idle" - }) - }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs -var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); -var import_classnames2 = __toESM(require_classnames(), 1); -var import_react23 = __toESM(require_react(), 1); -function DefaultCollaboratorHint({ - className, - zoom, - point, - color, - viewport, - opacity = 1 -}) { - const rSvg = (0, import_react23.useRef)(null); - useTransform(rSvg, clamp(point.x, viewport.minX + 5 / zoom, viewport.maxX - 5 / zoom), clamp(point.y, viewport.minY + 5 / zoom, viewport.maxY - 5 / zoom), 1 / zoom, Vec.Angle(viewport.center, point)); - return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("svg", { ref: rSvg, className: (0, import_classnames2.default)("tl-overlays__item", className), children: [ - /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("use", { href: "#cursor_hint", color, strokeWidth: 3, stroke: "var(--color-background)" }), - /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("use", { href: "#cursor_hint", color, opacity }) - ] }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultCursor.mjs -var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); -var import_classnames3 = __toESM(require_classnames(), 1); -var import_react24 = __toESM(require_react(), 1); -var DefaultCursor = (0, import_react24.memo)(function DefaultCursor2({ - className, - zoom, - point, - color, - name, - chatMessage -}) { - const rCursor = (0, import_react24.useRef)(null); - useTransform(rCursor, point?.x, point?.y, 1 / zoom); - if (!point) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref: rCursor, className: (0, import_classnames3.default)("tl-overlays__item", className), children: [ - /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("svg", { className: "tl-cursor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("use", { href: "#cursor", color }) }), - chatMessage ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [ - name && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "tl-nametag-title", style: { color }, children: name }), - /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "tl-nametag-chat", style: { backgroundColor: color }, children: chatMessage }) - ] }) : name && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "tl-nametag", style: { backgroundColor: color }, children: name }) - ] }); -}); - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultGrid.mjs -var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useSafeId.mjs -var import_react25 = __toESM(require_react(), 1); -function useSafeId() { - return (0, import_react25.useId)().replace(/:/g, "_"); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultGrid.mjs -function DefaultGrid({ x, y, z, size: size4 }) { - const id = `grid_${useSafeId()}`; - const editor = useEditor(); - const { gridSteps } = editor.options; - return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { className: "tl-grid", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: [ - /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: gridSteps.map(({ min: min3, mid, step }, i) => { - const s = step * size4 * z; - const xo = 0.5 + x * z; - const yo = 0.5 + y * z; - const gxo = xo > 0 ? xo % s : s + xo % s; - const gyo = yo > 0 ? yo % s : s + yo % s; - const opacity = z < mid ? modulate(z, [min3, mid], [0, 1]) : 1; - return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pattern", { - id: `${id}_${step}`, - width: s, - height: s, - patternUnits: "userSpaceOnUse", - children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { className: "tl-grid-dot", cx: gxo, cy: gyo, r: 1, opacity }) - }, i); - }) }), - gridSteps.map(({ step }, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { width: "100%", height: "100%", fill: `url(#${id}_${step})` }, i)) - ] }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultHandle.mjs -var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); -var import_classnames4 = __toESM(require_classnames(), 1); -function DefaultHandle({ handle, isCoarse, className, zoom }) { - const editor = useEditor(); - const br = (isCoarse ? editor.options.coarseHandleRadius : editor.options.handleRadius) / zoom; - if (handle.type === "clone") { - const fr2 = 3 / zoom; - const path = `M0,${-fr2} A${fr2},${fr2} 0 0,1 0,${fr2}`; - const index2 = SIDES.indexOf(handle.id); - return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { className: (0, import_classnames4.default)(`tl-handle tl-handle__${handle.type}`, className), children: [ - /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { className: "tl-handle__bg", r: br }), - /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { className: "tl-handle__fg", d: path, transform: `rotate(${-90 + 90 * index2})` }) - ] }); - } - const fr = (handle.type === "create" && isCoarse ? 3 : 4) / Math.max(zoom, 0.25); - return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { className: (0, import_classnames4.default)(`tl-handle tl-handle__${handle.type}`, className), children: [ - /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { className: "tl-handle__bg", r: br }), - /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { className: "tl-handle__fg", r: fr }) - ] }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultHandles.mjs -var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); -var DefaultHandles = ({ children }) => { - return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { className: "tl-user-handles tl-overlays__item", children }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultLoadingScreen.mjs -var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); -var DefaultLoadingScreen = () => { - const { Spinner: Spinner2 } = useEditorComponents(); - return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LoadingScreen, { children: Spinner2 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner2, {}) : null }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultScribble.mjs -var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); -var import_classnames5 = __toESM(require_classnames(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/getSvgPathFromPoints.mjs -function getSvgPathFromPoints(points, closed = true) { - const len = points.length; - if (len < 2) { - return ""; - } - let a = points[0]; - let b = points[1]; - if (len === 2) { - return `M${precise(a)}L${precise(b)}`; - } - let result = ""; - for (let i = 2, max2 = len - 1; i < max2; i++) { - a = points[i]; - b = points[i + 1]; - result += average(a, b); - } - if (closed) { - return `M${average(points[0], points[1])}Q${precise(points[1])}${average(points[1], points[2])}T${result}${average(points[len - 1], points[0])}${average(points[0], points[1])}Z`; - } else { - return `M${precise(points[0])}Q${precise(points[1])}${average(points[1], points[2])}${points.length > 3 ? "T" : ""}${result}L${precise(points[len - 1])}`; - } -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultScribble.mjs -function DefaultScribble({ scribble, zoom, color, opacity, className }) { - if (!scribble.points.length) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { className: className ? (0, import_classnames5.default)("tl-overlays__item", className) : className, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { - className: "tl-scribble", - d: getSvgPathFromPoints(scribble.points, false), - stroke: color ?? `var(--color-${scribble.color})`, - fill: "none", - strokeWidth: 8 / zoom, - opacity: opacity ?? scribble.opacity - }) }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultSelectionBackground.mjs -var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); -var React7 = __toESM(require_react(), 1); -function DefaultSelectionBackground({ bounds, rotation }) { - const rDiv = React7.useRef(null); - useTransform(rDiv, bounds.x, bounds.y, 1, rotation); - React7.useLayoutEffect(() => { - const div = rDiv.current; - if (!div) - return; - div.style.width = toDomPrecision(Math.max(1, bounds.width)) + "px"; - div.style.height = toDomPrecision(Math.max(1, bounds.height)) + "px"; - }, [bounds.width, bounds.height]); - return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref: rDiv, className: "tl-selection__bg", draggable: false }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs -var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); -var import_classnames6 = __toESM(require_classnames(), 1); -var import_react26 = __toESM(require_react(), 1); -function DefaultSelectionForeground({ bounds, rotation }) { - const editor = useEditor(); - const rSvg = (0, import_react26.useRef)(null); - const onlyShape = useValue("only selected shape", () => editor.getOnlySelectedShape(), [editor]); - const expandOutlineBy = onlyShape ? editor.getShapeUtil(onlyShape).expandSelectionOutlinePx(onlyShape) : 0; - useTransform(rSvg, bounds?.x, bounds?.y, 1, rotation, { - x: -expandOutlineBy, - y: -expandOutlineBy - }); - bounds = bounds.clone().expandBy(expandOutlineBy).zeroFix(); - return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("svg", { - ref: rSvg, - className: "tl-overlays__item tl-selection__fg", - "data-testid": "selection-foreground", - children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { - className: (0, import_classnames6.default)("tl-selection__fg__outline"), - width: toDomPrecision(bounds.width), - height: toDomPrecision(bounds.height) - }) - }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultShapeErrorFallback.mjs -var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); -var DefaultShapeErrorFallback = () => { - return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "tl-shape-error-boundary" }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs -var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); -var import_classnames7 = __toESM(require_classnames(), 1); -var import_react27 = __toESM(require_react(), 1); -var EvenInnererIndicator = ({ shape, util }) => { - return useStateTracking("Indicator: " + shape.type, () => util.indicator(util.editor.store.unsafeGetWithoutCapture(shape.id))); -}; -var InnerIndicator = ({ editor, id }) => { - const shape = useValue("shape for indicator", () => editor.store.get(id), [editor, id]); - const { ShapeIndicatorErrorFallback } = useEditorComponents(); - if (!shape || shape.isLocked) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionalErrorBoundary, { - fallback: ShapeIndicatorErrorFallback, - onError: (error3) => editor.annotateError(error3, { origin: "react.shapeIndicator", willCrashApp: false }), - children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EvenInnererIndicator, { shape, util: editor.getShapeUtil(shape) }, shape.id) - }); -}; -var DefaultShapeIndicator = (0, import_react27.memo)(function DefaultShapeIndicator2({ - shapeId, - className, - color, - hidden, - opacity -}) { - const editor = useEditor(); - const rIndicator = (0, import_react27.useRef)(null); - useQuickReactor("indicator transform", () => { - const elm = rIndicator.current; - if (!elm) - return; - const pageTransform = editor.getShapePageTransform(shapeId); - if (!pageTransform) - return; - elm.style.setProperty("transform", pageTransform.toCssString()); - }, [editor, shapeId]); - (0, import_react27.useLayoutEffect)(() => { - const elm = rIndicator.current; - if (!elm) - return; - elm.style.setProperty("display", hidden ? "none" : "block"); - }, [hidden]); - return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { ref: rIndicator, className: (0, import_classnames7.default)("tl-overlays__item", className), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("g", { className: "tl-shape-indicator", stroke: color ?? "var(--color-selected)", opacity, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(InnerIndicator, { editor, id: shapeId }) }) }); -}); - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs -var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); -var DefaultShapeIndicatorErrorFallback = () => { - return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: 4, cy: 4, r: 8, strokeWidth: "1", stroke: "red" }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs -var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); -var import_react28 = __toESM(require_react(), 1); -var DefaultShapeIndicators = (0, import_react28.memo)(function DefaultShapeIndicators2() { - const editor = useEditor(); - const rPreviousSelectedShapeIds = (0, import_react28.useRef)(/* @__PURE__ */ new Set()); - const idsToDisplay = useValue("should display selected ids", () => { - const prev = rPreviousSelectedShapeIds.current; - const next = /* @__PURE__ */ new Set(); - if (editor.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.editing_shape", "select.pointing_shape", "select.pointing_selection", "select.pointing_handle") && !editor.getInstanceState().isChangingStyle) { - const selected = editor.getSelectedShapeIds(); - for (const id of selected) { - next.add(id); - } - if (editor.isInAny("select.idle", "select.editing_shape")) { - const instanceState = editor.getInstanceState(); - if (instanceState.isHoveringCanvas && !instanceState.isCoarsePointer) { - const hovered = editor.getHoveredShapeId(); - if (hovered) - next.add(hovered); - } - } - } - if (prev.size !== next.size) { - rPreviousSelectedShapeIds.current = next; - return next; - } - for (const id of next) { - if (!prev.has(id)) { - rPreviousSelectedShapeIds.current = next; - return next; - } - } - return prev; - }, [editor]); - const renderingShapes = useValue("rendering shapes", () => editor.getRenderingShapes(), [editor]); - const { ShapeIndicator } = useEditorComponents(); - if (!ShapeIndicator) - return null; - return renderingShapes.map(({ id }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ShapeIndicator, { shapeId: id, hidden: !idsToDisplay.has(id) }, id + "_indicator")); -}); - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs -var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); -var import_classnames8 = __toESM(require_classnames(), 1); -var React8 = __toESM(require_react(), 1); -function PointsSnapIndicator({ points, zoom }) { - const l = 2.5 / zoom; - const minX = points.reduce((acc, p) => Math.min(acc, p.x), Infinity); - const maxX = points.reduce((acc, p) => Math.max(acc, p.x), -Infinity); - const minY = points.reduce((acc, p) => Math.min(acc, p.y), Infinity); - const maxY = points.reduce((acc, p) => Math.max(acc, p.y), -Infinity); - const useNWtoSEdireciton = points.some((p) => p.x === minX && p.y === minY); - let firstX, firstY, secondX, secondY; - if (useNWtoSEdireciton) { - firstX = minX; - firstY = minY; - secondX = maxX; - secondY = maxY; - } else { - firstX = minX; - firstY = maxY; - secondX = maxX; - secondY = minY; - } - return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("g", { className: "tl-snap-indicator", stroke: "lime", children: [ - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: firstX, y1: firstY, x2: secondX, y2: secondY }), - points.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("g", { transform: `translate(${p.x},${p.y})`, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { - className: "tl-snap-point", - d: `M ${-l},${-l} L ${l},${l} M ${-l},${l} L ${l},${-l}` - }) }, i)) - ] }); -} -function GapsSnapIndicator({ gaps, direction, zoom }) { - const l = 3.5 / zoom; - let edgeIntersection = [-Infinity, Infinity]; - let nextEdgeIntersection = null; - const horizontal = direction === "horizontal"; - for (const gap of gaps) { - nextEdgeIntersection = rangeIntersection(edgeIntersection[0], edgeIntersection[1], horizontal ? gap.startEdge[0].y : gap.startEdge[0].x, horizontal ? gap.startEdge[1].y : gap.startEdge[1].x); - if (nextEdgeIntersection) { - edgeIntersection = nextEdgeIntersection; - } else { - continue; - } - nextEdgeIntersection = rangeIntersection(edgeIntersection[0], edgeIntersection[1], horizontal ? gap.endEdge[0].y : gap.endEdge[0].x, horizontal ? gap.endEdge[1].y : gap.endEdge[1].x); - if (nextEdgeIntersection) { - edgeIntersection = nextEdgeIntersection; - } else { - continue; - } - } - if (edgeIntersection === null) { - return null; - } - const midPoint = (edgeIntersection[0] + edgeIntersection[1]) / 2; - return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("g", { className: "tl-snap-indicator", stroke: "cyan", children: gaps.map(({ startEdge, endEdge }, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(React8.Fragment, { children: horizontal ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { - x1: startEdge[0].x, - y1: midPoint - 2 * l, - x2: startEdge[1].x, - y2: midPoint + 2 * l - }), - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { - x1: endEdge[0].x, - y1: midPoint - 2 * l, - x2: endEdge[1].x, - y2: midPoint + 2 * l - }), - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: startEdge[0].x, y1: midPoint, x2: endEdge[0].x, y2: midPoint }), - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { - x1: (startEdge[0].x + endEdge[0].x) / 2, - y1: midPoint - l, - x2: (startEdge[0].x + endEdge[0].x) / 2, - y2: midPoint + l - }) - ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { - x1: midPoint - 2 * l, - y1: startEdge[0].y, - x2: midPoint + 2 * l, - y2: startEdge[1].y - }), - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { - x1: midPoint - 2 * l, - y1: endEdge[0].y, - x2: midPoint + 2 * l, - y2: endEdge[1].y - }), - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: midPoint, y1: startEdge[0].y, x2: midPoint, y2: endEdge[0].y }), - /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { - x1: midPoint - l, - y1: (startEdge[0].y + endEdge[0].y) / 2, - x2: midPoint + l, - y2: (startEdge[0].y + endEdge[0].y) / 2 - }) - ] }) }, i)) }); -} -function DefaultSnapIndicator({ className, line, zoom }) { - return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("svg", { className: (0, import_classnames8.default)("tl-overlays__item", className), children: line.type === "points" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PointsSnapIndicator, { ...line, zoom }) : line.type === "gaps" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(GapsSnapIndicator, { ...line, zoom }) : null }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultSpinner.mjs -var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); -function DefaultSpinner() { - return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { width: 16, height: 16, viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("g", { strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [ - /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("circle", { strokeOpacity: 0.25, cx: 8, cy: 8, r: 7, stroke: "currentColor" }), - /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { strokeLinecap: "round", d: "M15 8c0-4.5-4.5-7-7-7", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("animateTransform", { - attributeName: "transform", - type: "rotate", - from: "0 8 8", - to: "360 8 8", - dur: "1s", - repeatCount: "indefinite" - }) }) - ] }) }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultSvgDefs.mjs -var DefaultSvgDefs = () => { - return null; -}; - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useIdentity.mjs -var import_react29 = __toESM(require_react(), 1); -function useIdentity(value, isEqual2) { - const ref = (0, import_react29.useRef)(value); - if (isEqual2(value, ref.current)) { - return ref.current; - } - ref.current = value; - return value; -} -function useShallowArrayIdentity(arr) { - return useIdentity(arr, areArraysShallowEqual); -} -var areNullableObjectsShallowEqual = (a, b) => { - a ?? (a = null); - b ?? (b = null); - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return areObjectsShallowEqual(a, b); -}; -function useShallowObjectIdentity(obj) { - return useIdentity(obj, areNullableObjectsShallowEqual); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useEditorComponents.mjs -var EditorComponentsContext = (0, import_react30.createContext)(null); -function EditorComponentsProvider({ - overrides = {}, - children -}) { - const _overrides = useShallowObjectIdentity(overrides); - const value = (0, import_react30.useMemo)(() => ({ - Background: DefaultBackground, - SvgDefs: DefaultSvgDefs, - Brush: DefaultBrush, - ZoomBrush: DefaultBrush, - CollaboratorBrush: DefaultBrush, - Cursor: DefaultCursor, - CollaboratorCursor: DefaultCursor, - CollaboratorHint: DefaultCollaboratorHint, - CollaboratorShapeIndicator: DefaultShapeIndicator, - Grid: DefaultGrid, - Scribble: DefaultScribble, - SnapIndicator: DefaultSnapIndicator, - Handles: DefaultHandles, - Handle: DefaultHandle, - CollaboratorScribble: DefaultScribble, - ErrorFallback: DefaultErrorFallback, - ShapeErrorFallback: DefaultShapeErrorFallback, - ShapeIndicatorErrorFallback: DefaultShapeIndicatorErrorFallback, - Spinner: DefaultSpinner, - SelectionBackground: DefaultSelectionBackground, - SelectionForeground: DefaultSelectionForeground, - ShapeIndicators: DefaultShapeIndicators, - ShapeIndicator: DefaultShapeIndicator, - OnTheCanvas: null, - InFrontOfTheCanvas: null, - Canvas: DefaultCanvas, - LoadingScreen: DefaultLoadingScreen, - ..._overrides - }), [_overrides]); - return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(EditorComponentsContext.Provider, { value, children }); -} -function useEditorComponents() { - const components = (0, import_react30.useContext)(EditorComponentsContext); - if (!components) { - throw new Error("useEditorComponents must be used inside of <EditorComponentsProvider />"); - } - return components; -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/runtime.mjs -var runtime = { - openWindow: (url, target) => window.open(url, target, "noopener noreferrer"), - refreshPage: () => window.location.reload(), - hardReset: async () => await window.__tldraw__hardReset?.() -}; - -// node_modules/@tldraw/editor/dist-esm/lib/utils/hardResetEditor.mjs -function hardResetEditor() { - runtime.hardReset(); -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/refreshPage.mjs -function refreshPage() { - runtime.refreshPage(); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs -var BASE_ERROR_URL = "https://github.com/tldraw/tldraw/issues/new"; -var DefaultErrorFallback = ({ error: error3, editor }) => { - const containerRef = (0, import_react31.useRef)(null); - const [shouldShowError, setShouldShowError] = (0, import_react31.useState)(false); - const [didCopy, setDidCopy] = (0, import_react31.useState)(false); - const [shouldShowResetConfirmation, setShouldShowResetConfirmation] = (0, import_react31.useState)(false); - let Canvas = null; - try { - const components = useEditorComponents(); - Canvas = components.Canvas ?? null; - } catch (e) { - } - const errorMessage = error3 instanceof Error ? error3.message : String(error3); - const errorStack = error3 instanceof Error ? error3.stack : null; - const isDarkModeFromApp = useValue("isDarkMode", () => { - try { - if (editor) { - return editor.user.getIsDarkMode(); - } - } catch { - } - return null; - }, [editor]); - const [isDarkMode, setIsDarkMode] = (0, import_react31.useState)(null); - (0, import_react31.useLayoutEffect)(() => { - if (isDarkModeFromApp !== null) { - setIsDarkMode(isDarkModeFromApp); - } - let parent = containerRef.current?.parentElement; - let foundParentThemeClass = false; - while (parent) { - if (parent.classList.contains("tl-theme__dark") || parent.classList.contains("tl-theme__light")) { - foundParentThemeClass = true; - break; - } - parent = parent.parentElement; - } - if (foundParentThemeClass) { - setIsDarkMode(null); - return; - } - if (typeof window !== "undefined" && "matchMedia" in window) { - setIsDarkMode(window.matchMedia("(prefers-color-scheme: dark)").matches); - } - }, [isDarkModeFromApp]); - (0, import_react31.useEffect)(() => { - if (didCopy) { - const timeout = editor?.timers.setTimeout(() => { - setDidCopy(false); - }, 2e3); - return () => clearTimeout(timeout); - } - }, [didCopy, editor]); - const copyError = () => { - const textarea = document.createElement("textarea"); - textarea.value = errorStack ?? errorMessage; - document.body.appendChild(textarea); - textarea.select(); - document.execCommand("copy"); - textarea.remove(); - setDidCopy(true); - }; - const refresh = () => { - refreshPage(); - }; - const resetLocalState = async () => { - hardResetEditor(); - }; - const url = new URL(BASE_ERROR_URL); - url.searchParams.set("title", errorMessage); - url.searchParams.set("labels", `bug`); - url.searchParams.set("body", `Hey, I ran into an error while using tldraw: - -\`\`\`js -${errorStack ?? errorMessage} -\`\`\` - -My browser: ${navigator.userAgent}`); - return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { - ref: containerRef, - className: (0, import_classnames9.default)("tl-container tl-error-boundary", isDarkMode === null ? "" : isDarkMode ? "tl-theme__dark" : "tl-theme__light"), - children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "tl-error-boundary__overlay" }), - editor && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ErrorBoundary, { onError: noop, fallback: () => null, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "tl-overlay tl-error-boundary__canvas", children: Canvas ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Canvas, {}) : null }) }) }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { - className: (0, import_classnames9.default)("tl-modal", "tl-error-boundary__content", { - "tl-error-boundary__content__expanded": shouldShowError && !shouldShowResetConfirmation - }), - children: shouldShowResetConfirmation ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { children: "Are you sure?" }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { children: "Resetting your data will delete your drawing and cannot be undone." }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "tl-error-boundary__content__actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { onClick: () => setShouldShowResetConfirmation(false), children: "Cancel" }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { className: "tl-error-boundary__reset", onClick: resetLocalState, children: "Reset data" }) - ] }) - ] }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { children: "Something's gone wrong." }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { children: [ - "Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ", - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { href: url.toString(), children: "create a GitHub issue" }), - " or", - " ", - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { href: "https://discord.gg/Cq6cPsTfNy", children: "ask for help on Discord" }), - "." - ] }), - shouldShowError && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [ - "Message:", - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("code", { children: errorMessage }) }), - "Stack trace:", - /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "tl-error-boundary__content__error", children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("code", { children: errorStack ?? errorMessage }) }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { onClick: copyError, children: didCopy ? "Copied!" : "Copy" }) - ] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "tl-error-boundary__content__actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { onClick: () => setShouldShowError(!shouldShowError), children: shouldShowError ? "Hide details" : "Show details" }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "tl-error-boundary__content__actions__group", children: [ - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { - className: "tl-error-boundary__reset", - onClick: () => setShouldShowResetConfirmation(true), - children: "Reset data" - }), - /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { className: "tl-error-boundary__refresh", onClick: refresh, children: "Refresh Page" }) - ] }) - ] }) - ] }) - }) - ] - }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/config/createTLUser.mjs -var import_react32 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/node_modules/nanoid/index.browser.js -var nanoid3 = (size4 = 21) => crypto.getRandomValues(new Uint8Array(size4)).reduce((id, byte) => { - byte &= 63; - if (byte < 36) { - id += byte.toString(36); - } else if (byte < 62) { - id += (byte - 26).toString(36).toUpperCase(); - } else if (byte > 62) { - id += "-"; - } else { - id += "_"; - } - return id; -}, ""); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/uniqueId.mjs -function uniqueId() { - return nanoid3(); -} - -// node_modules/@tldraw/editor/dist-esm/lib/config/TLUserPreferences.mjs -var USER_DATA_KEY = "TLDRAW_USER_DATA_v3"; -var userTypeValidator = validation_exports.object({ - id: validation_exports.string, - name: validation_exports.string.nullable().optional(), - locale: validation_exports.string.nullable().optional(), - color: validation_exports.string.nullable().optional(), - colorScheme: validation_exports.literalEnum("light", "dark", "system").optional(), - animationSpeed: validation_exports.number.nullable().optional(), - edgeScrollSpeed: validation_exports.number.nullable().optional(), - isSnapMode: validation_exports.boolean.nullable().optional(), - isWrapMode: validation_exports.boolean.nullable().optional(), - isDynamicSizeMode: validation_exports.boolean.nullable().optional(), - isPasteAtCursorMode: validation_exports.boolean.nullable().optional() -}); -var Versions13 = { - AddAnimationSpeed: 1, - AddIsSnapMode: 2, - MakeFieldsNullable: 3, - AddEdgeScrollSpeed: 4, - AddExcalidrawSelectMode: 5, - AddDynamicSizeMode: 6, - AllowSystemColorScheme: 7, - AddPasteAtCursor: 8 -}; -var CURRENT_VERSION = Math.max(...Object.values(Versions13)); -function migrateSnapshot(data) { - if (data.version < Versions13.AddAnimationSpeed) { - data.user.animationSpeed = 1; - } - if (data.version < Versions13.AddIsSnapMode) { - data.user.isSnapMode = false; - } - if (data.version < Versions13.MakeFieldsNullable) { - } - if (data.version < Versions13.AddEdgeScrollSpeed) { - data.user.edgeScrollSpeed = 1; - } - if (data.version < Versions13.AddExcalidrawSelectMode) { - data.user.isWrapMode = false; - } - if (data.version < Versions13.AllowSystemColorScheme) { - if (data.user.isDarkMode === true) { - data.user.colorScheme = "dark"; - } else if (data.user.isDarkMode === false) { - data.user.colorScheme = "light"; - } - delete data.user.isDarkMode; - } - if (data.version < Versions13.AddDynamicSizeMode) { - data.user.isDynamicSizeMode = false; - } - if (data.version < Versions13.AddPasteAtCursor) { - data.user.isPasteAtCursorMode = false; - } - data.version = CURRENT_VERSION; -} -var USER_COLORS = [ - "#FF802B", - "#EC5E41", - "#F2555A", - "#F04F88", - "#E34BA9", - "#BD54C6", - "#9D5BD2", - "#7B66DC", - "#02B1CC", - "#11B3A3", - "#39B178", - "#55B467" -]; -function getRandomColor() { - return USER_COLORS[Math.floor(Math.random() * USER_COLORS.length)]; -} -function userPrefersReducedMotion() { - if (typeof window !== "undefined" && "matchMedia" in window) { - return window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false; - } - return false; -} -var defaultUserPreferences = Object.freeze({ - name: "New User", - locale: getDefaultTranslationLocale(), - color: getRandomColor(), - edgeScrollSpeed: 1, - animationSpeed: userPrefersReducedMotion() ? 0 : 1, - isSnapMode: false, - isWrapMode: false, - isDynamicSizeMode: false, - isPasteAtCursorMode: false, - colorScheme: "system" -}); -function getFreshUserPreferences() { - return { - id: uniqueId(), - color: getRandomColor() - }; -} -function migrateUserPreferences(userData) { - if (userData === null || typeof userData !== "object") { - return getFreshUserPreferences(); - } - if (!("version" in userData) || !("user" in userData) || typeof userData.version !== "number") { - return getFreshUserPreferences(); - } - const snapshot = structuredClone(userData); - migrateSnapshot(snapshot); - try { - return userTypeValidator.validate(snapshot.user); - } catch (e) { - return getFreshUserPreferences(); - } -} -function loadUserPreferences() { - const userData = JSON.parse(getFromLocalStorage(USER_DATA_KEY) || "null") ?? null; - return migrateUserPreferences(userData); -} -var globalUserPreferences = atom("globalUserData", null); -function storeUserPreferences() { - setInLocalStorage(USER_DATA_KEY, JSON.stringify({ - version: CURRENT_VERSION, - user: globalUserPreferences.get() - })); -} -function setUserPreferences(user) { - userTypeValidator.validate(user); - globalUserPreferences.set(user); - storeUserPreferences(); - broadcastUserPreferencesChange(); -} -var isTest2 = typeof process !== "undefined" && false; -var channel = typeof BroadcastChannel !== "undefined" && !isTest2 ? new BroadcastChannel("tldraw-user-sync") : null; -channel?.addEventListener("message", (e) => { - const data = e.data; - if (data?.type === broadcastEventKey && data?.origin !== getBroadcastOrigin()) { - globalUserPreferences.set(migrateUserPreferences(data.data)); - } -}); -var _broadcastOrigin = null; -function getBroadcastOrigin() { - if (_broadcastOrigin === null) { - _broadcastOrigin = uniqueId(); - } - return _broadcastOrigin; -} -var broadcastEventKey = "tldraw-user-preferences-change"; -function broadcastUserPreferencesChange() { - channel?.postMessage({ - type: broadcastEventKey, - origin: getBroadcastOrigin(), - data: { - user: getUserPreferences(), - version: CURRENT_VERSION - } - }); -} -function getUserPreferences() { - let prefs = globalUserPreferences.get(); - if (!prefs) { - prefs = loadUserPreferences(); - setUserPreferences(prefs); - } - return prefs; -} - -// node_modules/@tldraw/editor/dist-esm/lib/config/createTLUser.mjs -var defaultLocalStorageUserPrefs = computed("defaultLocalStorageUserPrefs", () => getUserPreferences()); -function createTLUser(opts = {}) { - return { - userPreferences: opts.userPreferences ?? defaultLocalStorageUserPrefs, - setUserPreferences: opts.setUserPreferences ?? setUserPreferences - }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/Editor.mjs -var import_eventemitter3 = __toESM(require_eventemitter3(), 1); -var import_react_dom = __toESM(require_react_dom(), 1); -var import_client = __toESM(require_client(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/config/TLSessionStateSnapshot.mjs -var tabIdKey = "TLDRAW_TAB_ID_v2"; -var window2 = globalThis.window; -function iOS() { - if (!window2) - return false; - return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(window2.navigator.platform) || window2.navigator.userAgent.includes("Mac") && "ontouchend" in document; -} -var TAB_ID = window2 ? window2[tabIdKey] ?? getFromSessionStorage(tabIdKey) ?? `TLDRAW_INSTANCE_STATE_V1_` + uniqueId() : "<error>"; -if (window2) { - window2[tabIdKey] = TAB_ID; - if (iOS()) { - setInSessionStorage(tabIdKey, TAB_ID); - } else { - deleteFromSessionStorage(tabIdKey); - } -} -window2?.addEventListener("beforeunload", () => { - setInSessionStorage(tabIdKey, TAB_ID); -}); -var Versions14 = { - Initial: 0 -}; -var CURRENT_SESSION_STATE_SNAPSHOT_VERSION = Math.max(...Object.values(Versions14)); -function migrate(snapshot) { - if (snapshot.version < Versions14.Initial) { - } - snapshot.version = CURRENT_SESSION_STATE_SNAPSHOT_VERSION; -} -var sessionStateSnapshotValidator = validation_exports.object({ - version: validation_exports.number, - currentPageId: pageIdValidator, - isFocusMode: validation_exports.boolean, - exportBackground: validation_exports.boolean, - isDebugMode: validation_exports.boolean, - isToolLocked: validation_exports.boolean, - isGridMode: validation_exports.boolean, - pageStates: validation_exports.arrayOf(validation_exports.object({ - pageId: pageIdValidator, - camera: validation_exports.object({ - x: validation_exports.number, - y: validation_exports.number, - z: validation_exports.number - }), - selectedShapeIds: validation_exports.arrayOf(shapeIdValidator), - focusedGroupId: shapeIdValidator.nullable() - })) -}); -function migrateAndValidateSessionStateSnapshot(state) { - if (!state || typeof state !== "object") { - console.warn("Invalid instance state"); - return null; - } - if (!("version" in state) || typeof state.version !== "number") { - console.warn("No version in instance state"); - return null; - } - if (state.version !== CURRENT_SESSION_STATE_SNAPSHOT_VERSION) { - state = structuredClone(state); - migrate(state); - } - try { - return sessionStateSnapshotValidator.validate(state); - } catch (e) { - console.warn(e); - return null; - } -} -function createSessionStateSnapshotSignal(store) { - const $allPageIds = store.query.ids("page"); - return computed("sessionStateSnapshot", () => { - const instanceState = store.get(TLINSTANCE_ID); - if (!instanceState) - return null; - const allPageIds = [...$allPageIds.get()]; - return { - version: CURRENT_SESSION_STATE_SNAPSHOT_VERSION, - currentPageId: instanceState.currentPageId, - exportBackground: instanceState.exportBackground, - isFocusMode: instanceState.isFocusMode, - isDebugMode: instanceState.isDebugMode, - isToolLocked: instanceState.isToolLocked, - isGridMode: instanceState.isGridMode, - pageStates: allPageIds.map((id) => { - const ps = store.get(InstancePageStateRecordType.createId(id)); - const camera = store.get(CameraRecordType.createId(id)); - return { - pageId: id, - camera: { - x: camera?.x ?? 0, - y: camera?.y ?? 0, - z: camera?.z ?? 1 - }, - selectedShapeIds: ps?.selectedShapeIds ?? [], - focusedGroupId: ps?.focusedGroupId ?? null - }; - }) - }; - }); -} -function loadSessionStateSnapshotIntoStore(store, snapshot) { - const res = migrateAndValidateSessionStateSnapshot(snapshot); - if (!res) - return; - const instanceState = store.schema.types.instance.create({ - id: TLINSTANCE_ID, - ...pluckPreservingValues(store.get(TLINSTANCE_ID)), - currentPageId: res.currentPageId, - isDebugMode: res.isDebugMode, - isFocusMode: res.isFocusMode, - isToolLocked: res.isToolLocked, - isGridMode: res.isGridMode, - exportBackground: res.exportBackground - }); - const allPageStatesAndCameras = store.allRecords().filter((r) => r.typeName === "instance_page_state" || r.typeName === "camera"); - store.atomic(() => { - store.remove(allPageStatesAndCameras.map((r) => r.id)); - for (const ps of res.pageStates) { - store.put([ - CameraRecordType.create({ - id: CameraRecordType.createId(ps.pageId), - x: ps.camera.x, - y: ps.camera.y, - z: ps.camera.z - }), - InstancePageStateRecordType.create({ - id: InstancePageStateRecordType.createId(ps.pageId), - pageId: ps.pageId, - selectedShapeIds: ps.selectedShapeIds, - focusedGroupId: ps.focusedGroupId - }) - ]); - } - store.put([instanceState]); - store.ensureStoreIsUsable(); - }); -} -function extractSessionStateFromLegacySnapshot(store) { - const instanceRecords = []; - for (const record of Object.values(store)) { - if (record.typeName?.match(/^(instance.*|pointer|camera)$/)) { - instanceRecords.push(record); - } - } - const oldInstance = instanceRecords.filter((r) => r.typeName === "instance" && r.id !== TLINSTANCE_ID)[0]; - if (!oldInstance) - return null; - const result = { - version: CURRENT_SESSION_STATE_SNAPSHOT_VERSION, - currentPageId: oldInstance.currentPageId, - exportBackground: !!oldInstance.exportBackground, - isFocusMode: !!oldInstance.isFocusMode, - isDebugMode: !!oldInstance.isDebugMode, - isToolLocked: !!oldInstance.isToolLocked, - isGridMode: false, - pageStates: instanceRecords.filter((r) => r.typeName === "instance_page_state" && r.instanceId === oldInstance.id).map((ps) => { - const camera = store[ps.cameraId] ?? { x: 0, y: 0, z: 1 }; - return { - pageId: ps.pageId, - camera: { - x: camera.x, - y: camera.y, - z: camera.z - }, - selectedShapeIds: ps.selectedShapeIds, - focusedGroupId: ps.focusedGroupId - }; - }) - }; - try { - sessionStateSnapshotValidator.validate(result); - return result; - } catch (e) { - return null; - } -} - -// node_modules/@tldraw/editor/dist-esm/lib/config/TLEditorSnapshot.mjs -function loadSnapshot(store, _snapshot) { - let snapshot = {}; - if ("store" in _snapshot) { - const migrationResult = store.schema.migrateStoreSnapshot(_snapshot); - if (migrationResult.type !== "success") { - throw new Error("Failed to migrate store snapshot: " + migrationResult.reason); - } - snapshot.document = { - schema: store.schema.serialize(), - store: filterEntries(migrationResult.value, (_, { typeName }) => store.scopedTypes.document.has(typeName)) - }; - } else { - snapshot = _snapshot; - } - const preservingInstanceState = pluckPreservingValues(store.get(TLINSTANCE_ID)); - store.atomic(() => { - if (snapshot.document) { - store.loadStoreSnapshot(snapshot.document); - } - if (preservingInstanceState) { - store.update(TLINSTANCE_ID, (r) => ({ ...r, ...preservingInstanceState })); - } - if (snapshot.session) { - loadSessionStateSnapshotIntoStore(store, snapshot.session); - } - }); -} -var sessionStateCache = new WeakCache(); -function getSnapshot(store) { - const sessionState$ = sessionStateCache.get(store, createSessionStateSnapshotSignal); - const session = sessionState$.get(); - if (!session) { - throw new Error("Session state is not ready yet"); - } - return { - document: store.getStoreSnapshot(), - session - }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/config/defaultBindings.mjs -function checkBindings(customBindings) { - const bindings = []; - const addedCustomBindingTypes = /* @__PURE__ */ new Set(); - for (const customBinding of customBindings) { - if (addedCustomBindingTypes.has(customBinding.type)) { - throw new Error(`Binding type "${customBinding.type}" is defined more than once`); - } - bindings.push(customBinding); - addedCustomBindingTypes.add(customBinding.type); - } - return bindings; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs -var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/components/SVGContainer.mjs -var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); -var import_classnames10 = __toESM(require_classnames(), 1); -function SVGContainer({ children, className = "", ...rest }) { - return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { ...rest, className: (0, import_classnames10.default)("tl-svg-container", className), children }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/intersect.mjs -function intersectLineSegmentLineSegment(a1, a2, b1, b2) { - const ABx = a1.x - b1.x; - const ABy = a1.y - b1.y; - const BVx = b2.x - b1.x; - const BVy = b2.y - b1.y; - const AVx = a2.x - a1.x; - const AVy = a2.y - a1.y; - const ua_t = BVx * ABy - BVy * ABx; - const ub_t = AVx * ABy - AVy * ABx; - const u_b = BVy * AVx - BVx * AVy; - if (ua_t === 0 || ub_t === 0) - return null; - if (u_b === 0) - return null; - if (u_b !== 0) { - const ua = ua_t / u_b; - const ub = ub_t / u_b; - if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) { - return Vec.AddXY(a1, ua * AVx, ua * AVy); - } - } - return null; -} -function intersectLineSegmentCircle(a1, a2, c, r) { - const a = (a2.x - a1.x) * (a2.x - a1.x) + (a2.y - a1.y) * (a2.y - a1.y); - const b = 2 * ((a2.x - a1.x) * (a1.x - c.x) + (a2.y - a1.y) * (a1.y - c.y)); - const cc = c.x * c.x + c.y * c.y + a1.x * a1.x + a1.y * a1.y - 2 * (c.x * a1.x + c.y * a1.y) - r * r; - const deter = b * b - 4 * a * cc; - if (deter < 0) - return null; - if (deter === 0) - return null; - const e = Math.sqrt(deter); - const u1 = (-b + e) / (2 * a); - const u2 = (-b - e) / (2 * a); - if ((u1 < 0 || u1 > 1) && (u2 < 0 || u2 > 1)) { - return null; - } - const result = []; - if (0 <= u1 && u1 <= 1) - result.push(Vec.Lrp(a1, a2, u1)); - if (0 <= u2 && u2 <= 1) - result.push(Vec.Lrp(a1, a2, u2)); - if (result.length === 0) - return null; - return result; -} -function intersectLineSegmentPolyline(a1, a2, points) { - const result = []; - let segmentIntersection; - for (let i = 0, n = points.length - 1; i < n; i++) { - segmentIntersection = intersectLineSegmentLineSegment(a1, a2, points[i], points[i + 1]); - if (segmentIntersection) - result.push(segmentIntersection); - } - if (result.length === 0) - return null; - return result; -} -function intersectLineSegmentPolygon(a1, a2, points) { - const result = []; - let segmentIntersection; - for (let i = 1, n = points.length; i < n + 1; i++) { - segmentIntersection = intersectLineSegmentLineSegment(a1, a2, points[i - 1], points[i % points.length]); - if (segmentIntersection) - result.push(segmentIntersection); - } - if (result.length === 0) - return null; - return result; -} -function intersectCircleCircle(c1, r1, c2, r2) { - let dx = c2.x - c1.x; - let dy = c2.y - c1.y; - const d = Math.sqrt(dx * dx + dy * dy), x = (d * d - r2 * r2 + r1 * r1) / (2 * d), y = Math.sqrt(r1 * r1 - x * x); - dx /= d; - dy /= d; - return [ - new Vec(c1.x + dx * x - dy * y, c1.y + dy * x + dx * y), - new Vec(c1.x + dx * x + dy * y, c1.y + dy * x - dx * y) - ]; -} -function intersectCirclePolygon(c, r, points) { - const result = []; - let a, b, int; - for (let i = 0, n = points.length; i < n; i++) { - a = points[i]; - b = points[(i + 1) % points.length]; - int = intersectLineSegmentCircle(a, b, c, r); - if (int) - result.push(...int); - } - if (result.length === 0) - return null; - return result; -} -function intersectCirclePolyline(c, r, points) { - const result = []; - let a, b, int; - for (let i = 1, n = points.length; i < n; i++) { - a = points[i - 1]; - b = points[i]; - int = intersectLineSegmentCircle(a, b, c, r); - if (int) - result.push(...int); - } - if (result.length === 0) - return null; - return result; -} -function ccw(A, B, C) { - return (C.y - A.y) * (B.x - A.x) > (B.y - A.y) * (C.x - A.x); -} -function linesIntersect(A, B, C, D) { - return ccw(A, C, D) !== ccw(B, C, D) && ccw(A, B, C) !== ccw(A, B, D); -} -function intersectPolygonPolygon(polygonA, polygonB) { - const result = /* @__PURE__ */ new Map(); - let a, b, c, d; - for (let i = 0, n = polygonA.length; i < n; i++) { - a = polygonA[i]; - if (pointInPolygon(a, polygonB)) { - const id = getPointId(a); - if (!result.has(id)) { - result.set(id, a); - } - } - } - for (let i = 0, n = polygonB.length; i < n; i++) { - a = polygonB[i]; - if (pointInPolygon(a, polygonA)) { - const id = getPointId(a); - if (!result.has(id)) { - result.set(id, a); - } - } - } - for (let i = 0, n = polygonA.length; i < n; i++) { - a = polygonA[i]; - b = polygonA[(i + 1) % polygonA.length]; - for (let j = 0, m = polygonB.length; j < m; j++) { - c = polygonB[j]; - d = polygonB[(j + 1) % polygonB.length]; - const intersection = intersectLineSegmentLineSegment(a, b, c, d); - if (intersection !== null) { - const id = getPointId(intersection); - if (!result.has(id)) { - result.set(id, intersection); - } - } - } - } - if (result.size === 0) - return null; - return orderClockwise([...result.values()]); -} -function getPointId(point) { - return `${point.x},${point.y}`; -} -function orderClockwise(points) { - const C = Vec.Average(points); - return points.sort((A, B) => Vec.Angle(C, A) - Vec.Angle(C, B)); -} -function polygonsIntersect(a, b) { - let a0, a1, b0, b1; - for (let i = 0, n = a.length; i < n; i++) { - a0 = a[i]; - a1 = a[(i + 1) % n]; - for (let j = 0, m = b.length; j < m; j++) { - b0 = b[j]; - b1 = b[(j + 1) % m]; - if (linesIntersect(a0, a1, b0, b1)) - return true; - } - } - return false; -} -function polygonIntersectsPolyline(polygon, polyline) { - let a, b, c, d; - for (let i = 0, n = polygon.length; i < n; i++) { - a = polygon[i]; - b = polygon[(i + 1) % n]; - for (let j = 1, m = polyline.length; j < m; j++) { - c = polyline[j - 1]; - d = polyline[j]; - if (linesIntersect(a, b, c, d)) - return true; - } - } - return false; -} - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Edge2d.mjs -var Edge2d = class extends Geometry2d { - constructor(config) { - super({ ...config, isClosed: false, isFilled: false }); - __publicField(this, "start"); - __publicField(this, "end"); - __publicField(this, "d"); - __publicField(this, "u"); - __publicField(this, "ul"); - const { start, end } = config; - this.start = start; - this.end = end; - this.d = start.clone().sub(end); - this.u = this.d.clone().uni(); - this.ul = this.u.len(); - } - getLength() { - return this.d.len(); - } - midPoint() { - return this.start.lrp(this.end, 0.5); - } - getVertices() { - return [this.start, this.end]; - } - nearestPoint(point) { - const { start, end, u, ul: l } = this; - if (l === 0) - return start; - const k = Vec.Sub(point, start).dpr(u) / l; - const cx = start.x + u.x * k; - if (cx < Math.min(start.x, end.x)) - return start.x < end.x ? start : end; - if (cx > Math.max(start.x, end.x)) - return start.x > end.x ? start : end; - const cy = start.y + u.y * k; - if (cy < Math.min(start.y, end.y)) - return start.y < end.y ? start : end; - if (cy > Math.max(start.y, end.y)) - return start.y > end.y ? start : end; - return new Vec(cx, cy); - } - hitTestLineSegment(A, B, distance = 0) { - return linesIntersect(A, B, this.start, this.end) || this.distanceToLineSegment(A, B) <= distance; - } - getSvgPathData(first = true) { - const { start, end } = this; - return `${first ? `M${start.toFixed()}` : ``} L${end.toFixed()}`; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Polyline2d.mjs -var Polyline2d = class extends Geometry2d { - constructor(config) { - super({ isClosed: false, isFilled: false, ...config }); - __publicField(this, "points"); - __publicField(this, "_segments"); - const { points } = config; - this.points = points; - } - get segments() { - if (!this._segments) { - this._segments = []; - const { vertices } = this; - for (let i = 0, n = vertices.length - 1; i < n; i++) { - const start = vertices[i]; - const end = vertices[i + 1]; - this._segments.push(new Edge2d({ start, end })); - } - if (this.isClosed) { - this._segments.push(new Edge2d({ start: vertices[vertices.length - 1], end: vertices[0] })); - } - } - return this._segments; - } - getLength() { - return this.segments.reduce((acc, segment) => acc + segment.length, 0); - } - getVertices() { - return this.points; - } - nearestPoint(A) { - const { segments } = this; - let nearest = this.points[0]; - let dist = Infinity; - let p; - let d; - for (let i = 0; i < segments.length; i++) { - p = segments[i].nearestPoint(A); - d = Vec.Dist2(p, A); - if (d < dist) { - nearest = p; - dist = d; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - hitTestLineSegment(A, B, distance = 0) { - const { segments } = this; - for (let i = 0, n = segments.length; i < n; i++) { - if (segments[i].hitTestLineSegment(A, B, distance)) { - return true; - } - } - return false; - } - getSvgPathData() { - const { vertices } = this; - if (vertices.length < 2) - return ""; - return vertices.reduce((acc, vertex, i) => { - if (i === 0) - return `M ${vertex.x} ${vertex.y}`; - return `${acc} L ${vertex.x} ${vertex.y}`; - }, ""); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Polygon2d.mjs -var Polygon2d = class extends Polyline2d { - constructor(config) { - super({ ...config }); - this.isClosed = true; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Rectangle2d.mjs -var Rectangle2d = class extends Polygon2d { - constructor(config) { - const { x = 0, y = 0, width, height } = config; - super({ - ...config, - points: [ - new Vec(x, y), - new Vec(x + width, y), - new Vec(x + width, y + height), - new Vec(x, y + height) - ] - }); - __publicField(this, "x"); - __publicField(this, "y"); - __publicField(this, "w"); - __publicField(this, "h"); - this.x = x; - this.y = y; - this.w = width; - this.h = height; - } - getBounds() { - return new Box(this.x, this.y, this.w, this.h); - } - getSvgPathData() { - const { x, y, w, h } = this; - return `M${x},${y} h${w} v${h} h-${w}z`; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/ShapeUtil.mjs -var ShapeUtil = class { - constructor(editor) { - __publicField(this, "canSnap", () => true); - __publicField(this, "canScroll", () => false); - __publicField(this, "canEdit", () => false); - __publicField(this, "canResize", () => true); - __publicField(this, "canEditInReadOnly", () => false); - __publicField(this, "canCrop", () => false); - __publicField(this, "canBeLaidOut", () => true); - __publicField(this, "hideResizeHandles", () => false); - __publicField(this, "hideRotateHandle", () => false); - __publicField(this, "hideSelectionBoundsBg", () => false); - __publicField(this, "hideSelectionBoundsFg", () => false); - __publicField(this, "isAspectRatioLocked", () => false); - __publicField(this, "onBeforeCreate"); - __publicField(this, "onBeforeUpdate"); - __publicField(this, "onDragShapesOver"); - __publicField(this, "onDragShapesOut"); - __publicField(this, "onDropShapesOver"); - __publicField(this, "onResizeStart"); - __publicField(this, "onResize"); - __publicField(this, "onResizeEnd"); - __publicField(this, "onTranslateStart"); - __publicField(this, "onTranslate"); - __publicField(this, "onTranslateEnd"); - __publicField(this, "onHandleDrag"); - __publicField(this, "onRotateStart"); - __publicField(this, "onRotate"); - __publicField(this, "onRotateEnd"); - __publicField(this, "onBindingChange"); - __publicField(this, "onChildrenChange"); - __publicField(this, "onDoubleClickHandle"); - __publicField(this, "onDoubleClickEdge"); - __publicField(this, "onDoubleClick"); - __publicField(this, "onClick"); - __publicField(this, "onEditEnd"); - this.editor = editor; - } - canBind(opts) { - return true; - } - providesBackgroundForChildren(shape) { - return false; - } - canReceiveNewChildrenOfType(shape, type) { - return false; - } - canDropShapes(shape, shapes) { - return false; - } - expandSelectionOutlinePx(shape) { - return 0; - } - getCanvasSvgDefs() { - return []; - } - getBoundsSnapGeometry(shape) { - return {}; - } - getHandleSnapGeometry(shape) { - return {}; - } -}; -__publicField(ShapeUtil, "props"); -__publicField(ShapeUtil, "migrations"); -__publicField(ShapeUtil, "type"); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/group/DashedOutlineBox.mjs -var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs -function getPerfectDashProps(totalLength, strokeWidth, opts = {}) { - const { - closed = false, - snap = 1, - start = "outset", - end = "outset", - lengthRatio = 2, - style = "dashed" - } = opts; - let dashLength = 0; - let dashCount = 0; - let ratio = 1; - let gapLength = 0; - let strokeDashoffset = 0; - switch (style) { - case "dashed": { - ratio = 1; - dashLength = Math.min(strokeWidth * lengthRatio, totalLength / 4); - break; - } - case "dotted": { - ratio = 100; - dashLength = strokeWidth / ratio; - break; - } - default: { - return { - strokeDasharray: "none", - strokeDashoffset: "none" - }; - } - } - if (!closed) { - if (start === "outset") { - totalLength += dashLength / 2; - strokeDashoffset += dashLength / 2; - } else if (start === "skip") { - totalLength -= dashLength; - strokeDashoffset -= dashLength; - } - if (end === "outset") { - totalLength += dashLength / 2; - } else if (end === "skip") { - totalLength -= dashLength; - } - } - dashCount = Math.floor(totalLength / dashLength / (2 * ratio)); - dashCount -= dashCount % snap; - if (dashCount < 3 && style === "dashed") { - if (totalLength / strokeWidth < 5) { - dashLength = totalLength; - dashCount = 1; - gapLength = 0; - } else { - dashLength = totalLength * 0.333; - gapLength = totalLength * 0.333; - } - } else { - dashCount = Math.max(dashCount, 3); - dashLength = totalLength / dashCount / (2 * ratio); - if (closed) { - strokeDashoffset = dashLength / 2; - gapLength = (totalLength - dashCount * dashLength) / dashCount; - } else { - gapLength = (totalLength - dashCount * dashLength) / Math.max(1, dashCount - 1); - } - } - return { - strokeDasharray: [dashLength, gapLength].join(" "), - strokeDashoffset: strokeDashoffset.toString() - }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/group/DashedOutlineBox.mjs -function DashedOutlineBox({ bounds, className }) { - const editor = useEditor(); - const zoomLevel = useValue("zoom level", () => editor.getZoomLevel(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("g", { className, pointerEvents: "none", strokeLinecap: "round", strokeLinejoin: "round", children: bounds.sides.map((side, i) => { - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps(side[0].dist(side[1]), 1 / zoomLevel, { - style: "dashed", - lengthRatio: 4 - }); - return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("line", { - x1: side[0].x, - y1: side[0].y, - x2: side[1].x, - y2: side[1].y, - strokeDasharray, - strokeDashoffset - }, i); - }) }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs -var GroupShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "hideSelectionBoundsFg", () => true); - __publicField(this, "canBind", () => false); - __publicField(this, "onChildrenChange", (group) => { - const children = this.editor.getSortedChildIdsForParent(group.id); - if (children.length === 0) { - if (this.editor.getCurrentPageState().focusedGroupId === group.id) { - this.editor.popFocusedGroupId(); - } - this.editor.deleteShapes([group.id]); - return; - } else if (children.length === 1) { - if (this.editor.getCurrentPageState().focusedGroupId === group.id) { - this.editor.popFocusedGroupId(); - } - this.editor.reparentShapes(children, group.parentId); - this.editor.deleteShapes([group.id]); - return; - } - }); - } - getDefaultProps() { - return {}; - } - getGeometry(shape) { - const children = this.editor.getSortedChildIdsForParent(shape.id); - if (children.length === 0) { - return new Rectangle2d({ width: 1, height: 1, isFilled: false }); - } - return new Group2d({ - children: children.map((childId) => { - const shape2 = this.editor.getShape(childId); - const geometry = this.editor.getShapeGeometry(childId); - const points = this.editor.getShapeLocalTransform(shape2).applyToPoints(geometry.vertices); - if (geometry.isClosed) { - return new Polygon2d({ - points, - isFilled: true - }); - } - return new Polyline2d({ - points - }); - }) - }); - } - component(shape) { - const isErasing = this.editor.getErasingShapeIds().includes(shape.id); - const { hintingShapeIds } = this.editor.getCurrentPageState(); - const isHintingOtherGroup = hintingShapeIds.length > 0 && hintingShapeIds.some((id) => id !== shape.id && this.editor.isShapeOfType(this.editor.getShape(id), "group")); - const isFocused = this.editor.getCurrentPageState().focusedGroupId !== shape.id; - if (!isErasing && (isFocused || isHintingOtherGroup)) { - return null; - } - const bounds = this.editor.getShapeGeometry(shape).bounds; - return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SVGContainer, { id: shape.id, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DashedOutlineBox, { className: "tl-group", bounds }) }); - } - indicator(shape) { - const bounds = this.editor.getShapeGeometry(shape).bounds; - return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DashedOutlineBox, { className: "", bounds }); - } -}; -__publicField(GroupShapeUtil, "type", "group"); -__publicField(GroupShapeUtil, "props", groupShapeProps); -__publicField(GroupShapeUtil, "migrations", groupShapeMigrations); - -// node_modules/@tldraw/editor/dist-esm/lib/config/defaultShapes.mjs -var coreShapes = [ - GroupShapeUtil -]; -var coreShapeTypes = new Set(coreShapes.map((s) => s.type)); -function checkShapesAndAddCore(customShapes) { - const shapes = [...coreShapes]; - const addedCustomShapeTypes = /* @__PURE__ */ new Set(); - for (const customShape of customShapes) { - if (coreShapeTypes.has(customShape.type)) { - throw new Error(`Shape type "${customShape.type}" is a core shapes type and cannot be overridden`); - } - if (addedCustomShapeTypes.has(customShape.type)) { - throw new Error(`Shape type "${customShape.type}" is defined more than once`); - } - shapes.push(customShape); - addedCustomShapeTypes.add(customShape.type); - } - return shapes; -} - -// node_modules/@tldraw/editor/dist-esm/lib/options.mjs -var defaultTldrawOptions = { - maxShapesPerPage: 4e3, - maxPages: 40, - animationMediumMs: 320, - followChaseViewportSnap: 2, - doubleClickDurationMs: 450, - multiClickDurationMs: 200, - coarseDragDistanceSquared: 36, - dragDistanceSquared: 16, - defaultSvgPadding: 32, - cameraSlideFriction: 0.09, - maxPointsPerDrawShape: 500, - gridSteps: [ - { min: -1, mid: 0.15, step: 64 }, - { min: 0.05, mid: 0.375, step: 16 }, - { min: 0.15, mid: 1, step: 4 }, - { min: 0.7, mid: 2.5, step: 1 } - ], - collaboratorInactiveTimeoutMs: 6e4, - collaboratorIdleTimeoutMs: 3e3, - collaboratorCheckIntervalMs: 1200, - cameraMovingTimeoutMs: 64, - hitTestMargin: 8, - edgeScrollDelay: 200, - edgeScrollEaseDuration: 200, - edgeScrollSpeed: 25, - edgeScrollDistance: 8, - coarsePointerWidth: 12, - coarseHandleRadius: 20, - handleRadius: 12, - longPressDurationMs: 500, - textShadowLod: 0.35, - adjacentShapeMargin: 10, - flattenImageBoundsExpand: 64, - flattenImageBoundsPadding: 16 -}; - -// node_modules/@tldraw/editor/dist-esm/lib/utils/SharedStylesMap.mjs -function sharedStyleEquals(a, b) { - if (!b) - return false; - switch (a.type) { - case "mixed": - return b.type === "mixed"; - case "shared": - return b.type === "shared" && a.value === b.value; - default: - throw exhaustiveSwitchError(a); - } -} -var ReadonlySharedStyleMap = class { - constructor(entries) { - __publicField(this, "map"); - this.map = new Map(entries); - } - get(prop) { - return this.map.get(prop); - } - getAsKnownValue(prop) { - const value = this.get(prop); - if (!value) - return void 0; - if (value.type === "mixed") - return void 0; - return value.value; - } - get size() { - return this.map.size; - } - equals(other) { - if (this.size !== other.size) - return false; - const checkedKeys = /* @__PURE__ */ new Set(); - for (const [styleProp, value] of this) { - if (!sharedStyleEquals(value, other.get(styleProp))) - return false; - checkedKeys.add(styleProp); - } - for (const [styleProp, value] of other) { - if (checkedKeys.has(styleProp)) - continue; - if (!sharedStyleEquals(value, this.get(styleProp))) - return false; - } - return true; - } - keys() { - return this.map.keys(); - } - values() { - return this.map.values(); - } - entries() { - return this.map.entries(); - } - [Symbol.iterator]() { - return this.map[Symbol.iterator](); - } -}; -var SharedStyleMap = class extends ReadonlySharedStyleMap { - set(prop, value) { - this.map.set(prop, value); - } - applyValue(prop, value) { - const existingValue = this.get(prop); - if (!existingValue) { - this.set(prop, { type: "shared", value }); - return; - } - switch (existingValue.type) { - case "mixed": - return; - case "shared": - if (existingValue.value !== value) { - this.set(prop, { type: "mixed" }); - } - return; - default: - exhaustiveSwitchError(existingValue, "type"); - } - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/utils/assets.mjs -function dataUrlToFile(url, filename, mimeType) { - return fetch2(url).then(function(res) { - return res.arrayBuffer(); - }).then(function(buf) { - return new File([buf], filename, { type: mimeType }); - }); -} -var CDN_BASE_URL = "https://cdn.tldraw.com"; -function getDefaultCdnBaseUrl() { - return `${CDN_BASE_URL}/${version}`; -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/getIncrementedName.mjs -function getIncrementedName(name, others) { - let result = name; - const set = new Set(others); - while (set.has(result)) { - result = /^.*(\d+)$/.exec(result)?.[1] ? result.replace(/(\d+)(?=\D?)$/, (m) => { - return (+m + 1).toString(); - }) : `${result} 1`; - } - return result; -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/reorderShapes.mjs -function getReorderingShapesChanges(editor, operation, ids) { - if (ids.length === 0) - return []; - const parents = /* @__PURE__ */ new Map(); - for (const shape of compact(ids.map((id) => editor.getShape(id)))) { - const { parentId } = shape; - if (!parents.has(parentId)) { - parents.set(parentId, { - children: compact(editor.getSortedChildIdsForParent(parentId).map((id) => editor.getShape(id))), - moving: /* @__PURE__ */ new Set() - }); - } - parents.get(parentId).moving.add(shape); - } - const changes = []; - switch (operation) { - case "toBack": { - parents.forEach(({ moving, children }) => reorderToBack(moving, children, changes)); - break; - } - case "toFront": { - parents.forEach(({ moving, children }) => reorderToFront(moving, children, changes)); - break; - } - case "forward": { - parents.forEach(({ moving, children }) => reorderForward(moving, children, changes)); - break; - } - case "backward": { - parents.forEach(({ moving, children }) => reorderBackward(moving, children, changes)); - break; - } - } - return changes; -} -function reorderToBack(moving, children, changes) { - const len = children.length; - if (moving.size === len) - return; - let below; - let above; - for (let i = 0; i < len; i++) { - const shape = children[i]; - if (moving.has(shape)) { - below = shape.index; - moving.delete(shape); - } else { - above = shape.index; - break; - } - } - if (moving.size === 0) { - return; - } else { - const indices = getIndicesBetween(below, above, moving.size); - changes.push(...Array.from(moving.values()).sort(sortByIndex).map((shape, i) => ({ ...shape, index: indices[i] }))); - } -} -function reorderToFront(moving, children, changes) { - const len = children.length; - if (moving.size === len) - return; - let below; - let above; - for (let i = len - 1; i > -1; i--) { - const shape = children[i]; - if (moving.has(shape)) { - above = shape.index; - moving.delete(shape); - } else { - below = shape.index; - break; - } - } - if (moving.size === 0) { - return; - } else { - const indices = getIndicesBetween(below, above, moving.size); - changes.push(...Array.from(moving.values()).sort(sortByIndex).map((shape, i) => ({ ...shape, index: indices[i] }))); - } -} -function reorderForward(moving, children, changes) { - const len = children.length; - if (moving.size === len) - return; - let state = { name: "skipping" }; - for (let i = 0; i < len; i++) { - const isMoving = moving.has(children[i]); - switch (state.name) { - case "skipping": { - if (!isMoving) - continue; - state = { name: "selecting", selectIndex: i }; - break; - } - case "selecting": { - if (isMoving) - continue; - const { selectIndex } = state; - getIndicesBetween(children[i].index, children[i + 1]?.index, i - selectIndex).forEach((index2, k) => changes.push({ ...children[selectIndex + k], index: index2 })); - state = { name: "skipping" }; - break; - } - } - } -} -function reorderBackward(moving, children, changes) { - const len = children.length; - if (moving.size === len) - return; - let state = { name: "skipping" }; - for (let i = len - 1; i > -1; i--) { - const isMoving = moving.has(children[i]); - switch (state.name) { - case "skipping": { - if (!isMoving) - continue; - state = { name: "selecting", selectIndex: i }; - break; - } - case "selecting": { - if (isMoving) - continue; - getIndicesBetween(children[i - 1]?.index, children[i].index, state.selectIndex - i).forEach((index2, k) => { - changes.push({ ...children[i + k + 1], index: index2 }); - }); - state = { name: "skipping" }; - break; - } - } - } -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/rotation.mjs -function getRotationSnapshot({ editor }) { - const selectedShapes = editor.getSelectedShapes(); - const selectionRotation = editor.getSelectionRotation(); - const selectionBounds = editor.getSelectionRotatedPageBounds(); - const { - inputs: { originPagePoint } - } = editor; - if (!selectionBounds) { - return null; - } - const selectionPageCenter = selectionBounds.center.clone().rotWith(selectionBounds.point, selectionRotation); - return { - selectionPageCenter, - initialCursorAngle: selectionPageCenter.angle(originPagePoint), - initialSelectionRotation: selectionRotation, - shapeSnapshots: selectedShapes.map((shape) => ({ - shape: structuredClone(shape), - initialPagePoint: editor.getShapePageTransform(shape.id).point() - })) - }; -} -function applyRotationToSnapshotShapes({ - delta, - editor, - snapshot, - stage -}) { - const { selectionPageCenter, shapeSnapshots } = snapshot; - editor.updateShapes(shapeSnapshots.map(({ shape, initialPagePoint }) => { - const parentTransform = isShapeId(shape.parentId) ? editor.getShapePageTransform(shape.parentId) : Mat.Identity(); - const newPagePoint = Vec.RotWith(initialPagePoint, selectionPageCenter, delta); - const newLocalPoint = Mat.applyToPoint(Mat.Inverse(parentTransform), newPagePoint); - const newRotation = canonicalizeRotation(shape.rotation + delta); - return { - id: shape.id, - type: shape.type, - x: newLocalPoint.x, - y: newLocalPoint.y, - rotation: newRotation - }; - })); - const changes = []; - shapeSnapshots.forEach(({ shape }) => { - const current = editor.getShape(shape.id); - if (!current) - return; - const util = editor.getShapeUtil(shape); - if (stage === "start" || stage === "one-off") { - const changeStart = util.onRotateStart?.(shape); - if (changeStart) - changes.push(changeStart); - } - const changeUpdate = util.onRotate?.(shape, current); - if (changeUpdate) - changes.push(changeUpdate); - if (stage === "end" || stage === "one-off") { - const changeEnd = util.onRotateEnd?.(shape, current); - if (changeEnd) - changes.push(changeEnd); - } - }); - if (changes.length > 0) { - editor.updateShapes(changes); - } -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/derivations/bindingsIndex.mjs -var bindingsIndex = (editor) => { - const { store } = editor; - const bindingsHistory = store.query.filterHistory("binding"); - const bindingsQuery = store.query.records("binding"); - function fromScratch() { - const allBindings = bindingsQuery.get(); - const shape2Binding = /* @__PURE__ */ new Map(); - for (const binding of allBindings) { - const { fromId, toId } = binding; - const bindingsForFromShape = shape2Binding.get(fromId); - if (!bindingsForFromShape) { - shape2Binding.set(fromId, [binding]); - } else { - bindingsForFromShape.push(binding); - } - const bindingsForToShape = shape2Binding.get(toId); - if (!bindingsForToShape) { - shape2Binding.set(toId, [binding]); - } else { - bindingsForToShape.push(binding); - } - } - return shape2Binding; - } - return computed("arrowBindingsIndex", (_lastValue, lastComputedEpoch) => { - if (isUninitialized(_lastValue)) { - return fromScratch(); - } - const lastValue = _lastValue; - const diff = bindingsHistory.getDiffSince(lastComputedEpoch); - if (diff === RESET_VALUE) { - return fromScratch(); - } - let nextValue = void 0; - function removingBinding(binding) { - nextValue ?? (nextValue = new Map(lastValue)); - const prevFrom = nextValue.get(binding.fromId); - const nextFrom = prevFrom?.filter((b) => b.id !== binding.id); - if (!nextFrom?.length) { - nextValue.delete(binding.fromId); - } else { - nextValue.set(binding.fromId, nextFrom); - } - const prevTo = nextValue.get(binding.toId); - const nextTo = prevTo?.filter((b) => b.id !== binding.id); - if (!nextTo?.length) { - nextValue.delete(binding.toId); - } else { - nextValue.set(binding.toId, nextTo); - } - } - function ensureNewArray(shapeId) { - nextValue ?? (nextValue = new Map(lastValue)); - let result = nextValue.get(shapeId); - if (!result) { - result = []; - nextValue.set(shapeId, result); - } else if (result === lastValue.get(shapeId)) { - result = result.slice(0); - nextValue.set(shapeId, result); - } - return result; - } - function addBinding(binding) { - ensureNewArray(binding.fromId).push(binding); - ensureNewArray(binding.toId).push(binding); - } - for (const changes of diff) { - for (const newBinding of objectMapValues(changes.added)) { - addBinding(newBinding); - } - for (const [prev, next] of objectMapValues(changes.updated)) { - removingBinding(prev); - addBinding(next); - } - for (const prev of objectMapValues(changes.removed)) { - removingBinding(prev); - } - } - return nextValue ?? lastValue; - }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/derivations/notVisibleShapes.mjs -function isShapeNotVisible(editor, id, viewportPageBounds) { - const maskedPageBounds = editor.getShapeMaskedPageBounds(id); - if (maskedPageBounds === void 0) - return true; - return !viewportPageBounds.includes(maskedPageBounds); -} -var notVisibleShapes = (editor) => { - function fromScratch(editor2) { - const shapes = editor2.getCurrentPageShapeIds(); - const viewportPageBounds = editor2.getViewportPageBounds(); - const notVisibleShapes2 = /* @__PURE__ */ new Set(); - shapes.forEach((id) => { - if (isShapeNotVisible(editor2, id, viewportPageBounds)) { - notVisibleShapes2.add(id); - } - }); - return notVisibleShapes2; - } - return computed("getCulledShapes", (prevValue) => { - if (isUninitialized(prevValue)) { - return fromScratch(editor); - } - const nextValue = fromScratch(editor); - if (prevValue.size !== nextValue.size) - return nextValue; - for (const prev of prevValue) { - if (!nextValue.has(prev)) { - return nextValue; - } - } - return prevValue; - }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/derivations/parentsToChildren.mjs -var parentsToChildren = (store) => { - const shapeIdsQuery = store.query.ids("shape"); - const shapeHistory = store.query.filterHistory("shape"); - function fromScratch() { - const result = {}; - const shapeIds = shapeIdsQuery.get(); - const shapes = Array(shapeIds.size); - shapeIds.forEach((id) => shapes.push(store.get(id))); - shapes.sort(sortByIndex); - shapes.forEach((shape) => { - if (!result[shape.parentId]) { - result[shape.parentId] = []; - } - result[shape.parentId].push(shape.id); - }); - return result; - } - return computed("parentsToChildrenWithIndexes", (lastValue, lastComputedEpoch) => { - if (isUninitialized(lastValue)) { - return fromScratch(); - } - const diff = shapeHistory.getDiffSince(lastComputedEpoch); - if (diff === RESET_VALUE) { - return fromScratch(); - } - if (diff.length === 0) - return lastValue; - let newValue = null; - const ensureNewArray = (parentId) => { - if (!newValue) { - newValue = { ...lastValue }; - } - if (!newValue[parentId]) { - newValue[parentId] = []; - } else if (newValue[parentId] === lastValue[parentId]) { - newValue[parentId] = [...newValue[parentId]]; - } - }; - const toSort = /* @__PURE__ */ new Set(); - let changes; - for (let i = 0, n = diff.length; i < n; i++) { - changes = diff[i]; - for (const record of Object.values(changes.added)) { - if (!isShape(record)) - continue; - ensureNewArray(record.parentId); - newValue[record.parentId].push(record.id); - toSort.add(newValue[record.parentId]); - } - for (const [from, to] of Object.values(changes.updated)) { - if (!isShape(to)) - continue; - if (!isShape(from)) - continue; - if (from.parentId !== to.parentId) { - ensureNewArray(from.parentId); - ensureNewArray(to.parentId); - newValue[from.parentId].splice(newValue[from.parentId].indexOf(to.id), 1); - newValue[to.parentId].push(to.id); - toSort.add(newValue[to.parentId]); - } else if (from.index !== to.index) { - ensureNewArray(to.parentId); - const idx = newValue[to.parentId].indexOf(to.id); - newValue[to.parentId][idx] = to.id; - toSort.add(newValue[to.parentId]); - } - } - for (const record of Object.values(changes.removed)) { - if (!isShape(record)) - continue; - ensureNewArray(record.parentId); - newValue[record.parentId].splice(newValue[record.parentId].indexOf(record.id), 1); - } - } - for (const arr of toSort) { - const shapesInArr = compact(arr.map((id) => store.get(id))); - shapesInArr.sort(sortByIndex); - arr.splice(0, arr.length, ...shapesInArr.map((shape) => shape.id)); - } - return newValue ?? lastValue; - }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs -var isShapeInPage = (store, pageId, shape) => { - while (!isPageId(shape.parentId)) { - const parent = store.get(shape.parentId); - if (!parent) - return false; - shape = parent; - } - return shape.parentId === pageId; -}; -var deriveShapeIdsInCurrentPage = (store, getCurrentPageId) => { - const shapesIndex = store.query.ids("shape"); - let lastPageId = null; - function fromScratch() { - const currentPageId = getCurrentPageId(); - lastPageId = currentPageId; - return new Set([...shapesIndex.get()].filter((id) => isShapeInPage(store, currentPageId, store.get(id)))); - } - return computed("_shapeIdsInCurrentPage", (prevValue, lastComputedEpoch) => { - if (isUninitialized(prevValue)) { - return fromScratch(); - } - const currentPageId = getCurrentPageId(); - if (currentPageId !== lastPageId) { - return fromScratch(); - } - const diff = store.history.getDiffSince(lastComputedEpoch); - if (diff === RESET_VALUE) { - return fromScratch(); - } - const builder = new IncrementalSetConstructor(prevValue); - for (const changes of diff) { - for (const record of Object.values(changes.added)) { - if (isShape(record) && isShapeInPage(store, currentPageId, record)) { - builder.add(record.id); - } - } - for (const [_from, to] of Object.values(changes.updated)) { - if (isShape(to)) { - if (isShapeInPage(store, currentPageId, to)) { - builder.add(to.id); - } else { - builder.remove(to.id); - } - } - } - for (const id of Object.keys(changes.removed)) { - if (isShapeId(id)) { - builder.remove(id); - } - } - } - const result = builder.get(); - if (!result) { - return prevValue; - } - return withDiff(result.value, result.diff); - }); -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/getSvgJsx.mjs -var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); -var import_react34 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/types/SvgExportContext.mjs -var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); -var import_react33 = __toESM(require_react(), 1); -var Context = (0, import_react33.createContext)(null); -function SvgExportContextProvider({ - context, - editor, - children -}) { - return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Context.Provider, { value: context, children }) }); -} -function useSvgExportContext() { - const ctx = (0, import_react33.useContext)(Context); - if (!ctx) - return null; - return { isDarkMode: ctx.isDarkMode }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/getSvgJsx.mjs -async function getSvgJsx(editor, shapes, opts = {}) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length === 0) - return; - if (!window.document) - throw Error("No document"); - const { - scale = 1, - background = false, - padding = editor.options.defaultSvgPadding, - preserveAspectRatio = false - } = opts; - const isDarkMode = opts.darkMode ?? editor.user.getIsDarkMode(); - const theme = getDefaultColorTheme({ isDarkMode }); - const shapeIdsToInclude = editor.getShapeAndDescendantIds(ids); - const renderingShapes = editor.getUnorderedRenderingShapes(false).filter(({ id }) => shapeIdsToInclude.has(id)); - let bbox = null; - if (opts.bounds) { - bbox = opts.bounds; - } else { - for (const { id } of renderingShapes) { - const maskedPageBounds = editor.getShapeMaskedPageBounds(id); - if (!maskedPageBounds) - continue; - if (bbox) { - bbox.union(maskedPageBounds); - } else { - bbox = maskedPageBounds.clone(); - } - } - } - if (!bbox) - return; - const singleFrameShapeId = ids.length === 1 && editor.isShapeOfType(editor.getShape(ids[0]), "frame") ? ids[0] : null; - if (!singleFrameShapeId) { - bbox.expandBy(padding); - } - const w = bbox.width * scale; - const h = bbox.height * scale; - try { - document.body.focus?.(); - } catch (e) { - } - const defChildren = []; - const exportDefPromisesById = /* @__PURE__ */ new Map(); - const exportContext = { - isDarkMode, - addExportDef: (def) => { - if (exportDefPromisesById.has(def.key)) - return; - const promise = (async () => { - const element = await def.getElement(); - if (!element) - return; - defChildren.push(/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react34.Fragment, { children: element }, defChildren.length)); - })(); - exportDefPromisesById.set(def.key, promise); - } - }; - const unorderedShapeElements = (await Promise.all(renderingShapes.map(async ({ id, opacity, index: index2, backgroundIndex }) => { - if (id === singleFrameShapeId) - return []; - const shape = editor.getShape(id); - if (editor.isShapeOfType(shape, "group")) - return []; - const util = editor.getShapeUtil(shape); - let toSvgResult = await util.toSvg?.(shape, exportContext); - let toBackgroundSvgResult = await util.toBackgroundSvg?.(shape, exportContext); - if (!toSvgResult && !toBackgroundSvgResult) { - const bounds = editor.getShapePageBounds(shape); - toSvgResult = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("rect", { - width: bounds.w, - height: bounds.h, - fill: theme.solid, - stroke: theme.grey.pattern, - strokeWidth: 1 - }); - } - let pageTransform = editor.getShapePageTransform(shape).toCssString(); - if ("scale" in shape.props) { - if (shape.props.scale !== 1) { - pageTransform = `${pageTransform} scale(${shape.props.scale}, ${shape.props.scale})`; - } - } - if (toSvgResult) { - toSvgResult = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("g", { transform: pageTransform, opacity, children: toSvgResult }, shape.id); - } - if (toBackgroundSvgResult) { - toBackgroundSvgResult = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("g", { transform: pageTransform, opacity, children: toBackgroundSvgResult }, `bg_${shape.id}`); - } - const pageMask = editor.getShapeMask(shape.id); - if (pageMask) { - const pageMaskId = `mask_${shape.id.replace(":", "_")}`; - defChildren.push(/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("clipPath", { id: pageMaskId, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: `M${pageMask.map(({ x, y }) => `${x},${y}`).join("L")}Z` }) }, defChildren.length)); - if (toSvgResult) { - toSvgResult = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("g", { clipPath: `url(#${pageMaskId})`, children: toSvgResult }, shape.id); - } - if (toBackgroundSvgResult) { - toBackgroundSvgResult = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("g", { clipPath: `url(#${pageMaskId})`, children: toBackgroundSvgResult }, `bg_${shape.id}`); - } - } - const elements = []; - if (toSvgResult) { - elements.push({ zIndex: index2, element: toSvgResult }); - } - if (toBackgroundSvgResult) { - elements.push({ zIndex: backgroundIndex, element: toBackgroundSvgResult }); - } - return elements; - }))).flat(); - await Promise.all(exportDefPromisesById.values()); - const svg = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(SvgExportContextProvider, { editor, context: exportContext, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("svg", { - preserveAspectRatio: preserveAspectRatio ? preserveAspectRatio : void 0, - direction: "ltr", - width: w, - height: h, - viewBox: `${bbox.minX} ${bbox.minY} ${bbox.width} ${bbox.height}`, - strokeLinecap: "round", - strokeLinejoin: "round", - style: { - backgroundColor: background ? singleFrameShapeId ? theme.solid : theme.background : "transparent" - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("defs", { children: defChildren }), - unorderedShapeElements.sort((a, b) => a.zIndex - b.zIndex).map(({ element }) => element) - ] - }) }); - return { jsx: svg, width: w, height: h }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/ClickManager.mjs -var MAX_CLICK_DISTANCE = 40; -var ClickManager = class { - constructor(editor) { - __publicField(this, "_clickId", ""); - __publicField(this, "_clickTimeout"); - __publicField(this, "_clickScreenPoint"); - __publicField(this, "_previousScreenPoint"); - __publicField(this, "_getClickTimeout", (state, id = uniqueId()) => { - this._clickId = id; - clearTimeout(this._clickTimeout); - this._clickTimeout = this.editor.timers.setTimeout(() => { - if (this._clickState === state && this._clickId === id) { - switch (this._clickState) { - case "pendingTriple": { - this.editor.dispatch({ - ...this.lastPointerInfo, - type: "click", - name: "double_click", - phase: "settle" - }); - break; - } - case "pendingQuadruple": { - this.editor.dispatch({ - ...this.lastPointerInfo, - type: "click", - name: "triple_click", - phase: "settle" - }); - break; - } - case "pendingOverflow": { - this.editor.dispatch({ - ...this.lastPointerInfo, - type: "click", - name: "quadruple_click", - phase: "settle" - }); - break; - } - default: { - } - } - this._clickState = "idle"; - } - }, state === "idle" || state === "pendingDouble" ? this.editor.options.doubleClickDurationMs : this.editor.options.multiClickDurationMs); - }); - __publicField(this, "_clickState", "idle"); - __publicField(this, "lastPointerInfo", {}); - __publicField(this, "handlePointerEvent", (info2) => { - switch (info2.name) { - case "pointer_down": { - if (!this._clickState) - return info2; - this._clickScreenPoint = Vec.From(info2.point); - if (this._previousScreenPoint && Vec.Dist2(this._previousScreenPoint, this._clickScreenPoint) > MAX_CLICK_DISTANCE ** 2) { - this._clickState = "idle"; - } - this._previousScreenPoint = this._clickScreenPoint; - this.lastPointerInfo = info2; - switch (this._clickState) { - case "pendingDouble": { - this._clickState = "pendingTriple"; - this._clickTimeout = this._getClickTimeout(this._clickState); - return { - ...info2, - type: "click", - name: "double_click", - phase: "down" - }; - } - case "pendingTriple": { - this._clickState = "pendingQuadruple"; - this._clickTimeout = this._getClickTimeout(this._clickState); - return { - ...info2, - type: "click", - name: "triple_click", - phase: "down" - }; - } - case "pendingQuadruple": { - this._clickState = "pendingOverflow"; - this._clickTimeout = this._getClickTimeout(this._clickState); - return { - ...info2, - type: "click", - name: "quadruple_click", - phase: "down" - }; - } - case "idle": { - this._clickState = "pendingDouble"; - break; - } - case "pendingOverflow": { - this._clickState = "overflow"; - break; - } - default: { - } - } - this._clickTimeout = this._getClickTimeout(this._clickState); - return info2; - } - case "pointer_up": { - if (!this._clickState) - return info2; - this._clickScreenPoint = Vec.From(info2.point); - switch (this._clickState) { - case "pendingTriple": { - return { - ...this.lastPointerInfo, - type: "click", - name: "double_click", - phase: "up" - }; - } - case "pendingQuadruple": { - return { - ...this.lastPointerInfo, - type: "click", - name: "triple_click", - phase: "up" - }; - } - case "pendingOverflow": { - return { - ...this.lastPointerInfo, - type: "click", - name: "quadruple_click", - phase: "up" - }; - } - default: { - } - } - return info2; - } - case "pointer_move": { - if (this._clickState !== "idle" && this._clickScreenPoint && Vec.Dist2(this._clickScreenPoint, this.editor.inputs.currentScreenPoint) > (this.editor.getInstanceState().isCoarsePointer ? this.editor.options.coarseDragDistanceSquared : this.editor.options.dragDistanceSquared)) { - this.cancelDoubleClickTimeout(); - } - return info2; - } - } - return info2; - }); - __publicField(this, "cancelDoubleClickTimeout", () => { - this._clickTimeout = clearTimeout(this._clickTimeout); - this._clickState = "idle"; - }); - this.editor = editor; - } - get clickState() { - return this._clickState; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/EdgeScrollManager.mjs -var EdgeScrollManager = class { - constructor(editor) { - __publicField(this, "_isEdgeScrolling", false); - __publicField(this, "_edgeScrollDuration", -1); - this.editor = editor; - } - updateEdgeScrolling(elapsed) { - const { editor } = this; - const edgeScrollProximityFactor = this.getEdgeScroll(); - if (edgeScrollProximityFactor.x === 0 && edgeScrollProximityFactor.y === 0) { - if (this._isEdgeScrolling) { - this._isEdgeScrolling = false; - this._edgeScrollDuration = 0; - } - } else { - if (!this._isEdgeScrolling) { - this._isEdgeScrolling = true; - this._edgeScrollDuration = 0; - } - this._edgeScrollDuration += elapsed; - if (this._edgeScrollDuration > editor.options.edgeScrollDelay) { - const eased = editor.options.edgeScrollEaseDuration > 0 ? EASINGS.easeInCubic(Math.min(1, this._edgeScrollDuration / (editor.options.edgeScrollDelay + editor.options.edgeScrollEaseDuration))) : 1; - this.moveCameraWhenCloseToEdge({ - x: edgeScrollProximityFactor.x * eased, - y: edgeScrollProximityFactor.y * eased - }); - } - } - } - getEdgeProximityFactors(position, dimension, isCoarse, insetStart, insetEnd) { - const { editor } = this; - const dist = editor.options.edgeScrollDistance; - const pw = isCoarse ? editor.options.coarsePointerWidth : 0; - const pMin = position - pw; - const pMax = position + pw; - const min3 = insetStart ? 0 : dist; - const max2 = insetEnd ? dimension : dimension - dist; - if (pMin < min3) { - return Math.min(1, (min3 - pMin) / dist); - } else if (pMax > max2) { - return -Math.min(1, (pMax - max2) / dist); - } - return 0; - } - getEdgeScroll() { - const { editor } = this; - const { - inputs: { - currentScreenPoint: { x, y } - } - } = editor; - const screenBounds = editor.getViewportScreenBounds(); - const { - isCoarsePointer, - insets: [t2, r, b, l] - } = editor.getInstanceState(); - const proximityFactorX = this.getEdgeProximityFactors(x, screenBounds.w, isCoarsePointer, l, r); - const proximityFactorY = this.getEdgeProximityFactors(y, screenBounds.h, isCoarsePointer, t2, b); - return { - x: proximityFactorX, - y: proximityFactorY - }; - } - moveCameraWhenCloseToEdge(proximityFactor) { - const { editor } = this; - if (!editor.inputs.isDragging || editor.inputs.isPanning || editor.getCameraOptions().isLocked) - return; - if (proximityFactor.x === 0 && proximityFactor.y === 0) - return; - const screenBounds = editor.getViewportScreenBounds(); - const screenSizeFactorX = screenBounds.w < 1e3 ? 0.612 : 1; - const screenSizeFactorY = screenBounds.h < 1e3 ? 0.612 : 1; - const zoomLevel = editor.getZoomLevel(); - const pxSpeed = editor.user.getEdgeScrollSpeed() * editor.options.edgeScrollSpeed; - const scrollDeltaX = pxSpeed * proximityFactor.x * screenSizeFactorX / zoomLevel; - const scrollDeltaY = pxSpeed * proximityFactor.y * screenSizeFactorY / zoomLevel; - const { x, y, z } = editor.getCamera(); - editor.setCamera(new Vec(x + scrollDeltaX, y + scrollDeltaY, z)); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/EnvironmentManager.mjs -var EnvironmentManager = class { - constructor(editor) { - __publicField(this, "isSafari"); - __publicField(this, "isIos"); - __publicField(this, "isChromeForIos"); - __publicField(this, "isFirefox"); - __publicField(this, "isAndroid"); - this.editor = editor; - if (typeof window !== "undefined" && "navigator" in window) { - this.isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); - this.isIos = !!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i); - this.isChromeForIos = /crios.*safari/i.test(navigator.userAgent); - this.isFirefox = /firefox/i.test(navigator.userAgent); - this.isAndroid = /android/i.test(navigator.userAgent); - } else { - this.isSafari = false; - this.isIos = false; - this.isChromeForIos = false; - this.isFirefox = false; - this.isAndroid = false; - } - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/FocusManager.mjs -var FocusManager = class { - constructor(editor, autoFocus) { - __publicField(this, "disposeSideEffectListener"); - this.editor = editor; - this.disposeSideEffectListener = editor.sideEffects.registerAfterChangeHandler("instance", (prev, next) => { - if (prev.isFocused !== next.isFocused) { - next.isFocused ? this.focus() : this.blur(); - this.updateContainerClass(); - } - }); - const currentFocusState = editor.getInstanceState().isFocused; - if (autoFocus !== currentFocusState) { - editor.updateInstanceState({ isFocused: !!autoFocus }); - } - this.updateContainerClass(); - } - updateContainerClass() { - const container = this.editor.getContainer(); - const instanceState = this.editor.getInstanceState(); - if (instanceState.isFocused) { - container.classList.add("tl-container__focused"); - } else { - container.classList.remove("tl-container__focused"); - } - } - focus() { - this.editor.getContainer().focus(); - } - blur() { - this.editor.complete(); - this.editor.getContainer().blur(); - } - dispose() { - this.disposeSideEffectListener?.(); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/Stack.mjs -function stack(items) { - if (items) { - let result = EMPTY_STACK_ITEM; - while (items.length) { - result = result.push(items.pop()); - } - return result; - } - return EMPTY_STACK_ITEM; -} -var EmptyStackItem = class { - constructor() { - __publicField(this, "length", 0); - __publicField(this, "head", null); - __publicField(this, "tail", this); - } - push(head) { - return new StackItem(head, this); - } - toArray() { - return EMPTY_ARRAY; - } - [Symbol.iterator]() { - return { - next() { - return { value: void 0, done: true }; - } - }; - } -}; -var EMPTY_STACK_ITEM = new EmptyStackItem(); -var StackItem = class { - constructor(head, tail) { - __publicField(this, "length"); - this.head = head; - this.tail = tail; - this.length = tail.length + 1; - } - push(head) { - return new StackItem(head, this); - } - toArray() { - return Array.from(this); - } - [Symbol.iterator]() { - let stack2 = this; - return { - next() { - if (stack2.length) { - const value = stack2.head; - stack2 = stack2.tail; - return { value, done: false }; - } else { - return { value: void 0, done: true }; - } - } - }; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/HistoryManager.mjs -var HistoryManager = class { - constructor(opts) { - __publicField(this, "store"); - __publicField(this, "dispose"); - __publicField(this, "state", "recording"); - __publicField(this, "pendingDiff", new PendingDiff()); - __publicField(this, "stacks", atom("HistoryManager.stacks", { - undos: stack(), - redos: stack() - }, { - isEqual: (a, b) => a.undos === b.undos && a.redos === b.redos - })); - __publicField(this, "annotateError"); - __publicField(this, "_isInBatch", false); - __publicField(this, "batch", (fn, opts) => { - const previousState = this.state; - if (previousState !== "paused" && opts?.history) { - this.state = modeToState[opts.history]; - } - try { - if (this._isInBatch) { - transact(fn); - return this; - } - this._isInBatch = true; - try { - transact(fn); - } catch (error3) { - this.annotateError(error3); - throw error3; - } finally { - this._isInBatch = false; - } - return this; - } finally { - this.state = previousState; - } - }); - __publicField(this, "_undo", ({ - pushToRedoStack, - toMark = void 0 - }) => { - const previousState = this.state; - this.state = "paused"; - try { - let { undos, redos } = this.stacks.get(); - const pendingDiff = this.pendingDiff.clear(); - const isPendingDiffEmpty = isRecordsDiffEmpty(pendingDiff); - const diffToUndo = reverseRecordsDiff(pendingDiff); - if (pushToRedoStack && !isPendingDiffEmpty) { - redos = redos.push({ type: "diff", diff: pendingDiff }); - } - let didFindMark = false; - if (isPendingDiffEmpty) { - while (undos.head?.type === "stop") { - const mark = undos.head; - undos = undos.tail; - if (pushToRedoStack) { - redos = redos.push(mark); - } - if (mark.id === toMark) { - didFindMark = true; - break; - } - } - } - if (!didFindMark) { - loop: - while (undos.head) { - const undo = undos.head; - undos = undos.tail; - if (pushToRedoStack) { - redos = redos.push(undo); - } - switch (undo.type) { - case "diff": - squashRecordDiffsMutable(diffToUndo, [reverseRecordsDiff(undo.diff)]); - break; - case "stop": - if (!toMark) - break loop; - if (undo.id === toMark) - break loop; - break; - default: - exhaustiveSwitchError(undo); - } - } - } - this.store.applyDiff(diffToUndo, { ignoreEphemeralKeys: true }); - this.store.ensureStoreIsUsable(); - this.stacks.set({ undos, redos }); - } finally { - this.state = previousState; - } - return this; - }); - __publicField(this, "undo", () => { - this._undo({ pushToRedoStack: true }); - return this; - }); - __publicField(this, "redo", () => { - const previousState = this.state; - this.state = "paused"; - try { - this.flushPendingDiff(); - let { undos, redos } = this.stacks.get(); - if (redos.length === 0) { - return this; - } - while (redos.head?.type === "stop") { - undos = undos.push(redos.head); - redos = redos.tail; - } - const diffToRedo = createEmptyRecordsDiff(); - while (redos.head) { - const redo = redos.head; - undos = undos.push(redo); - redos = redos.tail; - if (redo.type === "diff") { - squashRecordDiffsMutable(diffToRedo, [redo.diff]); - } else { - break; - } - } - this.store.applyDiff(diffToRedo, { ignoreEphemeralKeys: true }); - this.store.ensureStoreIsUsable(); - this.stacks.set({ undos, redos }); - } finally { - this.state = previousState; - } - return this; - }); - __publicField(this, "bail", () => { - this._undo({ pushToRedoStack: false }); - return this; - }); - __publicField(this, "bailToMark", (id) => { - this._undo({ pushToRedoStack: false, toMark: id }); - return this; - }); - __publicField(this, "squashToMark", (id) => { - let top = this.stacks.get().undos; - const popped = []; - while (top.head && !(top.head.type === "stop" && top.head.id === id)) { - if (top.head.type === "diff") { - popped.push(top.head.diff); - } - top = top.tail; - } - if (!top.head || top.head?.id !== id) { - console.error("Could not find mark to squash to: ", id); - return this; - } - if (popped.length === 0) { - return this; - } - const diff = createEmptyRecordsDiff(); - squashRecordDiffsMutable(diff, popped.reverse()); - this.stacks.update(({ redos }) => ({ - undos: top.push({ - type: "diff", - diff - }), - redos - })); - return this; - }); - __publicField(this, "mark", (id = uniqueId()) => { - transact(() => { - this.flushPendingDiff(); - this.stacks.update(({ undos, redos }) => ({ undos: undos.push({ type: "stop", id }), redos })); - }); - return id; - }); - this.store = opts.store; - this.annotateError = opts.annotateError ?? noop; - this.dispose = this.store.addHistoryInterceptor((entry, source) => { - if (source !== "user") - return; - switch (this.state) { - case "recording": - this.pendingDiff.apply(entry.changes); - this.stacks.update(({ undos }) => ({ undos, redos: stack() })); - break; - case "recordingPreserveRedoStack": - this.pendingDiff.apply(entry.changes); - break; - case "paused": - break; - default: - exhaustiveSwitchError(this.state); - } - }); - } - flushPendingDiff() { - if (this.pendingDiff.isEmpty()) - return; - const diff = this.pendingDiff.clear(); - this.stacks.update(({ undos, redos }) => ({ - undos: undos.push({ type: "diff", diff }), - redos - })); - } - getNumUndos() { - return this.stacks.get().undos.length + (this.pendingDiff.isEmpty() ? 0 : 1); - } - getNumRedos() { - return this.stacks.get().redos.length; - } - clear() { - this.stacks.set({ undos: stack(), redos: stack() }); - this.pendingDiff.clear(); - } - debug() { - const { undos, redos } = this.stacks.get(); - return { - undos: undos.toArray(), - redos: redos.toArray(), - pendingDiff: this.pendingDiff.debug(), - state: this.state - }; - } -}; -var modeToState = { - record: "recording", - "record-preserveRedoStack": "recordingPreserveRedoStack", - ignore: "paused" -}; -var PendingDiff = class { - constructor() { - __publicField(this, "diff", createEmptyRecordsDiff()); - __publicField(this, "isEmptyAtom", atom("PendingDiff.isEmpty", true)); - } - clear() { - const diff = this.diff; - this.diff = createEmptyRecordsDiff(); - this.isEmptyAtom.set(true); - return diff; - } - isEmpty() { - return this.isEmptyAtom.get(); - } - apply(diff) { - squashRecordDiffsMutable(this.diff, [diff]); - this.isEmptyAtom.set(isRecordsDiffEmpty(this.diff)); - } - debug() { - return { diff: this.diff, isEmpty: this.isEmpty() }; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/ScribbleManager.mjs -var ScribbleManager = class { - constructor(editor) { - __publicField(this, "scribbleItems", /* @__PURE__ */ new Map()); - __publicField(this, "state", "paused"); - __publicField(this, "addScribble", (scribble, id = uniqueId()) => { - const item = { - id, - scribble: { - id, - size: 20, - color: "accent", - opacity: 0.8, - delay: 0, - points: [], - shrink: 0.1, - taper: true, - ...scribble, - state: "starting" - }, - timeoutMs: 0, - delayRemaining: scribble.delay ?? 0, - prev: null, - next: null - }; - this.scribbleItems.set(id, item); - return item; - }); - __publicField(this, "stop", (id) => { - const item = this.scribbleItems.get(id); - if (!item) - throw Error(`Scribble with id ${id} not found`); - item.delayRemaining = Math.min(item.delayRemaining, 200); - item.scribble.state = "stopping"; - return item; - }); - __publicField(this, "addPoint", (id, x, y) => { - const item = this.scribbleItems.get(id); - if (!item) - throw Error(`Scribble with id ${id} not found`); - const { prev } = item; - const point = { x, y, z: 0.5 }; - if (!prev || Vec.Dist(prev, point) >= 1) { - item.next = point; - } - return item; - }); - __publicField(this, "tick", (elapsed) => { - if (this.scribbleItems.size === 0) - return; - this.editor.run(() => { - this.scribbleItems.forEach((item) => { - if (item.scribble.state === "starting") { - const { next: next2, prev: prev2 } = item; - if (next2 && next2 !== prev2) { - item.prev = next2; - item.scribble.points.push(next2); - } - if (item.scribble.points.length > 8) { - item.scribble.state = "active"; - } - return; - } - if (item.delayRemaining > 0) { - item.delayRemaining = Math.max(0, item.delayRemaining - elapsed); - } - item.timeoutMs += elapsed; - if (item.timeoutMs >= 16) { - item.timeoutMs = 0; - } - const { delayRemaining, timeoutMs, prev, next, scribble } = item; - switch (scribble.state) { - case "active": { - if (next && next !== prev) { - item.prev = next; - scribble.points.push(next); - if (delayRemaining === 0) { - if (scribble.points.length > 8) { - scribble.points.shift(); - } - } - } else { - if (timeoutMs === 0) { - if (scribble.points.length > 1) { - scribble.points.shift(); - } else { - item.delayRemaining = scribble.delay; - } - } - } - break; - } - case "stopping": { - if (item.delayRemaining === 0) { - if (timeoutMs === 0) { - if (scribble.points.length === 1) { - this.scribbleItems.delete(item.id); - return; - } - if (scribble.shrink) { - scribble.size = Math.max(1, scribble.size * (1 - scribble.shrink)); - } - scribble.points.shift(); - } - } - break; - } - case "paused": { - break; - } - } - }); - this.editor.updateInstanceState({ - scribbles: Array.from(this.scribbleItems.values()).map(({ scribble }) => ({ - ...scribble, - points: [...scribble.points] - })).slice(-5) - }); - }); - }); - this.editor = editor; - } - reset() { - this.editor.updateInstanceState({ scribbles: [] }); - this.scribbleItems.clear(); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs -var __defProp2 = Object.defineProperty; -var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; -var __decorateClass = (decorators, target, key, kind) => { - var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc2(target, key) : target; - for (var i = decorators.length - 1, decorator; i >= 0; i--) - if (decorator = decorators[i]) - result = (kind ? decorator(target, key, result) : decorator(result)) || result; - if (kind && result) - __defProp2(target, key, result); - return result; -}; -var round = (x) => { - const decimalPlacesTolerance = 8; - return Math.round(x * 10 ** decimalPlacesTolerance) / 10 ** decimalPlacesTolerance; -}; -function findAdjacentGaps(gaps, shapeId, gapLength, direction, intersection) { - const matches = gaps.filter((gap) => (direction === "forward" ? gap.startNode.id === shapeId : gap.endNode.id === shapeId) && round(gap.length) === round(gapLength) && rangeIntersection(gap.breadthIntersection[0], gap.breadthIntersection[1], intersection[0], intersection[1])); - if (matches.length === 0) - return []; - const nextNodes = /* @__PURE__ */ new Set(); - matches.forEach((match) => { - const node = direction === "forward" ? match.endNode.id : match.startNode.id; - if (!nextNodes.has(node)) { - nextNodes.add(node); - const foundGaps = findAdjacentGaps(gaps, node, gapLength, direction, rangeIntersection(match.breadthIntersection[0], match.breadthIntersection[1], intersection[0], intersection[1])); - matches.push(...foundGaps); - } - }); - return matches; -} -function dedupeGapSnaps(snaps) { - snaps.sort((a, b) => b.gaps.length - a.gaps.length); - for (let i = snaps.length - 1; i > 0; i--) { - const snap = snaps[i]; - for (let j = i - 1; j >= 0; j--) { - const otherSnap = snaps[j]; - if (otherSnap.direction === snap.direction && snap.gaps.every((gap) => otherSnap.gaps.some((otherGap) => round(gap.startEdge[0].x) === round(otherGap.startEdge[0].x) && round(gap.startEdge[0].y) === round(otherGap.startEdge[0].y) && round(gap.startEdge[1].x) === round(otherGap.startEdge[1].x) && round(gap.startEdge[1].y) === round(otherGap.startEdge[1].y)) && otherSnap.gaps.some((otherGap) => round(gap.endEdge[0].x) === round(otherGap.endEdge[0].x) && round(gap.endEdge[0].y) === round(otherGap.endEdge[0].y) && round(gap.endEdge[1].x) === round(otherGap.endEdge[1].x) && round(gap.endEdge[1].y) === round(otherGap.endEdge[1].y)))) { - snaps.splice(i, 1); - break; - } - } - } -} -var BoundsSnaps = class { - constructor(manager) { - __publicField(this, "editor"); - this.manager = manager; - this.editor = manager.editor; - } - getSnapPointsCache() { - const { editor } = this; - return editor.store.createComputedCache("snapPoints", (shape) => { - const pageTransform = editor.getShapePageTransform(shape.id); - if (!pageTransform) - return void 0; - const boundsSnapGeometry = editor.getShapeUtil(shape).getBoundsSnapGeometry(shape); - const snapPoints = boundsSnapGeometry.points ?? editor.getShapeGeometry(shape).bounds.cornersAndCenter; - if (!pageTransform || !snapPoints) - return void 0; - return snapPoints.map((point, i) => { - const { x, y } = Mat.applyToPoint(pageTransform, point); - return { x, y, id: `${shape.id}:${i}` }; - }); - }); - } - getSnapPoints(shapeId) { - return this.getSnapPointsCache().get(shapeId) ?? []; - } - getSnappablePoints() { - const snapPointsCache = this.getSnapPointsCache(); - const snappableShapes = this.manager.getSnappableShapes(); - const result = []; - for (const shapeId of snappableShapes) { - const snapPoints = snapPointsCache.get(shapeId); - if (snapPoints) { - result.push(...snapPoints); - } - } - return result; - } - getSnappableGapNodes() { - return Array.from(this.manager.getSnappableShapes(), (shapeId) => ({ - id: shapeId, - pageBounds: assertExists(this.editor.getShapePageBounds(shapeId)) - })); - } - getVisibleGaps() { - const horizontal = []; - const vertical = []; - let startNode, endNode; - const sortedShapesOnCurrentPageHorizontal = this.getSnappableGapNodes().sort((a, b) => { - return a.pageBounds.minX - b.pageBounds.minX; - }); - for (let i = 0; i < sortedShapesOnCurrentPageHorizontal.length; i++) { - startNode = sortedShapesOnCurrentPageHorizontal[i]; - for (let j = i + 1; j < sortedShapesOnCurrentPageHorizontal.length; j++) { - endNode = sortedShapesOnCurrentPageHorizontal[j]; - if (startNode.pageBounds.maxX < endNode.pageBounds.minX && rangesOverlap(startNode.pageBounds.minY, startNode.pageBounds.maxY, endNode.pageBounds.minY, endNode.pageBounds.maxY)) { - horizontal.push({ - startNode, - endNode, - startEdge: [ - new Vec(startNode.pageBounds.maxX, startNode.pageBounds.minY), - new Vec(startNode.pageBounds.maxX, startNode.pageBounds.maxY) - ], - endEdge: [ - new Vec(endNode.pageBounds.minX, endNode.pageBounds.minY), - new Vec(endNode.pageBounds.minX, endNode.pageBounds.maxY) - ], - length: endNode.pageBounds.minX - startNode.pageBounds.maxX, - breadthIntersection: rangeIntersection(startNode.pageBounds.minY, startNode.pageBounds.maxY, endNode.pageBounds.minY, endNode.pageBounds.maxY) - }); - } - } - } - const sortedShapesOnCurrentPageVertical = sortedShapesOnCurrentPageHorizontal.sort((a, b) => { - return a.pageBounds.minY - b.pageBounds.minY; - }); - for (let i = 0; i < sortedShapesOnCurrentPageVertical.length; i++) { - startNode = sortedShapesOnCurrentPageVertical[i]; - for (let j = i + 1; j < sortedShapesOnCurrentPageVertical.length; j++) { - endNode = sortedShapesOnCurrentPageVertical[j]; - if (startNode.pageBounds.maxY < endNode.pageBounds.minY && rangesOverlap(startNode.pageBounds.minX, startNode.pageBounds.maxX, endNode.pageBounds.minX, endNode.pageBounds.maxX)) { - vertical.push({ - startNode, - endNode, - startEdge: [ - new Vec(startNode.pageBounds.minX, startNode.pageBounds.maxY), - new Vec(startNode.pageBounds.maxX, startNode.pageBounds.maxY) - ], - endEdge: [ - new Vec(endNode.pageBounds.minX, endNode.pageBounds.minY), - new Vec(endNode.pageBounds.maxX, endNode.pageBounds.minY) - ], - length: endNode.pageBounds.minY - startNode.pageBounds.maxY, - breadthIntersection: rangeIntersection(startNode.pageBounds.minX, startNode.pageBounds.maxX, endNode.pageBounds.minX, endNode.pageBounds.maxX) - }); - } - } - } - return { horizontal, vertical }; - } - snapTranslateShapes({ - lockedAxis, - initialSelectionPageBounds, - initialSelectionSnapPoints, - dragDelta - }) { - const snapThreshold = this.manager.getSnapThreshold(); - const visibleSnapPointsNotInSelection = this.getSnappablePoints(); - const selectionPageBounds = initialSelectionPageBounds.clone().translate(dragDelta); - const selectionSnapPoints = initialSelectionSnapPoints.map(({ x, y }, i) => ({ - id: "selection:" + i, - x: x + dragDelta.x, - y: y + dragDelta.y - })); - const otherNodeSnapPoints = visibleSnapPointsNotInSelection; - const nearestSnapsX = []; - const nearestSnapsY = []; - const minOffset = new Vec(snapThreshold, snapThreshold); - this.collectPointSnaps({ - minOffset, - nearestSnapsX, - nearestSnapsY, - otherNodeSnapPoints, - selectionSnapPoints - }); - this.collectGapSnaps({ - selectionPageBounds, - nearestSnapsX, - nearestSnapsY, - minOffset - }); - const nudge = new Vec(lockedAxis === "x" ? 0 : nearestSnapsX[0]?.nudge ?? 0, lockedAxis === "y" ? 0 : nearestSnapsY[0]?.nudge ?? 0); - minOffset.x = 0; - minOffset.y = 0; - nearestSnapsX.length = 0; - nearestSnapsY.length = 0; - selectionSnapPoints.forEach((s) => { - s.x += nudge.x; - s.y += nudge.y; - }); - selectionPageBounds.translate(nudge); - this.collectPointSnaps({ - minOffset, - nearestSnapsX, - nearestSnapsY, - otherNodeSnapPoints, - selectionSnapPoints - }); - this.collectGapSnaps({ - selectionPageBounds, - nearestSnapsX, - nearestSnapsY, - minOffset - }); - const pointSnapsLines = this.getPointSnapLines({ - nearestSnapsX, - nearestSnapsY - }); - const gapSnapLines = this.getGapSnapLines({ - selectionPageBounds, - nearestSnapsX, - nearestSnapsY - }); - this.manager.setIndicators([...gapSnapLines, ...pointSnapsLines]); - return { nudge }; - } - snapResizeShapes({ - initialSelectionPageBounds, - dragDelta, - handle: originalHandle, - isAspectRatioLocked, - isResizingFromCenter - }) { - const snapThreshold = this.manager.getSnapThreshold(); - const { - box: unsnappedResizedPageBounds, - scaleX, - scaleY - } = Box.Resize(initialSelectionPageBounds, originalHandle, isResizingFromCenter ? dragDelta.x * 2 : dragDelta.x, isResizingFromCenter ? dragDelta.y * 2 : dragDelta.y, isAspectRatioLocked); - let handle = originalHandle; - if (scaleX < 0) { - handle = flipSelectionHandleX(handle); - } - if (scaleY < 0) { - handle = flipSelectionHandleY(handle); - } - if (isResizingFromCenter) { - unsnappedResizedPageBounds.center = initialSelectionPageBounds.center; - } - const isXLocked = handle === "top" || handle === "bottom"; - const isYLocked = handle === "left" || handle === "right"; - const selectionSnapPoints = getResizeSnapPointsForHandle(handle, unsnappedResizedPageBounds); - const otherNodeSnapPoints = this.getSnappablePoints(); - const nearestSnapsX = []; - const nearestSnapsY = []; - const minOffset = new Vec(snapThreshold, snapThreshold); - this.collectPointSnaps({ - minOffset, - nearestSnapsX, - nearestSnapsY, - otherNodeSnapPoints, - selectionSnapPoints - }); - const nudge = new Vec(isXLocked ? 0 : nearestSnapsX[0]?.nudge ?? 0, isYLocked ? 0 : nearestSnapsY[0]?.nudge ?? 0); - if (isAspectRatioLocked && isSelectionCorner(handle) && nudge.len() !== 0) { - const primaryNudgeAxis = nearestSnapsX.length && nearestSnapsY.length ? Math.abs(nudge.x) < Math.abs(nudge.y) ? "x" : "y" : nearestSnapsX.length ? "x" : "y"; - const ratio = initialSelectionPageBounds.aspectRatio; - if (primaryNudgeAxis === "x") { - nearestSnapsY.length = 0; - nudge.y = nudge.x / ratio; - if (handle === "bottom_left" || handle === "top_right") { - nudge.y = -nudge.y; - } - } else { - nearestSnapsX.length = 0; - nudge.x = nudge.y * ratio; - if (handle === "bottom_left" || handle === "top_right") { - nudge.x = -nudge.x; - } - } - } - const snappedDelta = Vec.Add(dragDelta, nudge); - const { box: snappedResizedPageBounds } = Box.Resize(initialSelectionPageBounds, originalHandle, isResizingFromCenter ? snappedDelta.x * 2 : snappedDelta.x, isResizingFromCenter ? snappedDelta.y * 2 : snappedDelta.y, isAspectRatioLocked); - if (isResizingFromCenter) { - snappedResizedPageBounds.center = initialSelectionPageBounds.center; - } - const snappedSelectionPoints = getResizeSnapPointsForHandle("any", snappedResizedPageBounds); - nearestSnapsX.length = 0; - nearestSnapsY.length = 0; - minOffset.x = 0; - minOffset.y = 0; - this.collectPointSnaps({ - minOffset, - nearestSnapsX, - nearestSnapsY, - otherNodeSnapPoints, - selectionSnapPoints: snappedSelectionPoints - }); - const pointSnaps = this.getPointSnapLines({ - nearestSnapsX, - nearestSnapsY - }); - this.manager.setIndicators([...pointSnaps]); - return { nudge }; - } - collectPointSnaps({ - selectionSnapPoints, - otherNodeSnapPoints, - minOffset, - nearestSnapsX, - nearestSnapsY - }) { - for (const thisSnapPoint of selectionSnapPoints) { - for (const otherSnapPoint of otherNodeSnapPoints) { - const offset4 = Vec.Sub(thisSnapPoint, otherSnapPoint); - const offsetX = Math.abs(offset4.x); - const offsetY = Math.abs(offset4.y); - if (round(offsetX) <= round(minOffset.x)) { - if (round(offsetX) < round(minOffset.x)) { - nearestSnapsX.length = 0; - } - nearestSnapsX.push({ - type: "points", - points: { thisPoint: thisSnapPoint, otherPoint: otherSnapPoint }, - nudge: otherSnapPoint.x - thisSnapPoint.x - }); - minOffset.x = offsetX; - } - if (round(offsetY) <= round(minOffset.y)) { - if (round(offsetY) < round(minOffset.y)) { - nearestSnapsY.length = 0; - } - nearestSnapsY.push({ - type: "points", - points: { thisPoint: thisSnapPoint, otherPoint: otherSnapPoint }, - nudge: otherSnapPoint.y - thisSnapPoint.y - }); - minOffset.y = offsetY; - } - } - } - } - collectGapSnaps({ - selectionPageBounds, - minOffset, - nearestSnapsX, - nearestSnapsY - }) { - const { horizontal, vertical } = this.getVisibleGaps(); - for (const gap of horizontal) { - if (!rangesOverlap(gap.breadthIntersection[0], gap.breadthIntersection[1], selectionPageBounds.minY, selectionPageBounds.maxY)) { - continue; - } - const gapMidX = gap.startEdge[0].x + gap.length / 2; - const centerNudge = gapMidX - selectionPageBounds.center.x; - const gapIsLargerThanSelection = gap.length > selectionPageBounds.width; - if (gapIsLargerThanSelection && round(Math.abs(centerNudge)) <= round(minOffset.x)) { - if (round(Math.abs(centerNudge)) < round(minOffset.x)) { - nearestSnapsX.length = 0; - } - minOffset.x = Math.abs(centerNudge); - const snap = { - type: "gap_center", - gap, - nudge: centerNudge - }; - const otherCenterSnap = nearestSnapsX.find(({ type }) => type === "gap_center"); - const gapBreadthsOverlap = otherCenterSnap && rangeIntersection(gap.breadthIntersection[0], gap.breadthIntersection[1], otherCenterSnap.gap.breadthIntersection[0], otherCenterSnap.gap.breadthIntersection[1]); - if (otherCenterSnap && otherCenterSnap.gap.length > gap.length && gapBreadthsOverlap) { - nearestSnapsX[nearestSnapsX.indexOf(otherCenterSnap)] = snap; - } else if (!otherCenterSnap || !gapBreadthsOverlap) { - nearestSnapsX.push(snap); - } - } - const duplicationLeftX = gap.startNode.pageBounds.minX - gap.length; - const selectionRightX = selectionPageBounds.maxX; - const duplicationLeftNudge = duplicationLeftX - selectionRightX; - if (round(Math.abs(duplicationLeftNudge)) <= round(minOffset.x)) { - if (round(Math.abs(duplicationLeftNudge)) < round(minOffset.x)) { - nearestSnapsX.length = 0; - } - minOffset.x = Math.abs(duplicationLeftNudge); - nearestSnapsX.push({ - type: "gap_duplicate", - gap, - protrusionDirection: "left", - nudge: duplicationLeftNudge - }); - } - const duplicationRightX = gap.endNode.pageBounds.maxX + gap.length; - const selectionLeftX = selectionPageBounds.minX; - const duplicationRightNudge = duplicationRightX - selectionLeftX; - if (round(Math.abs(duplicationRightNudge)) <= round(minOffset.x)) { - if (round(Math.abs(duplicationRightNudge)) < round(minOffset.x)) { - nearestSnapsX.length = 0; - } - minOffset.x = Math.abs(duplicationRightNudge); - nearestSnapsX.push({ - type: "gap_duplicate", - gap, - protrusionDirection: "right", - nudge: duplicationRightNudge - }); - } - } - for (const gap of vertical) { - if (!rangesOverlap(gap.breadthIntersection[0], gap.breadthIntersection[1], selectionPageBounds.minX, selectionPageBounds.maxX)) { - continue; - } - const gapMidY = gap.startEdge[0].y + gap.length / 2; - const centerNudge = gapMidY - selectionPageBounds.center.y; - const gapIsLargerThanSelection = gap.length > selectionPageBounds.height; - if (gapIsLargerThanSelection && round(Math.abs(centerNudge)) <= round(minOffset.y)) { - if (round(Math.abs(centerNudge)) < round(minOffset.y)) { - nearestSnapsY.length = 0; - } - minOffset.y = Math.abs(centerNudge); - const snap = { - type: "gap_center", - gap, - nudge: centerNudge - }; - const otherCenterSnap = nearestSnapsY.find(({ type }) => type === "gap_center"); - const gapBreadthsOverlap = otherCenterSnap && rangesOverlap(otherCenterSnap.gap.breadthIntersection[0], otherCenterSnap.gap.breadthIntersection[1], gap.breadthIntersection[0], gap.breadthIntersection[1]); - if (otherCenterSnap && otherCenterSnap.gap.length > gap.length && gapBreadthsOverlap) { - nearestSnapsY[nearestSnapsY.indexOf(otherCenterSnap)] = snap; - } else if (!otherCenterSnap || !gapBreadthsOverlap) { - nearestSnapsY.push(snap); - } - continue; - } - const duplicationTopY = gap.startNode.pageBounds.minY - gap.length; - const selectionBottomY = selectionPageBounds.maxY; - const duplicationTopNudge = duplicationTopY - selectionBottomY; - if (round(Math.abs(duplicationTopNudge)) <= round(minOffset.y)) { - if (round(Math.abs(duplicationTopNudge)) < round(minOffset.y)) { - nearestSnapsY.length = 0; - } - minOffset.y = Math.abs(duplicationTopNudge); - nearestSnapsY.push({ - type: "gap_duplicate", - gap, - protrusionDirection: "top", - nudge: duplicationTopNudge - }); - } - const duplicationBottomY = gap.endNode.pageBounds.maxY + gap.length; - const selectionTopY = selectionPageBounds.minY; - const duplicationBottomNudge = duplicationBottomY - selectionTopY; - if (round(Math.abs(duplicationBottomNudge)) <= round(minOffset.y)) { - if (round(Math.abs(duplicationBottomNudge)) < round(minOffset.y)) { - nearestSnapsY.length = 0; - } - minOffset.y = Math.abs(duplicationBottomNudge); - nearestSnapsY.push({ - type: "gap_duplicate", - gap, - protrusionDirection: "bottom", - nudge: duplicationBottomNudge - }); - } - } - } - getPointSnapLines({ - nearestSnapsX, - nearestSnapsY - }) { - const snapGroupsX = {}; - const snapGroupsY = {}; - if (nearestSnapsX.length > 0) { - for (const snap of nearestSnapsX) { - if (snap.type === "points") { - const key = round(snap.points.otherPoint.x); - if (!snapGroupsX[key]) { - snapGroupsX[key] = []; - } - snapGroupsX[key].push(snap.points); - } - } - } - if (nearestSnapsY.length > 0) { - for (const snap of nearestSnapsY) { - if (snap.type === "points") { - const key = round(snap.points.otherPoint.y); - if (!snapGroupsY[key]) { - snapGroupsY[key] = []; - } - snapGroupsY[key].push(snap.points); - } - } - } - return Object.values(snapGroupsX).concat(Object.values(snapGroupsY)).map((snapGroup) => ({ - id: uniqueId(), - type: "points", - points: dedupe(snapGroup.map((snap) => Vec.From(snap.otherPoint)).concat(snapGroup.map((snap) => Vec.From(snap.thisPoint))), (a, b) => a.equals(b)) - })); - } - getGapSnapLines({ - selectionPageBounds, - nearestSnapsX, - nearestSnapsY - }) { - const { vertical, horizontal } = this.getVisibleGaps(); - const selectionSides = { - top: selectionPageBounds.sides[0], - right: selectionPageBounds.sides[1], - bottom: [selectionPageBounds.corners[3], selectionPageBounds.corners[2]], - left: [selectionPageBounds.corners[0], selectionPageBounds.corners[3]] - }; - const result = []; - if (nearestSnapsX.length > 0) { - for (const snap of nearestSnapsX) { - if (snap.type === "points") - continue; - const { - gap: { breadthIntersection, startEdge, startNode, endNode, length, endEdge } - } = snap; - switch (snap.type) { - case "gap_center": { - const newGapsLength = (length - selectionPageBounds.width) / 2; - const gapBreadthIntersection = rangeIntersection(breadthIntersection[0], breadthIntersection[1], selectionPageBounds.minY, selectionPageBounds.maxY); - result.push({ - type: "gaps", - direction: "horizontal", - id: uniqueId(), - gaps: [ - ...findAdjacentGaps(horizontal, startNode.id, newGapsLength, "backward", gapBreadthIntersection), - { - startEdge, - endEdge: selectionSides.left - }, - { - startEdge: selectionSides.right, - endEdge - }, - ...findAdjacentGaps(horizontal, endNode.id, newGapsLength, "forward", gapBreadthIntersection) - ] - }); - break; - } - case "gap_duplicate": { - const gapBreadthIntersection = rangeIntersection(breadthIntersection[0], breadthIntersection[1], selectionPageBounds.minY, selectionPageBounds.maxY); - result.push({ - type: "gaps", - direction: "horizontal", - id: uniqueId(), - gaps: snap.protrusionDirection === "left" ? [ - { - startEdge: selectionSides.right, - endEdge: startEdge.map((v) => v.clone().addXY(-startNode.pageBounds.width, 0)) - }, - { startEdge, endEdge }, - ...findAdjacentGaps(horizontal, endNode.id, length, "forward", gapBreadthIntersection) - ] : [ - ...findAdjacentGaps(horizontal, startNode.id, length, "backward", gapBreadthIntersection), - { startEdge, endEdge }, - { - startEdge: endEdge.map((v) => v.clone().addXY(snap.gap.endNode.pageBounds.width, 0)), - endEdge: selectionSides.left - } - ] - }); - break; - } - } - } - } - if (nearestSnapsY.length > 0) { - for (const snap of nearestSnapsY) { - if (snap.type === "points") - continue; - const { - gap: { breadthIntersection, startEdge, startNode, endNode, length, endEdge } - } = snap; - switch (snap.type) { - case "gap_center": { - const newGapsLength = (length - selectionPageBounds.height) / 2; - const gapBreadthIntersection = rangeIntersection(breadthIntersection[0], breadthIntersection[1], selectionPageBounds.minX, selectionPageBounds.maxX); - result.push({ - type: "gaps", - direction: "vertical", - id: uniqueId(), - gaps: [ - ...findAdjacentGaps(vertical, startNode.id, newGapsLength, "backward", gapBreadthIntersection), - { - startEdge, - endEdge: selectionSides.top - }, - { - startEdge: selectionSides.bottom, - endEdge - }, - ...findAdjacentGaps(vertical, snap.gap.endNode.id, newGapsLength, "forward", gapBreadthIntersection) - ] - }); - break; - } - case "gap_duplicate": - { - const gapBreadthIntersection = rangeIntersection(breadthIntersection[0], breadthIntersection[1], selectionPageBounds.minX, selectionPageBounds.maxX); - result.push({ - type: "gaps", - direction: "vertical", - id: uniqueId(), - gaps: snap.protrusionDirection === "top" ? [ - { - startEdge: selectionSides.bottom, - endEdge: startEdge.map((v) => v.clone().addXY(0, -startNode.pageBounds.height)) - }, - { startEdge, endEdge }, - ...findAdjacentGaps(vertical, endNode.id, length, "forward", gapBreadthIntersection) - ] : [ - ...findAdjacentGaps(vertical, startNode.id, length, "backward", gapBreadthIntersection), - { startEdge, endEdge }, - { - startEdge: endEdge.map((v) => v.clone().addXY(0, endNode.pageBounds.height)), - endEdge: selectionSides.top - } - ] - }); - } - break; - } - } - } - dedupeGapSnaps(result); - return result; - } -}; -__decorateClass([ - computed -], BoundsSnaps.prototype, "getSnapPointsCache", 1); -__decorateClass([ - computed -], BoundsSnaps.prototype, "getSnappablePoints", 1); -__decorateClass([ - computed -], BoundsSnaps.prototype, "getSnappableGapNodes", 1); -__decorateClass([ - computed -], BoundsSnaps.prototype, "getVisibleGaps", 1); -function getResizeSnapPointsForHandle(handle, selectionPageBounds) { - const { minX, maxX, minY, maxY } = selectionPageBounds; - const result = []; - switch (handle) { - case "top": - case "left": - case "top_left": - case "any": - result.push({ - id: "top_left", - handle: "top_left", - x: minX, - y: minY - }); - } - switch (handle) { - case "top": - case "right": - case "top_right": - case "any": - result.push({ - id: "top_right", - handle: "top_right", - x: maxX, - y: minY - }); - } - switch (handle) { - case "bottom": - case "right": - case "bottom_right": - case "any": - result.push({ - id: "bottom_right", - handle: "bottom_right", - x: maxX, - y: maxY - }); - } - switch (handle) { - case "bottom": - case "left": - case "bottom_left": - case "any": - result.push({ - id: "bottom_left", - handle: "bottom_left", - x: minX, - y: maxY - }); - } - return result; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs -var __defProp3 = Object.defineProperty; -var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor; -var __decorateClass2 = (decorators, target, key, kind) => { - var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc3(target, key) : target; - for (var i = decorators.length - 1, decorator; i >= 0; i--) - if (decorator = decorators[i]) - result = (kind ? decorator(target, key, result) : decorator(result)) || result; - if (kind && result) - __defProp3(target, key, result); - return result; -}; -var defaultGetSelfSnapOutline = () => null; -var defaultGetSelfSnapPoints = () => []; -var HandleSnaps = class { - constructor(manager) { - __publicField(this, "editor"); - this.manager = manager; - this.editor = manager.editor; - } - getSnapGeometryCache() { - const { editor } = this; - return editor.store.createComputedCache("handle snap geometry", (shape) => { - const snapGeometry = editor.getShapeUtil(shape).getHandleSnapGeometry(shape); - return { - outline: snapGeometry.outline === void 0 ? editor.getShapeGeometry(shape) : snapGeometry.outline, - points: snapGeometry.points ?? [], - getSelfSnapOutline: snapGeometry.getSelfSnapOutline ?? defaultGetSelfSnapOutline, - getSelfSnapPoints: snapGeometry.getSelfSnapPoints ?? defaultGetSelfSnapPoints - }; - }); - } - *iterateSnapPointsInPageSpace(currentShapeId, currentHandle) { - const selfSnapPoints = this.getSnapGeometryCache().get(currentShapeId)?.getSelfSnapPoints(currentHandle); - if (selfSnapPoints && selfSnapPoints.length) { - const shapePageTransform = assertExists(this.editor.getShapePageTransform(currentShapeId)); - for (const point of selfSnapPoints) { - yield shapePageTransform.applyToPoint(point); - } - } - for (const shapeId of this.manager.getSnappableShapes()) { - if (shapeId === currentShapeId) - continue; - const snapPoints = this.getSnapGeometryCache().get(shapeId)?.points; - if (!snapPoints || !snapPoints.length) - continue; - const shapePageTransform = assertExists(this.editor.getShapePageTransform(shapeId)); - for (const point of snapPoints) { - yield shapePageTransform.applyToPoint(point); - } - } - } - *iterateSnapOutlines(currentShapeId, currentHandle) { - const selfSnapOutline = this.getSnapGeometryCache().get(currentShapeId)?.getSelfSnapOutline(currentHandle); - if (selfSnapOutline) { - yield { shapeId: currentShapeId, outline: selfSnapOutline }; - } - for (const shapeId of this.manager.getSnappableShapes()) { - if (shapeId === currentShapeId) - continue; - const snapOutline = this.getSnapGeometryCache().get(shapeId)?.outline; - if (!snapOutline) - continue; - yield { shapeId, outline: snapOutline }; - } - } - getHandleSnapPosition({ - currentShapeId, - handle, - handleInPageSpace - }) { - const snapThreshold = this.manager.getSnapThreshold(); - let minDistanceForSnapPoint = snapThreshold; - let nearestSnapPoint = null; - for (const snapPoint of this.iterateSnapPointsInPageSpace(currentShapeId, handle)) { - if (Vec.DistMin(handleInPageSpace, snapPoint, minDistanceForSnapPoint)) { - minDistanceForSnapPoint = Vec.Dist(handleInPageSpace, snapPoint); - nearestSnapPoint = snapPoint; - } - } - if (nearestSnapPoint) - return nearestSnapPoint; - let minDistanceForOutline = snapThreshold; - let nearestPointOnOutline = null; - for (const { shapeId, outline } of this.iterateSnapOutlines(currentShapeId, handle)) { - const shapePageTransform = assertExists(this.editor.getShapePageTransform(shapeId)); - const pointInShapeSpace = this.editor.getPointInShapeSpace(shapeId, handleInPageSpace); - const nearestShapePointInShapeSpace = outline.nearestPoint(pointInShapeSpace); - const nearestInPageSpace = shapePageTransform.applyToPoint(nearestShapePointInShapeSpace); - if (Vec.DistMin(handleInPageSpace, nearestInPageSpace, minDistanceForOutline)) { - minDistanceForOutline = Vec.Dist(handleInPageSpace, nearestInPageSpace); - nearestPointOnOutline = nearestInPageSpace; - } - } - if (nearestPointOnOutline) - return nearestPointOnOutline; - return null; - } - snapHandle({ - currentShapeId, - handle - }) { - const currentShapeTransform = assertExists(this.editor.getShapePageTransform(currentShapeId)); - const handleInPageSpace = currentShapeTransform.applyToPoint(handle); - const snapPosition = this.getHandleSnapPosition({ currentShapeId, handle, handleInPageSpace }); - if (snapPosition) { - this.manager.setIndicators([ - { - id: uniqueId(), - type: "points", - points: [snapPosition] - } - ]); - return { nudge: Vec.Sub(snapPosition, handleInPageSpace) }; - } - return null; - } -}; -__decorateClass2([ - computed -], HandleSnaps.prototype, "getSnapGeometryCache", 1); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs -var __defProp4 = Object.defineProperty; -var __getOwnPropDesc4 = Object.getOwnPropertyDescriptor; -var __decorateClass3 = (decorators, target, key, kind) => { - var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc4(target, key) : target; - for (var i = decorators.length - 1, decorator; i >= 0; i--) - if (decorator = decorators[i]) - result = (kind ? decorator(target, key, result) : decorator(result)) || result; - if (kind && result) - __defProp4(target, key, result); - return result; -}; -var SnapManager = class { - constructor(editor) { - __publicField(this, "shapeBounds"); - __publicField(this, "handles"); - __publicField(this, "_snapIndicators", atom("snapLines", void 0)); - this.editor = editor; - this.shapeBounds = new BoundsSnaps(this); - this.handles = new HandleSnaps(this); - } - getIndicators() { - return this._snapIndicators.get() ?? EMPTY_ARRAY; - } - clearIndicators() { - if (this.getIndicators().length) { - this._snapIndicators.set(void 0); - } - } - setIndicators(indicators) { - this._snapIndicators.set(indicators); - } - getSnapThreshold() { - return 8 / this.editor.getZoomLevel(); - } - getSnappableShapes() { - const { editor } = this; - const renderingBounds = editor.getViewportPageBounds(); - const selectedShapeIds = editor.getSelectedShapeIds(); - const snappableShapes = /* @__PURE__ */ new Set(); - const collectSnappableShapesFromParent = (parentId) => { - if (isShapeId(parentId)) { - const parent = editor.getShape(parentId); - if (parent && editor.isShapeOfType(parent, "frame")) { - snappableShapes.add(parentId); - } - } - const sortedChildIds = editor.getSortedChildIdsForParent(parentId); - for (const childId of sortedChildIds) { - if (selectedShapeIds.includes(childId)) - continue; - const childShape = editor.getShape(childId); - if (!childShape) - continue; - const util = editor.getShapeUtil(childShape); - if (!util.canSnap(childShape)) - continue; - const pageBounds = editor.getShapePageBounds(childId); - if (!(pageBounds && renderingBounds.includes(pageBounds))) - continue; - if (editor.isShapeOfType(childShape, "group")) { - collectSnappableShapesFromParent(childId); - continue; - } - snappableShapes.add(childId); - } - }; - collectSnappableShapesFromParent(this.getCurrentCommonAncestor() ?? editor.getCurrentPageId()); - return snappableShapes; - } - getCurrentCommonAncestor() { - return this.editor.findCommonAncestor(this.editor.getSelectedShapes()); - } -}; -__decorateClass3([ - computed -], SnapManager.prototype, "getSnapThreshold", 1); -__decorateClass3([ - computed -], SnapManager.prototype, "getSnappableShapes", 1); -__decorateClass3([ - computed -], SnapManager.prototype, "getCurrentCommonAncestor", 1); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/TextManager.mjs -var fixNewLines = /\r?\n|\r/g; -function normalizeTextForDom(text) { - return text.replace(fixNewLines, "\n").split("\n").map((x) => x || " ").join("\n"); -} -var textAlignmentsForLtr = { - start: "left", - "start-legacy": "left", - middle: "center", - "middle-legacy": "center", - end: "right", - "end-legacy": "right" -}; -var spaceCharacterRegex = /\s/; -var TextManager = class { - constructor(editor) { - __publicField(this, "baseElm"); - __publicField(this, "measureText", (textToMeasure, opts) => { - const elm = this.baseElm?.cloneNode(); - this.baseElm.insertAdjacentElement("afterend", elm); - elm.setAttribute("dir", "auto"); - elm.style.setProperty("unicode-bidi", "plaintext"); - elm.style.setProperty("font-family", opts.fontFamily); - elm.style.setProperty("font-style", opts.fontStyle); - elm.style.setProperty("font-weight", opts.fontWeight); - elm.style.setProperty("font-size", opts.fontSize + "px"); - elm.style.setProperty("line-height", opts.lineHeight * opts.fontSize + "px"); - elm.style.setProperty("max-width", opts.maxWidth === null ? null : opts.maxWidth + "px"); - elm.style.setProperty("min-width", opts.minWidth === null ? null : opts.minWidth + "px"); - elm.style.setProperty("padding", opts.padding); - elm.style.setProperty("overflow-wrap", opts.disableOverflowWrapBreaking ? "normal" : "break-word"); - elm.textContent = normalizeTextForDom(textToMeasure); - const scrollWidth = elm.scrollWidth; - const rect = elm.getBoundingClientRect(); - elm.remove(); - return { - x: 0, - y: 0, - w: rect.width, - h: rect.height, - scrollWidth - }; - }); - this.editor = editor; - const container = this.editor.getContainer(); - const elm = document.createElement("div"); - elm.classList.add("tl-text"); - elm.classList.add("tl-text-measure"); - elm.tabIndex = -1; - container.appendChild(elm); - this.baseElm = elm; - editor.disposables.add(() => { - elm.remove(); - }); - } - measureElementTextNodeSpans(element, { shouldTruncateToFirstLine = false } = {}) { - const spans = []; - const elmBounds = element.getBoundingClientRect(); - const offsetX = -elmBounds.left; - const offsetY = -elmBounds.top; - const range = new Range(); - const textNode = element.childNodes[0]; - let idx = 0; - let currentSpan = null; - let prevCharWasSpaceCharacter = null; - let prevCharTop = 0; - let prevCharLeftForRTLTest = 0; - let didTruncate = false; - for (const childNode of element.childNodes) { - if (childNode.nodeType !== Node.TEXT_NODE) - continue; - for (const char of childNode.textContent ?? "") { - range.setStart(textNode, idx); - range.setEnd(textNode, idx + char.length); - const rects = range.getClientRects(); - const rect = rects[rects.length - 1]; - const top = rect.top + offsetY; - const left = rect.left + offsetX; - const right = rect.right + offsetX; - const isRTL2 = left < prevCharLeftForRTLTest; - const isSpaceCharacter = spaceCharacterRegex.test(char); - if (isSpaceCharacter !== prevCharWasSpaceCharacter || top !== prevCharTop || !currentSpan) { - if (currentSpan) { - if (shouldTruncateToFirstLine && top !== prevCharTop) { - didTruncate = true; - break; - } - spans.push(currentSpan); - } - currentSpan = { - box: { x: left, y: top, w: rect.width, h: rect.height }, - text: char - }; - prevCharLeftForRTLTest = left; - } else { - if (isRTL2) { - currentSpan.box.x = left; - } - currentSpan.box.w = isRTL2 ? currentSpan.box.w + rect.width : right - currentSpan.box.x; - currentSpan.text += char; - } - if (char === "\n") { - prevCharLeftForRTLTest = 0; - } - prevCharWasSpaceCharacter = isSpaceCharacter; - prevCharTop = top; - idx += char.length; - } - } - if (currentSpan) { - spans.push(currentSpan); - } - return { spans, didTruncate }; - } - measureTextSpans(textToMeasure, opts) { - if (textToMeasure === "") - return []; - const elm = this.baseElm?.cloneNode(); - this.baseElm.insertAdjacentElement("afterend", elm); - const elementWidth = Math.ceil(opts.width - opts.padding * 2); - elm.setAttribute("dir", "auto"); - elm.style.setProperty("unicode-bidi", "plaintext"); - elm.style.setProperty("width", `${elementWidth}px`); - elm.style.setProperty("height", "min-content"); - elm.style.setProperty("font-size", `${opts.fontSize}px`); - elm.style.setProperty("font-family", opts.fontFamily); - elm.style.setProperty("font-weight", opts.fontWeight); - elm.style.setProperty("line-height", `${opts.lineHeight * opts.fontSize}px`); - elm.style.setProperty("text-align", textAlignmentsForLtr[opts.textAlign]); - const shouldTruncateToFirstLine = opts.overflow === "truncate-ellipsis" || opts.overflow === "truncate-clip"; - if (shouldTruncateToFirstLine) { - elm.style.setProperty("overflow-wrap", "anywhere"); - elm.style.setProperty("word-break", "break-all"); - } - const normalizedText = normalizeTextForDom(textToMeasure); - elm.textContent = normalizedText; - const { spans, didTruncate } = this.measureElementTextNodeSpans(elm, { - shouldTruncateToFirstLine - }); - if (opts.overflow === "truncate-ellipsis" && didTruncate) { - elm.textContent = "\u2026"; - const ellipsisWidth = Math.ceil(this.measureElementTextNodeSpans(elm).spans[0].box.w); - elm.style.setProperty("width", `${elementWidth - ellipsisWidth}px`); - elm.textContent = normalizedText; - const truncatedSpans = this.measureElementTextNodeSpans(elm, { - shouldTruncateToFirstLine: true - }).spans; - const lastSpan = truncatedSpans[truncatedSpans.length - 1]; - truncatedSpans.push({ - text: "\u2026", - box: { - x: Math.min(lastSpan.box.x + lastSpan.box.w, opts.width - opts.padding - ellipsisWidth), - y: lastSpan.box.y, - w: ellipsisWidth, - h: lastSpan.box.h - } - }); - return truncatedSpans; - } - elm.remove(); - return spans; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/TickManager.mjs -var throttleToNextFrame2 = typeof process !== "undefined" && false ? function mockThrottle(cb) { - const frame2 = requestAnimationFrame(cb); - return () => cancelAnimationFrame(frame2); -} : throttleToNextFrame; -var TickManager = class { - constructor(editor) { - __publicField(this, "cancelRaf"); - __publicField(this, "isPaused", true); - __publicField(this, "now", 0); - __publicField(this, "start", () => { - this.isPaused = false; - this.cancelRaf?.(); - this.cancelRaf = throttleToNextFrame2(this.tick); - this.now = Date.now(); - }); - __publicField(this, "tick", () => { - if (this.isPaused) { - return; - } - const now = Date.now(); - const elapsed = now - this.now; - this.now = now; - this.updatePointerVelocity(elapsed); - this.editor.emit("frame", elapsed); - this.editor.emit("tick", elapsed); - this.cancelRaf = throttleToNextFrame2(this.tick); - }); - __publicField(this, "dispose", () => { - this.isPaused = true; - this.cancelRaf?.(); - }); - __publicField(this, "prevPoint", new Vec()); - __publicField(this, "updatePointerVelocity", (elapsed) => { - const { - prevPoint, - editor: { - inputs: { currentScreenPoint, pointerVelocity } - } - } = this; - if (elapsed === 0) - return; - const delta = Vec.Sub(currentScreenPoint, prevPoint); - this.prevPoint = currentScreenPoint.clone(); - const length = delta.len(); - const direction = length ? delta.div(length) : new Vec(0, 0); - const next = pointerVelocity.clone().lrp(direction.mul(length / elapsed), 0.5); - if (Math.abs(next.x) < 0.01) - next.x = 0; - if (Math.abs(next.y) < 0.01) - next.y = 0; - if (!pointerVelocity.equals(next)) { - this.editor.inputs.pointerVelocity = next; - } - }); - this.editor = editor; - this.editor.disposables.add(this.dispose); - this.start(); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/managers/UserPreferencesManager.mjs -var __defProp5 = Object.defineProperty; -var __getOwnPropDesc5 = Object.getOwnPropertyDescriptor; -var __decorateClass4 = (decorators, target, key, kind) => { - var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc5(target, key) : target; - for (var i = decorators.length - 1, decorator; i >= 0; i--) - if (decorator = decorators[i]) - result = (kind ? decorator(target, key, result) : decorator(result)) || result; - if (kind && result) - __defProp5(target, key, result); - return result; -}; -var UserPreferencesManager = class { - constructor(user, inferDarkMode) { - __publicField(this, "systemColorScheme", atom("systemColorScheme", "light")); - __publicField(this, "updateUserPreferences", (userPreferences) => { - this.user.setUserPreferences({ - ...this.user.userPreferences.get(), - ...userPreferences - }); - }); - this.user = user; - this.inferDarkMode = inferDarkMode; - if (typeof window === "undefined" || !("matchMedia" in window)) - return; - const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)"); - if (darkModeMediaQuery?.matches) { - this.systemColorScheme.set("dark"); - } - darkModeMediaQuery?.addEventListener("change", (e) => { - if (e.matches) { - this.systemColorScheme.set("dark"); - } else { - this.systemColorScheme.set("light"); - } - }); - } - getUserPreferences() { - return { - id: this.getId(), - name: this.getName(), - locale: this.getLocale(), - color: this.getColor(), - animationSpeed: this.getAnimationSpeed(), - isSnapMode: this.getIsSnapMode(), - colorScheme: this.user.userPreferences.get().colorScheme, - isDarkMode: this.getIsDarkMode(), - isWrapMode: this.getIsWrapMode(), - isDynamicResizeMode: this.getIsDynamicResizeMode() - }; - } - getIsDarkMode() { - switch (this.user.userPreferences.get().colorScheme) { - case "dark": - return true; - case "light": - return false; - case "system": - return this.systemColorScheme.get() === "dark"; - default: - return this.inferDarkMode ? this.systemColorScheme.get() === "dark" : false; - } - } - getEdgeScrollSpeed() { - return this.user.userPreferences.get().edgeScrollSpeed ?? defaultUserPreferences.edgeScrollSpeed; - } - getAnimationSpeed() { - return this.user.userPreferences.get().animationSpeed ?? defaultUserPreferences.animationSpeed; - } - getId() { - return this.user.userPreferences.get().id; - } - getName() { - return this.user.userPreferences.get().name ?? defaultUserPreferences.name; - } - getLocale() { - return this.user.userPreferences.get().locale ?? defaultUserPreferences.locale; - } - getColor() { - return this.user.userPreferences.get().color ?? defaultUserPreferences.color; - } - getIsSnapMode() { - return this.user.userPreferences.get().isSnapMode ?? defaultUserPreferences.isSnapMode; - } - getIsWrapMode() { - return this.user.userPreferences.get().isWrapMode ?? defaultUserPreferences.isWrapMode; - } - getIsDynamicResizeMode() { - return this.user.userPreferences.get().isDynamicSizeMode ?? defaultUserPreferences.isDynamicSizeMode; - } - getIsPasteAtCursorMode() { - return this.user.userPreferences.get().isPasteAtCursorMode ?? defaultUserPreferences.isPasteAtCursorMode; - } -}; -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getUserPreferences", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getIsDarkMode", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getEdgeScrollSpeed", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getAnimationSpeed", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getId", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getName", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getLocale", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getColor", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getIsSnapMode", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getIsWrapMode", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getIsDynamicResizeMode", 1); -__decorateClass4([ - computed -], UserPreferencesManager.prototype, "getIsPasteAtCursorMode", 1); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/types/event-types.mjs -var EVENT_NAME_MAP = { - wheel: "onWheel", - pointer_down: "onPointerDown", - pointer_move: "onPointerMove", - long_press: "onLongPress", - pointer_up: "onPointerUp", - right_click: "onRightClick", - middle_click: "onMiddleClick", - key_down: "onKeyDown", - key_up: "onKeyUp", - key_repeat: "onKeyRepeat", - cancel: "onCancel", - complete: "onComplete", - interrupt: "onInterrupt", - double_click: "onDoubleClick", - triple_click: "onTripleClick", - quadruple_click: "onQuadrupleClick", - tick: "onTick" -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/tools/StateNode.mjs -var STATE_NODES_TO_MEASURE = [ - "brushing", - "cropping", - "dragging", - "dragging_handle", - "drawing", - "erasing", - "lasering", - "resizing", - "rotating", - "scribble_brushing", - "translating" -]; -var StateNode = class { - constructor(editor, parent) { - __publicField(this, "performanceTracker"); - __publicField(this, "id"); - __publicField(this, "type"); - __publicField(this, "shapeType"); - __publicField(this, "initial"); - __publicField(this, "children"); - __publicField(this, "isLockable"); - __publicField(this, "parent"); - __publicField(this, "_path"); - __publicField(this, "_current"); - __publicField(this, "_isActive"); - __publicField(this, "transition", (id, info2 = {}) => { - const path = id.split("."); - let currState = this; - for (let i = 0; i < path.length; i++) { - const id2 = path[i]; - const prevChildState = currState.getCurrent(); - const nextChildState = currState.children?.[id2]; - if (!nextChildState) { - throw Error(`${currState.id} - no child state exists with the id ${id2}.`); - } - if (prevChildState?.id !== nextChildState.id) { - prevChildState?.exit(info2, id2); - currState._current.set(nextChildState); - nextChildState.enter(info2, prevChildState?.id || "initial"); - if (!nextChildState.getIsActive()) - break; - } - currState = nextChildState; - } - return this; - }); - __publicField(this, "handleEvent", (info2) => { - const cbName = EVENT_NAME_MAP[info2.name]; - const currentActiveChild = this._current.__unsafe__getWithoutCapture(); - this[cbName]?.(info2); - if (this._isActive.__unsafe__getWithoutCapture() && currentActiveChild && currentActiveChild === this._current.__unsafe__getWithoutCapture()) { - currentActiveChild.handleEvent(info2); - } - }); - __publicField(this, "enter", (info2, from) => { - if (debugFlags.measurePerformance.get() && STATE_NODES_TO_MEASURE.includes(this.id)) { - this.performanceTracker.start(this.id); - } - this._isActive.set(true); - this.onEnter?.(info2, from); - if (this.children && this.initial && this.getIsActive()) { - const initial = this.children[this.initial]; - this._current.set(initial); - initial.enter(info2, from); - } - }); - __publicField(this, "exit", (info2, from) => { - if (debugFlags.measurePerformance.get() && this.performanceTracker.isStarted()) { - this.performanceTracker.stop(); - } - this._isActive.set(false); - this.onExit?.(info2, from); - if (!this.getIsActive()) { - this.getCurrent()?.exit(info2, from); - } - }); - __publicField(this, "_currentToolIdMask", atom("curent tool id mask", void 0)); - __publicField(this, "onWheel"); - __publicField(this, "onPointerDown"); - __publicField(this, "onPointerMove"); - __publicField(this, "onLongPress"); - __publicField(this, "onPointerUp"); - __publicField(this, "onDoubleClick"); - __publicField(this, "onTripleClick"); - __publicField(this, "onQuadrupleClick"); - __publicField(this, "onRightClick"); - __publicField(this, "onMiddleClick"); - __publicField(this, "onKeyDown"); - __publicField(this, "onKeyUp"); - __publicField(this, "onKeyRepeat"); - __publicField(this, "onCancel"); - __publicField(this, "onComplete"); - __publicField(this, "onInterrupt"); - __publicField(this, "onTick"); - __publicField(this, "onEnter"); - __publicField(this, "onExit"); - this.editor = editor; - const { id, children, initial, isLockable } = this.constructor; - this.id = id; - this._isActive = atom("toolIsActive" + this.id, false); - this._current = atom("toolState" + this.id, void 0); - this._path = computed("toolPath" + this.id, () => { - const current = this.getCurrent(); - return this.id + (current ? `.${current.getPath()}` : ""); - }); - this.parent = parent ?? {}; - if (this.parent) { - if (children && initial) { - this.type = "branch"; - this.initial = initial; - this.children = Object.fromEntries(children().map((Ctor) => [Ctor.id, new Ctor(this.editor, this)])); - this._current.set(this.children[this.initial]); - } else { - this.type = "leaf"; - } - } else { - this.type = "root"; - if (children && initial) { - this.initial = initial; - this.children = Object.fromEntries(children().map((Ctor) => [Ctor.id, new Ctor(this.editor, this)])); - this._current.set(this.children[this.initial]); - } - } - this.isLockable = isLockable; - this.performanceTracker = new PerformanceTracker(); - } - getPath() { - return this._path.get(); - } - getCurrent() { - return this._current.get(); - } - getIsActive() { - return this._isActive.get(); - } - getCurrentToolIdMask() { - return this._currentToolIdMask.get(); - } - setCurrentToolIdMask(id) { - this._currentToolIdMask.set(id); - } -}; -__publicField(StateNode, "id"); -__publicField(StateNode, "initial"); -__publicField(StateNode, "children"); -__publicField(StateNode, "isLockable", true); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/tools/RootState.mjs -var RootState = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onKeyDown", (info2) => { - switch (info2.code) { - case "KeyZ": { - if (!(info2.shiftKey || info2.ctrlKey)) { - const currentTool = this.getCurrent(); - if (currentTool && currentTool.getCurrent()?.id === "idle" && this.children["zoom"]) { - this.editor.setCurrentTool("zoom", { ...info2, onInteractionEnd: currentTool.id }); - } - } - break; - } - } - }); - } -}; -__publicField(RootState, "id", "root"); -__publicField(RootState, "initial", ""); -__publicField(RootState, "children", () => []); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/Editor.mjs -var __defProp6 = Object.defineProperty; -var __getOwnPropDesc6 = Object.getOwnPropertyDescriptor; -var __decorateClass5 = (decorators, target, key, kind) => { - var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc6(target, key) : target; - for (var i = decorators.length - 1, decorator; i >= 0; i--) - if (decorator = decorators[i]) - result = (kind ? decorator(target, key, result) : decorator(result)) || result; - if (kind && result) - __defProp6(target, key, result); - return result; -}; -var Editor = class extends import_eventemitter3.default { - constructor({ - store, - user, - shapeUtils, - bindingUtils, - tools, - getContainer, - cameraOptions, - initialState: initialState2, - autoFocus, - inferDarkMode, - options - }) { - super(); - __publicField(this, "options"); - __publicField(this, "store"); - __publicField(this, "root"); - __publicField(this, "disposables", /* @__PURE__ */ new Set()); - __publicField(this, "isDisposed", false); - __publicField(this, "_tickManager"); - __publicField(this, "snaps"); - __publicField(this, "timers"); - __publicField(this, "user"); - __publicField(this, "textMeasure"); - __publicField(this, "environment"); - __publicField(this, "scribbles"); - __publicField(this, "sideEffects"); - __publicField(this, "edgeScrollManager"); - __publicField(this, "focusManager"); - __publicField(this, "getContainer"); - __publicField(this, "shapeUtils"); - __publicField(this, "styleProps"); - __publicField(this, "bindingUtils"); - __publicField(this, "history"); - __publicField(this, "_shouldIgnoreShapeLock", false); - __publicField(this, "_crashingError", null); - __publicField(this, "_updateInstanceState", (partial, opts) => { - this.run(() => { - this.store.put([ - { - ...this.getInstanceState(), - ...partial - } - ]); - }, opts); - }); - __publicField(this, "_isChangingStyleTimeout", -1); - __publicField(this, "setCursor", (cursor) => { - this.updateInstanceState({ cursor: { ...this.getInstanceState().cursor, ...cursor } }); - return this; - }); - __publicField(this, "_updateCurrentPageState", (partial) => { - this.store.update(partial.id ?? this.getCurrentPageState().id, (state) => ({ - ...state, - ...partial - })); - }); - __publicField(this, "_cameraOptions", atom("camera options", DEFAULT_CAMERA_OPTIONS)); - __publicField(this, "_viewportAnimation", null); - __publicField(this, "_willSetInitialBounds", true); - __publicField(this, "_isLockedOnFollowingUser", atom("isLockedOnFollowingUser", false)); - __publicField(this, "_cameraState", atom("camera state", "idle")); - __publicField(this, "_cameraStateTimeoutRemaining", 0); - __publicField(this, "_decayCameraStateTimeout", (elapsed) => { - this._cameraStateTimeoutRemaining -= elapsed; - if (this._cameraStateTimeoutRemaining > 0) - return; - this.off("tick", this._decayCameraStateTimeout); - this._cameraState.set("idle"); - }); - __publicField(this, "_tickCameraState", () => { - this._cameraStateTimeoutRemaining = this.options.cameraMovingTimeoutMs; - if (this._cameraState.__unsafe__getWithoutCapture() !== "idle") - return; - this._cameraState.set("moving"); - this.on("tick", this._decayCameraStateTimeout); - }); - __publicField(this, "_currentPageShapeIds"); - __publicField(this, "_parentIdsToChildIds"); - __publicField(this, "animatingShapes", /* @__PURE__ */ new Map()); - __publicField(this, "_updateShapes", (_partials) => { - if (this.getInstanceState().isReadonly) - return; - this.run(() => { - const updates = []; - let shape; - let updated; - for (let i = 0, n = _partials.length; i < n; i++) { - const partial = _partials[i]; - if (!partial) - continue; - shape = this.getShape(partial.id); - if (!shape) - continue; - updated = applyPartialToRecordWithProps(shape, partial); - if (updated === shape) - continue; - updated = this.getShapeUtil(shape).onBeforeUpdate?.(shape, updated) ?? updated; - updates.push(updated); - } - this.store.put(updates); - }); - }); - __publicField(this, "externalAssetContentHandlers", { - file: null, - url: null - }); - __publicField(this, "externalContentHandlers", { - text: null, - files: null, - embed: null, - "svg-text": null, - url: null - }); - __publicField(this, "inputs", { - originPagePoint: new Vec(), - originScreenPoint: new Vec(), - previousPagePoint: new Vec(), - previousScreenPoint: new Vec(), - currentPagePoint: new Vec(), - currentScreenPoint: new Vec(), - keys: /* @__PURE__ */ new Set(), - buttons: /* @__PURE__ */ new Set(), - isPen: false, - shiftKey: false, - ctrlKey: false, - altKey: false, - isDragging: false, - isPointing: false, - isPinching: false, - isEditing: false, - isPanning: false, - pointerVelocity: new Vec() - }); - __publicField(this, "_clickManager", new ClickManager(this)); - __publicField(this, "_prevCursor", "default"); - __publicField(this, "_shiftKeyTimeout", -1); - __publicField(this, "_setShiftKeyTimeout", () => { - this.inputs.shiftKey = false; - this.dispatch({ - type: "keyboard", - name: "key_up", - key: "Shift", - shiftKey: this.inputs.shiftKey, - ctrlKey: this.inputs.ctrlKey, - altKey: this.inputs.altKey, - code: "ShiftLeft" - }); - }); - __publicField(this, "_altKeyTimeout", -1); - __publicField(this, "_setAltKeyTimeout", () => { - this.inputs.altKey = false; - this.dispatch({ - type: "keyboard", - name: "key_up", - key: "Alt", - shiftKey: this.inputs.shiftKey, - ctrlKey: this.inputs.ctrlKey, - altKey: this.inputs.altKey, - code: "AltLeft" - }); - }); - __publicField(this, "_ctrlKeyTimeout", -1); - __publicField(this, "_setCtrlKeyTimeout", () => { - this.inputs.ctrlKey = false; - this.dispatch({ - type: "keyboard", - name: "key_up", - key: "Ctrl", - shiftKey: this.inputs.shiftKey, - ctrlKey: this.inputs.ctrlKey, - altKey: this.inputs.altKey, - code: "ControlLeft" - }); - }); - __publicField(this, "_restoreToolId", "select"); - __publicField(this, "_pinchStart", 1); - __publicField(this, "_didPinch", false); - __publicField(this, "_selectedShapeIdsAtPointerDown", []); - __publicField(this, "_longPressTimeout", -1); - __publicField(this, "capturedPointerId", null); - __publicField(this, "performanceTracker"); - __publicField(this, "performanceTrackerTimeout", -1); - __publicField(this, "dispatch", (info2) => { - this._pendingEventsForNextTick.push(info2); - if (!(info2.type === "pointer" && info2.name === "pointer_move" || info2.type === "wheel" || info2.type === "pinch")) { - this._flushEventsForTick(0); - } - return this; - }); - __publicField(this, "_pendingEventsForNextTick", []); - __publicField(this, "_flushEventForTick", (info2) => { - if (this.getCrashingError()) - return this; - const { inputs } = this; - const { type } = info2; - if (info2.type === "misc") { - if (info2.name === "cancel" || info2.name === "complete") { - this.inputs.isDragging = false; - if (this.inputs.isPanning) { - this.inputs.isPanning = false; - this.setCursor({ type: this._prevCursor, rotation: 0 }); - } - } - this.root.handleEvent(info2); - return; - } - if (info2.shiftKey) { - clearTimeout(this._shiftKeyTimeout); - this._shiftKeyTimeout = -1; - inputs.shiftKey = true; - } else if (!info2.shiftKey && inputs.shiftKey && this._shiftKeyTimeout === -1) { - this._shiftKeyTimeout = this.timers.setTimeout(this._setShiftKeyTimeout, 150); - } - if (info2.altKey) { - clearTimeout(this._altKeyTimeout); - this._altKeyTimeout = -1; - inputs.altKey = true; - } else if (!info2.altKey && inputs.altKey && this._altKeyTimeout === -1) { - this._altKeyTimeout = this.timers.setTimeout(this._setAltKeyTimeout, 150); - } - if (info2.ctrlKey) { - clearTimeout(this._ctrlKeyTimeout); - this._ctrlKeyTimeout = -1; - inputs.ctrlKey = true; - } else if (!info2.ctrlKey && inputs.ctrlKey && this._ctrlKeyTimeout === -1) { - this._ctrlKeyTimeout = this.timers.setTimeout(this._setCtrlKeyTimeout, 150); - } - const { originPagePoint, currentPagePoint } = inputs; - if (!inputs.isPointing) { - inputs.isDragging = false; - } - const instanceState = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID); - const pageState = this.store.get(this._getCurrentPageStateId()); - const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture(); - switch (type) { - case "pinch": { - if (cameraOptions.isLocked) - return; - clearTimeout(this._longPressTimeout); - this._updateInputsFromEvent(info2); - switch (info2.name) { - case "pinch_start": { - if (inputs.isPinching) - return; - if (!inputs.isEditing) { - this._pinchStart = this.getCamera().z; - if (!this._selectedShapeIdsAtPointerDown.length) { - this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds]; - } - this._didPinch = true; - inputs.isPinching = true; - this.interrupt(); - } - return; - } - case "pinch": { - if (!inputs.isPinching) - return; - const { - point: { z = 1 }, - delta: { x: dx, y: dy } - } = info2; - const { x, y } = Vec.SubXY(info2.point, instanceState.screenBounds.x, instanceState.screenBounds.y); - this.stopCameraAnimation(); - if (instanceState.followingUserId) { - this.stopFollowingUser(); - } - const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera()); - const { panSpeed, zoomSpeed } = cameraOptions; - this._setCamera(new Vec(cx + dx * panSpeed / cz - x / cz + x / (z * zoomSpeed), cy + dy * panSpeed / cz - y / cz + y / (z * zoomSpeed), z * zoomSpeed), { immediate: true }); - return; - } - case "pinch_end": { - if (!inputs.isPinching) - return this; - inputs.isPinching = false; - const { _selectedShapeIdsAtPointerDown: shapesToReselect } = this; - this.setSelectedShapes(this._selectedShapeIdsAtPointerDown); - this._selectedShapeIdsAtPointerDown = []; - if (this._didPinch) { - this._didPinch = false; - if (shapesToReselect.length > 0) { - this.once("tick", () => { - if (!this._didPinch) { - this.setSelectedShapes(shapesToReselect); - } - }); - } - } - return; - } - } - } - case "wheel": { - if (cameraOptions.isLocked) - return; - this._updateInputsFromEvent(info2); - if (this.getIsMenuOpen()) { - } else { - const { panSpeed, zoomSpeed, wheelBehavior } = cameraOptions; - if (wheelBehavior !== "none") { - this.stopCameraAnimation(); - if (instanceState.followingUserId) { - this.stopFollowingUser(); - } - const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera()); - const { x: dx, y: dy, z: dz = 0 } = info2.delta; - let behavior = wheelBehavior; - if (inputs.ctrlKey) - behavior = wheelBehavior === "pan" ? "zoom" : "pan"; - switch (behavior) { - case "zoom": { - const { x, y } = this.inputs.currentScreenPoint; - let delta = dz; - if (wheelBehavior === "zoom") { - if (Math.abs(dy) > 10) { - delta = 10 * Math.sign(dy) / 100; - } else { - delta = dy / 100; - } - } - const zoom = cz + (delta ?? 0) * zoomSpeed * cz; - this._setCamera(new Vec(cx + (x / zoom - x) - (x / cz - x), cy + (y / zoom - y) - (y / cz - y), zoom), { immediate: true }); - this.maybeTrackPerformance("Zooming"); - return; - } - case "pan": { - this._setCamera(new Vec(cx + dx * panSpeed / cz, cy + dy * panSpeed / cz, cz), { - immediate: true - }); - this.maybeTrackPerformance("Panning"); - return; - } - } - } - } - break; - } - case "pointer": { - if (inputs.isPinching) - return; - this._updateInputsFromEvent(info2); - const { isPen } = info2; - const { isPenMode } = instanceState; - switch (info2.name) { - case "pointer_down": { - if (isPenMode && !isPen) - return; - this.clearOpenMenus(); - if (!this.inputs.isPanning) { - this._longPressTimeout = this.timers.setTimeout(() => { - this.dispatch({ - ...info2, - point: this.inputs.currentScreenPoint, - name: "long_press" - }); - }, this.options.longPressDurationMs); - } - this._selectedShapeIdsAtPointerDown = this.getSelectedShapeIds(); - if (info2.button === LEFT_MOUSE_BUTTON) - this.capturedPointerId = info2.pointerId; - inputs.buttons.add(info2.button); - inputs.isPointing = true; - inputs.isDragging = false; - if (!isPenMode && isPen) - this.updateInstanceState({ isPenMode: true }); - if (info2.button === STYLUS_ERASER_BUTTON) { - this._restoreToolId = this.getCurrentToolId(); - this.complete(); - this.setCurrentTool("eraser"); - } else if (info2.button === MIDDLE_MOUSE_BUTTON) { - if (!this.inputs.isPanning) { - this._prevCursor = this.getInstanceState().cursor.type; - } - this.inputs.isPanning = true; - clearTimeout(this._longPressTimeout); - } - if (this.inputs.isPanning) { - this.stopCameraAnimation(); - this.setCursor({ type: "grabbing", rotation: 0 }); - return this; - } - break; - } - case "pointer_move": { - if (!isPen && isPenMode) - return; - const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera()); - if (this.inputs.isPanning && this.inputs.isPointing) { - const { currentScreenPoint, previousScreenPoint } = this.inputs; - const { panSpeed } = cameraOptions; - const offset4 = Vec.Sub(currentScreenPoint, previousScreenPoint); - this.setCamera(new Vec(cx + offset4.x * panSpeed / cz, cy + offset4.y * panSpeed / cz, cz), { immediate: true }); - this.maybeTrackPerformance("Panning"); - return; - } - if (inputs.isPointing && !inputs.isDragging && Vec.Dist2(originPagePoint, currentPagePoint) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) { - inputs.isDragging = true; - clearTimeout(this._longPressTimeout); - } - break; - } - case "pointer_up": { - inputs.isDragging = false; - inputs.isPointing = false; - clearTimeout(this._longPressTimeout); - inputs.buttons.delete(info2.button); - if (this.getIsMenuOpen()) - return; - if (instanceState.isPenMode && !isPen) - return; - if (this.capturedPointerId === info2.pointerId) { - this.capturedPointerId = null; - info2.button = 0; - } - if (inputs.isPanning) { - if (!inputs.keys.has("Space")) { - inputs.isPanning = false; - } - const slideDirection = this.inputs.pointerVelocity; - const slideSpeed = Math.min(2, slideDirection.len()); - switch (info2.button) { - case LEFT_MOUSE_BUTTON: { - this.setCursor({ type: "grab", rotation: 0 }); - break; - } - case MIDDLE_MOUSE_BUTTON: { - if (this.inputs.keys.has(" ")) { - this.setCursor({ type: "grab", rotation: 0 }); - } else { - this.setCursor({ type: this._prevCursor, rotation: 0 }); - } - } - } - if (slideSpeed > 0) { - this.slideCamera({ speed: slideSpeed, direction: slideDirection }); - } - } else { - if (info2.button === STYLUS_ERASER_BUTTON) { - this.complete(); - this.setCurrentTool(this._restoreToolId); - } - } - break; - } - } - break; - } - case "keyboard": { - if (info2.key === "ShiftRight") - info2.key = "ShiftLeft"; - if (info2.key === "AltRight") - info2.key = "AltLeft"; - if (info2.code === "ControlRight") - info2.code = "ControlLeft"; - switch (info2.name) { - case "key_down": { - inputs.keys.add(info2.code); - if (info2.code === "Space" && !info2.ctrlKey) { - if (!this.inputs.isPanning) { - this._prevCursor = instanceState.cursor.type; - } - this.inputs.isPanning = true; - clearTimeout(this._longPressTimeout); - this.setCursor({ type: this.inputs.isPointing ? "grabbing" : "grab", rotation: 0 }); - } - break; - } - case "key_up": { - inputs.keys.delete(info2.code); - if (info2.code === "Space") { - if (this.inputs.buttons.has(MIDDLE_MOUSE_BUTTON)) { - } else { - this.inputs.isPanning = false; - this.setCursor({ type: this._prevCursor, rotation: 0 }); - } - } - break; - } - case "key_repeat": { - break; - } - } - break; - } - } - if (info2.type === "pointer") { - if (info2.button === MIDDLE_MOUSE_BUTTON) { - info2.name = "middle_click"; - } else if (info2.button === RIGHT_MOUSE_BUTTON) { - info2.name = "right_click"; - } - const { isPenMode } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID); - if (info2.isPen === isPenMode) { - const clickInfo = this._clickManager.handlePointerEvent(info2); - if (info2.name !== clickInfo.name) { - this.root.handleEvent(info2); - this.emit("event", info2); - this.root.handleEvent(clickInfo); - this.emit("event", clickInfo); - return; - } - } - } - this.root.handleEvent(info2); - this.emit("event", info2); - return this; - }); - this.options = { ...defaultTldrawOptions, ...options }; - this.store = store; - this.disposables.add(this.store.dispose.bind(this.store)); - this.history = new HistoryManager({ - store, - annotateError: (error3) => { - this.annotateError(error3, { origin: "history.batch", willCrashApp: true }); - this.crash(error3); - } - }); - this.snaps = new SnapManager(this); - this.timers = new Timers(); - this.disposables.add(this.timers.dispose.bind(this.timers)); - this._cameraOptions.set({ ...DEFAULT_CAMERA_OPTIONS, ...cameraOptions }); - this.user = new UserPreferencesManager(user ?? createTLUser(), inferDarkMode ?? false); - this.getContainer = getContainer ?? (() => document.body); - this.textMeasure = new TextManager(this); - this._tickManager = new TickManager(this); - class NewRoot extends RootState { - } - __publicField(NewRoot, "initial", initialState2 ?? ""); - this.root = new NewRoot(this); - this.root.children = {}; - const allShapeUtils = checkShapesAndAddCore(shapeUtils); - const _shapeUtils = {}; - const _styleProps = {}; - const allStylesById = /* @__PURE__ */ new Map(); - for (const Util of allShapeUtils) { - const util = new Util(this); - _shapeUtils[Util.type] = util; - const propKeysByStyle = getShapePropKeysByStyle(Util.props ?? {}); - _styleProps[Util.type] = propKeysByStyle; - for (const style of propKeysByStyle.keys()) { - if (!allStylesById.has(style.id)) { - allStylesById.set(style.id, style); - } else if (allStylesById.get(style.id) !== style) { - throw Error(`Multiple style props with id "${style.id}" in use. Style prop IDs must be unique.`); - } - } - } - this.shapeUtils = _shapeUtils; - this.styleProps = _styleProps; - const allBindingUtils = checkBindings(bindingUtils); - const _bindingUtils = {}; - for (const Util of allBindingUtils) { - const util = new Util(this); - _bindingUtils[Util.type] = util; - } - this.bindingUtils = _bindingUtils; - for (const Tool of [...tools]) { - if (hasOwnProperty(this.root.children, Tool.id)) { - throw Error(`Can't override tool with id "${Tool.id}"`); - } - this.root.children[Tool.id] = new Tool(this, this.root); - } - this.environment = new EnvironmentManager(this); - this.scribbles = new ScribbleManager(this); - const cleanupInstancePageState = (prevPageState, shapesNoLongerInPage) => { - let nextPageState = null; - const selectedShapeIds = prevPageState.selectedShapeIds.filter((id) => !shapesNoLongerInPage.has(id)); - if (selectedShapeIds.length !== prevPageState.selectedShapeIds.length) { - if (!nextPageState) - nextPageState = { ...prevPageState }; - nextPageState.selectedShapeIds = selectedShapeIds; - } - const erasingShapeIds = prevPageState.erasingShapeIds.filter((id) => !shapesNoLongerInPage.has(id)); - if (erasingShapeIds.length !== prevPageState.erasingShapeIds.length) { - if (!nextPageState) - nextPageState = { ...prevPageState }; - nextPageState.erasingShapeIds = erasingShapeIds; - } - if (prevPageState.hoveredShapeId && shapesNoLongerInPage.has(prevPageState.hoveredShapeId)) { - if (!nextPageState) - nextPageState = { ...prevPageState }; - nextPageState.hoveredShapeId = null; - } - if (prevPageState.editingShapeId && shapesNoLongerInPage.has(prevPageState.editingShapeId)) { - if (!nextPageState) - nextPageState = { ...prevPageState }; - nextPageState.editingShapeId = null; - } - const hintingShapeIds = prevPageState.hintingShapeIds.filter((id) => !shapesNoLongerInPage.has(id)); - if (hintingShapeIds.length !== prevPageState.hintingShapeIds.length) { - if (!nextPageState) - nextPageState = { ...prevPageState }; - nextPageState.hintingShapeIds = hintingShapeIds; - } - if (prevPageState.focusedGroupId && shapesNoLongerInPage.has(prevPageState.focusedGroupId)) { - if (!nextPageState) - nextPageState = { ...prevPageState }; - nextPageState.focusedGroupId = null; - } - return nextPageState; - }; - this.sideEffects = this.store.sideEffects; - let deletedBindings = /* @__PURE__ */ new Map(); - const deletedShapeIds = /* @__PURE__ */ new Set(); - const invalidParents = /* @__PURE__ */ new Set(); - let invalidBindingTypes = /* @__PURE__ */ new Set(); - this.disposables.add(this.sideEffects.registerOperationCompleteHandler(() => { - deletedShapeIds.clear(); - for (const parentId of invalidParents) { - invalidParents.delete(parentId); - const parent = this.getShape(parentId); - if (!parent) - continue; - const util = this.getShapeUtil(parent); - const changes = util.onChildrenChange?.(parent); - if (changes?.length) { - this.updateShapes(changes); - } - } - if (invalidBindingTypes.size) { - const t2 = invalidBindingTypes; - invalidBindingTypes = /* @__PURE__ */ new Set(); - for (const type of t2) { - const util = this.getBindingUtil(type); - util.onOperationComplete?.(); - } - } - if (deletedBindings.size) { - const t2 = deletedBindings; - deletedBindings = /* @__PURE__ */ new Map(); - for (const opts of t2.values()) { - this.getBindingUtil(opts.binding).onAfterDelete?.(opts); - } - } - this.emit("update"); - })); - this.disposables.add(this.sideEffects.register({ - shape: { - afterChange: (shapeBefore, shapeAfter) => { - for (const binding of this.getBindingsInvolvingShape(shapeAfter)) { - invalidBindingTypes.add(binding.type); - if (binding.fromId === shapeAfter.id) { - this.getBindingUtil(binding).onAfterChangeFromShape?.({ - binding, - shapeBefore, - shapeAfter - }); - } - if (binding.toId === shapeAfter.id) { - this.getBindingUtil(binding).onAfterChangeToShape?.({ - binding, - shapeBefore, - shapeAfter - }); - } - } - if (shapeBefore.parentId !== shapeAfter.parentId) { - const notifyBindingAncestryChange = (id) => { - const descendantShape = this.getShape(id); - if (!descendantShape) - return; - for (const binding of this.getBindingsInvolvingShape(descendantShape)) { - invalidBindingTypes.add(binding.type); - if (binding.fromId === descendantShape.id) { - this.getBindingUtil(binding).onAfterChangeFromShape?.({ - binding, - shapeBefore: descendantShape, - shapeAfter: descendantShape - }); - } - if (binding.toId === descendantShape.id) { - this.getBindingUtil(binding).onAfterChangeToShape?.({ - binding, - shapeBefore: descendantShape, - shapeAfter: descendantShape - }); - } - } - }; - notifyBindingAncestryChange(shapeAfter.id); - this.visitDescendants(shapeAfter.id, notifyBindingAncestryChange); - } - if (shapeBefore.parentId !== shapeAfter.parentId && isPageId(shapeAfter.parentId)) { - const allMovingIds = /* @__PURE__ */ new Set([shapeBefore.id]); - this.visitDescendants(shapeBefore.id, (id) => { - allMovingIds.add(id); - }); - for (const instancePageState of this.getPageStates()) { - if (instancePageState.pageId === shapeAfter.parentId) - continue; - const nextPageState = cleanupInstancePageState(instancePageState, allMovingIds); - if (nextPageState) { - this.store.put([nextPageState]); - } - } - } - if (shapeBefore.parentId && isShapeId(shapeBefore.parentId)) { - invalidParents.add(shapeBefore.parentId); - } - if (shapeAfter.parentId !== shapeBefore.parentId && isShapeId(shapeAfter.parentId)) { - invalidParents.add(shapeAfter.parentId); - } - }, - beforeDelete: (shape) => { - if (deletedShapeIds.has(shape.id)) - return; - if (shape.parentId && isShapeId(shape.parentId)) { - invalidParents.add(shape.parentId); - } - deletedShapeIds.add(shape.id); - const deleteBindingIds = []; - for (const binding of this.getBindingsInvolvingShape(shape)) { - invalidBindingTypes.add(binding.type); - deleteBindingIds.push(binding.id); - const util = this.getBindingUtil(binding); - if (binding.fromId === shape.id) { - util.onBeforeIsolateToShape?.({ binding, removedShape: shape }); - util.onBeforeDeleteFromShape?.({ binding, shape }); - } else { - util.onBeforeIsolateFromShape?.({ binding, removedShape: shape }); - util.onBeforeDeleteToShape?.({ binding, shape }); - } - } - if (deleteBindingIds.length) { - this.deleteBindings(deleteBindingIds); - } - const deletedIds = /* @__PURE__ */ new Set([shape.id]); - const updates = compact(this.getPageStates().map((pageState) => { - return cleanupInstancePageState(pageState, deletedIds); - })); - if (updates.length) { - this.store.put(updates); - } - } - }, - binding: { - beforeCreate: (binding) => { - const next = this.getBindingUtil(binding).onBeforeCreate?.({ binding }); - if (next) - return next; - return binding; - }, - afterCreate: (binding) => { - invalidBindingTypes.add(binding.type); - this.getBindingUtil(binding).onAfterCreate?.({ binding }); - }, - beforeChange: (bindingBefore, bindingAfter) => { - const updated = this.getBindingUtil(bindingAfter).onBeforeChange?.({ - bindingBefore, - bindingAfter - }); - if (updated) - return updated; - return bindingAfter; - }, - afterChange: (bindingBefore, bindingAfter) => { - invalidBindingTypes.add(bindingAfter.type); - this.getBindingUtil(bindingAfter).onAfterChange?.({ bindingBefore, bindingAfter }); - }, - beforeDelete: (binding) => { - this.getBindingUtil(binding).onBeforeDelete?.({ binding }); - }, - afterDelete: (binding) => { - this.getBindingUtil(binding).onAfterDelete?.({ binding }); - invalidBindingTypes.add(binding.type); - } - }, - page: { - afterCreate: (record) => { - const cameraId = CameraRecordType.createId(record.id); - const _pageStateId = InstancePageStateRecordType.createId(record.id); - if (!this.store.has(cameraId)) { - this.store.put([CameraRecordType.create({ id: cameraId })]); - } - if (!this.store.has(_pageStateId)) { - this.store.put([ - InstancePageStateRecordType.create({ id: _pageStateId, pageId: record.id }) - ]); - } - }, - afterDelete: (record, source) => { - if (this.getInstanceState()?.currentPageId === record.id) { - const backupPageId = this.getPages().find((p) => p.id !== record.id)?.id; - if (backupPageId) { - this.store.put([{ ...this.getInstanceState(), currentPageId: backupPageId }]); - } else if (source === "user") { - this.store.ensureStoreIsUsable(); - } - } - const cameraId = CameraRecordType.createId(record.id); - const instance_PageStateId = InstancePageStateRecordType.createId(record.id); - this.store.remove([cameraId, instance_PageStateId]); - } - }, - instance: { - afterChange: (prev, next, source) => { - if (!this.store.has(next.currentPageId)) { - const backupPageId = this.store.has(prev.currentPageId) ? prev.currentPageId : this.getPages()[0]?.id; - if (backupPageId) { - this.store.update(next.id, (instance) => ({ - ...instance, - currentPageId: backupPageId - })); - } else if (source === "user") { - this.store.ensureStoreIsUsable(); - } - } - } - }, - instance_page_state: { - afterChange: (prev, next) => { - if (prev?.selectedShapeIds !== next?.selectedShapeIds) { - const filtered = next.selectedShapeIds.filter((id) => { - let parentId = this.getShape(id)?.parentId; - while (isShapeId(parentId)) { - if (next.selectedShapeIds.includes(parentId)) { - return false; - } - parentId = this.getShape(parentId)?.parentId; - } - return true; - }); - let nextFocusedGroupId = null; - if (filtered.length > 0) { - const commonGroupAncestor = this.findCommonAncestor(compact(filtered.map((id) => this.getShape(id))), (shape) => this.isShapeOfType(shape, "group")); - if (commonGroupAncestor) { - nextFocusedGroupId = commonGroupAncestor; - } - } else { - if (next?.focusedGroupId) { - nextFocusedGroupId = next.focusedGroupId; - } - } - if (filtered.length !== next.selectedShapeIds.length || nextFocusedGroupId !== next.focusedGroupId) { - this.store.put([ - { - ...next, - selectedShapeIds: filtered, - focusedGroupId: nextFocusedGroupId ?? null - } - ]); - } - } - } - } - })); - this._currentPageShapeIds = deriveShapeIdsInCurrentPage(this.store, () => this.getCurrentPageId()); - this._parentIdsToChildIds = parentsToChildren(this.store); - this.disposables.add(this.store.listen((changes) => { - this.emit("change", changes); - })); - this.disposables.add(this.history.dispose); - this.run(() => { - this.store.ensureStoreIsUsable(); - this._updateCurrentPageState({ - editingShapeId: null, - hoveredShapeId: null, - erasingShapeIds: [] - }); - }, { history: "ignore" }); - if (initialState2 && this.root.children[initialState2] === void 0) { - throw Error(`No state found for initialState "${initialState2}".`); - } - this.root.enter(void 0, "initial"); - this.edgeScrollManager = new EdgeScrollManager(this); - this.focusManager = new FocusManager(this, autoFocus); - this.disposables.add(this.focusManager.dispose.bind(this.focusManager)); - if (this.getInstanceState().followingUserId) { - this.stopFollowingUser(); - } - this.on("tick", this._flushEventsForTick); - this.timers.requestAnimationFrame(() => { - this._tickManager.start(); - }); - this.performanceTracker = new PerformanceTracker(); - } - dispose() { - this.disposables.forEach((dispose) => dispose()); - this.disposables.clear(); - this.isDisposed = true; - } - getShapeUtil(arg) { - const type = typeof arg === "string" ? arg : arg.type; - const shapeUtil = getOwnProperty(this.shapeUtils, type); - assert(shapeUtil, `No shape util found for type "${type}"`); - return shapeUtil; - } - getBindingUtil(arg) { - const type = typeof arg === "string" ? arg : arg.type; - const bindingUtil = getOwnProperty(this.bindingUtils, type); - assert(bindingUtil, `No binding util found for type "${type}"`); - return bindingUtil; - } - undo() { - this._flushEventsForTick(0); - this.complete(); - this.history.undo(); - return this; - } - getCanUndo() { - return this.history.getNumUndos() > 0; - } - redo() { - this._flushEventsForTick(0); - this.complete(); - this.history.redo(); - return this; - } - clearHistory() { - this.history.clear(); - return this; - } - getCanRedo() { - return this.history.getNumRedos() > 0; - } - mark(markId) { - this.history.mark(markId); - return this; - } - squashToMark(markId) { - this.history.squashToMark(markId); - return this; - } - bail() { - this.history.bail(); - return this; - } - bailToMark(id) { - this.history.bailToMark(id); - return this; - } - run(fn, opts) { - const previousIgnoreShapeLock = this._shouldIgnoreShapeLock; - this._shouldIgnoreShapeLock = opts?.ignoreShapeLock ?? previousIgnoreShapeLock; - try { - this.history.batch(fn, opts); - } finally { - this._shouldIgnoreShapeLock = previousIgnoreShapeLock; - } - return this; - } - batch(fn, opts) { - return this.run(fn, opts); - } - annotateError(error3, { - origin, - willCrashApp, - tags, - extras - }) { - const defaultAnnotations = this.createErrorAnnotations(origin, willCrashApp); - annotateError(error3, { - tags: { ...defaultAnnotations.tags, ...tags }, - extras: { ...defaultAnnotations.extras, ...extras } - }); - if (willCrashApp) { - this.store.markAsPossiblyCorrupted(); - } - return this; - } - createErrorAnnotations(origin, willCrashApp) { - try { - const editingShapeId = this.getEditingShapeId(); - return { - tags: { - origin, - willCrashApp - }, - extras: { - activeStateNode: this.root.getPath(), - selectedShapes: this.getSelectedShapes(), - editingShape: editingShapeId ? this.getShape(editingShapeId) : void 0, - inputs: this.inputs - } - }; - } catch { - return { - tags: { - origin, - willCrashApp - }, - extras: {} - }; - } - } - getCrashingError() { - return this._crashingError; - } - crash(error3) { - this._crashingError = error3; - this.store.markAsPossiblyCorrupted(); - this.emit("crash", { error: error3 }); - return this; - } - getPath() { - return this.root.getPath().split("root.")[1]; - } - isIn(path) { - const ids = path.split(".").reverse(); - let state = this.root; - while (ids.length > 0) { - const id = ids.pop(); - if (!id) - return true; - const current = state.getCurrent(); - if (current?.id === id) { - if (ids.length === 0) - return true; - state = current; - continue; - } else - return false; - } - return false; - } - isInAny(...paths) { - return paths.some((path) => this.isIn(path)); - } - setCurrentTool(id, info2 = {}) { - this.root.transition(id, info2); - return this; - } - getCurrentTool() { - return this.root.getCurrent(); - } - getCurrentToolId() { - const currentTool = this.getCurrentTool(); - if (!currentTool) - return ""; - return currentTool.getCurrentToolIdMask() ?? currentTool.id; - } - getStateDescendant(path) { - const ids = path.split(".").reverse(); - let state = this.root; - while (ids.length > 0) { - const id = ids.pop(); - if (!id) - return state; - const childState = state.children?.[id]; - if (!childState) - return void 0; - state = childState; - } - return state; - } - getDocumentSettings() { - return this.store.get(TLDOCUMENT_ID); - } - updateDocumentSettings(settings) { - this.run(() => { - this.store.put([{ ...this.getDocumentSettings(), ...settings }]); - }, { history: "ignore" }); - return this; - } - getInstanceState() { - return this.store.get(TLINSTANCE_ID); - } - updateInstanceState(partial, historyOptions) { - this._updateInstanceState(partial, { history: "ignore", ...historyOptions }); - if (partial.isChangingStyle !== void 0) { - clearTimeout(this._isChangingStyleTimeout); - if (partial.isChangingStyle === true) { - this._isChangingStyleTimeout = this.timers.setTimeout(() => { - this._updateInstanceState({ isChangingStyle: false }, { history: "ignore" }); - }, 2e3); - } - } - return this; - } - getOpenMenus() { - return this.getInstanceState().openMenus; - } - addOpenMenu(id) { - const menus = new Set(this.getOpenMenus()); - if (!menus.has(id)) { - menus.add(id); - this.updateInstanceState({ openMenus: [...menus] }); - } - return this; - } - deleteOpenMenu(id) { - const menus = new Set(this.getOpenMenus()); - if (menus.has(id)) { - menus.delete(id); - this.updateInstanceState({ openMenus: [...menus] }); - } - return this; - } - clearOpenMenus() { - if (this.getOpenMenus().length) { - this.updateInstanceState({ openMenus: [] }); - } - return this; - } - getIsMenuOpen() { - return this.getOpenMenus().length > 0; - } - getPageStates() { - return this._getPageStatesQuery().get(); - } - _getPageStatesQuery() { - return this.store.query.records("instance_page_state"); - } - getCurrentPageState() { - return this.store.get(this._getCurrentPageStateId()); - } - _getCurrentPageStateId() { - return InstancePageStateRecordType.createId(this.getCurrentPageId()); - } - updateCurrentPageState(partial) { - this._updateCurrentPageState(partial); - return this; - } - getSelectedShapeIds() { - return this.getCurrentPageState().selectedShapeIds; - } - getSelectedShapes() { - const { selectedShapeIds } = this.getCurrentPageState(); - return compact(selectedShapeIds.map((id) => this.store.get(id))); - } - setSelectedShapes(shapes) { - return this.run(() => { - const ids = shapes.map((shape) => typeof shape === "string" ? shape : shape.id); - const { selectedShapeIds: prevSelectedShapeIds } = this.getCurrentPageState(); - const prevSet = new Set(prevSelectedShapeIds); - if (ids.length === prevSet.size && ids.every((id) => prevSet.has(id))) - return null; - this.store.put([{ ...this.getCurrentPageState(), selectedShapeIds: ids }]); - }, { history: "record-preserveRedoStack" }); - } - isAncestorSelected(shape) { - const id = typeof shape === "string" ? shape : shape?.id ?? null; - const _shape = this.getShape(id); - if (!_shape) - return false; - const selectedShapeIds = this.getSelectedShapeIds(); - return !!this.findShapeAncestor(_shape, (parent) => selectedShapeIds.includes(parent.id)); - } - select(...shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id); - this.setSelectedShapes(ids); - return this; - } - deselect(...shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id); - const selectedShapeIds = this.getSelectedShapeIds(); - if (selectedShapeIds.length > 0 && ids.length > 0) { - this.setSelectedShapes(selectedShapeIds.filter((id) => !ids.includes(id))); - } - return this; - } - selectAll() { - const ids = this.getSortedChildIdsForParent(this.getCurrentPageId()); - if (ids.length <= 0) - return this; - this.setSelectedShapes(this._getUnlockedShapeIds(ids)); - return this; - } - selectNone() { - if (this.getSelectedShapeIds().length > 0) { - this.setSelectedShapes([]); - } - return this; - } - getOnlySelectedShapeId() { - return this.getOnlySelectedShape()?.id ?? null; - } - getOnlySelectedShape() { - const selectedShapes = this.getSelectedShapes(); - return selectedShapes.length === 1 ? selectedShapes[0] : null; - } - getSelectionPageBounds() { - const selectedShapeIds = this.getCurrentPageState().selectedShapeIds; - if (selectedShapeIds.length === 0) - return null; - return Box.Common(compact(selectedShapeIds.map((id) => this.getShapePageBounds(id)))); - } - getSelectionRotation() { - const selectedShapeIds = this.getSelectedShapeIds(); - let foundFirst = false; - let rotation = 0; - for (let i = 0, n = selectedShapeIds.length; i < n; i++) { - const pageTransform = this.getShapePageTransform(selectedShapeIds[i]); - if (!pageTransform) - continue; - if (foundFirst) { - if (pageTransform.rotation() !== rotation) { - return 0; - } - } else { - foundFirst = true; - rotation = pageTransform.rotation(); - } - } - return rotation; - } - getSelectionRotatedPageBounds() { - const selectedShapeIds = this.getSelectedShapeIds(); - if (selectedShapeIds.length === 0) { - return void 0; - } - const selectionRotation = this.getSelectionRotation(); - if (selectionRotation === 0) { - return this.getSelectionPageBounds(); - } - if (selectedShapeIds.length === 1) { - const bounds = this.getShapeGeometry(selectedShapeIds[0]).bounds.clone(); - const pageTransform = this.getShapePageTransform(selectedShapeIds[0]); - bounds.point = pageTransform.applyToPoint(bounds.point); - return bounds; - } - const boxFromRotatedVertices = Box.FromPoints(this.getSelectedShapeIds().flatMap((id) => { - const pageTransform = this.getShapePageTransform(id); - if (!pageTransform) - return []; - return pageTransform.applyToPoints(this.getShapeGeometry(id).bounds.corners); - }).map((p) => p.rot(-selectionRotation))); - boxFromRotatedVertices.point = boxFromRotatedVertices.point.rot(selectionRotation); - return boxFromRotatedVertices; - } - getSelectionRotatedScreenBounds() { - const bounds = this.getSelectionRotatedPageBounds(); - if (!bounds) - return void 0; - const { x, y } = this.pageToScreen(bounds.point); - const zoom = this.getZoomLevel(); - return new Box(x, y, bounds.width * zoom, bounds.height * zoom); - } - getFocusedGroupId() { - return this.getCurrentPageState().focusedGroupId ?? this.getCurrentPageId(); - } - getFocusedGroup() { - const focusedGroupId = this.getFocusedGroupId(); - return focusedGroupId ? this.getShape(focusedGroupId) : void 0; - } - setFocusedGroup(shape) { - const id = typeof shape === "string" ? shape : shape?.id ?? null; - if (id !== null) { - const shape2 = this.getShape(id); - if (!shape2) { - throw Error(`Editor.setFocusedGroup: Shape with id ${id} does not exist`); - } - if (!this.isShapeOfType(shape2, "group")) { - throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${shape2.type}`); - } - } - if (id === this.getFocusedGroupId()) - return this; - return this.run(() => { - this.store.update(this.getCurrentPageState().id, (s) => ({ ...s, focusedGroupId: id })); - }, { history: "record-preserveRedoStack" }); - } - popFocusedGroupId() { - const focusedGroup = this.getFocusedGroup(); - if (focusedGroup) { - const match = this.findShapeAncestor(focusedGroup, (shape) => this.isShapeOfType(shape, "group")); - this.setFocusedGroup(match?.id ?? null); - this.select(focusedGroup.id); - } else { - this.setFocusedGroup(null); - this.selectNone(); - } - return this; - } - getEditingShapeId() { - return this.getCurrentPageState().editingShapeId; - } - getEditingShape() { - const editingShapeId = this.getEditingShapeId(); - return editingShapeId ? this.getShape(editingShapeId) : void 0; - } - setEditingShape(shape) { - const id = typeof shape === "string" ? shape : shape?.id ?? null; - if (id !== this.getEditingShapeId()) { - if (id) { - const shape2 = this.getShape(id); - if (shape2 && this.getShapeUtil(shape2).canEdit(shape2)) { - this.run(() => { - this._updateCurrentPageState({ editingShapeId: id }); - }, { history: "ignore" }); - return this; - } - } - this.run(() => { - this._updateCurrentPageState({ editingShapeId: null }); - }, { history: "ignore" }); - } - return this; - } - getHoveredShapeId() { - return this.getCurrentPageState().hoveredShapeId; - } - getHoveredShape() { - const hoveredShapeId = this.getHoveredShapeId(); - return hoveredShapeId ? this.getShape(hoveredShapeId) : void 0; - } - setHoveredShape(shape) { - const id = typeof shape === "string" ? shape : shape?.id ?? null; - if (id === this.getHoveredShapeId()) - return this; - this.run(() => { - this.updateCurrentPageState({ hoveredShapeId: id }); - }, { history: "ignore" }); - return this; - } - getHintingShapeIds() { - return this.getCurrentPageState().hintingShapeIds; - } - getHintingShape() { - const hintingShapeIds = this.getHintingShapeIds(); - return compact(hintingShapeIds.map((id) => this.getShape(id))); - } - setHintingShapes(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id); - this.run(() => { - this._updateCurrentPageState({ hintingShapeIds: dedupe(ids) }); - }, { history: "ignore" }); - return this; - } - getErasingShapeIds() { - return this.getCurrentPageState().erasingShapeIds; - } - getErasingShapes() { - const erasingShapeIds = this.getErasingShapeIds(); - return compact(erasingShapeIds.map((id) => this.getShape(id))); - } - setErasingShapes(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id); - ids.sort(); - const erasingShapeIds = this.getErasingShapeIds(); - this.run(() => { - if (ids.length === erasingShapeIds.length) { - for (let i = 0; i < ids.length; i++) { - if (ids[i] !== erasingShapeIds[i]) { - this._updateCurrentPageState({ erasingShapeIds: ids }); - break; - } - } - } else { - this._updateCurrentPageState({ erasingShapeIds: ids }); - } - }, { history: "ignore" }); - return this; - } - getCroppingShapeId() { - return this.getCurrentPageState().croppingShapeId; - } - setCroppingShape(shape) { - const id = typeof shape === "string" ? shape : shape?.id ?? null; - if (id !== this.getCroppingShapeId()) { - this.run(() => { - if (!id) { - this.updateCurrentPageState({ croppingShapeId: null }); - } else { - const shape2 = this.getShape(id); - const util = this.getShapeUtil(shape2); - if (shape2 && util.canCrop(shape2)) { - this.updateCurrentPageState({ croppingShapeId: id }); - } - } - }, { history: "ignore" }); - } - return this; - } - _unsafe_getCameraId() { - return CameraRecordType.createId(this.getCurrentPageId()); - } - getCamera() { - const baseCamera = this.store.get(this._unsafe_getCameraId()); - if (this._isLockedOnFollowingUser.get()) { - const followingCamera = this.getCameraForFollowing(); - if (followingCamera) { - return { ...baseCamera, ...followingCamera }; - } - } - return baseCamera; - } - getViewportPageBoundsForFollowing() { - const followingUserId = this.getInstanceState().followingUserId; - if (!followingUserId) - return null; - const leaderPresence = this.getCollaborators().find((c) => c.userId === followingUserId); - if (!leaderPresence) - return null; - const { w: lw, h: lh } = leaderPresence.screenBounds; - const { x: lx, y: ly, z: lz2 } = leaderPresence.camera; - const theirViewport = new Box(-lx, -ly, lw / lz2, lh / lz2); - const ourViewport = this.getViewportScreenBounds().clone(); - const ourAspectRatio = ourViewport.width / ourViewport.height; - ourViewport.width = theirViewport.width; - ourViewport.height = ourViewport.width / ourAspectRatio; - if (ourViewport.height < theirViewport.height) { - ourViewport.height = theirViewport.height; - ourViewport.width = ourViewport.height * ourAspectRatio; - } - ourViewport.center = theirViewport.center; - return ourViewport; - } - getCameraForFollowing() { - const viewport = this.getViewportPageBoundsForFollowing(); - if (!viewport) - return null; - return { - x: -viewport.x, - y: -viewport.y, - z: this.getViewportScreenBounds().w / viewport.width - }; - } - getZoomLevel() { - return this.getCamera().z; - } - getInitialZoom() { - const cameraOptions = this.getCameraOptions(); - if (!cameraOptions.constraints) - return 1; - if (cameraOptions.constraints.initialZoom === "default") - return 1; - const { zx, zy } = getCameraFitXFitY(this, cameraOptions); - switch (cameraOptions.constraints.initialZoom) { - case "fit-min": { - return Math.max(zx, zy); - } - case "fit-max": { - return Math.min(zx, zy); - } - case "fit-x": { - return zx; - } - case "fit-y": { - return zy; - } - case "fit-min-100": { - return Math.min(1, Math.max(zx, zy)); - } - case "fit-max-100": { - return Math.min(1, Math.min(zx, zy)); - } - case "fit-x-100": { - return Math.min(1, zx); - } - case "fit-y-100": { - return Math.min(1, zy); - } - default: { - throw exhaustiveSwitchError(cameraOptions.constraints.initialZoom); - } - } - } - getBaseZoom() { - const cameraOptions = this.getCameraOptions(); - if (!cameraOptions.constraints) - return 1; - if (cameraOptions.constraints.baseZoom === "default") - return 1; - const { zx, zy } = getCameraFitXFitY(this, cameraOptions); - switch (cameraOptions.constraints.baseZoom) { - case "fit-min": { - return Math.max(zx, zy); - } - case "fit-max": { - return Math.min(zx, zy); - } - case "fit-x": { - return zx; - } - case "fit-y": { - return zy; - } - case "fit-min-100": { - return Math.min(1, Math.max(zx, zy)); - } - case "fit-max-100": { - return Math.min(1, Math.min(zx, zy)); - } - case "fit-x-100": { - return Math.min(1, zx); - } - case "fit-y-100": { - return Math.min(1, zy); - } - default: { - throw exhaustiveSwitchError(cameraOptions.constraints.baseZoom); - } - } - } - getCameraOptions() { - return this._cameraOptions.get(); - } - setCameraOptions(options) { - const next = structuredClone({ - ...this._cameraOptions.__unsafe__getWithoutCapture(), - ...options - }); - if (next.zoomSteps?.length < 1) - next.zoomSteps = [1]; - this._cameraOptions.set(next); - return this; - } - getConstrainedCamera(point, opts) { - const currentCamera = this.getCamera(); - let { x, y, z = currentCamera.z } = point; - if (!opts?.force) { - const cameraOptions = this.getCameraOptions(); - const zoomMin = cameraOptions.zoomSteps[0]; - const zoomMax = last(cameraOptions.zoomSteps); - const vsb = this.getViewportScreenBounds(); - if (cameraOptions.constraints) { - const { constraints } = cameraOptions; - const py = Math.min(constraints.padding.y, vsb.w / 2); - const px = Math.min(constraints.padding.x, vsb.h / 2); - const bounds = Box.From(cameraOptions.constraints.bounds); - const zx = (vsb.w - px * 2) / bounds.w; - const zy = (vsb.h - py * 2) / bounds.h; - const baseZoom = this.getBaseZoom(); - const maxZ = zoomMax * baseZoom; - const minZ = zoomMin * baseZoom; - if (opts?.reset) { - z = this.getInitialZoom(); - } - if (z < minZ || z > maxZ) { - const { x: cx, y: cy, z: cz } = currentCamera; - const cxA = -cx + vsb.w / cz / 2; - const cyA = -cy + vsb.h / cz / 2; - z = clamp(z, minZ, maxZ); - const cxB = -cx + vsb.w / z / 2; - const cyB = -cy + vsb.h / z / 2; - x = cx + cxB - cxA; - y = cy + cyB - cyA; - } - const minX = px / z - bounds.x; - const minY = py / z - bounds.y; - const freeW = (vsb.w - px * 2) / z - bounds.w; - const freeH = (vsb.h - py * 2) / z - bounds.h; - const originX = minX + freeW * constraints.origin.x; - const originY = minY + freeH * constraints.origin.y; - const behaviorX = typeof constraints.behavior === "string" ? constraints.behavior : constraints.behavior.x; - const behaviorY = typeof constraints.behavior === "string" ? constraints.behavior : constraints.behavior.y; - if (opts?.reset) { - x = originX; - y = originY; - } else { - switch (behaviorX) { - case "fixed": { - x = originX; - break; - } - case "contain": { - if (z < zx) - x = originX; - else - x = clamp(x, minX + freeW, minX); - break; - } - case "inside": { - if (z < zx) - x = clamp(x, minX, (vsb.w - px) / z - bounds.w); - else - x = clamp(x, minX + freeW, minX); - break; - } - case "outside": { - x = clamp(x, px / z - bounds.w, (vsb.w - px) / z); - break; - } - case "free": { - break; - } - default: { - throw exhaustiveSwitchError(behaviorX); - } - } - switch (behaviorY) { - case "fixed": { - y = originY; - break; - } - case "contain": { - if (z < zy) - y = originY; - else - y = clamp(y, minY + freeH, minY); - break; - } - case "inside": { - if (z < zy) - y = clamp(y, minY, (vsb.h - py) / z - bounds.h); - else - y = clamp(y, minY + freeH, minY); - break; - } - case "outside": { - y = clamp(y, py / z - bounds.h, (vsb.h - py) / z); - break; - } - case "free": { - break; - } - default: { - throw exhaustiveSwitchError(behaviorY); - } - } - } - } else { - if (z > zoomMax || z < zoomMin) { - const { x: cx, y: cy, z: cz } = currentCamera; - z = clamp(z, zoomMin, zoomMax); - x = cx + (-cx + vsb.w / z / 2) - (-cx + vsb.w / cz / 2); - y = cy + (-cy + vsb.h / z / 2) - (-cy + vsb.h / cz / 2); - } - } - } - return { x, y, z }; - } - _setCamera(point, opts) { - const currentCamera = this.getCamera(); - const { x, y, z } = this.getConstrainedCamera(point, opts); - if (currentCamera.x === x && currentCamera.y === y && currentCamera.z === z) { - return this; - } - transact(() => { - const camera = { ...currentCamera, x, y, z }; - this.run(() => { - this.store.put([camera]); - }, { history: "ignore" }); - const { currentScreenPoint, currentPagePoint } = this.inputs; - const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID); - if (currentScreenPoint.x / z - x !== currentPagePoint.x || currentScreenPoint.y / z - y !== currentPagePoint.y) { - const event = { - type: "pointer", - target: "canvas", - name: "pointer_move", - point: Vec.AddXY(currentScreenPoint, screenBounds.x, screenBounds.y), - pointerId: INTERNAL_POINTER_IDS.CAMERA_MOVE, - ctrlKey: this.inputs.ctrlKey, - altKey: this.inputs.altKey, - shiftKey: this.inputs.shiftKey, - button: 0, - isPen: this.getInstanceState().isPenMode ?? false - }; - if (opts?.immediate) { - this._flushEventForTick(event); - } else { - this.dispatch(event); - } - } - this._tickCameraState(); - }); - return this; - } - setCamera(point, opts) { - const { isLocked } = this._cameraOptions.__unsafe__getWithoutCapture(); - if (isLocked && !opts?.force) - return this; - this.stopCameraAnimation(); - if (this.getInstanceState().followingUserId) { - this.stopFollowingUser(); - } - const _point = Vec.Cast(point); - if (!Number.isFinite(_point.x)) - _point.x = 0; - if (!Number.isFinite(_point.y)) - _point.y = 0; - if (_point.z === void 0 || !Number.isFinite(_point.z)) - point.z = this.getZoomLevel(); - const camera = this.getConstrainedCamera(_point, opts); - if (opts?.animation) { - const { width, height } = this.getViewportScreenBounds(); - this._animateToViewport(new Box(-camera.x, -camera.y, width / camera.z, height / camera.z), opts); - } else { - this._setCamera(camera, { - ...opts, - force: true - }); - } - return this; - } - centerOnPoint(point, opts) { - const { isLocked } = this.getCameraOptions(); - if (isLocked && !opts?.force) - return this; - const { width: pw, height: ph } = this.getViewportPageBounds(); - this.setCamera(new Vec(-(point.x - pw / 2), -(point.y - ph / 2), this.getCamera().z), opts); - return this; - } - zoomToFit(opts) { - const ids = [...this.getCurrentPageShapeIds()]; - if (ids.length <= 0) - return this; - const pageBounds = Box.Common(compact(ids.map((id) => this.getShapePageBounds(id)))); - this.zoomToBounds(pageBounds, opts); - return this; - } - resetZoom(point = this.getViewportScreenCenter(), opts) { - const { isLocked, constraints } = this.getCameraOptions(); - if (isLocked && !opts?.force) - return this; - const currentCamera = this.getCamera(); - const { x: cx, y: cy, z: cz } = currentCamera; - const { x, y } = point; - let z = 1; - if (constraints) { - const initialZoom = this.getInitialZoom(); - if (cz !== initialZoom) { - z = initialZoom; - } - } - this.setCamera(new Vec(cx + (x / z - x) - (x / cz - x), cy + (y / z - y) - (y / cz - y), z), opts); - return this; - } - zoomIn(point = this.getViewportScreenCenter(), opts) { - const { isLocked } = this.getCameraOptions(); - if (isLocked && !opts?.force) - return this; - const { x: cx, y: cy, z: cz } = this.getCamera(); - const { zoomSteps } = this.getCameraOptions(); - if (zoomSteps !== null && zoomSteps.length > 1) { - const baseZoom = this.getBaseZoom(); - let zoom = last(zoomSteps) * baseZoom; - for (let i = 1; i < zoomSteps.length; i++) { - const z1 = zoomSteps[i - 1] * baseZoom; - const z2 = zoomSteps[i] * baseZoom; - if (z2 - cz <= (z2 - z1) / 2) - continue; - zoom = z2; - break; - } - this.setCamera(new Vec(cx + (point.x / zoom - point.x) - (point.x / cz - point.x), cy + (point.y / zoom - point.y) - (point.y / cz - point.y), zoom), opts); - } - return this; - } - zoomOut(point = this.getViewportScreenCenter(), opts) { - const { isLocked } = this.getCameraOptions(); - if (isLocked && !opts?.force) - return this; - const { zoomSteps } = this.getCameraOptions(); - if (zoomSteps !== null && zoomSteps.length > 1) { - const baseZoom = this.getBaseZoom(); - const { x: cx, y: cy, z: cz } = this.getCamera(); - let zoom = zoomSteps[0] * baseZoom; - for (let i = zoomSteps.length - 1; i > 0; i--) { - const z1 = zoomSteps[i - 1] * baseZoom; - const z2 = zoomSteps[i] * baseZoom; - if (z2 - cz >= (z2 - z1) / 2) - continue; - zoom = z1; - break; - } - this.setCamera(new Vec(cx + (point.x / zoom - point.x) - (point.x / cz - point.x), cy + (point.y / zoom - point.y) - (point.y / cz - point.y), zoom), opts); - } - return this; - } - zoomToSelection(opts) { - const { isLocked } = this.getCameraOptions(); - if (isLocked && !opts?.force) - return this; - const selectionPageBounds = this.getSelectionPageBounds(); - if (selectionPageBounds) { - this.zoomToBounds(selectionPageBounds, { - targetZoom: Math.max(1, this.getZoomLevel()), - ...opts - }); - } - return this; - } - zoomToBounds(bounds, opts) { - const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture(); - if (cameraOptions.isLocked && !opts?.force) - return this; - const viewportScreenBounds = this.getViewportScreenBounds(); - const inset = opts?.inset ?? Math.min(ZOOM_TO_FIT_PADDING, viewportScreenBounds.width * 0.28); - const baseZoom = this.getBaseZoom(); - const zoomMin = cameraOptions.zoomSteps[0]; - const zoomMax = last(cameraOptions.zoomSteps); - let zoom = clamp(Math.min((viewportScreenBounds.width - inset) / bounds.w, (viewportScreenBounds.height - inset) / bounds.h), zoomMin * baseZoom, zoomMax * baseZoom); - if (opts?.targetZoom !== void 0) { - zoom = Math.min(opts.targetZoom, zoom); - } - this.setCamera(new Vec(-bounds.x + (viewportScreenBounds.width - bounds.w * zoom) / 2 / zoom, -bounds.y + (viewportScreenBounds.height - bounds.h * zoom) / 2 / zoom, zoom), opts); - return this; - } - stopCameraAnimation() { - this.emit("stop-camera-animation"); - return this; - } - _animateViewport(ms) { - if (!this._viewportAnimation) - return; - this._viewportAnimation.elapsed += ms; - const { elapsed, easing, duration, start, end } = this._viewportAnimation; - if (elapsed > duration) { - this.off("tick", this._animateViewport); - this._viewportAnimation = null; - this._setCamera(new Vec(-end.x, -end.y, this.getViewportScreenBounds().width / end.width)); - return; - } - const remaining = duration - elapsed; - const t2 = easing(1 - remaining / duration); - const left = start.minX + (end.minX - start.minX) * t2; - const top = start.minY + (end.minY - start.minY) * t2; - const right = start.maxX + (end.maxX - start.maxX) * t2; - this._setCamera(new Vec(-left, -top, this.getViewportScreenBounds().width / (right - left)), { - force: true - }); - } - _animateToViewport(targetViewportPage, opts = { animation: DEFAULT_ANIMATION_OPTIONS }) { - const { animation, ...rest } = opts; - if (!animation) - return; - const { duration = 0, easing = EASINGS.easeInOutCubic } = animation; - const animationSpeed = this.user.getAnimationSpeed(); - const viewportPageBounds = this.getViewportPageBounds(); - this.stopCameraAnimation(); - if (this.getInstanceState().followingUserId) { - this.stopFollowingUser(); - } - if (duration === 0 || animationSpeed === 0) { - return this._setCamera(new Vec(-targetViewportPage.x, -targetViewportPage.y, this.getViewportScreenBounds().width / targetViewportPage.width), { ...rest }); - } - this._viewportAnimation = { - elapsed: 0, - duration: duration / animationSpeed, - easing, - start: viewportPageBounds.clone(), - end: targetViewportPage.clone() - }; - this.once("stop-camera-animation", () => { - this.off("tick", this._animateViewport); - this._viewportAnimation = null; - }); - this.on("tick", this._animateViewport); - return this; - } - slideCamera(opts = {}) { - const { isLocked } = this.getCameraOptions(); - if (isLocked && !opts?.force) - return this; - const animationSpeed = this.user.getAnimationSpeed(); - if (animationSpeed === 0) - return this; - this.stopCameraAnimation(); - const { - speed, - friction = this.options.cameraSlideFriction, - direction, - speedThreshold = 0.01 - } = opts; - let currentSpeed = Math.min(speed, 1); - const cancel = () => { - this.off("tick", moveCamera); - this.off("stop-camera-animation", cancel); - }; - this.once("stop-camera-animation", cancel); - const moveCamera = (elapsed) => { - const { x: cx, y: cy, z: cz } = this.getCamera(); - const movementVec = Vec.Mul(direction, currentSpeed * elapsed / cz); - currentSpeed *= 1 - friction; - if (currentSpeed < speedThreshold) { - cancel(); - } else { - this._setCamera(new Vec(cx + movementVec.x, cy + movementVec.y, cz)); - } - }; - this.on("tick", moveCamera); - return this; - } - zoomToUser(userId, opts = { animation: { duration: 500 } }) { - const presence = this.getCollaborators().find((c) => c.userId === userId); - if (!presence) - return this; - this.run(() => { - if (this.getInstanceState().followingUserId !== null) { - this.stopFollowingUser(); - } - const isOnSamePage = presence.currentPageId === this.getCurrentPageId(); - if (!isOnSamePage) { - this.setCurrentPage(presence.currentPageId); - } - if (opts && opts.animation && !isOnSamePage) { - opts.animation = void 0; - } - this.centerOnPoint(presence.cursor, opts); - const { highlightedUserIds } = this.getInstanceState(); - this.updateInstanceState({ highlightedUserIds: [...highlightedUserIds, userId] }); - this.timers.setTimeout(() => { - const highlightedUserIds2 = [...this.getInstanceState().highlightedUserIds]; - const index2 = highlightedUserIds2.indexOf(userId); - if (index2 < 0) - return; - highlightedUserIds2.splice(index2, 1); - this.updateInstanceState({ highlightedUserIds: highlightedUserIds2 }); - }, this.options.collaboratorIdleTimeoutMs); - }); - return this; - } - updateViewportScreenBounds(screenBounds, center = false) { - screenBounds.width = Math.max(screenBounds.width, 1); - screenBounds.height = Math.max(screenBounds.height, 1); - const insets = [ - screenBounds.minY !== 0, - !approximately(document.body.scrollWidth, screenBounds.maxX, 1), - !approximately(document.body.scrollHeight, screenBounds.maxY, 1), - screenBounds.minX !== 0 - ]; - const { screenBounds: prevScreenBounds, insets: prevInsets } = this.getInstanceState(); - if (screenBounds.equals(prevScreenBounds) && insets.every((v, i) => v === prevInsets[i])) { - return this; - } - const { _willSetInitialBounds } = this; - this._willSetInitialBounds = false; - if (_willSetInitialBounds) { - this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets }); - this.setCamera(this.getCamera()); - } else { - if (center && !this.getInstanceState().followingUserId) { - const before = this.getViewportPageBounds().center; - this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets }); - this.centerOnPoint(before); - } else { - this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets }); - this._setCamera(Vec.From({ ...this.getCamera() })); - } - } - this._tickCameraState(); - return this; - } - getViewportScreenBounds() { - const { x, y, w, h } = this.getInstanceState().screenBounds; - return new Box(x, y, w, h); - } - getViewportScreenCenter() { - const viewportScreenBounds = this.getViewportScreenBounds(); - return new Vec(viewportScreenBounds.midX - viewportScreenBounds.minX, viewportScreenBounds.midY - viewportScreenBounds.minY); - } - getViewportPageBounds() { - const { w, h } = this.getViewportScreenBounds(); - const { x: cx, y: cy, z: cz } = this.getCamera(); - return new Box(-cx, -cy, w / cz, h / cz); - } - screenToPage(point) { - const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID); - const { x: cx, y: cy, z: cz = 1 } = this.getCamera(); - return new Vec((point.x - screenBounds.x) / cz - cx, (point.y - screenBounds.y) / cz - cy, point.z ?? 0.5); - } - pageToScreen(point) { - const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID); - const { x: cx, y: cy, z: cz = 1 } = this.getCamera(); - return new Vec((point.x + cx) * cz + screenBounds.x, (point.y + cy) * cz + screenBounds.y, point.z ?? 0.5); - } - pageToViewport(point) { - const { x: cx, y: cy, z: cz = 1 } = this.getCamera(); - return new Vec((point.x + cx) * cz, (point.y + cy) * cz, point.z ?? 0.5); - } - _getCollaboratorsQuery() { - return this.store.query.records("instance_presence", () => ({ - userId: { neq: this.user.getId() } - })); - } - getCollaborators() { - const allPresenceRecords = this._getCollaboratorsQuery().get(); - if (!allPresenceRecords.length) - return EMPTY_ARRAY; - const userIds = [...new Set(allPresenceRecords.map((c) => c.userId))].sort(); - return userIds.map((id) => { - const latestPresence = allPresenceRecords.filter((c) => c.userId === id).sort((a, b) => b.lastActivityTimestamp - a.lastActivityTimestamp)[0]; - return latestPresence; - }); - } - getCollaboratorsOnCurrentPage() { - const currentPageId = this.getCurrentPageId(); - return this.getCollaborators().filter((c) => c.currentPageId === currentPageId); - } - startFollowingUser(userId) { - this.stopFollowingUser(); - const leaderPresences = this._getCollaboratorsQuery().get().filter((p) => p.userId === userId); - if (!leaderPresences.length) { - console.warn("User not found"); - return this; - } - const thisUserId = this.user.getId(); - if (!thisUserId) { - console.warn("You should set the userId for the current instance before following a user"); - } - if (leaderPresences.some((p) => p.followingUserId === thisUserId)) { - return this; - } - const latestLeaderPresence = computed("latestLeaderPresence", () => { - return this.getCollaborators().find((p) => p.userId === userId); - }); - transact(() => { - this.updateInstanceState({ followingUserId: userId }, { history: "ignore" }); - const dispose = react("update current page", () => { - const leaderPresence = latestLeaderPresence.get(); - if (!leaderPresence) { - this.stopFollowingUser(); - return; - } - if (leaderPresence.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence.currentPageId)) { - this.run(() => { - this.store.put([ - { ...this.getInstanceState(), currentPageId: leaderPresence.currentPageId } - ]); - this._isLockedOnFollowingUser.set(true); - }, { history: "ignore" }); - } - }); - const cancel = () => { - dispose(); - this._isLockedOnFollowingUser.set(false); - this.off("frame", moveTowardsUser); - this.off("stop-following", cancel); - }; - const moveTowardsUser = () => { - const leaderPresence = latestLeaderPresence.get(); - if (!leaderPresence) { - this.stopFollowingUser(); - return; - } - if (this._isLockedOnFollowingUser.get()) - return; - const animationSpeed = this.user.getAnimationSpeed(); - if (animationSpeed === 0) { - this._isLockedOnFollowingUser.set(true); - return; - } - const targetViewport = this.getViewportPageBoundsForFollowing(); - if (!targetViewport) { - this.stopFollowingUser(); - return; - } - const currentViewport = this.getViewportPageBounds(); - const diffX = Math.abs(targetViewport.minX - currentViewport.minX) + Math.abs(targetViewport.maxX - currentViewport.maxX); - const diffY = Math.abs(targetViewport.minY - currentViewport.minY) + Math.abs(targetViewport.maxY - currentViewport.maxY); - if (diffX < this.options.followChaseViewportSnap && diffY < this.options.followChaseViewportSnap) { - this._isLockedOnFollowingUser.set(true); - return; - } - const t2 = clamp(animationSpeed * 0.5, 0.1, 0.8); - const nextViewport = new Box(lerp(currentViewport.minX, targetViewport.minX, t2), lerp(currentViewport.minY, targetViewport.minY, t2), lerp(currentViewport.width, targetViewport.width, t2), lerp(currentViewport.height, targetViewport.height, t2)); - const nextCamera = new Vec(-nextViewport.x, -nextViewport.y, this.getViewportScreenBounds().width / nextViewport.width); - this.stopCameraAnimation(); - this._setCamera(nextCamera); - }; - this.once("stop-following", cancel); - this.addListener("frame", moveTowardsUser); - moveTowardsUser(); - }); - return this; - } - stopFollowingUser() { - this.run(() => { - this.store.put([this.getCamera()]); - this._isLockedOnFollowingUser.set(false); - this.updateInstanceState({ followingUserId: null }); - this.emit("stop-following"); - }, { history: "ignore" }); - return this; - } - getUnorderedRenderingShapes(useEditorState) { - const renderingShapes = []; - let nextIndex = this.options.maxShapesPerPage * 2; - let nextBackgroundIndex = this.options.maxShapesPerPage; - const erasingShapeIds = this.getErasingShapeIds(); - const addShapeById = (id, opacity, isAncestorErasing) => { - const shape = this.getShape(id); - if (!shape) - return; - opacity *= shape.opacity; - let isShapeErasing = false; - const util = this.getShapeUtil(shape); - if (useEditorState) { - isShapeErasing = !isAncestorErasing && erasingShapeIds.includes(id); - if (isShapeErasing) { - opacity *= 0.32; - } - } - renderingShapes.push({ - id, - shape, - util, - index: nextIndex, - backgroundIndex: nextBackgroundIndex, - opacity - }); - nextIndex += 1; - nextBackgroundIndex += 1; - const childIds = this.getSortedChildIdsForParent(id); - if (!childIds.length) - return; - let backgroundIndexToRestore = null; - if (util.providesBackgroundForChildren(shape)) { - backgroundIndexToRestore = nextBackgroundIndex; - nextBackgroundIndex = nextIndex; - nextIndex += this.options.maxShapesPerPage; - } - for (const childId of childIds) { - addShapeById(childId, opacity, isAncestorErasing || isShapeErasing); - } - if (backgroundIndexToRestore !== null) { - nextBackgroundIndex = backgroundIndexToRestore; - } - }; - const pages = useEditorState ? [this.getCurrentPage()] : this.getPages(); - for (const page of pages) { - for (const childId of this.getSortedChildIdsForParent(page.id)) { - addShapeById(childId, 1, false); - } - } - return renderingShapes; - } - getCameraState() { - return this._cameraState.get(); - } - getRenderingShapes() { - const renderingShapes = this.getUnorderedRenderingShapes(true); - return renderingShapes.sort(sortById); - } - _getAllPagesQuery() { - return this.store.query.records("page"); - } - getPages() { - return this._getAllPagesQuery().get().sort(sortByIndex); - } - getCurrentPage() { - return this.getPage(this.getCurrentPageId()); - } - getCurrentPageId() { - return this.getInstanceState().currentPageId; - } - getPage(page) { - return this.store.get(typeof page === "string" ? page : page.id); - } - getCurrentPageShapeIds() { - return this._currentPageShapeIds.get(); - } - getCurrentPageShapeIdsSorted() { - return Array.from(this.getCurrentPageShapeIds()).sort(); - } - getPageShapeIds(page) { - const pageId = typeof page === "string" ? page : page.id; - const result = this.store.query.exec("shape", { parentId: { eq: pageId } }); - return this.getShapeAndDescendantIds(result.map((s) => s.id)); - } - setCurrentPage(page) { - const pageId = typeof page === "string" ? page : page.id; - if (!this.store.has(pageId)) { - console.error("Tried to set the current page id to a page that doesn't exist."); - return this; - } - this.stopFollowingUser(); - this.complete(); - return this.run(() => { - this.store.put([{ ...this.getInstanceState(), currentPageId: pageId }]); - }, { history: "record-preserveRedoStack" }); - } - updatePage(partial) { - if (this.getInstanceState().isReadonly) - return this; - const prev = this.getPage(partial.id); - if (!prev) - return this; - return this.run(() => this.store.update(partial.id, (page) => ({ ...page, ...partial }))); - } - createPage(page) { - this.run(() => { - if (this.getInstanceState().isReadonly) - return; - if (this.getPages().length >= this.options.maxPages) - return; - const pages = this.getPages(); - const name = getIncrementedName(page.name ?? "Page 1", pages.map((p) => p.name)); - let index2 = page.index; - if (!index2 || pages.some((p) => p.index === index2)) { - index2 = getIndexAbove(pages[pages.length - 1].index); - } - const newPage = PageRecordType.create({ - meta: {}, - ...page, - name, - index: index2 - }); - this.store.put([newPage]); - }); - return this; - } - deletePage(page) { - const id = typeof page === "string" ? page : page.id; - this.run(() => { - if (this.getInstanceState().isReadonly) - return; - const pages = this.getPages(); - if (pages.length === 1) - return; - const deletedPage = this.getPage(id); - if (!deletedPage) - return; - if (id === this.getCurrentPageId()) { - const index2 = pages.findIndex((page2) => page2.id === id); - const next = pages[index2 - 1] ?? pages[index2 + 1]; - this.setCurrentPage(next.id); - } - this.store.remove([deletedPage.id]); - }); - return this; - } - duplicatePage(page, createId = PageRecordType.createId()) { - if (this.getPages().length >= this.options.maxPages) - return this; - const id = typeof page === "string" ? page : page.id; - const freshPage = this.getPage(id); - if (!freshPage) - return this; - const prevCamera = { ...this.getCamera() }; - const content = this.getContentFromCurrentPage(this.getSortedChildIdsForParent(freshPage.id)); - this.run(() => { - const pages = this.getPages(); - const index2 = getIndexBetween(freshPage.index, pages[pages.indexOf(freshPage) + 1]?.index); - this.createPage({ name: freshPage.name + " Copy", id: createId, index: index2 }); - this.setCurrentPage(createId); - this.setCamera(prevCamera); - if (content) { - return this.putContentOntoCurrentPage(content); - } - }); - return this; - } - renamePage(page, name) { - const id = typeof page === "string" ? page : page.id; - if (this.getInstanceState().isReadonly) - return this; - this.updatePage({ id, name }); - return this; - } - _getAllAssetsQuery() { - return this.store.query.records("asset"); - } - getAssets() { - return this._getAllAssetsQuery().get(); - } - createAssets(assets) { - if (this.getInstanceState().isReadonly) - return this; - if (assets.length <= 0) - return this; - this.run(() => this.store.put(assets), { history: "ignore" }); - return this; - } - updateAssets(assets) { - if (this.getInstanceState().isReadonly) - return this; - if (assets.length <= 0) - return this; - this.run(() => { - this.store.put(assets.map((partial) => ({ - ...this.store.get(partial.id), - ...partial - }))); - }, { history: "ignore" }); - return this; - } - deleteAssets(assets) { - if (this.getInstanceState().isReadonly) - return this; - const ids = typeof assets[0] === "string" ? assets : assets.map((a) => a.id); - if (ids.length <= 0) - return this; - this.run(() => this.store.remove(ids), { history: "ignore" }); - return this; - } - getAsset(asset) { - return this.store.get(typeof asset === "string" ? asset : asset.id); - } - async resolveAssetUrl(assetId, context) { - if (!assetId) - return null; - const asset = this.getAsset(assetId); - if (!asset) - return null; - const { screenScale = 1, shouldResolveToOriginal = false } = context; - const zoomStepFunction = (zoom) => Math.pow(2, Math.ceil(Math.log2(zoom))); - const steppedScreenScale = Math.max(0.125, zoomStepFunction(screenScale)); - const networkEffectiveType = "connection" in navigator ? navigator.connection.effectiveType : null; - const dpr = this.getInstanceState().devicePixelRatio; - return await this.store.props.assets.resolve(asset, { - screenScale: screenScale || 1, - steppedScreenScale, - dpr, - networkEffectiveType, - shouldResolveToOriginal - }); - } - async uploadAsset(asset, file) { - return await this.store.props.assets.upload(asset, file); - } - _getShapeGeometryCache() { - return this.store.createComputedCache("bounds", (shape) => this.getShapeUtil(shape).getGeometry(shape), (a, b) => a.props === b.props); - } - getShapeGeometry(shape) { - return this._getShapeGeometryCache().get(typeof shape === "string" ? shape : shape.id); - } - _getShapeHandlesCache() { - return this.store.createComputedCache("handles", (shape) => { - return this.getShapeUtil(shape).getHandles?.(shape); - }); - } - getShapeHandles(shape) { - return this._getShapeHandlesCache().get(typeof shape === "string" ? shape : shape.id); - } - getShapeLocalTransform(shape) { - const id = typeof shape === "string" ? shape : shape.id; - const freshShape = this.getShape(id); - if (!freshShape) - throw Error("Editor.getTransform: shape not found"); - return Mat.Identity().translate(freshShape.x, freshShape.y).rotate(freshShape.rotation); - } - _getShapePageTransformCache() { - return this.store.createComputedCache("pageTransformCache", (shape) => { - if (isPageId(shape.parentId)) { - return this.getShapeLocalTransform(shape); - } - const parentTransform = this._getShapePageTransformCache().get(shape.parentId) ?? Mat.Identity(); - return Mat.Compose(parentTransform, this.getShapeLocalTransform(shape)); - }); - } - getShapeParentTransform(shape) { - const id = typeof shape === "string" ? shape : shape.id; - const freshShape = this.getShape(id); - if (!freshShape || isPageId(freshShape.parentId)) - return Mat.Identity(); - return this._getShapePageTransformCache().get(freshShape.parentId) ?? Mat.Identity(); - } - getShapePageTransform(shape) { - const id = typeof shape === "string" ? shape : shape.id; - return this._getShapePageTransformCache().get(id) ?? Mat.Identity(); - } - _getShapePageBoundsCache() { - return this.store.createComputedCache("pageBoundsCache", (shape) => { - const pageTransform = this._getShapePageTransformCache().get(shape.id); - if (!pageTransform) - return new Box(); - const result = Box.FromPoints(Mat.applyToPoints(pageTransform, this.getShapeGeometry(shape).vertices)); - return result; - }); - } - getShapePageBounds(shape) { - return this._getShapePageBoundsCache().get(typeof shape === "string" ? shape : shape.id); - } - _getShapeClipPathCache() { - return this.store.createComputedCache("clipPathCache", (shape) => { - const pageMask = this._getShapeMaskCache().get(shape.id); - if (!pageMask) - return void 0; - if (pageMask.length === 0) { - return `polygon(0px 0px, 0px 0px, 0px 0px)`; - } - const pageTransform = this._getShapePageTransformCache().get(shape.id); - if (!pageTransform) - return void 0; - const localMask = Mat.applyToPoints(Mat.Inverse(pageTransform), pageMask); - return `polygon(${localMask.map((p) => `${p.x}px ${p.y}px`).join(",")})`; - }); - } - getShapeClipPath(shape) { - return this._getShapeClipPathCache().get(typeof shape === "string" ? shape : shape.id); - } - _getShapeMaskCache() { - return this.store.createComputedCache("pageMaskCache", (shape) => { - if (isPageId(shape.parentId)) - return void 0; - const frameAncestors = this.getShapeAncestors(shape.id).filter((shape2) => this.isShapeOfType(shape2, "frame")); - if (frameAncestors.length === 0) - return void 0; - const pageMask = frameAncestors.map((s) => this._getShapePageTransformCache().get(s.id).applyToPoints(this.getShapeGeometry(s).vertices)).reduce((acc, b) => { - if (!(b && acc)) - return void 0; - const intersection = intersectPolygonPolygon(acc, b); - if (intersection) { - return intersection.map(Vec.Cast); - } - return []; - }); - return pageMask; - }); - } - getShapeMask(shape) { - return this._getShapeMaskCache().get(typeof shape === "string" ? shape : shape.id); - } - getShapeMaskedPageBounds(shape) { - if (typeof shape !== "string") - shape = shape.id; - return this._getShapeMaskedPageBoundsCache().get(shape); - } - _getShapeMaskedPageBoundsCache() { - return this.store.createComputedCache("shapeMaskedPageBoundsCache", (shape) => { - const pageBounds = this._getShapePageBoundsCache().get(shape.id); - if (!pageBounds) - return; - const pageMask = this._getShapeMaskCache().get(shape.id); - if (pageMask) { - if (pageMask.length === 0) - return void 0; - const { corners } = pageBounds; - if (corners.every((p, i) => p && Vec.Equals(p, pageMask[i]))) - return pageBounds.clone(); - const intersection = intersectPolygonPolygon(pageMask, corners); - if (!intersection) - return; - return Box.FromPoints(intersection); - } - return pageBounds; - }); - } - getShapeAncestors(shape, acc = []) { - const id = typeof shape === "string" ? shape : shape.id; - const freshShape = this.getShape(id); - if (!freshShape) - return acc; - const parentId = freshShape.parentId; - if (isPageId(parentId)) { - acc.reverse(); - return acc; - } - const parent = this.store.get(parentId); - if (!parent) - return acc; - acc.push(parent); - return this.getShapeAncestors(parent, acc); - } - findShapeAncestor(shape, predicate) { - const id = typeof shape === "string" ? shape : shape.id; - const freshShape = this.getShape(id); - if (!freshShape) - return; - const parentId = freshShape.parentId; - if (isPageId(parentId)) - return; - const parent = this.getShape(parentId); - if (!parent) - return; - return predicate(parent) ? parent : this.findShapeAncestor(parent, predicate); - } - hasAncestor(shape, ancestorId) { - const id = typeof shape === "string" ? shape : shape?.id; - const freshShape = id && this.getShape(id); - if (!freshShape) - return false; - if (freshShape.parentId === ancestorId) - return true; - return this.hasAncestor(this.getShapeParent(freshShape), ancestorId); - } - findCommonAncestor(shapes, predicate) { - if (shapes.length === 0) { - return; - } - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - const freshShapes = compact(ids.map((id) => this.getShape(id))); - if (freshShapes.length === 1) { - const parentId = freshShapes[0].parentId; - if (isPageId(parentId)) { - return; - } - return predicate ? this.findShapeAncestor(freshShapes[0], predicate)?.id : parentId; - } - const [nodeA, ...others] = freshShapes; - let ancestor = this.getShapeParent(nodeA); - while (ancestor) { - if (predicate && !predicate(ancestor)) { - ancestor = this.getShapeParent(ancestor); - continue; - } - if (others.every((shape) => this.hasAncestor(shape, ancestor.id))) { - return ancestor.id; - } - ancestor = this.getShapeParent(ancestor); - } - return void 0; - } - isShapeOrAncestorLocked(arg) { - const shape = typeof arg === "string" ? this.getShape(arg) : arg; - if (shape === void 0) - return false; - if (shape.isLocked) - return true; - return this.isShapeOrAncestorLocked(this.getShapeParent(shape)); - } - _notVisibleShapes() { - return notVisibleShapes(this); - } - getCulledShapes() { - const notVisibleShapes2 = this._notVisibleShapes().get(); - const selectedShapeIds = this.getSelectedShapeIds(); - const editingId = this.getEditingShapeId(); - const culledShapes = new Set(notVisibleShapes2); - if (editingId) { - culledShapes.delete(editingId); - } - selectedShapeIds.forEach((id) => { - culledShapes.delete(id); - }); - return culledShapes; - } - getCurrentPageBounds() { - let commonBounds; - this.getCurrentPageShapeIdsSorted().forEach((shapeId) => { - const bounds = this.getShapeMaskedPageBounds(shapeId); - if (!bounds) - return; - if (!commonBounds) { - commonBounds = bounds.clone(); - } else { - commonBounds = commonBounds.expand(bounds); - } - }); - return commonBounds; - } - getSelectedShapeAtPoint(point) { - const selectedShapeIds = this.getSelectedShapeIds(); - return this.getCurrentPageShapesSorted().filter((shape) => shape.type !== "group" && selectedShapeIds.includes(shape.id)).reverse().find((shape) => this.isPointInShape(shape, point, { hitInside: true, margin: 0 })); - } - getShapeAtPoint(point, opts = {}) { - const zoomLevel = this.getZoomLevel(); - const viewportPageBounds = this.getViewportPageBounds(); - const { - filter: filter2, - margin = 0, - hitLocked = false, - hitLabels = false, - hitInside = false, - hitFrameInside = false - } = opts; - let inHollowSmallestArea = Infinity; - let inHollowSmallestAreaHit = null; - let inMarginClosestToEdgeDistance = Infinity; - let inMarginClosestToEdgeHit = null; - const shapesToCheck = (opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted()).filter((shape) => { - if (shape.isLocked && !hitLocked || this.isShapeOfType(shape, "group")) - return false; - const pageMask = this.getShapeMask(shape); - if (pageMask && !pointInPolygon(point, pageMask)) - return false; - if (filter2) - return filter2(shape); - return true; - }); - for (let i = shapesToCheck.length - 1; i >= 0; i--) { - const shape = shapesToCheck[i]; - const geometry = this.getShapeGeometry(shape); - const isGroup = geometry instanceof Group2d; - const pointInShapeSpace = this.getPointInShapeSpace(shape, point); - if (this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") { - if (shape.props.text.trim()) { - for (const childGeometry of geometry.children) { - if (childGeometry.isLabel && childGeometry.isPointInBounds(pointInShapeSpace)) { - return shape; - } - } - } - } - if (this.isShapeOfType(shape, "frame")) { - const distance2 = geometry.distanceToPoint(pointInShapeSpace, hitInside); - if (Math.abs(distance2) <= margin) { - return inMarginClosestToEdgeHit || shape; - } - if (geometry.hitTestPoint(pointInShapeSpace, 0, true)) { - return inMarginClosestToEdgeHit || inHollowSmallestAreaHit || (hitFrameInside ? shape : void 0); - } - continue; - } - let distance; - if (isGroup) { - let minDistance = Infinity; - for (const childGeometry of geometry.children) { - if (childGeometry.isLabel && !hitLabels) - continue; - const tDistance = childGeometry.distanceToPoint(pointInShapeSpace, hitInside); - if (tDistance < minDistance) { - minDistance = tDistance; - } - } - distance = minDistance; - } else { - if (margin === 0 && (geometry.bounds.w < 1 || geometry.bounds.h < 1)) { - distance = geometry.distanceToPoint(pointInShapeSpace, hitInside); - } else { - if (geometry.bounds.containsPoint(pointInShapeSpace, margin)) { - distance = geometry.distanceToPoint(pointInShapeSpace, hitInside); - } else { - distance = Infinity; - } - } - } - if (geometry.isClosed) { - if (distance <= margin) { - if (geometry.isFilled || isGroup && geometry.children[0].isFilled) { - return inMarginClosestToEdgeHit || shape; - } else { - if (this.getShapePageBounds(shape).contains(viewportPageBounds)) - continue; - if (Math.abs(distance) < margin) { - if (Math.abs(distance) < inMarginClosestToEdgeDistance) { - inMarginClosestToEdgeDistance = Math.abs(distance); - inMarginClosestToEdgeHit = shape; - } - } else if (!inMarginClosestToEdgeHit) { - const { area } = geometry; - if (area < inHollowSmallestArea) { - inHollowSmallestArea = area; - inHollowSmallestAreaHit = shape; - } - } - } - } - } else { - if (distance < this.options.hitTestMargin / zoomLevel) { - return shape; - } - } - } - return inMarginClosestToEdgeHit || inHollowSmallestAreaHit || void 0; - } - getShapesAtPoint(point, opts = {}) { - return this.getCurrentPageShapes().filter((shape) => this.isPointInShape(shape, point, opts)); - } - isPointInShape(shape, point, opts = {}) { - const { hitInside = false, margin = 0 } = opts; - const id = typeof shape === "string" ? shape : shape.id; - const pageMask = this.getShapeMask(id); - if (pageMask && !pointInPolygon(point, pageMask)) - return false; - return this.getShapeGeometry(id).hitTestPoint(this.getPointInShapeSpace(shape, point), margin, hitInside); - } - getPointInShapeSpace(shape, point) { - const id = typeof shape === "string" ? shape : shape.id; - return this._getShapePageTransformCache().get(id).clone().invert().applyToPoint(point); - } - getPointInParentSpace(shape, point) { - const id = typeof shape === "string" ? shape : shape.id; - const freshShape = this.getShape(id); - if (!freshShape) - return new Vec(0, 0); - if (isPageId(freshShape.parentId)) - return Vec.From(point); - const parentTransform = this.getShapePageTransform(freshShape.parentId); - if (!parentTransform) - return Vec.From(point); - return parentTransform.clone().invert().applyToPoint(point); - } - getCurrentPageShapes() { - return Array.from(this.getCurrentPageShapeIds(), (id) => this.store.get(id)); - } - getCurrentPageShapesSorted() { - const result = []; - const topLevelShapes = this.getSortedChildIdsForParent(this.getCurrentPageId()); - for (let i = 0, n = topLevelShapes.length; i < n; i++) { - pushShapeWithDescendants(this, topLevelShapes[i], result); - } - return result; - } - getCurrentPageRenderingShapesSorted() { - const culledShapes = this.getCulledShapes(); - return this.getCurrentPageShapesSorted().filter(({ id }) => !culledShapes.has(id)); - } - isShapeOfType(arg, type) { - const shape = typeof arg === "string" ? this.getShape(arg) : arg; - if (!shape) - return false; - return shape.type === type; - } - getShape(shape) { - const id = typeof shape === "string" ? shape : shape.id; - if (!isShapeId(id)) - return void 0; - return this.store.get(id); - } - getShapeParent(shape) { - const id = typeof shape === "string" ? shape : shape?.id; - if (!id) - return void 0; - const freshShape = this.getShape(id); - if (freshShape === void 0 || !isShapeId(freshShape.parentId)) - return void 0; - return this.store.get(freshShape.parentId); - } - getShapeNearestSibling(siblingShape, targetShape) { - if (!targetShape) { - return void 0; - } - if (targetShape.parentId === siblingShape.parentId) { - return targetShape; - } - const ancestor = this.findShapeAncestor(targetShape, (ancestor2) => ancestor2.parentId === siblingShape.parentId); - return ancestor; - } - isShapeInPage(shape, pageId = this.getCurrentPageId()) { - const id = typeof shape === "string" ? shape : shape.id; - const shapeToCheck = this.getShape(id); - if (!shapeToCheck) - return false; - let shapeIsInPage = false; - if (shapeToCheck.parentId === pageId) { - shapeIsInPage = true; - } else { - let parent = this.getShape(shapeToCheck.parentId); - isInPageSearch: - while (parent) { - if (parent.parentId === pageId) { - shapeIsInPage = true; - break isInPageSearch; - } - parent = this.getShape(parent.parentId); - } - } - return shapeIsInPage; - } - getAncestorPageId(shape) { - const id = typeof shape === "string" ? shape : shape?.id; - const _shape = id && this.getShape(id); - if (!_shape) - return void 0; - if (isPageId(_shape.parentId)) { - return _shape.parentId; - } else { - return this.getAncestorPageId(this.getShape(_shape.parentId)); - } - } - reparentShapes(shapes, parentId, insertIndex) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length === 0) - return this; - const changes = []; - const parentTransform = isPageId(parentId) ? Mat.Identity() : this.getShapePageTransform(parentId); - const parentPageRotation = parentTransform.rotation(); - let indices = []; - const sibs = compact(this.getSortedChildIdsForParent(parentId).map((id) => this.getShape(id))); - if (insertIndex) { - const sibWithInsertIndex = sibs.find((s) => s.index === insertIndex); - if (sibWithInsertIndex) { - const sibAbove = sibs[sibs.indexOf(sibWithInsertIndex) + 1]; - if (sibAbove) { - indices = getIndicesBetween(insertIndex, sibAbove.index, ids.length); - } else { - indices = getIndicesAbove(insertIndex, ids.length); - } - } else { - const sibAbove = sibs.sort(sortByIndex).find((s) => s.index > insertIndex); - if (sibAbove) { - indices = getIndicesBetween(insertIndex, sibAbove.index, ids.length); - } else { - indices = getIndicesAbove(insertIndex, ids.length); - } - } - } else { - const sib = sibs.length && sibs[sibs.length - 1]; - indices = sib ? getIndicesAbove(sib.index, ids.length) : getIndices(ids.length); - } - const invertedParentTransform = parentTransform.clone().invert(); - const shapesToReparent = compact(ids.map((id) => this.getShape(id))); - this.run(() => { - for (let i = 0; i < shapesToReparent.length; i++) { - const shape = shapesToReparent[i]; - const pageTransform = this.getShapePageTransform(shape); - if (!pageTransform) - continue; - const pagePoint = pageTransform.point(); - if (!pagePoint) - continue; - const newPoint = invertedParentTransform.applyToPoint(pagePoint); - const newRotation = pageTransform.rotation() - parentPageRotation; - changes.push({ - id: shape.id, - type: shape.type, - parentId, - x: newPoint.x, - y: newPoint.y, - rotation: newRotation, - index: indices[i] - }); - } - this.updateShapes(changes); - }, { ignoreShapeLock: true }); - return this; - } - getHighestIndexForParent(parent) { - const parentId = typeof parent === "string" ? parent : parent.id; - const children = this._parentIdsToChildIds.get()[parentId]; - if (!children || children.length === 0) { - return "a1"; - } - const shape = this.getShape(children[children.length - 1]); - return getIndexAbove(shape.index); - } - getSortedChildIdsForParent(parent) { - const parentId = typeof parent === "string" ? parent : parent.id; - const ids = this._parentIdsToChildIds.get()[parentId]; - if (!ids) - return EMPTY_ARRAY; - return ids; - } - visitDescendants(parent, visitor) { - const parentId = typeof parent === "string" ? parent : parent.id; - const children = this.getSortedChildIdsForParent(parentId); - for (const id of children) { - if (visitor(id) === false) - continue; - this.visitDescendants(id, visitor); - } - return this; - } - getShapeAndDescendantIds(ids) { - const shapeIds = /* @__PURE__ */ new Set(); - for (const shape of ids.map((id) => this.getShape(id)).sort(sortByIndex)) { - shapeIds.add(shape.id); - this.visitDescendants(shape, (descendantId) => { - shapeIds.add(descendantId); - }); - } - return shapeIds; - } - getDroppingOverShape(point, droppingShapes = []) { - const currentPageShapesSorted = this.getCurrentPageShapesSorted(); - for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) { - const shape = currentPageShapesSorted[i]; - if (this.getSelectedShapeIds().includes(shape.id) || !this.getShapeUtil(shape).canDropShapes(shape, droppingShapes) || droppingShapes.find((s) => s.id === shape.id || this.hasAncestor(shape, s.id))) { - continue; - } - const maskedPageBounds = this.getShapeMaskedPageBounds(shape.id); - if (maskedPageBounds && maskedPageBounds.containsPoint(point) && this.getShapeGeometry(shape).hitTestPoint(this.getPointInShapeSpace(shape, point), 0, true)) { - return shape; - } - } - } - getOutermostSelectableShape(shape, filter2) { - const id = typeof shape === "string" ? shape : shape.id; - const freshShape = this.getShape(id); - let match = freshShape; - let node = freshShape; - const focusedGroup = this.getFocusedGroup(); - while (node) { - if (this.isShapeOfType(node, "group") && focusedGroup?.id !== node.id && !this.hasAncestor(focusedGroup, node.id) && (filter2?.(node) ?? true)) { - match = node; - } else if (focusedGroup?.id === node.id) { - break; - } - node = this.getShapeParent(node); - } - return match; - } - _getBindingsIndexCache() { - const index2 = bindingsIndex(this); - return this.store.createComputedCache("bindingsIndex", (shape) => { - return index2.get().get(shape.id); - }); - } - getBinding(id) { - return this.store.get(id); - } - getBindingsFromShape(shape, type) { - const id = typeof shape === "string" ? shape : shape.id; - return this.getBindingsInvolvingShape(id).filter((b) => b.fromId === id && b.type === type); - } - getBindingsToShape(shape, type) { - const id = typeof shape === "string" ? shape : shape.id; - return this.getBindingsInvolvingShape(id).filter((b) => b.toId === id && b.type === type); - } - getBindingsInvolvingShape(shape, type) { - const id = typeof shape === "string" ? shape : shape.id; - const result = this._getBindingsIndexCache().get(id) ?? EMPTY_ARRAY; - if (!type) - return result; - return result.filter((b) => b.type === type); - } - createBindings(partials) { - const bindings = []; - for (const partial of partials) { - const fromShape = this.getShape(partial.fromId); - const toShape = this.getShape(partial.toId); - if (!fromShape || !toShape) - continue; - if (!this.canBindShapes({ fromShape, toShape, binding: partial })) - continue; - const util = this.getBindingUtil(partial.type); - const defaultProps = util.getDefaultProps(); - const binding = this.store.schema.types.binding.create({ - ...partial, - id: partial.id ?? createBindingId(), - props: { - ...defaultProps, - ...partial.props - } - }); - bindings.push(binding); - } - this.store.put(bindings); - return this; - } - createBinding(partial) { - return this.createBindings([partial]); - } - updateBindings(partials) { - const updated = []; - for (const partial of partials) { - if (!partial) - continue; - const current = this.getBinding(partial.id); - if (!current) - continue; - const updatedBinding = applyPartialToRecordWithProps(current, partial); - if (updatedBinding === current) - continue; - const fromShape = this.getShape(updatedBinding.fromId); - const toShape = this.getShape(updatedBinding.toId); - if (!fromShape || !toShape) - continue; - if (!this.canBindShapes({ fromShape, toShape, binding: updatedBinding })) - continue; - updated.push(updatedBinding); - } - this.store.put(updated); - return this; - } - updateBinding(partial) { - return this.updateBindings([partial]); - } - deleteBindings(bindings, { isolateShapes = false } = {}) { - const ids = bindings.map((binding) => typeof binding === "string" ? binding : binding.id); - if (isolateShapes) { - this.store.atomic(() => { - for (const id of ids) { - const binding = this.getBinding(id); - if (!binding) - continue; - const util = this.getBindingUtil(binding); - util.onBeforeIsolateFromShape?.({ binding, removedShape: this.getShape(binding.toId) }); - util.onBeforeIsolateToShape?.({ binding, removedShape: this.getShape(binding.fromId) }); - this.store.remove([id]); - } - }); - } else { - this.store.remove(ids); - } - return this; - } - deleteBinding(binding, opts) { - return this.deleteBindings([binding], opts); - } - canBindShapes({ - fromShape, - toShape, - binding - }) { - const fromShapeType = typeof fromShape === "string" ? fromShape : fromShape.type; - const toShapeType = typeof toShape === "string" ? toShape : toShape.type; - const bindingType = typeof binding === "string" ? binding : binding.type; - const canBindOpts = { fromShapeType, toShapeType, bindingType }; - if (fromShapeType === toShapeType) { - return this.getShapeUtil(fromShapeType).canBind(canBindOpts); - } - return this.getShapeUtil(fromShapeType).canBind(canBindOpts) && this.getShapeUtil(toShapeType).canBind(canBindOpts); - } - rotateShapesBy(shapes, delta) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length <= 0) - return this; - const snapshot = getRotationSnapshot({ editor: this }); - if (!snapshot) - return this; - applyRotationToSnapshotShapes({ delta, snapshot, editor: this, stage: "one-off" }); - return this; - } - getChangesToTranslateShape(initialShape, newShapeCoords) { - let workingShape = initialShape; - const util = this.getShapeUtil(initialShape); - workingShape = applyPartialToRecordWithProps(workingShape, util.onTranslateStart?.(workingShape) ?? void 0); - workingShape = applyPartialToRecordWithProps(workingShape, { - id: initialShape.id, - type: initialShape.type, - x: newShapeCoords.x, - y: newShapeCoords.y - }); - workingShape = applyPartialToRecordWithProps(workingShape, util.onTranslate?.(initialShape, workingShape) ?? void 0); - workingShape = applyPartialToRecordWithProps(workingShape, util.onTranslateEnd?.(initialShape, workingShape) ?? void 0); - return workingShape; - } - nudgeShapes(shapes, offset4) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length <= 0) - return this; - const changes = []; - for (const id of ids) { - const shape = this.getShape(id); - const localDelta = Vec.From(offset4); - const parentTransform = this.getShapeParentTransform(shape); - if (parentTransform) - localDelta.rot(-parentTransform.rotation()); - changes.push(this.getChangesToTranslateShape(shape, localDelta.add(shape))); - } - this.updateShapes(changes); - return this; - } - duplicateShapes(shapes, offset4) { - this.run(() => { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length <= 0) - return this; - const initialIds = new Set(ids); - const shapeIdSet = this.getShapeAndDescendantIds(ids); - const orderedShapeIds = [...shapeIdSet].reverse(); - const shapeIds = /* @__PURE__ */ new Map(); - for (const shapeId of shapeIdSet) { - shapeIds.set(shapeId, createShapeId()); - } - const { shapesToCreate, bindingsToCreate } = withIsolatedShapes(this, shapeIdSet, (bindingIdsToMaintain) => { - const bindingsToCreate2 = []; - for (const originalId of bindingIdsToMaintain) { - const originalBinding = this.getBinding(originalId); - if (!originalBinding) - continue; - const duplicatedId = createBindingId(); - bindingsToCreate2.push({ - ...originalBinding, - id: duplicatedId, - fromId: assertExists(shapeIds.get(originalBinding.fromId)), - toId: assertExists(shapeIds.get(originalBinding.toId)) - }); - } - const shapesToCreate2 = []; - for (const originalId of orderedShapeIds) { - const duplicatedId = assertExists(shapeIds.get(originalId)); - const originalShape = this.getShape(originalId); - if (!originalShape) - continue; - let ox = 0; - let oy = 0; - if (offset4 && initialIds.has(originalId)) { - const parentTransform = this.getShapeParentTransform(originalShape); - const vec = new Vec(offset4.x, offset4.y).rot(-parentTransform.rotation()); - ox = vec.x; - oy = vec.y; - } - const parentId = originalShape.parentId; - const siblings = this.getSortedChildIdsForParent(parentId); - const currentIndex = siblings.indexOf(originalShape.id); - const siblingAboveId = siblings[currentIndex + 1]; - const siblingAbove = siblingAboveId ? this.getShape(siblingAboveId) : null; - const index2 = siblingAbove ? getIndexBetween(originalShape.index, siblingAbove.index) : getIndexAbove(originalShape.index); - shapesToCreate2.push({ - ...originalShape, - id: duplicatedId, - x: originalShape.x + ox, - y: originalShape.y + oy, - index: index2, - parentId: shapeIds.get(originalShape.parentId) ?? originalShape.parentId - }); - } - return { shapesToCreate: shapesToCreate2, bindingsToCreate: bindingsToCreate2 }; - }); - const maxShapesReached = shapesToCreate.length + this.getCurrentPageShapeIds().size > this.options.maxShapesPerPage; - if (maxShapesReached) { - alertMaxShapes(this); - return; - } - this.createShapes(shapesToCreate); - this.createBindings(bindingsToCreate); - this.setSelectedShapes(compact(ids.map((id) => shapeIds.get(id)))); - if (offset4 !== void 0) { - const selectionPageBounds = this.getSelectionPageBounds(); - const viewportPageBounds = this.getViewportPageBounds(); - if (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) { - this.centerOnPoint(selectionPageBounds.center, { - animation: { duration: this.options.animationMediumMs } - }); - } - } - }); - return this; - } - moveShapesToPage(shapes, pageId) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length === 0) - return this; - if (this.getInstanceState().isReadonly) - return this; - const currentPageId = this.getCurrentPageId(); - if (pageId === currentPageId) - return this; - if (!this.store.has(pageId)) - return this; - const content = this.getContentFromCurrentPage(ids); - if (!content) - return this; - if (this.getPageShapeIds(pageId).size + content.shapes.length > this.options.maxShapesPerPage) { - alertMaxShapes(this, pageId); - return this; - } - const fromPageZ = this.getCamera().z; - this.run(() => { - this.deleteShapes(ids); - this.setCurrentPage(pageId); - this.setFocusedGroup(null); - this.selectNone(); - this.putContentOntoCurrentPage(content, { - select: true, - preserveIds: true, - preservePosition: true - }); - this.setCamera({ ...this.getCamera(), z: fromPageZ }); - this.centerOnPoint(this.getSelectionRotatedPageBounds().center); - }); - return this; - } - toggleLock(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly || ids.length === 0) - return this; - let allLocked = true, allUnlocked = true; - const shapesToToggle = []; - for (const id of ids) { - const shape = this.getShape(id); - if (shape) { - shapesToToggle.push(shape); - if (shape.isLocked) { - allUnlocked = false; - } else { - allLocked = false; - } - } - } - this.run(() => { - if (allUnlocked) { - this.updateShapes(shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: true }))); - this.setSelectedShapes([]); - } else if (allLocked) { - this.updateShapes(shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: false }))); - } else { - this.updateShapes(shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: true }))); - } - }); - return this; - } - sendToBack(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - const changes = getReorderingShapesChanges(this, "toBack", ids); - if (changes) - this.updateShapes(changes); - return this; - } - sendBackward(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - const changes = getReorderingShapesChanges(this, "backward", ids); - if (changes) - this.updateShapes(changes); - return this; - } - bringForward(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - const changes = getReorderingShapesChanges(this, "forward", ids); - if (changes) - this.updateShapes(changes); - return this; - } - bringToFront(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - const changes = getReorderingShapesChanges(this, "toFront", ids); - if (changes) - this.updateShapes(changes); - return this; - } - flipShapes(shapes, operation) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly) - return this; - let shapesToFlip = compact(ids.map((id) => this.getShape(id))); - if (!shapesToFlip.length) - return this; - shapesToFlip = compact(shapesToFlip.map((shape) => { - if (this.isShapeOfType(shape, "group")) { - return this.getSortedChildIdsForParent(shape.id).map((id) => this.getShape(id)); - } - return shape; - }).flat()); - const scaleOriginPage = Box.Common(compact(shapesToFlip.map((id) => this.getShapePageBounds(id)))).center; - this.run(() => { - for (const shape of shapesToFlip) { - const bounds = this.getShapeGeometry(shape).bounds; - const initialPageTransform = this.getShapePageTransform(shape.id); - if (!initialPageTransform) - continue; - this.resizeShape(shape.id, { x: operation === "horizontal" ? -1 : 1, y: operation === "vertical" ? -1 : 1 }, { - initialBounds: bounds, - initialPageTransform, - initialShape: shape, - mode: "scale_shape", - isAspectRatioLocked: this.getShapeUtil(shape).isAspectRatioLocked(shape), - scaleOrigin: scaleOriginPage, - scaleAxisRotation: 0 - }); - } - }); - return this; - } - stackShapes(shapes, operation, gap) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly) - return this; - const shapesToStack = ids.map((id) => this.getShape(id)).filter((shape) => { - if (!shape) - return false; - return this.getShapeUtil(shape).canBeLaidOut(shape); - }); - const len = shapesToStack.length; - if (gap === 0 && len < 3 || len < 2) - return this; - const pageBounds = Object.fromEntries(shapesToStack.map((shape) => [shape.id, this.getShapePageBounds(shape)])); - let val; - let min3; - let max2; - let dim; - if (operation === "horizontal") { - val = "x"; - min3 = "minX"; - max2 = "maxX"; - dim = "width"; - } else { - val = "y"; - min3 = "minY"; - max2 = "maxY"; - dim = "height"; - } - let shapeGap; - if (gap === 0) { - const gaps = []; - shapesToStack.sort((a, b) => pageBounds[a.id][min3] - pageBounds[b.id][min3]); - for (let i = 0; i < len - 1; i++) { - const shape = shapesToStack[i]; - const nextShape = shapesToStack[i + 1]; - const bounds = pageBounds[shape.id]; - const nextBounds = pageBounds[nextShape.id]; - const gap2 = nextBounds[min3] - bounds[max2]; - const current = gaps.find((g) => g.gap === gap2); - if (current) { - current.count++; - } else { - gaps.push({ gap: gap2, count: 1 }); - } - } - let maxCount = 0; - gaps.forEach((g) => { - if (g.count > maxCount) { - maxCount = g.count; - shapeGap = g.gap; - } - }); - if (maxCount === 1) { - shapeGap = Math.max(0, gaps.reduce((a, c) => a + c.gap * c.count, 0) / (len - 1)); - } - } else { - shapeGap = gap; - } - const changes = []; - let v = pageBounds[shapesToStack[0].id][max2]; - shapesToStack.forEach((shape, i) => { - if (i === 0) - return; - const delta = { x: 0, y: 0 }; - delta[val] = v + shapeGap - pageBounds[shape.id][val]; - const parent = this.getShapeParent(shape); - const localDelta = parent ? Vec.Rot(delta, -this.getShapePageTransform(parent).decompose().rotation) : delta; - const translateStartChanges = this.getShapeUtil(shape).onTranslateStart?.(shape); - changes.push(translateStartChanges ? { - ...translateStartChanges, - [val]: shape[val] + localDelta[val] - } : { - id: shape.id, - type: shape.type, - [val]: shape[val] + localDelta[val] - }); - v += pageBounds[shape.id][dim] + shapeGap; - }); - this.updateShapes(changes); - return this; - } - packShapes(shapes, gap) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly) - return this; - if (ids.length < 2) - return this; - const shapesToPack = ids.map((id) => this.getShape(id)).filter((shape2) => { - if (!shape2) - return false; - return this.getShapeUtil(shape2).canBeLaidOut(shape2); - }); - const shapePageBounds = {}; - const nextShapePageBounds = {}; - let shape, bounds, area = 0; - for (let i = 0; i < shapesToPack.length; i++) { - shape = shapesToPack[i]; - bounds = this.getShapePageBounds(shape); - shapePageBounds[shape.id] = bounds; - nextShapePageBounds[shape.id] = bounds.clone(); - area += bounds.width * bounds.height; - } - const commonBounds = Box.Common(compact(Object.values(shapePageBounds))); - const maxWidth2 = commonBounds.width; - shapesToPack.sort((a, b) => shapePageBounds[b.id].height - shapePageBounds[a.id].height); - const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth2); - const spaces = [new Box(commonBounds.x, commonBounds.y, startWidth, Infinity)]; - let width = 0; - let height = 0; - let space; - let last22; - for (let i = 0; i < shapesToPack.length; i++) { - shape = shapesToPack[i]; - bounds = nextShapePageBounds[shape.id]; - for (let i2 = spaces.length - 1; i2 >= 0; i2--) { - space = spaces[i2]; - if (bounds.width > space.width || bounds.height > space.height) - continue; - bounds.x = space.x; - bounds.y = space.y; - height = Math.max(height, bounds.maxY); - width = Math.max(width, bounds.maxX); - if (bounds.width === space.width && bounds.height === space.height) { - last22 = spaces.pop(); - if (i2 < spaces.length) - spaces[i2] = last22; - } else if (bounds.height === space.height) { - space.x += bounds.width + gap; - space.width -= bounds.width + gap; - } else if (bounds.width === space.width) { - space.y += bounds.height + gap; - space.height -= bounds.height + gap; - } else { - spaces.push(new Box(space.x + (bounds.width + gap), space.y, space.width - (bounds.width + gap), bounds.height)); - space.y += bounds.height + gap; - space.height -= bounds.height + gap; - } - break; - } - } - const commonAfter = Box.Common(Object.values(nextShapePageBounds)); - const centerDelta = Vec.Sub(commonBounds.center, commonAfter.center); - let nextBounds; - const changes = []; - for (let i = 0; i < shapesToPack.length; i++) { - shape = shapesToPack[i]; - bounds = shapePageBounds[shape.id]; - nextBounds = nextShapePageBounds[shape.id]; - const delta = Vec.Sub(nextBounds.point, bounds.point).add(centerDelta); - const parentTransform = this.getShapeParentTransform(shape); - if (parentTransform) - delta.rot(-parentTransform.rotation()); - const change = { - id: shape.id, - type: shape.type, - x: shape.x + delta.x, - y: shape.y + delta.y - }; - const translateStartChange = this.getShapeUtil(shape).onTranslateStart?.({ - ...shape, - ...change - }); - if (translateStartChange) { - changes.push({ ...change, ...translateStartChange }); - } else { - changes.push(change); - } - } - if (changes.length) { - this.updateShapes(changes); - } - return this; - } - alignShapes(shapes, operation) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly) - return this; - if (ids.length < 2) - return this; - const shapesToAlign = compact(ids.map((id) => this.getShape(id))); - const shapePageBounds = Object.fromEntries(shapesToAlign.map((shape) => [shape.id, this.getShapePageBounds(shape)])); - const commonBounds = Box.Common(compact(Object.values(shapePageBounds))); - const changes = []; - shapesToAlign.forEach((shape) => { - const pageBounds = shapePageBounds[shape.id]; - if (!pageBounds) - return; - const delta = { x: 0, y: 0 }; - switch (operation) { - case "top": { - delta.y = commonBounds.minY - pageBounds.minY; - break; - } - case "center-vertical": { - delta.y = commonBounds.midY - pageBounds.minY - pageBounds.height / 2; - break; - } - case "bottom": { - delta.y = commonBounds.maxY - pageBounds.minY - pageBounds.height; - break; - } - case "left": { - delta.x = commonBounds.minX - pageBounds.minX; - break; - } - case "center-horizontal": { - delta.x = commonBounds.midX - pageBounds.minX - pageBounds.width / 2; - break; - } - case "right": { - delta.x = commonBounds.maxX - pageBounds.minX - pageBounds.width; - break; - } - } - const parent = this.getShapeParent(shape); - const localDelta = parent ? Vec.Rot(delta, -this.getShapePageTransform(parent).decompose().rotation) : delta; - changes.push(this.getChangesToTranslateShape(shape, Vec.Add(shape, localDelta))); - }); - this.updateShapes(changes); - return this; - } - distributeShapes(shapes, operation) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly) - return this; - if (ids.length < 3) - return this; - const len = ids.length; - const shapesToDistribute = compact(ids.map((id) => this.getShape(id))); - const pageBounds = Object.fromEntries(shapesToDistribute.map((shape) => [shape.id, this.getShapePageBounds(shape)])); - let val; - let min3; - let max2; - let mid; - let dim; - if (operation === "horizontal") { - val = "x"; - min3 = "minX"; - max2 = "maxX"; - mid = "midX"; - dim = "width"; - } else { - val = "y"; - min3 = "minY"; - max2 = "maxY"; - mid = "midY"; - dim = "height"; - } - const changes = []; - const first = shapesToDistribute.sort((a, b) => pageBounds[a.id][min3] - pageBounds[b.id][min3])[0]; - const last22 = shapesToDistribute.sort((a, b) => pageBounds[b.id][max2] - pageBounds[a.id][max2])[0]; - const midFirst = pageBounds[first.id][mid]; - const step = (pageBounds[last22.id][mid] - midFirst) / (len - 1); - const v = midFirst + step; - shapesToDistribute.filter((shape) => shape !== first && shape !== last22).sort((a, b) => pageBounds[a.id][mid] - pageBounds[b.id][mid]).forEach((shape, i) => { - const delta = { x: 0, y: 0 }; - delta[val] = v + step * i - pageBounds[shape.id][dim] / 2 - pageBounds[shape.id][val]; - const parent = this.getShapeParent(shape); - const localDelta = parent ? Vec.Rot(delta, -this.getShapePageTransform(parent).rotation()) : delta; - changes.push(this.getChangesToTranslateShape(shape, Vec.Add(shape, localDelta))); - }); - this.updateShapes(changes); - return this; - } - stretchShapes(shapes, operation) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (this.getInstanceState().isReadonly) - return this; - if (ids.length < 2) - return this; - const shapesToStretch = compact(ids.map((id) => this.getShape(id))); - const shapeBounds = Object.fromEntries(ids.map((id) => [id, this.getShapeGeometry(id).bounds])); - const shapePageBounds = Object.fromEntries(ids.map((id) => [id, this.getShapePageBounds(id)])); - const commonBounds = Box.Common(compact(Object.values(shapePageBounds))); - switch (operation) { - case "vertical": { - this.run(() => { - for (const shape of shapesToStretch) { - const pageRotation = this.getShapePageTransform(shape).rotation(); - if (pageRotation % PI2) - continue; - const bounds = shapeBounds[shape.id]; - const pageBounds = shapePageBounds[shape.id]; - const localOffset = new Vec(0, commonBounds.minY - pageBounds.minY); - const parentTransform = this.getShapeParentTransform(shape); - if (parentTransform) - localOffset.rot(-parentTransform.rotation()); - const { x, y } = Vec.Add(localOffset, shape); - this.updateShapes([{ id: shape.id, type: shape.type, x, y }]); - const scale = new Vec(1, commonBounds.height / pageBounds.height); - this.resizeShape(shape.id, scale, { - initialBounds: bounds, - scaleOrigin: new Vec(pageBounds.center.x, commonBounds.minY), - isAspectRatioLocked: this.getShapeUtil(shape).isAspectRatioLocked(shape), - scaleAxisRotation: 0 - }); - } - }); - break; - } - case "horizontal": { - this.run(() => { - for (const shape of shapesToStretch) { - const bounds = shapeBounds[shape.id]; - const pageBounds = shapePageBounds[shape.id]; - const pageRotation = this.getShapePageTransform(shape).rotation(); - if (pageRotation % PI2) - continue; - const localOffset = new Vec(commonBounds.minX - pageBounds.minX, 0); - const parentTransform = this.getShapeParentTransform(shape); - if (parentTransform) - localOffset.rot(-parentTransform.rotation()); - const { x, y } = Vec.Add(localOffset, shape); - this.updateShapes([{ id: shape.id, type: shape.type, x, y }]); - const scale = new Vec(commonBounds.width / pageBounds.width, 1); - this.resizeShape(shape.id, scale, { - initialBounds: bounds, - scaleOrigin: new Vec(commonBounds.minX, pageBounds.center.y), - isAspectRatioLocked: this.getShapeUtil(shape).isAspectRatioLocked(shape), - scaleAxisRotation: 0 - }); - } - }); - break; - } - } - return this; - } - resizeShape(shape, scale, options = {}) { - const id = typeof shape === "string" ? shape : shape.id; - if (this.getInstanceState().isReadonly) - return this; - if (!Number.isFinite(scale.x)) - scale = new Vec(1, scale.y); - if (!Number.isFinite(scale.y)) - scale = new Vec(scale.x, 1); - const initialShape = options.initialShape ?? this.getShape(id); - if (!initialShape) - return this; - const scaleOrigin = options.scaleOrigin ?? this.getShapePageBounds(id)?.center; - if (!scaleOrigin) - return this; - const pageTransform = options.initialPageTransform ? Mat.Cast(options.initialPageTransform) : this.getShapePageTransform(id); - if (!pageTransform) - return this; - const pageRotation = pageTransform.rotation(); - if (pageRotation == null) - return this; - const scaleAxisRotation = options.scaleAxisRotation ?? pageRotation; - const initialBounds = options.initialBounds ?? this.getShapeGeometry(id).bounds; - if (!initialBounds) - return this; - const isAspectRatioLocked = options.isAspectRatioLocked ?? this.getShapeUtil(initialShape).isAspectRatioLocked(initialShape); - if (!areAnglesCompatible(pageRotation, scaleAxisRotation)) { - return this._resizeUnalignedShape(id, scale, { - ...options, - initialBounds, - scaleOrigin, - scaleAxisRotation, - initialPageTransform: pageTransform, - isAspectRatioLocked, - initialShape - }); - } - const util = this.getShapeUtil(initialShape); - if (isAspectRatioLocked) { - if (Math.abs(scale.x) > Math.abs(scale.y)) { - scale = new Vec(scale.x, Math.sign(scale.y) * Math.abs(scale.x)); - } else { - scale = new Vec(Math.sign(scale.x) * Math.abs(scale.y), scale.y); - } - } - if (util.onResize && util.canResize(initialShape)) { - const newPagePoint = this._scalePagePoint(Mat.applyToPoint(pageTransform, new Vec(0, 0)), scaleOrigin, scale, scaleAxisRotation); - const newLocalPoint = this.getPointInParentSpace(initialShape.id, newPagePoint); - const myScale = new Vec(scale.x, scale.y); - const areWidthAndHeightAlignedWithCorrectAxis = approximately((pageRotation - scaleAxisRotation) % Math.PI, 0); - myScale.x = areWidthAndHeightAlignedWithCorrectAxis ? scale.x : scale.y; - myScale.y = areWidthAndHeightAlignedWithCorrectAxis ? scale.y : scale.x; - const initialPagePoint = Mat.applyToPoint(pageTransform, new Vec()); - const { x, y } = this.getPointInParentSpace(initialShape.id, initialPagePoint); - let workingShape = initialShape; - if (!options.skipStartAndEndCallbacks) { - workingShape = applyPartialToRecordWithProps(initialShape, util.onResizeStart?.(initialShape) ?? void 0); - } - workingShape = applyPartialToRecordWithProps(workingShape, { - id, - type: initialShape.type, - x: newLocalPoint.x, - y: newLocalPoint.y, - ...util.onResize({ ...initialShape, x, y }, { - newPoint: newLocalPoint, - handle: options.dragHandle ?? "bottom_right", - mode: options.mode ?? "scale_shape", - scaleX: myScale.x, - scaleY: myScale.y, - initialBounds, - initialShape - }) - }); - if (!options.skipStartAndEndCallbacks) { - workingShape = applyPartialToRecordWithProps(workingShape, util.onResizeEnd?.(initialShape, workingShape) ?? void 0); - } - this.updateShapes([workingShape]); - } else { - const initialPageCenter = Mat.applyToPoint(pageTransform, initialBounds.center); - const newPageCenter = this._scalePagePoint(initialPageCenter, scaleOrigin, scale, scaleAxisRotation); - const initialPageCenterInParentSpace = this.getPointInParentSpace(initialShape.id, initialPageCenter); - const newPageCenterInParentSpace = this.getPointInParentSpace(initialShape.id, newPageCenter); - const delta = Vec.Sub(newPageCenterInParentSpace, initialPageCenterInParentSpace); - this.updateShapes([ - { - id, - type: initialShape.type, - x: initialShape.x + delta.x, - y: initialShape.y + delta.y - } - ]); - } - return this; - } - _scalePagePoint(point, scaleOrigin, scale, scaleAxisRotation) { - const relativePoint = Vec.RotWith(point, scaleOrigin, -scaleAxisRotation).sub(scaleOrigin); - const newRelativePagePoint = Vec.MulV(relativePoint, scale); - const destination = Vec.Add(newRelativePagePoint, scaleOrigin).rotWith(scaleOrigin, scaleAxisRotation); - return destination; - } - _resizeUnalignedShape(id, scale, options) { - const { type } = options.initialShape; - const shapeScale = new Vec(scale.x, scale.y); - if (Math.abs(scale.x) > Math.abs(scale.y)) { - shapeScale.x = Math.sign(scale.x) * Math.abs(scale.y); - } else { - shapeScale.y = Math.sign(scale.y) * Math.abs(scale.x); - } - this.resizeShape(id, shapeScale, { - initialShape: options.initialShape, - initialBounds: options.initialBounds, - isAspectRatioLocked: options.isAspectRatioLocked - }); - if (Math.sign(scale.x) * Math.sign(scale.y) < 0) { - let { rotation } = Mat.Decompose(options.initialPageTransform); - rotation -= 2 * rotation; - this.updateShapes([{ id, type, rotation }]); - } - const preScaleShapePageCenter = Mat.applyToPoint(options.initialPageTransform, options.initialBounds.center); - const postScaleShapePageCenter = this._scalePagePoint(preScaleShapePageCenter, options.scaleOrigin, scale, options.scaleAxisRotation); - const pageBounds = this.getShapePageBounds(id); - const pageTransform = this.getShapePageTransform(id); - const currentPageCenter = pageBounds.center; - const shapePageTransformOrigin = pageTransform.point(); - if (!currentPageCenter || !shapePageTransformOrigin) - return this; - const pageDelta = Vec.Sub(postScaleShapePageCenter, currentPageCenter); - const postScaleShapePagePoint = Vec.Add(shapePageTransformOrigin, pageDelta); - const { x, y } = this.getPointInParentSpace(id, postScaleShapePagePoint); - this.updateShapes([{ id, type, x, y }]); - return this; - } - getInitialMetaForShape(_shape) { - return {}; - } - createShape(shape) { - this.createShapes([shape]); - return this; - } - createShapes(shapes) { - if (!Array.isArray(shapes)) { - throw Error("Editor.createShapes: must provide an array of shapes or shape partials"); - } - if (this.getInstanceState().isReadonly) - return this; - if (shapes.length <= 0) - return this; - const currentPageShapeIds = this.getCurrentPageShapeIds(); - const maxShapesReached = shapes.length + currentPageShapeIds.size > this.options.maxShapesPerPage; - if (maxShapesReached) { - alertMaxShapes(this); - return this; - } - const focusedGroupId = this.getFocusedGroupId(); - this.run(() => { - const currentPageShapesSorted = this.getCurrentPageShapesSorted(); - const partials = shapes.map((partial) => { - if (!partial.id) { - partial = { id: createShapeId(), ...partial }; - } - if (!partial.parentId || !(this.store.has(partial.parentId) || shapes.some((p) => p.id === partial.parentId))) { - let parentId = this.getFocusedGroupId(); - for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) { - const parent = currentPageShapesSorted[i]; - if (this.getShapeUtil(parent).canReceiveNewChildrenOfType(parent, partial.type) && this.isPointInShape(parent, { x: partial.x ?? 0, y: partial.y ?? 0 }, { - margin: 0, - hitInside: true - })) { - parentId = parent.id; - break; - } - } - const prevParentId = partial.parentId; - if (parentId === partial.id) { - parentId = focusedGroupId; - } - if (parentId !== prevParentId) { - partial = { ...partial }; - partial.parentId = parentId; - if (isShapeId(parentId)) { - const point = this.getPointInShapeSpace(this.getShape(parentId), { - x: partial.x ?? 0, - y: partial.y ?? 0 - }); - partial.x = point.x; - partial.y = point.y; - partial.rotation = -this.getShapePageTransform(parentId).rotation() + (partial.rotation ?? 0); - } - } - } - return partial; - }); - const parentIndices = /* @__PURE__ */ new Map(); - const shapeRecordsToCreate = []; - const { opacityForNextShape } = this.getInstanceState(); - for (const partial of partials) { - const util = this.getShapeUtil(partial); - let index2 = partial.index; - if (!index2) { - const parentId = partial.parentId ?? focusedGroupId; - if (!parentIndices.has(parentId)) { - parentIndices.set(parentId, this.getHighestIndexForParent(parentId)); - } - index2 = parentIndices.get(parentId); - parentIndices.set(parentId, getIndexAbove(index2)); - } - const initialProps = util.getDefaultProps(); - for (const [style, propKey] of this.styleProps[partial.type]) { - ; - initialProps[propKey] = this.getStyleForNextShape(style); - } - let shapeRecordToCreate = this.store.schema.types.shape.create({ - ...partial, - index: index2, - opacity: partial.opacity ?? opacityForNextShape, - parentId: partial.parentId ?? focusedGroupId, - props: "props" in partial ? { ...initialProps, ...partial.props } : initialProps - }); - if (shapeRecordToCreate.index === void 0) { - throw Error("no index!"); - } - const next = this.getShapeUtil(shapeRecordToCreate).onBeforeCreate?.(shapeRecordToCreate); - if (next) { - shapeRecordToCreate = next; - } - shapeRecordsToCreate.push(shapeRecordToCreate); - } - shapeRecordsToCreate.forEach((shape) => { - shape.meta = { - ...this.getInitialMetaForShape(shape), - ...shape.meta - }; - }); - this.store.put(shapeRecordsToCreate); - }); - return this; - } - animateShape(partial, opts = { animation: DEFAULT_ANIMATION_OPTIONS }) { - return this.animateShapes([partial], opts); - } - animateShapes(partials, opts = { animation: DEFAULT_ANIMATION_OPTIONS }) { - if (!opts.animation) - return this; - const { duration = 500, easing = EASINGS.linear } = opts.animation; - const animationId = uniqueId(); - let remaining = duration; - let t2; - const animations = []; - let partial, result; - for (let i = 0, n = partials.length; i < n; i++) { - partial = partials[i]; - if (!partial) - continue; - const shape = this.getShape(partial.id); - if (!shape) - continue; - result = { - start: structuredClone(shape), - end: applyPartialToRecordWithProps(structuredClone(shape), partial) - }; - animations.push(result); - this.animatingShapes.set(shape.id, animationId); - } - const handleTick = (elapsed) => { - remaining -= elapsed; - if (remaining < 0) { - const { animatingShapes: animatingShapes2 } = this; - const partialsToUpdate = partials.filter((p) => p && animatingShapes2.get(p.id) === animationId); - if (partialsToUpdate.length) { - this.updateShapes(partialsToUpdate); - } - this.off("tick", handleTick); - return; - } - t2 = easing(1 - remaining / duration); - const { animatingShapes } = this; - const updates = []; - let animationIdForShape; - for (let i = 0, n = animations.length; i < n; i++) { - const { start, end } = animations[i]; - animationIdForShape = animatingShapes.get(start.id); - if (animationIdForShape !== animationId) - continue; - updates.push({ - ...end, - x: start.x + (end.x - start.x) * t2, - y: start.y + (end.y - start.y) * t2, - opacity: start.opacity + (end.opacity - start.opacity) * t2, - rotation: start.rotation + (end.rotation - start.rotation) * t2, - props: this.getShapeUtil(end).getInterpolatedProps?.(start, end, t2) ?? end.props - }); - } - this._updateShapes(updates); - }; - this.on("tick", handleTick); - return this; - } - groupShapes(shapes, options = {}) { - const { groupId = createShapeId(), select = true } = options; - if (!Array.isArray(shapes)) { - throw Error("Editor.groupShapes: must provide an array of shapes or shape ids"); - } - if (this.getInstanceState().isReadonly) - return this; - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (ids.length <= 1) - return this; - const shapesToGroup = compact((this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map((id) => this.getShape(id))); - const sortedShapeIds = shapesToGroup.sort(sortByIndex).map((s) => s.id); - const pageBounds = Box.Common(compact(shapesToGroup.map((id) => this.getShapePageBounds(id)))); - const { x, y } = pageBounds.point; - const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId(); - if (this.getCurrentToolId() !== "select") - return this; - if (!this.isIn("select.idle")) { - this.cancel(); - } - const shapesWithRootParent = shapesToGroup.filter((shape) => shape.parentId === parentId).sort(sortByIndex); - const highestIndex = shapesWithRootParent[shapesWithRootParent.length - 1]?.index; - this.run(() => { - this.createShapes([ - { - id: groupId, - type: "group", - parentId, - index: highestIndex, - x, - y, - opacity: 1, - props: {} - } - ]); - this.reparentShapes(sortedShapeIds, groupId); - if (select) { - this.select(groupId); - } - }); - return this; - } - ungroupShapes(shapes, options = {}) { - if (this.getInstanceState().isReadonly) - return this; - const { select = true } = options; - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - const shapesToUngroup = compact((this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map((id) => this.getShape(id))); - if (shapesToUngroup.length === 0) - return this; - if (this.getCurrentToolId() !== "select") - return this; - if (!this.isIn("select.idle")) { - this.cancel(); - } - const idsToSelect = /* @__PURE__ */ new Set(); - const groups = []; - shapesToUngroup.forEach((shape) => { - if (this.isShapeOfType(shape, "group")) { - groups.push(shape); - } else { - idsToSelect.add(shape.id); - } - }); - if (groups.length === 0) - return this; - this.run(() => { - let group; - for (let i = 0, n = groups.length; i < n; i++) { - group = groups[i]; - const childIds = this.getSortedChildIdsForParent(group.id); - for (let j = 0, n2 = childIds.length; j < n2; j++) { - idsToSelect.add(childIds[j]); - } - this.reparentShapes(childIds, group.parentId, group.index); - } - this.deleteShapes(groups.map((group2) => group2.id)); - if (select) { - this.select(...idsToSelect); - } - }); - return this; - } - updateShape(partial) { - this.updateShapes([partial]); - return this; - } - updateShapes(partials) { - const compactedPartials = Array(partials.length); - for (let i = 0, n = partials.length; i < n; i++) { - const partial = partials[i]; - if (!partial) - continue; - const shape = this.getShape(partial.id); - if (!shape) - continue; - if (!this._shouldIgnoreShapeLock) { - if (shape.isLocked) { - if (!(Object.hasOwn(partial, "isLocked") && !partial.isLocked)) { - continue; - } - } else if (this.isShapeOrAncestorLocked(shape)) { - continue; - } - } - this.animatingShapes.delete(partial.id); - compactedPartials.push(partial); - } - this._updateShapes(compactedPartials); - return this; - } - _getUnlockedShapeIds(ids) { - return ids.filter((id) => !this.getShape(id)?.isLocked); - } - deleteShapes(_ids) { - if (this.getInstanceState().isReadonly) - return this; - if (!Array.isArray(_ids)) { - throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds"); - } - const shapeIds = typeof _ids[0] === "string" ? _ids : _ids.map((s) => s.id); - const shapeIdsToDelete = this._shouldIgnoreShapeLock ? shapeIds : this._getUnlockedShapeIds(shapeIds); - if (shapeIdsToDelete.length === 0) - return this; - const allShapeIdsToDelete = new Set(shapeIdsToDelete); - for (const id of shapeIdsToDelete) { - this.visitDescendants(id, (childId) => { - allShapeIdsToDelete.add(childId); - }); - } - return this.run(() => this.store.remove([...allShapeIdsToDelete])); - } - deleteShape(_id) { - this.deleteShapes([typeof _id === "string" ? _id : _id.id]); - return this; - } - _extractSharedStyles(shape, sharedStyleMap) { - if (this.isShapeOfType(shape, "group")) { - const childIds = this._parentIdsToChildIds.get()[shape.id]; - if (!childIds) - return; - for (let i = 0, n = childIds.length; i < n; i++) { - this._extractSharedStyles(this.getShape(childIds[i]), sharedStyleMap); - } - } else { - for (const [style, propKey] of this.styleProps[shape.type]) { - sharedStyleMap.applyValue(style, getOwnProperty(shape.props, propKey)); - } - } - } - _getSelectionSharedStyles() { - const selectedShapes = this.getSelectedShapes(); - const sharedStyles = new SharedStyleMap(); - for (const selectedShape of selectedShapes) { - this._extractSharedStyles(selectedShape, sharedStyles); - } - return sharedStyles; - } - getStyleForNextShape(style) { - const value = this.getInstanceState().stylesForNextShape[style.id]; - return value === void 0 ? style.defaultValue : value; - } - getShapeStyleIfExists(shape, style) { - const styleKey = this.styleProps[shape.type].get(style); - if (styleKey === void 0) - return void 0; - return getOwnProperty(shape.props, styleKey); - } - getSharedStyles() { - if (this.isIn("select") && this.getSelectedShapeIds().length > 0) { - return this._getSelectionSharedStyles(); - } - const currentTool = this.root.getCurrent(); - const styles3 = new SharedStyleMap(); - if (!currentTool) - return styles3; - if (currentTool.shapeType) { - for (const style of this.styleProps[currentTool.shapeType].keys()) { - styles3.applyValue(style, this.getStyleForNextShape(style)); - } - } - return styles3; - } - getSharedOpacity() { - if (this.isIn("select") && this.getSelectedShapeIds().length > 0) { - const shapesToCheck = []; - const addShape = (shapeId) => { - const shape = this.getShape(shapeId); - if (!shape) - return; - if (this.isShapeOfType(shape, "group")) { - for (const childId of this.getSortedChildIdsForParent(shape.id)) { - addShape(childId); - } - } else { - shapesToCheck.push(shape); - } - }; - for (const shapeId of this.getSelectedShapeIds()) { - addShape(shapeId); - } - let opacity = null; - for (const shape of shapesToCheck) { - if (opacity === null) { - opacity = shape.opacity; - } else if (opacity !== shape.opacity) { - return { type: "mixed" }; - } - } - if (opacity !== null) - return { type: "shared", value: opacity }; - } - return { type: "shared", value: this.getInstanceState().opacityForNextShape }; - } - setOpacityForNextShapes(opacity, historyOptions) { - this.updateInstanceState({ opacityForNextShape: opacity }, historyOptions); - return this; - } - setOpacityForSelectedShapes(opacity) { - const selectedShapes = this.getSelectedShapes(); - if (selectedShapes.length > 0) { - const shapesToUpdate = []; - const addShapeById = (shape) => { - if (this.isShapeOfType(shape, "group")) { - const childIds = this.getSortedChildIdsForParent(shape); - for (const childId of childIds) { - addShapeById(this.getShape(childId)); - } - } else { - shapesToUpdate.push(shape); - } - }; - for (const id of selectedShapes) { - addShapeById(id); - } - this.updateShapes(shapesToUpdate.map((shape) => { - return { - id: shape.id, - type: shape.type, - opacity - }; - })); - } - return this; - } - setStyleForNextShapes(style, value, historyOptions) { - const stylesForNextShape = this.getInstanceState().stylesForNextShape; - this.updateInstanceState({ stylesForNextShape: { ...stylesForNextShape, [style.id]: value } }, historyOptions); - return this; - } - setStyleForSelectedShapes(style, value) { - const selectedShapes = this.getSelectedShapes(); - if (selectedShapes.length > 0) { - const updates = []; - const addShapeById = (shape) => { - if (this.isShapeOfType(shape, "group")) { - const childIds = this.getSortedChildIdsForParent(shape.id); - for (const childId of childIds) { - addShapeById(this.getShape(childId)); - } - } else { - const util = this.getShapeUtil(shape); - const stylePropKey = this.styleProps[shape.type].get(style); - if (stylePropKey) { - const shapePartial = { - id: shape.id, - type: shape.type, - props: { [stylePropKey]: value } - }; - updates.push({ - util, - originalShape: shape, - updatePartial: shapePartial - }); - } - } - }; - for (const shape of selectedShapes) { - addShapeById(shape); - } - this.updateShapes(updates.map(({ updatePartial }) => updatePartial)); - } - return this; - } - registerExternalAssetHandler(type, handler) { - this.externalAssetContentHandlers[type] = handler; - return this; - } - async getAssetForExternalContent(info2) { - return await this.externalAssetContentHandlers[info2.type]?.(info2); - } - hasExternalAssetHandler(type) { - return !!this.externalAssetContentHandlers[type]; - } - registerExternalContentHandler(type, handler) { - this.externalContentHandlers[type] = handler; - return this; - } - async putExternalContent(info2) { - return this.externalContentHandlers[info2.type]?.(info2); - } - getContentFromCurrentPage(shapes) { - const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id); - if (!ids) - return; - if (ids.length === 0) - return; - const shapeIds = this.getShapeAndDescendantIds(ids); - return withIsolatedShapes(this, shapeIds, (bindingIdsToKeep) => { - const bindings = []; - for (const id of bindingIdsToKeep) { - const binding = this.getBinding(id); - if (!binding) - continue; - bindings.push(binding); - } - const rootShapeIds = []; - const shapes2 = []; - for (const shapeId of shapeIds) { - const shape = this.getShape(shapeId); - if (!shape) - continue; - const isRootShape = !shapeIds.has(shape.parentId); - if (isRootShape) { - const pageTransform = this.getShapePageTransform(shape.id); - const pagePoint = pageTransform.point(); - shapes2.push({ - ...shape, - x: pagePoint.x, - y: pagePoint.y, - rotation: pageTransform.rotation(), - parentId: this.getCurrentPageId() - }); - rootShapeIds.push(shape.id); - } else { - shapes2.push(shape); - } - } - const assets = []; - const seenAssetIds = /* @__PURE__ */ new Set(); - for (const shape of shapes2) { - if (!("assetId" in shape.props)) - continue; - const assetId = shape.props.assetId; - if (!assetId || seenAssetIds.has(assetId)) - continue; - seenAssetIds.add(assetId); - const asset = this.getAsset(assetId); - if (!asset) - continue; - assets.push(asset); - } - return { - schema: this.store.schema.serialize(), - shapes: shapes2, - rootShapeIds, - bindings, - assets - }; - }); - } - async resolveAssetsInContent(content) { - if (!content) - return void 0; - const assets = []; - await Promise.allSettled(content.assets.map(async (asset) => { - if ((asset.type === "image" || asset.type === "video") && !asset.props.src?.startsWith("data:image") && !asset.props.src?.startsWith("http")) { - const assetWithDataUrl = structuredClone(asset); - const objectUrl = await this.store.props.assets.resolve(asset, { - screenScale: 1, - steppedScreenScale: 1, - dpr: 1, - networkEffectiveType: null, - shouldResolveToOriginal: true - }); - assetWithDataUrl.props.src = await FileHelpers.blobToDataUrl(await fetch2(objectUrl).then((r) => r.blob())); - assets.push(assetWithDataUrl); - } else { - assets.push(asset); - } - })); - content.assets = assets; - return content; - } - putContentOntoCurrentPage(content, options = {}) { - if (this.getInstanceState().isReadonly) - return this; - if (!content.schema) { - throw Error("Could not put content:\ncontent is missing a schema."); - } - const { select = false, preserveIds = false, preservePosition = false } = options; - let { point = void 0 } = options; - const currentPageId = this.getCurrentPageId(); - const { rootShapeIds } = content; - const assets = []; - const shapes = []; - const bindings = []; - const store = { - store: { - ...Object.fromEntries(content.assets.map((asset) => [asset.id, asset])), - ...Object.fromEntries(content.shapes.map((shape) => [shape.id, shape])), - ...Object.fromEntries(content.bindings?.map((bindings2) => [bindings2.id, bindings2]) ?? []) - }, - schema: content.schema - }; - const result = this.store.schema.migrateStoreSnapshot(store); - if (result.type === "error") { - throw Error("Could not put content: could not migrate content"); - } - for (const record of Object.values(result.value)) { - switch (record.typeName) { - case "asset": { - assets.push(record); - break; - } - case "shape": { - shapes.push(record); - break; - } - case "binding": { - bindings.push(record); - break; - } - } - } - const shapeIdMap = new Map(preserveIds ? shapes.map((shape) => [shape.id, shape.id]) : shapes.map((shape) => [shape.id, createShapeId()])); - const bindingIdMap = new Map(preserveIds ? bindings.map((binding) => [binding.id, binding.id]) : bindings.map((binding) => [binding.id, createBindingId()])); - let pasteParentId = this.getCurrentPageId(); - let lowestDepth = Infinity; - let lowestAncestors = []; - for (const shape of this.getSelectedShapes()) { - if (lowestDepth === 0) - break; - const isFrame = this.isShapeOfType(shape, "frame"); - const ancestors = this.getShapeAncestors(shape); - if (isFrame) - ancestors.push(shape); - const depth = isFrame ? ancestors.length + 1 : ancestors.length; - if (depth < lowestDepth) { - lowestDepth = depth; - lowestAncestors = ancestors; - pasteParentId = isFrame ? shape.id : shape.parentId; - } else if (depth === lowestDepth) { - if (lowestAncestors.length !== ancestors.length) { - throw Error(`Ancestors: ${lowestAncestors.length} !== ${ancestors.length}`); - } - if (lowestAncestors.length === 0) { - pasteParentId = currentPageId; - break; - } else { - pasteParentId = currentPageId; - for (let i = 0; i < lowestAncestors.length; i++) { - if (ancestors[i] !== lowestAncestors[i]) - break; - pasteParentId = ancestors[i].id; - } - } - } - } - let isDuplicating = false; - if (!isPageId(pasteParentId)) { - const parent = this.getShape(pasteParentId); - if (parent) { - if (!this.getViewportPageBounds().includes(this.getShapePageBounds(parent))) { - pasteParentId = currentPageId; - } else { - if (rootShapeIds.length === 1) { - const rootShape = shapes.find((s) => s.id === rootShapeIds[0]); - if (this.isShapeOfType(parent, "frame") && this.isShapeOfType(rootShape, "frame") && rootShape.props.w === parent?.props.w && rootShape.props.h === parent?.props.h) { - isDuplicating = true; - } - } - } - } else { - pasteParentId = currentPageId; - } - } - if (!isDuplicating) { - isDuplicating = shapeIdMap.has(pasteParentId); - } - if (isDuplicating) { - pasteParentId = this.getShape(pasteParentId).parentId; - } - let index2 = this.getHighestIndexForParent(pasteParentId); - const rootShapes = []; - const newShapes = shapes.map((oldShape) => { - const newId = shapeIdMap.get(oldShape.id); - const newShape = { ...oldShape, id: newId }; - if (rootShapeIds.includes(oldShape.id)) { - newShape.parentId = currentPageId; - rootShapes.push(newShape); - } - if (shapeIdMap.has(newShape.parentId)) { - newShape.parentId = shapeIdMap.get(oldShape.parentId); - } else { - rootShapeIds.push(newShape.id); - newShape.index = index2; - index2 = getIndexAbove(index2); - } - return newShape; - }); - if (newShapes.length + this.getCurrentPageShapeIds().size > this.options.maxShapesPerPage) { - alertMaxShapes(this); - return this; - } - const newBindings = bindings.map((oldBinding) => ({ - ...oldBinding, - id: assertExists(bindingIdMap.get(oldBinding.id)), - fromId: assertExists(shapeIdMap.get(oldBinding.fromId)), - toId: assertExists(shapeIdMap.get(oldBinding.toId)) - })); - const assetsToCreate = []; - const assetsToUpdate = []; - for (const asset of assets) { - if (this.store.has(asset.id)) { - continue; - } - if ((asset.type === "image" || asset.type === "video") && asset.props.src?.startsWith("data:image")) { - assetsToUpdate.push(structuredClone(asset)); - asset.props.src = null; - } - assetsToCreate.push(asset); - } - Promise.allSettled(assetsToUpdate.map(async (asset) => { - const file = await dataUrlToFile(asset.props.src, asset.props.name, asset.props.mimeType ?? "image/png"); - const newAsset = await this.getAssetForExternalContent({ type: "file", file }); - if (!newAsset) { - this.deleteAssets([asset.id]); - return; - } - this.updateAssets([{ ...newAsset, id: asset.id }]); - })); - this.run(() => { - if (assetsToCreate.length > 0) { - this.createAssets(assetsToCreate); - } - this.createShapes(newShapes); - this.createBindings(newBindings); - if (select) { - this.select(...rootShapes.map((s) => s.id)); - } - if (pasteParentId !== currentPageId) { - this.reparentShapes(rootShapes.map((s) => s.id), pasteParentId); - } - const newCreatedShapes = newShapes.map((s) => this.getShape(s.id)); - const bounds = Box.Common(newCreatedShapes.map((s) => this.getShapePageBounds(s))); - if (point === void 0) { - if (!isPageId(pasteParentId)) { - const shape = this.getShape(pasteParentId); - point = Mat.applyToPoint(this.getShapePageTransform(shape), this.getShapeGeometry(shape).bounds.center); - } else { - const viewportPageBounds = this.getViewportPageBounds(); - if (preservePosition || viewportPageBounds.includes(Box.From(bounds))) { - point = bounds.center; - } else { - point = viewportPageBounds.center; - } - } - } - if (rootShapes.length === 1) { - const onlyRoot = rootShapes[0]; - if (this.isShapeOfType(onlyRoot, "frame")) { - while (this.getShapesAtPoint(point).some((shape) => this.isShapeOfType(shape, "frame") && shape.props.w === onlyRoot.props.w && shape.props.h === onlyRoot.props.h)) { - point.x += bounds.w + 16; - } - } - } - const pageCenter = Box.Common(compact(rootShapes.map(({ id }) => this.getShapePageBounds(id)))).center; - const offset4 = Vec.Sub(point, pageCenter); - this.updateShapes(rootShapes.map(({ id }) => { - const s = this.getShape(id); - const localRotation = this.getShapeParentTransform(id).decompose().rotation; - const localDelta = Vec.Rot(offset4, -localRotation); - return { id: s.id, type: s.type, x: s.x + localDelta.x, y: s.y + localDelta.y }; - })); - }); - return this; - } - async getSvgElement(shapes, opts = {}) { - const result = await getSvgJsx(this, shapes, opts); - if (!result) - return void 0; - const fragment = document.createDocumentFragment(); - const root = (0, import_client.createRoot)(fragment); - (0, import_react_dom.flushSync)(() => { - root.render(result.jsx); - }); - const svg = fragment.firstElementChild; - assert(svg instanceof SVGSVGElement, "Expected an SVG element"); - root.unmount(); - return { svg, width: result.width, height: result.height }; - } - async getSvgString(shapes, opts = {}) { - const result = await this.getSvgElement(shapes, opts); - if (!result) - return void 0; - const serializer = new XMLSerializer(); - return { - svg: serializer.serializeToString(result.svg), - width: result.width, - height: result.height - }; - } - async getSvg(shapes, opts = {}) { - const result = await this.getSvgElement(shapes, opts); - if (!result) - return void 0; - return result.svg; - } - _updateInputsFromEvent(info2) { - const { - pointerVelocity, - previousScreenPoint, - previousPagePoint, - currentScreenPoint, - currentPagePoint - } = this.inputs; - const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID); - const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera()); - const sx = info2.point.x - screenBounds.x; - const sy = info2.point.y - screenBounds.y; - const sz = info2.point.z ?? 0.5; - previousScreenPoint.setTo(currentScreenPoint); - previousPagePoint.setTo(currentPagePoint); - currentScreenPoint.set(sx, sy); - const nx = sx / cz - cx; - const ny = sy / cz - cy; - if (isFinite(nx) && isFinite(ny)) { - currentPagePoint.set(nx, ny, sz); - } - this.inputs.isPen = info2.type === "pointer" && info2.isPen; - if (info2.name === "pointer_down" || this.inputs.isPinching) { - pointerVelocity.set(0, 0); - this.inputs.originScreenPoint.setTo(currentScreenPoint); - this.inputs.originPagePoint.setTo(currentPagePoint); - } - this.run(() => { - this.store.put([ - { - id: TLPOINTER_ID, - typeName: "pointer", - x: currentPagePoint.x, - y: currentPagePoint.y, - lastActivityTimestamp: info2.type === "pointer" && info2.pointerId === INTERNAL_POINTER_IDS.CAMERA_MOVE ? this.store.unsafeGetWithoutCapture(TLPOINTER_ID)?.lastActivityTimestamp ?? this._tickManager.now : this._tickManager.now, - meta: {} - } - ]); - }, { history: "ignore" }); - } - cancel() { - this.dispatch({ type: "misc", name: "cancel" }); - return this; - } - interrupt() { - this.dispatch({ type: "misc", name: "interrupt" }); - return this; - } - complete() { - this.dispatch({ type: "misc", name: "complete" }); - return this; - } - focus({ focusContainer = true } = {}) { - if (focusContainer) { - this.focusManager.focus(); - } - this.updateInstanceState({ isFocused: true }); - return this; - } - blur({ blurContainer = true } = {}) { - if (!this.getIsFocused()) - return this; - if (blurContainer) { - this.focusManager.blur(); - } else { - this.complete(); - } - this.updateInstanceState({ isFocused: false }); - return this; - } - getIsFocused() { - return this.getInstanceState().isFocused; - } - getSnapshot() { - return getSnapshot(this.store); - } - loadSnapshot(snapshot) { - loadSnapshot(this.store, snapshot); - return this; - } - cancelDoubleClick() { - this._clickManager.cancelDoubleClickTimeout(); - } - _flushEventsForTick(elapsed) { - this.run(() => { - if (this._pendingEventsForNextTick.length > 0) { - const events = [...this._pendingEventsForNextTick]; - this._pendingEventsForNextTick.length = 0; - for (const info2 of events) { - this._flushEventForTick(info2); - } - } - if (elapsed > 0) { - this.root.handleEvent({ type: "misc", name: "tick", elapsed }); - } - this.scribbles.tick(elapsed); - }); - } - maybeTrackPerformance(name) { - if (debugFlags.measurePerformance.get()) { - if (this.performanceTracker.isStarted()) { - clearTimeout(this.performanceTrackerTimeout); - } else { - this.performanceTracker.start(name); - } - this.performanceTrackerTimeout = this.timers.setTimeout(() => { - this.performanceTracker.stop(); - }, 50); - } - } -}; -__decorateClass5([ - computed -], Editor.prototype, "getCanUndo", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCanRedo", 1); -__decorateClass5([ - computed -], Editor.prototype, "getPath", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentTool", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentToolId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getDocumentSettings", 1); -__decorateClass5([ - computed -], Editor.prototype, "getInstanceState", 1); -__decorateClass5([ - computed -], Editor.prototype, "getOpenMenus", 1); -__decorateClass5([ - computed -], Editor.prototype, "getIsMenuOpen", 1); -__decorateClass5([ - computed -], Editor.prototype, "getPageStates", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getPageStatesQuery", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageState", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getCurrentPageStateId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSelectedShapeIds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSelectedShapes", 1); -__decorateClass5([ - computed -], Editor.prototype, "getOnlySelectedShapeId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getOnlySelectedShape", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSelectionPageBounds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSelectionRotation", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSelectionRotatedPageBounds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSelectionRotatedScreenBounds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getFocusedGroupId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getFocusedGroup", 1); -__decorateClass5([ - computed -], Editor.prototype, "getEditingShapeId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getEditingShape", 1); -__decorateClass5([ - computed -], Editor.prototype, "getHoveredShapeId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getHoveredShape", 1); -__decorateClass5([ - computed -], Editor.prototype, "getHintingShapeIds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getHintingShape", 1); -__decorateClass5([ - computed -], Editor.prototype, "getErasingShapeIds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getErasingShapes", 1); -__decorateClass5([ - computed -], Editor.prototype, "_unsafe_getCameraId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCamera", 1); -__decorateClass5([ - computed -], Editor.prototype, "getViewportPageBoundsForFollowing", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCameraForFollowing", 1); -__decorateClass5([ - computed -], Editor.prototype, "getZoomLevel", 1); -__decorateClass5([ - computed -], Editor.prototype, "getViewportScreenBounds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getViewportScreenCenter", 1); -__decorateClass5([ - computed -], Editor.prototype, "getViewportPageBounds", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getCollaboratorsQuery", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCollaborators", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCollaboratorsOnCurrentPage", 1); -__decorateClass5([ - computed -], Editor.prototype, "getRenderingShapes", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getAllPagesQuery", 1); -__decorateClass5([ - computed -], Editor.prototype, "getPages", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageId", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageShapeIdsSorted", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getAllAssetsQuery", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapeGeometryCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapeHandlesCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapePageTransformCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapePageBoundsCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapeClipPathCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapeMaskCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getShapeMaskedPageBoundsCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_notVisibleShapes", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCulledShapes", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageBounds", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageShapes", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageShapesSorted", 1); -__decorateClass5([ - computed -], Editor.prototype, "getCurrentPageRenderingShapesSorted", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getBindingsIndexCache", 1); -__decorateClass5([ - computed -], Editor.prototype, "_getSelectionSharedStyles", 1); -__decorateClass5([ - computed({ isEqual: (a, b) => a.equals(b) }) -], Editor.prototype, "getSharedStyles", 1); -__decorateClass5([ - computed -], Editor.prototype, "getSharedOpacity", 1); -__decorateClass5([ - computed -], Editor.prototype, "getIsFocused", 1); -function alertMaxShapes(editor, pageId = editor.getCurrentPageId()) { - const name = editor.getPage(pageId).name; - editor.emit("max-shapes", { name, pageId, count: editor.options.maxShapesPerPage }); -} -function applyPartialToRecordWithProps(prev, partial) { - if (!partial) - return prev; - let next = null; - const entries = Object.entries(partial); - for (let i = 0, n = entries.length; i < n; i++) { - const [k, v] = entries[i]; - if (v === void 0) - continue; - if (k === "id" || k === "type" || k === "typeName") - continue; - if (v === prev[k]) - continue; - if (!next) - next = { ...prev }; - if (k === "props" || k === "meta") { - next[k] = { ...prev[k] }; - for (const [nextKey, nextValue] of Object.entries(v)) { - if (nextValue !== void 0) { - ; - next[k][nextKey] = nextValue; - } - } - continue; - } - ; - next[k] = v; - } - if (!next) - return prev; - return next; -} -function pushShapeWithDescendants(editor, id, result) { - const shape = editor.getShape(id); - if (!shape) - return; - result.push(shape); - const childIds = editor.getSortedChildIdsForParent(id); - for (let i = 0, n = childIds.length; i < n; i++) { - pushShapeWithDescendants(editor, childIds[i], result); - } -} -function withIsolatedShapes(editor, shapeIds, callback) { - let result; - editor.run(() => { - const changes = editor.store.extractingChanges(() => { - const bindingsWithBoth = /* @__PURE__ */ new Set(); - const bindingsToRemove = /* @__PURE__ */ new Set(); - for (const shapeId of shapeIds) { - const shape = editor.getShape(shapeId); - if (!shape) - continue; - for (const binding of editor.getBindingsInvolvingShape(shapeId)) { - const hasFrom = shapeIds.has(binding.fromId); - const hasTo = shapeIds.has(binding.toId); - if (hasFrom && hasTo) { - bindingsWithBoth.add(binding.id); - continue; - } - if (!hasFrom || !hasTo) { - bindingsToRemove.add(binding.id); - } - } - } - editor.deleteBindings([...bindingsToRemove], { isolateShapes: true }); - try { - result = Result.ok(callback(bindingsWithBoth)); - } catch (error3) { - result = Result.err(error3); - } - }); - editor.store.applyDiff(reverseRecordsDiff(changes)); - }, { history: "ignore" }); - if (result.ok) { - return result.value; - } else { - throw result.error; - } -} -function getCameraFitXFitY(editor, cameraOptions) { - if (!cameraOptions.constraints) - throw Error("Should have constraints here"); - const { - padding: { x: px, y: py } - } = cameraOptions.constraints; - const vsb = editor.getViewportScreenBounds(); - const bounds = Box.From(cameraOptions.constraints.bounds); - const zx = (vsb.w - px * 2) / bounds.w; - const zy = (vsb.h - py * 2) / bounds.h; - return { zx, zy }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useIsDarkMode.mjs -function useIsDarkMode() { - const editor = useEditor(); - const exportContext = useSvgExportContext(); - return useValue("isDarkMode", () => exportContext?.isDarkMode ?? editor.user.getIsDarkMode(), [ - exportContext, - editor - ]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useCursor.mjs -var CORNER_SVG = `<path d='m19.7432 17.0869-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z' fill='%23fff'/><path d='m18.6826 16.7334-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z' fill='%23000'/>`; -var EDGE_SVG = `<path d='m9 17.9907v.005l5.997 5.996.001-3.999h1.999 2.02v4l5.98-6.001-5.98-5.999.001 4.019-2.021.002h-2l.001-4.022zm1.411.003 3.587-3.588-.001 2.587h3.5 2.521v-2.585l3.565 3.586-3.564 3.585-.001-2.585h-2.521l-3.499-.001-.001 2.586z' fill='%23fff'/><path d='m17.4971 18.9932h2.521v2.586l3.565-3.586-3.565-3.585v2.605h-2.521-3.5v-2.607l-3.586 3.587 3.586 3.586v-2.587z' fill='%23000'/>`; -var ROTATE_CORNER_SVG = `<path d="M22.4789 9.45728L25.9935 12.9942L22.4789 16.5283V14.1032C18.126 14.1502 14.6071 17.6737 14.5675 22.0283H17.05L13.513 25.543L9.97889 22.0283H12.5674C12.6071 16.5691 17.0214 12.1503 22.4789 12.1031L22.4789 9.45728Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21.4789 7.03223L27.4035 12.9945L21.4789 18.9521V15.1868C18.4798 15.6549 16.1113 18.0273 15.649 21.0284H19.475L13.5128 26.953L7.55519 21.0284H11.6189C12.1243 15.8155 16.2679 11.6677 21.4789 11.1559L21.4789 7.03223ZM22.4789 12.1031C17.0214 12.1503 12.6071 16.5691 12.5674 22.0284H9.97889L13.513 25.543L17.05 22.0284H14.5675C14.5705 21.6896 14.5947 21.3558 14.6386 21.0284C15.1157 17.4741 17.9266 14.6592 21.4789 14.1761C21.8063 14.1316 22.1401 14.1069 22.4789 14.1032V16.5284L25.9935 12.9942L22.4789 9.45729L22.4789 12.1031Z" fill="white"/>`; -function getCursorCss(svg, r, tr, f, color, hotspotX = 16, hotspotY = 16) { - const a = (-tr - r) * (PI / 180); - const s = Math.sin(a); - const c = Math.cos(a); - const dx = 1 * c - 1 * s; - const dy = 1 * s + 1 * c; - return `url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: ${color};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${dx}' dy='${dy}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${r + tr} 16 16)${f ? ` scale(-1,-1) translate(0, -32)` : ""}' filter='url(%23shadow)'>` + svg.replaceAll(`"`, `'`) + `</g></svg>") ${hotspotX} ${hotspotY}, pointer`; -} -var STATIC_CURSORS = [ - "default", - "pointer", - "cross", - "move", - "grab", - "grabbing", - "text", - "zoom-in", - "zoom-out" -]; -var CURSORS = { - none: () => "none", - "ew-resize": (r, f, c) => getCursorCss(EDGE_SVG, r, 0, f, c), - "ns-resize": (r, f, c) => getCursorCss(EDGE_SVG, r, 90, f, c), - "nesw-resize": (r, f, c) => getCursorCss(CORNER_SVG, r, 0, f, c), - "nwse-resize": (r, f, c) => getCursorCss(CORNER_SVG, r, 90, f, c), - "nwse-rotate": (r, f, c) => getCursorCss(ROTATE_CORNER_SVG, r, 0, f, c), - "nesw-rotate": (r, f, c) => getCursorCss(ROTATE_CORNER_SVG, r, 90, f, c), - "senw-rotate": (r, f, c) => getCursorCss(ROTATE_CORNER_SVG, r, 180, f, c), - "swne-rotate": (r, f, c) => getCursorCss(ROTATE_CORNER_SVG, r, 270, f, c) -}; -function getCursor(cursor, rotation = 0, color = "black") { - return CURSORS[cursor](radiansToDegrees(rotation), false, color); -} -function useCursor() { - const editor = useEditor(); - const container = useContainer(); - const isDarkMode = useIsDarkMode(); - useQuickReactor("useCursor", () => { - const { type, rotation } = editor.getInstanceState().cursor; - if (STATIC_CURSORS.includes(type)) { - container.style.setProperty("--tl-cursor", `var(--tl-cursor-${type})`); - return; - } - container.style.setProperty("--tl-cursor", getCursor(type, rotation, isDarkMode ? "white" : "black")); - }, [editor, container, isDarkMode]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useDarkMode.mjs -var import_react35 = __toESM(require_react(), 1); -function useDarkMode() { - const editor = useEditor(); - const container = useContainer(); - const isDarkMode = useIsDarkMode(); - const forceSrgb = useValue(debugFlags.forceSrgb); - import_react35.default.useEffect(() => { - if (isDarkMode) { - container.setAttribute("data-color-mode", "dark"); - container.classList.remove("tl-theme__light"); - container.classList.add("tl-theme__dark"); - } else { - container.setAttribute("data-color-mode", "light"); - container.classList.remove("tl-theme__dark"); - container.classList.add("tl-theme__light"); - } - if (forceSrgb) { - container.classList.add("tl-theme__force-sRGB"); - } else { - container.classList.remove("tl-theme__force-sRGB"); - } - }, [editor, container, forceSrgb, isDarkMode]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useEvent.mjs -var import_react36 = __toESM(require_react(), 1); -function useEvent(handler) { - const handlerRef = (0, import_react36.useRef)(); - (0, import_react36.useLayoutEffect)(() => { - handlerRef.current = handler; - }); - (0, import_react36.useDebugValue)(handler); - return (0, import_react36.useCallback)((...args) => { - const fn = handlerRef.current; - assert(fn, "fn does not exist"); - return fn(...args); - }, []); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useForceUpdate.mjs -var import_react37 = __toESM(require_react(), 1); -function useForceUpdate() { - const [_, ss] = (0, import_react37.useState)(0); - (0, import_react37.useEffect)(() => ss((s) => s + 1), []); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useLocalStore.mjs -var import_react39 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/config/createTLStore.mjs -var defaultAssetResolve = (asset) => asset.props.src; -var inlineBase64AssetStore = { - upload: (_, file) => FileHelpers.blobToDataUrl(file) -}; -function createTLSchemaFromUtils(opts) { - if ("schema" in opts && opts.schema) - return opts.schema; - return createTLSchema({ - shapes: "shapeUtils" in opts && opts.shapeUtils ? utilsToMap(checkShapesAndAddCore(opts.shapeUtils)) : void 0, - bindings: "bindingUtils" in opts && opts.bindingUtils ? utilsToMap(checkBindings(opts.bindingUtils)) : void 0, - migrations: "migrations" in opts ? opts.migrations : void 0 - }); -} -function createTLStore({ - initialData, - defaultName = "", - id, - assets = inlineBase64AssetStore, - onEditorMount, - multiplayerStatus, - ...rest -} = {}) { - const schema = createTLSchemaFromUtils(rest); - const store = new Store({ - id, - schema, - initialData, - props: { - defaultName, - assets: { - upload: assets.upload, - resolve: assets.resolve ?? defaultAssetResolve - }, - onEditorMount: (editor) => { - assert(editor instanceof Editor); - onEditorMount?.(editor); - }, - multiplayerStatus: multiplayerStatus ?? null - } - }); - if (rest.snapshot) { - if (initialData) - throw new Error("Cannot provide both initialData and snapshot"); - loadSnapshot(store, rest.snapshot); - } - return store; -} -function utilsToMap(utils) { - return Object.fromEntries(utils.map((s) => [ - s.type, - { - props: s.props, - migrations: s.migrations - } - ])); -} - -// node_modules/idb/build/wrap-idb-value.js -var instanceOfAny = (object2, constructors) => constructors.some((c) => object2 instanceof c); -var idbProxyableTypes; -var cursorAdvanceMethods; -function getIdbProxyableTypes() { - return idbProxyableTypes || (idbProxyableTypes = [ - IDBDatabase, - IDBObjectStore, - IDBIndex, - IDBCursor, - IDBTransaction - ]); -} -function getCursorAdvanceMethods() { - return cursorAdvanceMethods || (cursorAdvanceMethods = [ - IDBCursor.prototype.advance, - IDBCursor.prototype.continue, - IDBCursor.prototype.continuePrimaryKey - ]); -} -var cursorRequestMap = /* @__PURE__ */ new WeakMap(); -var transactionDoneMap = /* @__PURE__ */ new WeakMap(); -var transactionStoreNamesMap = /* @__PURE__ */ new WeakMap(); -var transformCache = /* @__PURE__ */ new WeakMap(); -var reverseTransformCache = /* @__PURE__ */ new WeakMap(); -function promisifyRequest(request2) { - const promise = new Promise((resolve, reject) => { - const unlisten = () => { - request2.removeEventListener("success", success); - request2.removeEventListener("error", error3); - }; - const success = () => { - resolve(wrap(request2.result)); - unlisten(); - }; - const error3 = () => { - reject(request2.error); - unlisten(); - }; - request2.addEventListener("success", success); - request2.addEventListener("error", error3); - }); - promise.then((value) => { - if (value instanceof IDBCursor) { - cursorRequestMap.set(value, request2); - } - }).catch(() => { - }); - reverseTransformCache.set(promise, request2); - return promise; -} -function cacheDonePromiseForTransaction(tx) { - if (transactionDoneMap.has(tx)) - return; - const done = new Promise((resolve, reject) => { - const unlisten = () => { - tx.removeEventListener("complete", complete); - tx.removeEventListener("error", error3); - tx.removeEventListener("abort", error3); - }; - const complete = () => { - resolve(); - unlisten(); - }; - const error3 = () => { - reject(tx.error || new DOMException("AbortError", "AbortError")); - unlisten(); - }; - tx.addEventListener("complete", complete); - tx.addEventListener("error", error3); - tx.addEventListener("abort", error3); - }); - transactionDoneMap.set(tx, done); -} -var idbProxyTraps = { - get(target, prop, receiver) { - if (target instanceof IDBTransaction) { - if (prop === "done") - return transactionDoneMap.get(target); - if (prop === "objectStoreNames") { - return target.objectStoreNames || transactionStoreNamesMap.get(target); - } - if (prop === "store") { - return receiver.objectStoreNames[1] ? void 0 : receiver.objectStore(receiver.objectStoreNames[0]); - } - } - return wrap(target[prop]); - }, - set(target, prop, value) { - target[prop] = value; - return true; - }, - has(target, prop) { - if (target instanceof IDBTransaction && (prop === "done" || prop === "store")) { - return true; - } - return prop in target; - } -}; -function replaceTraps(callback) { - idbProxyTraps = callback(idbProxyTraps); -} -function wrapFunction(func) { - if (func === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype)) { - return function(storeNames, ...args) { - const tx = func.call(unwrap(this), storeNames, ...args); - transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]); - return wrap(tx); - }; - } - if (getCursorAdvanceMethods().includes(func)) { - return function(...args) { - func.apply(unwrap(this), args); - return wrap(cursorRequestMap.get(this)); - }; - } - return function(...args) { - return wrap(func.apply(unwrap(this), args)); - }; -} -function transformCachableValue(value) { - if (typeof value === "function") - return wrapFunction(value); - if (value instanceof IDBTransaction) - cacheDonePromiseForTransaction(value); - if (instanceOfAny(value, getIdbProxyableTypes())) - return new Proxy(value, idbProxyTraps); - return value; -} -function wrap(value) { - if (value instanceof IDBRequest) - return promisifyRequest(value); - if (transformCache.has(value)) - return transformCache.get(value); - const newValue = transformCachableValue(value); - if (newValue !== value) { - transformCache.set(value, newValue); - reverseTransformCache.set(newValue, value); - } - return newValue; -} -var unwrap = (value) => reverseTransformCache.get(value); - -// node_modules/idb/build/index.js -function openDB(name, version2, { blocked, upgrade, blocking, terminated } = {}) { - const request2 = indexedDB.open(name, version2); - const openPromise = wrap(request2); - if (upgrade) { - request2.addEventListener("upgradeneeded", (event) => { - upgrade(wrap(request2.result), event.oldVersion, event.newVersion, wrap(request2.transaction), event); - }); - } - if (blocked) { - request2.addEventListener("blocked", (event) => blocked(event.oldVersion, event.newVersion, event)); - } - openPromise.then((db) => { - if (terminated) - db.addEventListener("close", () => terminated()); - if (blocking) { - db.addEventListener("versionchange", (event) => blocking(event.oldVersion, event.newVersion, event)); - } - }).catch(() => { - }); - return openPromise; -} -function deleteDB(name, { blocked } = {}) { - const request2 = indexedDB.deleteDatabase(name); - if (blocked) { - request2.addEventListener("blocked", (event) => blocked(event.oldVersion, event)); - } - return wrap(request2).then(() => void 0); -} -var readMethods = ["get", "getKey", "getAll", "getAllKeys", "count"]; -var writeMethods = ["put", "add", "delete", "clear"]; -var cachedMethods = /* @__PURE__ */ new Map(); -function getMethod(target, prop) { - if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === "string")) { - return; - } - if (cachedMethods.get(prop)) - return cachedMethods.get(prop); - const targetFuncName = prop.replace(/FromIndex$/, ""); - const useIndex = prop !== targetFuncName; - const isWrite = writeMethods.includes(targetFuncName); - if (!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName))) { - return; - } - const method = async function(storeName, ...args) { - const tx = this.transaction(storeName, isWrite ? "readwrite" : "readonly"); - let target2 = tx.store; - if (useIndex) - target2 = target2.index(args.shift()); - return (await Promise.all([ - target2[targetFuncName](...args), - isWrite && tx.done - ]))[0]; - }; - cachedMethods.set(prop, method); - return method; -} -replaceTraps((oldTraps) => ({ - ...oldTraps, - get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver), - has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop) -})); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/sync/LocalIndexedDb.mjs -var STORE_PREFIX = "TLDRAW_DOCUMENT_v2"; -var LEGACY_ASSET_STORE_PREFIX = "TLDRAW_ASSET_STORE_v1"; -var dbNameIndexKey = "TLDRAW_DB_NAME_INDEX_v2"; -var Table = { - Records: "records", - Schema: "schema", - SessionState: "session_state", - Assets: "assets" -}; -async function openLocalDb(persistenceKey) { - const storeId = STORE_PREFIX + persistenceKey; - addDbName(storeId); - return await openDB(storeId, 4, { - upgrade(database) { - if (!database.objectStoreNames.contains(Table.Records)) { - database.createObjectStore(Table.Records); - } - if (!database.objectStoreNames.contains(Table.Schema)) { - database.createObjectStore(Table.Schema); - } - if (!database.objectStoreNames.contains(Table.SessionState)) { - database.createObjectStore(Table.SessionState); - } - if (!database.objectStoreNames.contains(Table.Assets)) { - database.createObjectStore(Table.Assets); - } - } - }); -} -async function migrateLegacyAssetDbIfNeeded(persistenceKey) { - const databases = window.indexedDB.databases ? (await window.indexedDB.databases()).map((db) => db.name) : getAllIndexDbNames(); - const oldStoreId = LEGACY_ASSET_STORE_PREFIX + persistenceKey; - const existing = databases.find((dbName) => dbName === oldStoreId); - if (!existing) - return; - const oldAssetDb = await openDB(oldStoreId, 1, { - upgrade(database) { - if (!database.objectStoreNames.contains("assets")) { - database.createObjectStore("assets"); - } - } - }); - const oldTx = oldAssetDb.transaction(["assets"], "readonly"); - const oldAssetStore = oldTx.objectStore("assets"); - const oldAssetsKeys = await oldAssetStore.getAllKeys(); - const oldAssets = await Promise.all(oldAssetsKeys.map(async (key) => [key, await oldAssetStore.get(key)])); - await oldTx.done; - const newDb = await openLocalDb(persistenceKey); - const newTx = newDb.transaction([Table.Assets], "readwrite"); - const newAssetTable = newTx.objectStore(Table.Assets); - for (const [key, value] of oldAssets) { - newAssetTable.put(value, key); - } - await newTx.done; - oldAssetDb.close(); - newDb.close(); - await deleteDB(oldStoreId); -} -var _LocalIndexedDb = class { - constructor(persistenceKey) { - __publicField(this, "getDbPromise"); - __publicField(this, "isClosed", false); - __publicField(this, "pendingTransactionSet", /* @__PURE__ */ new Set()); - _LocalIndexedDb.connectedInstances.add(this); - this.getDbPromise = (async () => { - await migrateLegacyAssetDbIfNeeded(persistenceKey); - return await openLocalDb(persistenceKey); - })(); - } - getDb() { - return this.getDbPromise; - } - pending() { - return Promise.allSettled([this.getDbPromise, ...this.pendingTransactionSet]).then(noop); - } - async close() { - if (this.isClosed) - return; - this.isClosed = true; - await this.pending(); - (await this.getDb()).close(); - _LocalIndexedDb.connectedInstances.delete(this); - } - tx(mode, names, cb) { - const txPromise = (async () => { - assert(!this.isClosed, "db is closed"); - const db = await this.getDb(); - const tx = db.transaction(names, mode); - try { - return await cb(tx); - } finally { - if (!this.isClosed) { - await tx.done; - } else { - tx.abort(); - } - } - })(); - this.pendingTransactionSet.add(txPromise); - txPromise.finally(() => this.pendingTransactionSet.delete(txPromise)); - return txPromise; - } - async load({ sessionId } = {}) { - return await this.tx("readonly", [Table.Records, Table.Schema, Table.SessionState], async (tx) => { - const recordsStore = tx.objectStore(Table.Records); - const schemaStore = tx.objectStore(Table.Schema); - const sessionStateStore = tx.objectStore(Table.SessionState); - let sessionStateSnapshot = sessionId ? (await sessionStateStore.get(sessionId))?.snapshot : null; - if (!sessionStateSnapshot) { - const all = await sessionStateStore.getAll(); - sessionStateSnapshot = all.sort((a, b) => a.updatedAt - b.updatedAt).pop()?.snapshot; - } - const result = { - records: await recordsStore.getAll(), - schema: await schemaStore.get(Table.Schema), - sessionStateSnapshot - }; - return result; - }); - } - async storeChanges({ - schema, - changes, - sessionId, - sessionStateSnapshot - }) { - await this.tx("readwrite", [Table.Records, Table.Schema, Table.SessionState], async (tx) => { - const recordsStore = tx.objectStore(Table.Records); - const schemaStore = tx.objectStore(Table.Schema); - const sessionStateStore = tx.objectStore(Table.SessionState); - for (const [id, record] of Object.entries(changes.added)) { - await recordsStore.put(record, id); - } - for (const [_prev, updated] of Object.values(changes.updated)) { - await recordsStore.put(updated, updated.id); - } - for (const id of Object.keys(changes.removed)) { - await recordsStore.delete(id); - } - schemaStore.put(schema.serialize(), Table.Schema); - if (sessionStateSnapshot && sessionId) { - sessionStateStore.put({ - snapshot: sessionStateSnapshot, - updatedAt: Date.now(), - id: sessionId - }, sessionId); - } else if (sessionStateSnapshot || sessionId) { - console.error("sessionStateSnapshot and instanceId must be provided together"); - } - }); - } - async storeSnapshot({ - schema, - snapshot, - sessionId, - sessionStateSnapshot - }) { - await this.tx("readwrite", [Table.Records, Table.Schema, Table.SessionState], async (tx) => { - const recordsStore = tx.objectStore(Table.Records); - const schemaStore = tx.objectStore(Table.Schema); - const sessionStateStore = tx.objectStore(Table.SessionState); - await recordsStore.clear(); - for (const [id, record] of Object.entries(snapshot)) { - await recordsStore.put(record, id); - } - schemaStore.put(schema.serialize(), Table.Schema); - if (sessionStateSnapshot && sessionId) { - sessionStateStore.put({ - snapshot: sessionStateSnapshot, - updatedAt: Date.now(), - id: sessionId - }, sessionId); - } else if (sessionStateSnapshot || sessionId) { - console.error("sessionStateSnapshot and instanceId must be provided together"); - } - }); - } - async pruneSessions() { - await this.tx("readwrite", [Table.SessionState], async (tx) => { - const sessionStateStore = tx.objectStore(Table.SessionState); - const all = (await sessionStateStore.getAll()).sort((a, b) => a.updatedAt - b.updatedAt); - if (all.length < 10) { - await tx.done; - return; - } - const toDelete = all.slice(0, all.length - 10); - for (const { id } of toDelete) { - await sessionStateStore.delete(id); - } - }); - } - async getAsset(assetId) { - return await this.tx("readonly", [Table.Assets], async (tx) => { - const assetsStore = tx.objectStore(Table.Assets); - return await assetsStore.get(assetId); - }); - } - async storeAsset(assetId, blob) { - await this.tx("readwrite", [Table.Assets], async (tx) => { - const assetsStore = tx.objectStore(Table.Assets); - await assetsStore.put(blob, assetId); - }); - } -}; -var LocalIndexedDb = _LocalIndexedDb; -__publicField(LocalIndexedDb, "connectedInstances", /* @__PURE__ */ new Set()); -function getAllIndexDbNames() { - const result = JSON.parse(getFromLocalStorage(dbNameIndexKey) || "[]") ?? []; - if (!Array.isArray(result)) { - return []; - } - return result; -} -function addDbName(name) { - const all = new Set(getAllIndexDbNames()); - all.add(name); - setInLocalStorage(dbNameIndexKey, JSON.stringify([...all])); -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/sync/alerts.mjs -function showCantWriteToIndexDbAlert() { - window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again. - -Keep seeing this message? -\u2022 If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser. -\u2022 If your hard disk is full, try clearing up some space and then reload the page.`); -} -function showCantReadFromIndexDbAlert() { - window.alert(`Oops! We could not access your browser's storage\u2014and the app won't work correctly without that. We now need to reload the page and try again. - -Keep seeing this message? -\u2022 If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`); -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs -var PERSIST_THROTTLE_MS = 350; -var PERSIST_RETRY_THROTTLE_MS = 1e4; -var UPDATE_INSTANCE_STATE = Symbol("UPDATE_INSTANCE_STATE"); -var msg = (msg2) => msg2; -var BroadcastChannelMock = class { - constructor(_name) { - __publicField(this, "onmessage"); - } - postMessage(_msg) { - } - close() { - } -}; -var BC = typeof BroadcastChannel === "undefined" ? BroadcastChannelMock : BroadcastChannel; -var TLLocalSyncClient = class { - constructor(store, { - persistenceKey, - sessionId = TAB_ID, - onLoad, - onLoadError - }, channel2 = new BC(`tldraw-tab-sync-${persistenceKey}`)) { - __publicField(this, "disposables", /* @__PURE__ */ new Set()); - __publicField(this, "diffQueue", []); - __publicField(this, "didDispose", false); - __publicField(this, "shouldDoFullDBWrite", true); - __publicField(this, "isReloading", false); - __publicField(this, "persistenceKey"); - __publicField(this, "sessionId"); - __publicField(this, "serializedSchema"); - __publicField(this, "isDebugging", false); - __publicField(this, "documentTypes"); - __publicField(this, "$sessionStateSnapshot"); - __publicField(this, "db"); - __publicField(this, "initTime", Date.now()); - __publicField(this, "isPersisting", false); - __publicField(this, "didLastWriteError", false); - __publicField(this, "scheduledPersistTimeout", null); - this.store = store; - this.channel = channel2; - if (typeof window !== "undefined") { - ; - window.tlsync = this; - } - this.persistenceKey = persistenceKey; - this.sessionId = sessionId; - this.db = new LocalIndexedDb(persistenceKey); - this.disposables.add(() => this.db.close()); - this.serializedSchema = this.store.schema.serialize(); - this.$sessionStateSnapshot = createSessionStateSnapshotSignal(this.store); - this.disposables.add(store.listen(({ changes }) => { - this.diffQueue.push(changes); - this.channel.postMessage(msg({ - type: "diff", - storeId: this.store.id, - changes, - schema: this.serializedSchema - })); - this.schedulePersist(); - }, { source: "user", scope: "document" })); - this.disposables.add(store.listen(() => { - this.diffQueue.push(UPDATE_INSTANCE_STATE); - this.schedulePersist(); - }, { scope: "session" })); - this.connect(onLoad, onLoadError); - this.documentTypes = new Set(Object.values(this.store.schema.types).filter((t2) => t2.scope === "document").map((t2) => t2.typeName)); - } - debug(...args) { - if (this.isDebugging) { - console.debug(...args); - } - } - async connect(onLoad, onLoadError) { - this.debug("connecting"); - let data; - try { - data = await this.db.load({ sessionId: this.sessionId }); - } catch (error3) { - onLoadError(error3); - showCantReadFromIndexDbAlert(); - return; - } - this.debug("loaded data from store", data, "didDispose", this.didDispose); - if (this.didDispose) - return; - try { - if (data) { - const documentSnapshot = Object.fromEntries(data.records.map((r) => [r.id, r])); - const sessionStateSnapshot = data.sessionStateSnapshot ?? extractSessionStateFromLegacySnapshot(documentSnapshot); - const migrationResult = this.store.schema.migrateStoreSnapshot({ - store: documentSnapshot, - schema: data.schema ?? this.store.schema.serializeEarliestVersion() - }); - if (migrationResult.type === "error") { - console.error("failed to migrate store", migrationResult); - onLoadError(new Error(`Failed to migrate store: ${migrationResult.reason}`)); - return; - } - this.store.mergeRemoteChanges(() => { - this.store.put(Object.values(migrationResult.value).filter((r) => this.documentTypes.has(r.typeName)), "initialize"); - }); - if (sessionStateSnapshot) { - loadSessionStateSnapshotIntoStore(this.store, sessionStateSnapshot); - } - } - this.channel.onmessage = ({ data: data2 }) => { - this.debug("got message", data2); - const msg2 = data2; - const res = this.store.schema.getMigrationsSince(msg2.schema); - if (!res.ok) { - const timeSinceInit = Date.now() - this.initTime; - if (timeSinceInit < 5e3) { - onLoadError(new Error("Schema mismatch, please close other tabs and reload the page")); - return; - } - this.debug("reloading"); - this.isReloading = true; - window?.location?.reload?.(); - return; - } else if (res.value.length > 0) { - this.debug("telling them to reload"); - this.channel.postMessage({ type: "announce", schema: this.serializedSchema }); - this.shouldDoFullDBWrite = true; - this.persistIfNeeded(); - return; - } - if (msg2.type === "diff") { - this.debug("applying diff"); - transact(() => { - this.store.mergeRemoteChanges(() => { - this.store.applyDiff(msg2.changes); - this.store.ensureStoreIsUsable(); - }); - }); - } - }; - this.channel.postMessage({ type: "announce", schema: this.serializedSchema }); - this.disposables.add(() => { - this.channel.close(); - }); - onLoad(this); - } catch (e) { - this.debug("error loading data from store", e); - if (this.didDispose) - return; - onLoadError(e); - return; - } - } - close() { - this.debug("closing"); - this.didDispose = true; - this.disposables.forEach((d) => d()); - } - schedulePersist() { - this.debug("schedulePersist", this.scheduledPersistTimeout); - if (this.scheduledPersistTimeout) - return; - this.scheduledPersistTimeout = setTimeout(() => { - this.scheduledPersistTimeout = null; - this.persistIfNeeded(); - }, this.didLastWriteError ? PERSIST_RETRY_THROTTLE_MS : PERSIST_THROTTLE_MS); - } - persistIfNeeded() { - this.debug("persistIfNeeded", { - isPersisting: this.isPersisting, - isReloading: this.isReloading, - shouldDoFullDBWrite: this.shouldDoFullDBWrite, - diffQueueLength: this.diffQueue.length, - storeIsPossiblyCorrupt: this.store.isPossiblyCorrupted() - }); - if (this.scheduledPersistTimeout) { - clearTimeout(this.scheduledPersistTimeout); - this.scheduledPersistTimeout = null; - } - if (this.isPersisting) - return; - if (this.isReloading) - return; - if (this.store.isPossiblyCorrupted()) - return; - if (this.shouldDoFullDBWrite || this.diffQueue.length > 0) { - this.doPersist(); - } - } - async doPersist() { - assert(!this.isPersisting, "persist already in progress"); - if (this.didDispose) - return; - this.isPersisting = true; - this.debug("doPersist start"); - const diffQueue = this.diffQueue; - this.diffQueue = []; - try { - if (this.shouldDoFullDBWrite) { - this.shouldDoFullDBWrite = false; - await this.db.storeSnapshot({ - schema: this.store.schema, - snapshot: this.store.serialize(), - sessionId: this.sessionId, - sessionStateSnapshot: this.$sessionStateSnapshot.get() - }); - } else { - const diffs = squashRecordDiffs(diffQueue.filter((d) => d !== UPDATE_INSTANCE_STATE)); - await this.db.storeChanges({ - changes: diffs, - schema: this.store.schema, - sessionId: this.sessionId, - sessionStateSnapshot: this.$sessionStateSnapshot.get() - }); - } - this.didLastWriteError = false; - } catch (e) { - this.shouldDoFullDBWrite = true; - this.didLastWriteError = true; - console.error("failed to store changes in indexed db", e); - showCantWriteToIndexDbAlert(); - if (typeof window !== "undefined") { - window.location.reload(); - } - } - this.isPersisting = false; - this.debug("doPersist end"); - this.schedulePersist(); - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useRefState.mjs -var import_react38 = __toESM(require_react(), 1); -function useRefState(initialValue) { - const ref = (0, import_react38.useRef)(initialValue); - const [state, setState] = (0, import_react38.useState)(initialValue); - if (state !== ref.current) { - setState(ref.current); - } - const update = (0, import_react38.useCallback)((value) => { - if (typeof value === "function") { - ref.current = value(ref.current); - } else { - ref.current = value; - } - setState(ref.current); - }, []); - return [state, update]; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useLocalStore.mjs -function useLocalStore(options) { - const [state, setState] = useRefState({ status: "loading" }); - options = useShallowObjectIdentity(options); - (0, import_react39.useEffect)(() => { - const { persistenceKey, sessionId, ...rest } = options; - if (!persistenceKey) { - setState({ - status: "not-synced", - store: createTLStore(rest) - }); - return; - } - setState({ status: "loading" }); - const objectURLCache = new WeakCache(); - const assets = { - upload: async (asset, file) => { - await client.db.storeAsset(asset.id, file); - return asset.id; - }, - resolve: async (asset) => { - if (!asset.props.src) - return null; - if (asset.props.src.startsWith("asset:")) { - return await objectURLCache.get(asset, async () => { - const blob = await client.db.getAsset(asset.id); - if (!blob) - return null; - return URL.createObjectURL(blob); - }); - } - return asset.props.src; - }, - ...rest.assets - }; - const store = createTLStore({ ...rest, assets }); - let isClosed = false; - const client = new TLLocalSyncClient(store, { - sessionId, - persistenceKey, - onLoad() { - if (isClosed) - return; - setState({ store, status: "synced-local" }); - }, - onLoadError(err) { - if (isClosed) - return; - setState({ status: "error", error: err }); - } - }); - return () => { - isClosed = true; - client.close(); - }; - }, [options, setState]); - return state; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useZoomCss.mjs -var React10 = __toESM(require_react(), 1); -function useZoomCss() { - const editor = useEditor(); - const container = useContainer(); - React10.useEffect(() => { - const setScale = (s) => container.style.setProperty("--tl-zoom", s.toString()); - const setScaleDebounced = debounce(setScale, 100); - const scheduler = new EffectScheduler("useZoomCss", () => { - const numShapes = editor.getCurrentPageShapeIds().size; - if (numShapes < 300) { - setScale(editor.getZoomLevel()); - } else { - setScaleDebounced(editor.getZoomLevel()); - } - }); - scheduler.attach(); - scheduler.execute(); - return () => { - scheduler.detach(); - setScaleDebounced.cancel(); - }; - }, [editor, container]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/license/LicenseProvider.mjs -var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); -var import_react40 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/utils/licensing.mjs -function str2ab(str) { - const buf = new ArrayBuffer(str.length); - const bufView = new Uint8Array(buf); - for (let i = 0, strLen = str.length; i < strLen; i++) { - bufView[i] = str.charCodeAt(i); - } - return buf; -} -function importPublicKey(pemContents) { - const binaryDerString = atob(pemContents); - const binaryDer = str2ab(binaryDerString); - return crypto.subtle.importKey("spki", new Uint8Array(binaryDer), { - name: "ECDSA", - namedCurve: "P-256" - }, true, ["verify"]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/license/LicenseManager.mjs -var GRACE_PERIOD_DAYS = 5; -var FLAGS = { - ANNUAL_LICENSE: 1, - PERPETUAL_LICENSE: 2, - INTERNAL_LICENSE: 4 -}; -var HIGHEST_FLAG = Math.max(...Object.values(FLAGS)); -var PROPERTIES = { - ID: 0, - HOSTS: 1, - FLAGS: 2, - EXPIRY_DATE: 3 -}; -var NUMBER_OF_KNOWN_PROPERTIES = Object.keys(PROPERTIES).length; -var LICENSE_EMAIL = "sales@tldraw.com"; -var LicenseManager = class { - constructor(licenseKey, testPublicKey, testEnvironment) { - __publicField(this, "publicKey", "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ"); - __publicField(this, "isDevelopment"); - __publicField(this, "isTest"); - __publicField(this, "isCryptoAvailable"); - __publicField(this, "state", atom("license state", "pending")); - this.isTest = false; - this.isDevelopment = this.getIsDevelopment(testEnvironment); - this.publicKey = testPublicKey || this.publicKey; - this.isCryptoAvailable = !!crypto.subtle; - if (!featureFlags.enableLicensing.get()) { - this.state.set("licensed"); - } else { - this.getLicenseFromKey(licenseKey).then((result) => { - const isUnlicensed = isEditorUnlicensed(result); - this.state.set(isUnlicensed ? "unlicensed" : "licensed"); - if (isUnlicensed) { - } - }); - } - } - getIsDevelopment(testEnvironment) { - if (testEnvironment === "development") - return true; - if (testEnvironment === "production") - return false; - return window.location.protocol !== "https:"; - } - async extractLicenseKey(licenseKey) { - const [data, signature] = licenseKey.split("."); - const [prefix, encodedData] = data.split("/"); - if (!prefix.startsWith("tldraw-")) { - throw new Error(`Unsupported prefix '${prefix}'`); - } - const publicCryptoKey = await importPublicKey(this.publicKey); - let isVerified; - try { - isVerified = await crypto.subtle.verify({ - name: "ECDSA", - hash: { name: "SHA-256" } - }, publicCryptoKey, new Uint8Array(str2ab(atob(signature))), new Uint8Array(str2ab(atob(encodedData)))); - } catch (e) { - console.error(e); - throw new Error("Could not perform signature validation"); - } - if (!isVerified) { - throw new Error("Invalid signature"); - } - let decodedData; - try { - decodedData = JSON.parse(atob(encodedData)); - } catch (e) { - throw new Error("Could not parse object"); - } - if (decodedData.length > NUMBER_OF_KNOWN_PROPERTIES) { - this.outputMessages([ - "License key contains some unknown properties.", - "You may want to update tldraw packages to a newer version to get access to new functionality." - ]); - } - return { - id: decodedData[PROPERTIES.ID], - hosts: decodedData[PROPERTIES.HOSTS], - flags: decodedData[PROPERTIES.FLAGS], - expiryDate: decodedData[PROPERTIES.EXPIRY_DATE] - }; - } - async getLicenseFromKey(licenseKey) { - if (!licenseKey) { - if (!this.isDevelopment) { - this.outputNoLicenseKeyProvided(); - } - return { isLicenseParseable: false, reason: "no-key-provided" }; - } - if (this.isDevelopment && !this.isCryptoAvailable) { - console.log("tldraw: you seem to be in a development environment that does not support crypto. License not verified."); - console.log("You should check that this works in production separately."); - return { isLicenseParseable: false, reason: "has-key-development-mode" }; - } - let cleanedLicenseKey = licenseKey.replace(/[\u200B-\u200D\uFEFF]/g, ""); - cleanedLicenseKey = cleanedLicenseKey.replace(/\r?\n|\r/g, ""); - try { - const licenseInfo = await this.extractLicenseKey(cleanedLicenseKey); - const expiryDate = new Date(licenseInfo.expiryDate); - const isAnnualLicense = this.isFlagEnabled(licenseInfo.flags, FLAGS.ANNUAL_LICENSE); - const isPerpetualLicense = this.isFlagEnabled(licenseInfo.flags, FLAGS.PERPETUAL_LICENSE); - const result = { - license: licenseInfo, - isLicenseParseable: true, - isDevelopment: this.isDevelopment, - isDomainValid: this.isDomainValid(licenseInfo), - expiryDate, - isAnnualLicense, - isAnnualLicenseExpired: isAnnualLicense && this.isAnnualLicenseExpired(expiryDate), - isPerpetualLicense, - isPerpetualLicenseExpired: isPerpetualLicense && this.isPerpetualLicenseExpired(expiryDate), - isInternalLicense: this.isFlagEnabled(licenseInfo.flags, FLAGS.INTERNAL_LICENSE) - }; - this.outputLicenseInfoIfNeeded(result); - return result; - } catch (e) { - this.outputInvalidLicenseKey(e.message); - return { isLicenseParseable: false, reason: "invalid-license-key" }; - } - } - isDomainValid(licenseInfo) { - const currentHostname = window.location.hostname.toLowerCase(); - return licenseInfo.hosts.some((host) => { - const normalizedHost = host.toLowerCase().trim(); - if (normalizedHost === currentHostname || `www.${normalizedHost}` === currentHostname || normalizedHost === `www.${currentHostname}`) { - return true; - } - if (host === "*") { - return true; - } - if (host.includes("*")) { - const globToRegex = new RegExp(host.replace(/\*/g, ".*?")); - return globToRegex.test(currentHostname); - } - return false; - }); - } - getExpirationDateWithoutGracePeriod(expiryDate) { - return new Date(expiryDate.getFullYear(), expiryDate.getMonth(), expiryDate.getDate()); - } - getExpirationDateWithGracePeriod(expiryDate) { - return new Date(expiryDate.getFullYear(), expiryDate.getMonth(), expiryDate.getDate() + GRACE_PERIOD_DAYS + 1); - } - isAnnualLicenseExpired(expiryDate) { - const expiration = this.getExpirationDateWithGracePeriod(expiryDate); - const isExpired = /* @__PURE__ */ new Date() >= expiration; - if (!isExpired && /* @__PURE__ */ new Date() >= this.getExpirationDateWithoutGracePeriod(expiryDate)) { - this.outputMessages([ - "tldraw license is about to expire, you are in a grace period.", - `Please reach out to ${LICENSE_EMAIL} if you would like to renew your license.` - ]); - } - return isExpired; - } - isPerpetualLicenseExpired(expiryDate) { - const expiration = this.getExpirationDateWithGracePeriod(expiryDate); - const dates = { - major: new Date(publishDates.major), - minor: new Date(publishDates.minor) - }; - return dates.major >= expiration || dates.minor >= expiration; - } - isFlagEnabled(flags, flag) { - return (flags & flag) === flag; - } - outputNoLicenseKeyProvided() { - this.outputMessages([ - "No tldraw license key provided!", - `Please reach out to ${LICENSE_EMAIL} if you would like to license tldraw or if you'd like a trial.` - ]); - } - outputInvalidLicenseKey(msg2) { - this.outputMessages(["Invalid tldraw license key", `Reason: ${msg2}`]); - } - outputLicenseInfoIfNeeded(result) { - if (result.isAnnualLicenseExpired) { - this.outputMessages([ - "Your tldraw license has expired!", - `Please reach out to ${LICENSE_EMAIL} to renew.` - ]); - } - if (!result.isDomainValid && !result.isDevelopment) { - this.outputMessages([ - "This tldraw license key is not valid for this domain!", - `Please reach out to ${LICENSE_EMAIL} if you would like to use tldraw on other domains.` - ]); - } - if (result.license.flags >= HIGHEST_FLAG * 2) { - this.outputMessages([ - "This tldraw license contains some unknown flags.", - "You may want to update tldraw packages to a newer version to get access to new functionality." - ]); - } - } - outputMessages(messages) { - if (this.isTest) - return; - this.outputDelimiter(); - for (const message of messages) { - console.log(`%c${message}`, `color: white; background: crimson; padding: 2px; border-radius: 3px;`); - } - this.outputDelimiter(); - } - outputDelimiter() { - console.log("%c-------------------------------------------------------------------", `color: white; background: crimson; padding: 2px; border-radius: 3px;`); - } -}; -__publicField(LicenseManager, "className", "tl-watermark_SEE-LICENSE"); -function isEditorUnlicensed(result) { - if (!result.isLicenseParseable) - return true; - if (!result.isDomainValid && !result.isDevelopment) - return true; - if (result.isPerpetualLicenseExpired || result.isAnnualLicenseExpired) { - if (result.isInternalLicense) { - throw new Error("License: Internal license expired."); - } - return true; - } - return false; -} - -// node_modules/@tldraw/editor/dist-esm/lib/license/LicenseProvider.mjs -var LicenseContext = (0, import_react40.createContext)({}); -var useLicenseContext = () => (0, import_react40.useContext)(LicenseContext); -function LicenseProvider({ - licenseKey, - children -}) { - const [licenseManager] = (0, import_react40.useState)(() => new LicenseManager(licenseKey)); - return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(LicenseContext.Provider, { value: licenseManager, children }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/license/Watermark.mjs -var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); -var import_react41 = __toESM(require_react(), 1); - -// node_modules/@tldraw/editor/dist-esm/lib/watermarks.mjs -var watermarkDesktopSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="3001" height="1000" fill="none"><path fill="#000" d="M590.656 300.449c0 49.706-40.294 90-90 90-49.705 0-90-40.294-90-90 0-49.705 40.295-90 90-90 49.706 0 90 40.295 90 90M569.431 719.011c-15.247 32.821-56.006 91.589-98.338 91.438-32.004-.115-38.642-30.904-17.414-50.856 17.381-16.337 28.246-48.075 31.995-72.719.415-2.728-1.556-5.197-4.272-5.679-39.666-7.04-70.746-40.877-70.746-83.417 0-48.23 38.983-87.329 87.07-87.329 39.936 0 70.172 22.237 83.369 52.397 18.839 43.055 7.117 115.733-11.664 156.165M2613.29 385.681V239.319c0-11.363 9.22-20.569 20.59-20.569h8.26c11.37 0 20.59 9.206 20.59 20.569v36.911c0 8.629 7 15.625 15.63 15.625h35.25c8.63 0 15.63-6.996 15.63-15.625v-36.911c0-11.363 9.22-20.569 20.59-20.569h8.17c11.37 0 20.59 9.206 20.59 20.569v146.362c0 11.363-9.22 20.569-20.59 20.569h-8.17c-11.37 0-20.59-9.206-20.59-20.569v-36.999c0-8.63-7-15.625-15.63-15.625h-35.25c-8.63 0-15.63 6.995-15.63 15.625v36.999c0 11.363-9.22 20.569-20.59 20.569h-8.26c-11.37 0-20.59-9.206-20.59-20.569M2391.97 239.319v146.362c0 11.348-9.16 20.569-20.49 20.569h-8.2c-11.33 0-20.49-9.221-20.49-20.569V239.319c0-11.348 9.16-20.569 20.49-20.569h8.2c11.33 0 20.49 9.221 20.49 20.569M2098.23 391.43l-42.69-146.361c-3.85-13.171 6.06-26.319 19.79-26.319h10.6c9.59 0 17.93 6.611 20.08 15.952l17.01 73.045c1.48 6.348 10.47 6.478 12.14.176l19.47-73.838c2.38-9.04 10.57-15.335 19.93-15.335h12.1c9.37 0 17.56 6.3 19.94 15.346l19.49 74.067c1.66 6.305 10.65 6.178 12.13-.171l17.09-73.294c2.15-9.339 10.49-15.948 20.08-15.948h10.53c13.72 0 23.63 13.141 19.79 26.31l-42.63 146.361c-2.56 8.789-10.63 14.829-19.79 14.829h-15.68c-9.12 0-17.16-5.98-19.76-14.709l-21.17-71.059c-1.77-5.948-10.19-5.957-11.97-.012l-21.33 71.071c-2.6 8.729-10.64 14.709-19.76 14.709h-15.59c-9.17 0-17.23-6.035-19.8-14.82M2443.23 218.75h118.59c11.38 0 20.62 9.195 20.62 20.557s-9.24 20.556-20.62 20.556h-24.79c-5.53 0-10 4.477-10 10v115.818c0 11.368-9.25 20.569-20.63 20.569h-7.65c-11.39 0-20.63-9.201-20.63-20.569V269.863c0-5.523-4.48-10-10-10h-24.89c-11.37 0-20.61-9.195-20.61-20.556s9.24-20.557 20.61-20.557M1174.15 218.75h24.64c8.35 0 15.88 5.042 19.04 12.764l34.61 83.942c2.13 5.161 9.44 5.155 11.56-.01l34.43-83.932a20.58 20.58 0 0 1 19.04-12.764h24.64c11.37 0 20.58 9.208 20.58 20.569v146.362c0 11.361-9.21 20.569-20.58 20.569h-7.09c-11.36 0-20.58-9.208-20.58-20.569l-.12-50.645c-.01-6.888-9.53-8.688-12.06-2.283l-23.46 59.332a20.57 20.57 0 0 1-19.14 13.009h-3.03a20.57 20.57 0 0 1-19.15-13.046l-23.47-59.68c-2.52-6.416-12.05-4.623-12.06 2.271l-.13 51.042c0 11.361-9.21 20.569-20.57 20.569h-7.1c-11.36 0-20.57-9.208-20.57-20.569V239.319c0-11.361 9.21-20.569 20.57-20.569"/><path fill="#000" fill-rule="evenodd" d="m1449.94 391.836 6.12-19.392a6.255 6.255 0 0 1 5.96-4.369l50.22-.061a6.24 6.24 0 0 1 5.96 4.348l6.23 19.486c2.71 8.581 10.71 14.402 19.74 14.402h9.34c14.13 0 24.15-13.791 19.61-27.151l-49.74-146.361c-2.85-8.37-10.74-13.988-19.61-13.988h-33.16c-8.87 0-16.77 5.618-19.61 13.988l-49.74 146.361c-4.54 13.36 5.48 27.151 19.61 27.151h9.32c9.04 0 17.04-5.827 19.75-14.414m31.1-98.858c1.85-5.807 10.08-5.796 11.91.016l8.83 27.916c1.28 4.028-1.73 8.134-5.96 8.134h-17.74c-4.23 0-7.24-4.119-5.95-8.151zM1681.81 406.25c18.91 0 35.39-3.686 49.36-11.168 13.97-7.544 24.73-18.394 32.24-32.489 7.56-14.105 11.29-30.866 11.29-50.182 0-19.256-3.73-35.957-11.29-50.004-7.57-14.094-18.35-24.912-32.32-32.397-13.91-7.545-30.4-11.26-49.37-11.26h-49.5c-11.38 0-20.63 9.201-20.63 20.569v146.362c0 11.368 9.25 20.569 20.63 20.569zm23.13-47.701c-6.62 3.215-14.85 4.886-24.79 4.886-10.49 0-19-8.507-19-19v-64.34c0-10.149 8.23-18.376 18.38-18.376 10.18 0 18.56 1.703 25.23 4.974 6.59 3.149 11.63 8.315 15.08 15.633 3.45 7.269 5.28 17.268 5.28 30.162 0 12.891-1.82 22.951-5.28 30.347-3.39 7.319-8.36 12.509-14.9 15.714" clip-rule="evenodd"/><path fill="#000" d="M1804.21 385.681V239.319c0-11.361 9.21-20.569 20.58-20.569h91.28c11.36 0 20.57 9.202 20.57 20.557s-9.21 20.556-20.57 20.556h-54.64a7.807 7.807 0 0 0-7.81 7.813v16.366a7.806 7.806 0 0 0 7.81 7.812h48.13c11.37 0 20.58 9.246 20.58 20.602s-9.21 20.601-20.58 20.601h-48.13a7.806 7.806 0 0 0-7.81 7.812v16.455a7.807 7.807 0 0 0 7.81 7.813h54.64c11.36 0 20.57 9.202 20.57 20.556s-9.21 20.557-20.57 20.557h-91.28c-11.37 0-20.58-9.208-20.58-20.569"/><path fill="#000" fill-rule="evenodd" d="M2875.5 68.75h-2750c-31.066 0-56.25 25.184-56.25 56.25v750c0 31.066 25.184 56.25 56.25 56.25h2750c31.07 0 56.25-25.184 56.25-56.25V125c0-31.066-25.18-56.25-56.25-56.25M125.5 0C56.464 0 .5 55.964.5 125v750c0 69.036 55.965 125 125 125h2750c69.04 0 125-55.964 125-125V125c0-69.036-55.96-125-125-125z" clip-rule="evenodd"/><path fill="#000" d="M2476.06 804.813c-10.54 0-19.82-6.947-22.81-17.068L2390.79 575.7c-4.49-15.248 6.92-30.534 22.8-30.534h27.75c11.1 0 20.72 7.686 23.18 18.52L2489 671.402c2.07 9.093 14.93 9.321 17.32.308l28.83-108.844c2.76-10.435 12.19-17.7 22.98-17.7h25.17c10.8 0 20.25 7.293 22.99 17.755l28.27 107.739c2.36 9.001 15.18 8.829 17.3-.232l25.01-106.888c2.51-10.763 12.1-18.374 23.14-18.374h27.87c15.88 0 27.29 15.286 22.8 30.534l-62.46 212.045a23.78 23.78 0 0 1-22.81 17.068h-32.12c-10.39 0-19.58-6.763-22.69-16.696l-32.08-102.694c-2.62-8.397-14.51-8.331-17.04.095l-30.74 102.346c-3.02 10.061-12.27 16.949-22.76 16.949zM1742.44 804.813h-75.81c-13.09 0-23.71-10.656-23.71-23.801V568.967c0-13.145 10.62-23.801 23.71-23.801h74.8c26.6 0 49.59 5.198 68.95 15.594 19.45 10.312 34.44 25.187 44.96 44.627 10.61 19.355 15.91 42.556 15.91 69.602q0 40.57-15.78 69.73c-10.53 19.355-25.43 34.231-44.71 44.627-19.28 10.311-42.05 15.467-68.32 15.467m-29.3-83.642c0 13.145 10.61 23.801 23.71 23.801h3.06c12.8 0 23.7-2.07 32.71-6.212 9.09-4.141 16-11.283 20.71-21.426q7.2-15.213 7.2-42.345 0-27.13-7.32-42.344c-4.8-10.143-11.87-17.285-21.22-21.426-9.26-4.142-20.63-6.212-34.1-6.212h-1.04c-13.1 0-23.71 10.656-23.71 23.801zM1460.86 804.813c-13.12 0-23.76-10.656-23.76-23.801V568.967c0-13.145 10.64-23.801 23.76-23.801h22.84c13.13 0 23.76 10.656 23.76 23.801v155.247c0 13.145 10.64 23.801 23.76 23.801h57.27c13.12 0 23.76 10.656 23.76 23.801v9.196c0 13.145-10.64 23.801-23.76 23.801zM1204.45 601.964c-13.13 0-23.77-10.656-23.77-23.801v-9.196c0-13.145 10.64-23.801 23.77-23.801h177.89c13.13 0 23.78 10.656 23.78 23.801v9.196c0 13.145-10.65 23.801-23.78 23.801h-39.38c-8.21 0-14.86 6.66-14.86 14.875v164.173c0 13.145-10.64 23.801-23.78 23.801h-21.85c-13.13 0-23.78-10.656-23.78-23.801V616.839c0-8.215-6.65-14.875-14.86-14.875z"/><path fill="#000" fill-rule="evenodd" d="M2223.05 787.891c-3.02 10.047-12.27 16.922-22.74 16.922h-25.43c-16.19 0-27.64-15.862-22.57-31.261l69.88-212.045c3.21-9.753 12.31-16.341 22.56-16.341h61.84c10.25 0 19.35 6.588 22.56 16.341l69.87 212.045c5.08 15.399-6.37 31.261-22.56 31.261h-25.43c-10.48 0-19.72-6.875-22.74-16.922l-6.7-22.2a14.84 14.84 0 0 0-14.21-10.576h-63.42c-6.55 0-12.32 4.296-14.22 10.576zm76.13-96.945-14.13-48.436c-2.46-8.451-14.36-8.602-17.04-.217l-15.46 48.436c-1.84 5.759 2.45 11.645 8.48 11.645h29.6c5.94 0 10.22-5.715 8.55-11.428" clip-rule="evenodd"/><path fill="#000" d="M1939.6 804.813c-13.13 0-23.77-10.656-23.77-23.801V568.967c0-13.145 10.64-23.801 23.77-23.801h88.13c19.24 0 36.08 3.508 50.51 10.523s25.65 17.115 33.67 30.3q12.03 19.779 12.03 47.416c0 18.595-4.14 34.273-12.41 47.036-7.64 11.913-18.18 21.101-31.63 27.564-16.98 8.159-36 11.104-54.7 11.104h-43.07c-76.56 0 4.08-135.84 4.08-84.706v7.996c0 12.117 9.81 21.941 21.91 21.941 8.12 0 16.3-.345 24.04-3.043 5.91-2.113 10.43-5.451 13.55-10.015 3.2-4.565 4.81-10.523 4.81-17.877 0-7.437-1.61-13.481-4.81-18.129-3.12-4.733-7.64-8.199-13.55-10.396-7.05-2.766-14.67-3.423-22.18-3.423-13.13 0-23.77 10.656-23.77 23.801v47.71c0 11.825 11.14 16.003 19.91 20.752 12.31 6.671 7.58 25.389-6.42 25.389-7.45 0-13.49 6.048-13.49 13.508v48.395c0 13.145-10.63 23.801-23.76 23.801zm134.89-106.758 5.41 9.95 33.51 61.622c8.62 15.86-2.84 35.186-20.87 35.186h-22.27c-8.74 0-16.77-4.798-20.92-12.496l-35.05-65.04a15.52 15.52 0 0 0-13.66-8.168c-42.24 0 40.62-82.154 73.85-21.054M931.652 0h68.748v1000h-68.748z"/></svg>'; - -// node_modules/@tldraw/editor/dist-esm/lib/license/Watermark.mjs -var WATERMARK_REMOTE_SRC = `${getDefaultCdnBaseUrl()}/watermarks/watermark-desktop.svg`; -var WATERMARK_LOCAL_SRC = `data:image/svg+xml;utf8,${encodeURIComponent(watermarkDesktopSvg)}`; -var watermarkUrlPromise = null; -async function getWatermarkUrl(forceLocal) { - if (forceLocal) { - return WATERMARK_LOCAL_SRC; - } - if (!watermarkUrlPromise) { - watermarkUrlPromise = Promise.race([ - (async () => { - try { - const response = await fetch2(WATERMARK_REMOTE_SRC); - if (!response.ok) - return WATERMARK_LOCAL_SRC; - const blob = await response.blob(); - return URL.createObjectURL(blob); - } catch { - return WATERMARK_LOCAL_SRC; - } - })(), - new Promise((resolve) => { - setTimeout(() => { - resolve(WATERMARK_LOCAL_SRC); - }, 3e3); - }) - ]); - } - return watermarkUrlPromise; -} -var Watermark = import_react41.default.memo(function Watermark2({ - forceLocal = false -}) { - const events = useCanvasEvents(); - const editor = useEditor(); - const licenseManager = useLicenseContext(); - const showWatermark = useValue("show watermark", () => featureFlags.enableLicensing.get() && editor.getViewportScreenBounds().width > 760 && licenseManager.state.get() === "unlicensed", [editor, licenseManager]); - const isDebugMode = useValue("debug mode", () => editor.getInstanceState().isDebugMode, [editor]); - const isMenuOpen = useValue("is menu open", () => editor.getIsMenuOpen(), [editor]); - const [src, setSrc] = (0, import_react41.useState)(null); - const shouldUseLocal = forceLocal || licenseManager.isDevelopment; - (0, import_react41.useEffect)(() => { - if (!showWatermark) - return; - let isCancelled = false; - (async () => { - const src2 = await getWatermarkUrl(shouldUseLocal); - if (isCancelled) - return; - setSrc(src2); - })(); - return () => { - isCancelled = true; - }; - }, [shouldUseLocal, showWatermark]); - if (!showWatermark || !src) - return null; - const className = LicenseManager.className; - const maskCss = `url('${src}') center 100% / 100% no-repeat`; - return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: ` -/* ------------------- SEE LICENSE ------------------- -The tldraw watermark is part of tldraw's license. It is shown for unlicensed -users. By using this library, you agree to keep the watermark's behavior, -keeping it visible, unobscured, and available to user-interaction. - -To remove the watermark, please purchase a license at tldraw.dev. -*/ - -.${className} { - position: absolute; - bottom: var(--space-2); - right: var(--space-2); - width: 96px; - height: 32px; - z-index: 2147483647 !important; - pointer-events: ${isMenuOpen ? "none" : "all"}; - background-color: color-mix(in srgb, var(--color-background) 62%, transparent); - border-radius: 5px; - padding: 2px; - box-sizing: content-box; -} - -.${className}[data-debug='true'] { - bottom: 46px; -} - -.${className} > a { - position: absolute; - width: 96px; - height: 32px; - pointer-events: none; - cursor: inherit; - color: var(--color-text); - background-color: currentColor; - opacity: .28; -} - -@media (hover: hover) { - .${className}:hover { - background-color: var(--color-background); - transition: background-color 0.2s ease-in-out; - transition-delay: 0.32s; - } - .${className}:hover > a { - animation: delayed_link 0.2s forwards ease-in-out; - animation-delay: 0.32s; - } -} - -@keyframes delayed_link { - 0% { - cursor: inherit; - opacity: .38; - pointer-events: none; - } - 100% { - cursor: pointer; - opacity: 1; - pointer-events: all; - } -} -` }), - /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className, "data-debug": isDebugMode, draggable: false, ...events, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("a", { - href: "https://tldraw.dev", - target: "_blank", - rel: "noreferrer", - draggable: false, - onPointerDown: stopEventPropagation, - style: { mask: maskCss, WebkitMask: maskCss } - }) }) - ] }); -}); - -// node_modules/@tldraw/editor/dist-esm/lib/TldrawEditor.mjs -var EMPTY_SHAPE_UTILS_ARRAY = []; -var EMPTY_BINDING_UTILS_ARRAY = []; -var EMPTY_TOOLS_ARRAY = []; -var TL_CONTAINER_CLASS = "tl-container"; -var TldrawEditor = (0, import_react42.memo)(function TldrawEditor2({ - store, - components, - className, - user: _user, - ...rest -}) { - const [container, setContainer] = import_react42.default.useState(null); - const user = (0, import_react42.useMemo)(() => _user ?? createTLUser(), [_user]); - const ErrorFallback = components?.ErrorFallback === void 0 ? DefaultErrorFallback : components?.ErrorFallback; - const withDefaults = { - ...rest, - shapeUtils: rest.shapeUtils ?? EMPTY_SHAPE_UTILS_ARRAY, - bindingUtils: rest.bindingUtils ?? EMPTY_BINDING_UTILS_ARRAY, - tools: rest.tools ?? EMPTY_TOOLS_ARRAY, - components - }; - return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { - ref: setContainer, - "data-tldraw": version, - draggable: false, - className: (0, import_classnames11.default)(`${TL_CONTAINER_CLASS} tl-theme__light`, className), - onPointerDown: stopEventPropagation, - tabIndex: -1, - children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(OptionalErrorBoundary, { - fallback: ErrorFallback, - onError: (error3) => annotateError(error3, { tags: { origin: "react.tldraw-before-app" } }), - children: container && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(LicenseProvider, { licenseKey: rest.licenseKey, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ContainerProvider, { container, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EditorComponentsProvider, { overrides: components, children: store ? store instanceof Store ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TldrawEditorWithReadyStore, { ...withDefaults, store, user }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TldrawEditorWithLoadingStore, { ...withDefaults, store, user }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TldrawEditorWithOwnStore, { ...withDefaults, store, user }) }) }) }) - }) - }); -}); -function TldrawEditorWithOwnStore(props) { - const { - defaultName, - snapshot, - initialData, - shapeUtils, - bindingUtils, - persistenceKey, - sessionId, - user, - assets - } = props; - const syncedStore = useLocalStore({ - shapeUtils, - bindingUtils, - initialData, - persistenceKey, - sessionId, - defaultName, - snapshot, - assets - }); - return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TldrawEditorWithLoadingStore, { ...props, store: syncedStore, user }); -} -var TldrawEditorWithLoadingStore = (0, import_react42.memo)(function TldrawEditorBeforeLoading({ - store, - user, - ...rest -}) { - const container = useContainer(); - (0, import_react42.useLayoutEffect)(() => { - if (user.userPreferences.get().colorScheme === "dark") { - container.classList.remove("tl-theme__light"); - container.classList.add("tl-theme__dark"); - } - }, [container, user]); - const { LoadingScreen: LoadingScreen2 } = useEditorComponents(); - switch (store.status) { - case "error": { - throw store.error; - } - case "loading": { - return LoadingScreen2 ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(LoadingScreen2, {}) : null; - } - case "not-synced": { - break; - } - case "synced-local": { - break; - } - case "synced-remote": { - break; - } - } - return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TldrawEditorWithReadyStore, { ...rest, store: store.store, user }); -}); -function TldrawEditorWithReadyStore({ - onMount, - children, - store, - tools, - shapeUtils, - bindingUtils, - user, - initialState: initialState2, - autoFocus = true, - inferDarkMode, - cameraOptions, - options, - licenseKey -}) { - const { ErrorFallback } = useEditorComponents(); - const container = useContainer(); - const [editor, setEditor] = useRefState(null); - const editorOptionsRef = (0, import_react42.useRef)({ - autoFocus, - inferDarkMode, - initialState: initialState2, - cameraOptions - }); - (0, import_react42.useLayoutEffect)(() => { - editorOptionsRef.current = { - autoFocus, - inferDarkMode, - initialState: initialState2, - cameraOptions - }; - }, [autoFocus, inferDarkMode, initialState2, cameraOptions]); - (0, import_react42.useLayoutEffect)(() => { - const { autoFocus: autoFocus2, inferDarkMode: inferDarkMode2, initialState: initialState22, cameraOptions: cameraOptions2 } = editorOptionsRef.current; - const editor2 = new Editor({ - store, - shapeUtils, - bindingUtils, - tools, - getContainer: () => container, - user, - initialState: initialState22, - autoFocus: autoFocus2, - inferDarkMode: inferDarkMode2, - cameraOptions: cameraOptions2, - options, - licenseKey - }); - setEditor(editor2); - return () => { - editor2.dispose(); - }; - }, [bindingUtils, container, options, shapeUtils, store, tools, user, setEditor, licenseKey]); - (0, import_react42.useLayoutEffect)(() => { - if (editor && cameraOptions) { - editor.setCameraOptions(cameraOptions); - } - }, [editor, cameraOptions]); - const crashingError = (0, import_react42.useSyncExternalStore)((0, import_react42.useCallback)((onStoreChange) => { - if (editor) { - editor.on("crash", onStoreChange); - return () => editor.off("crash", onStoreChange); - } - return () => { - }; - }, [editor]), () => editor?.getCrashingError() ?? null); - const { Canvas } = useEditorComponents(); - if (!editor) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(OptionalErrorBoundary, { - fallback: ErrorFallback, - onError: (error3) => editor.annotateError(error3, { origin: "react.tldraw", willCrashApp: true }), - children: crashingError ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Crash, { crashingError }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Layout, { onMount, children: [ - children ?? (Canvas ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Canvas, {}) : null), - /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Watermark, {}) - ] }) }) - }); -} -function Layout({ children, onMount }) { - useZoomCss(); - useCursor(); - useDarkMode(); - useForceUpdate(); - useOnMount((editor) => { - const teardownStore = editor.store.props.onEditorMount(editor); - const teardownCallback = onMount?.(editor); - return () => { - teardownStore?.(); - teardownCallback?.(); - }; - }); - return children; -} -function Crash({ crashingError }) { - throw crashingError; -} -function LoadingScreen({ children }) { - return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "tl-loading", children }); -} -function ErrorScreen({ children }) { - return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "tl-loading", children }); -} -function useOnMount(onMount) { - const editor = useEditor(); - const onMountEvent = useEvent((editor2) => { - let teardown = void 0; - editor2.run(() => { - teardown = onMount?.(editor2); - editor2.emit("mount"); - }, { history: "ignore" }); - window.tldrawReady = true; - return teardown; - }); - import_react42.default.useLayoutEffect(() => { - if (editor) - return onMountEvent?.(editor); - }, [editor, onMountEvent]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/components/HTMLContainer.mjs -var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); -var import_classnames12 = __toESM(require_classnames(), 1); -function HTMLContainer({ children, className = "", ...rest }) { - return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...rest, className: (0, import_classnames12.default)("tl-html-container", className), children }); -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/bindings/BindingUtil.mjs -var BindingUtil = class { - constructor(editor) { - this.editor = editor; - } -}; -__publicField(BindingUtil, "props"); -__publicField(BindingUtil, "migrations"); -__publicField(BindingUtil, "type"); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/shared/resizeBox.mjs -function resizeBox(shape, info2, opts = {}) { - const { newPoint, handle, scaleX, scaleY } = info2; - const { minWidth = 1, maxWidth: maxWidth2 = Infinity, minHeight = 1, maxHeight: maxHeight2 = Infinity } = opts; - let w = shape.props.w * scaleX; - let h = shape.props.h * scaleY; - const offset4 = new Vec(0, 0); - if (w > 0) { - if (w < minWidth) { - switch (handle) { - case "top_left": - case "left": - case "bottom_left": { - offset4.x = w - minWidth; - break; - } - case "top": - case "bottom": { - offset4.x = (w - minWidth) / 2; - break; - } - default: { - offset4.x = 0; - } - } - w = minWidth; - } - } else { - offset4.x = w; - w = -w; - if (w < minWidth) { - switch (handle) { - case "top_left": - case "left": - case "bottom_left": { - offset4.x = -w; - break; - } - default: { - offset4.x = -minWidth; - } - } - w = minWidth; - } - } - if (h > 0) { - if (h < minHeight) { - switch (handle) { - case "top_left": - case "top": - case "top_right": { - offset4.y = h - minHeight; - break; - } - case "right": - case "left": { - offset4.y = (h - minHeight) / 2; - break; - } - default: { - offset4.y = 0; - } - } - h = minHeight; - } - } else { - offset4.y = h; - h = -h; - if (h < minHeight) { - switch (handle) { - case "top_left": - case "top": - case "top_right": { - offset4.y = -h; - break; - } - default: { - offset4.y = -minHeight; - } - } - h = minHeight; - } - } - const { x, y } = offset4.rot(shape.rotation).add(newPoint); - return { - ...shape, - x, - y, - props: { - w: Math.min(maxWidth2, w), - h: Math.min(maxHeight2, h) - } - }; -} - -// node_modules/@tldraw/editor/dist-esm/lib/editor/shapes/BaseBoxShapeUtil.mjs -var BaseBoxShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "onResize", (shape, info2) => { - return resizeBox(shape, info2); - }); - } - getGeometry(shape) { - return new Rectangle2d({ - width: shape.props.w, - height: shape.props.h, - isFilled: true - }); - } - getHandleSnapGeometry(shape) { - return { - points: this.getGeometry(shape).bounds.cornersAndCenter - }; - } - getInterpolatedProps(startShape, endShape, t2) { - return { - ...endShape.props, - w: lerp(startShape.props.w, endShape.props.w, t2), - h: lerp(startShape.props.h, endShape.props.h, t2) - }; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Idle.mjs -var Idle = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle, "id", "idle"); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs -var Pointing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "markId", ""); - __publicField(this, "wasFocusedOnEnter", false); - __publicField(this, "onEnter", () => { - this.wasFocusedOnEnter = !this.editor.getIsMenuOpen(); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - const { originPagePoint } = this.editor.inputs; - const shapeType = this.parent.shapeType; - const id = createShapeId(); - this.markId = `creating:${id}`; - this.editor.mark(this.markId); - this.editor.createShapes([ - { - id, - type: shapeType, - x: originPagePoint.x, - y: originPagePoint.y, - props: { - w: 1, - h: 1 - } - } - ]).select(id); - this.editor.setCurrentTool("select.resizing", { - ...info2, - target: "selection", - handle: "bottom_right", - isCreating: true, - creationCursorOffset: { x: 1, y: 1 }, - onInteractionEnd: this.parent.id, - onCreate: this.parent.onCreate - }); - } - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - complete() { - const { originPagePoint } = this.editor.inputs; - if (!this.wasFocusedOnEnter) { - return; - } - this.editor.mark(this.markId); - const shapeType = this.parent.shapeType; - const id = createShapeId(); - this.editor.mark(this.markId); - this.editor.createShapes([ - { - id, - type: shapeType, - x: originPagePoint.x, - y: originPagePoint.y - } - ]); - const shape = this.editor.getShape(id); - if (!shape) { - this.cancel(); - return; - } - let { w, h } = shape.props; - const delta = new Vec(w / 2, h / 2); - const parentTransform = this.editor.getShapeParentTransform(shape); - if (parentTransform) - delta.rot(-parentTransform.rotation()); - let scale = 1; - if (this.editor.user.getIsDynamicResizeMode()) { - scale = 1 / this.editor.getZoomLevel(); - w *= scale; - h *= scale; - delta.mul(scale); - } - const next = structuredClone(shape); - next.x = shape.x - delta.x; - next.y = shape.y - delta.y; - next.props.w = w; - next.props.h = h; - if ("scale" in shape.props) { - ; - next.props.scale = scale; - } - this.editor.updateShape(next); - this.editor.setSelectedShapes([id]); - if (this.editor.getInstanceState().isToolLocked) { - this.parent.transition("idle"); - } else { - this.editor.setCurrentTool("select.idle"); - } - } - cancel() { - this.parent.transition("idle"); - } -}; -__publicField(Pointing, "id", "pointing"); - -// node_modules/@tldraw/editor/dist-esm/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.mjs -var BaseBoxShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onCreate"); - } -}; -__publicField(BaseBoxShapeTool, "id", "box"); -__publicField(BaseBoxShapeTool, "initial", "idle"); -__publicField(BaseBoxShapeTool, "children", () => [Idle, Pointing]); - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useIsEditing.mjs -function useIsEditing(shapeId) { - const editor = useEditor(); - return useValue("isEditing", () => editor.getEditingShapeId() === shapeId, [editor, shapeId]); -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useSelectionEvents.mjs -var import_react43 = __toESM(require_react(), 1); -function useSelectionEvents(handle) { - const editor = useEditor(); - const events = (0, import_react43.useMemo)(function selectionEvents() { - const onPointerDown = (e) => { - if (e.isKilled) - return; - if (e.button === RIGHT_MOUSE_BUTTON) { - editor.dispatch({ - type: "pointer", - target: "selection", - handle, - name: "right_click", - ...getPointerInfo(e) - }); - return; - } - if (e.button !== 0) - return; - const elm = loopToHtmlElement(e.currentTarget); - function releaseCapture() { - elm.removeEventListener("pointerup", releaseCapture); - releasePointerCapture(elm, e); - } - setPointerCapture(elm, e); - elm.addEventListener("pointerup", releaseCapture); - editor.dispatch({ - name: "pointer_down", - type: "pointer", - target: "selection", - handle, - ...getPointerInfo(e) - }); - stopEventPropagation(e); - }; - let lastX, lastY; - function onPointerMove(e) { - if (e.isKilled) - return; - if (e.button !== 0) - return; - if (e.clientX === lastX && e.clientY === lastY) - return; - lastX = e.clientX; - lastY = e.clientY; - editor.dispatch({ - name: "pointer_move", - type: "pointer", - target: "selection", - handle, - ...getPointerInfo(e) - }); - } - const onPointerUp = (e) => { - if (e.isKilled) - return; - if (e.button !== 0) - return; - editor.dispatch({ - name: "pointer_up", - type: "pointer", - target: "selection", - handle, - ...getPointerInfo(e) - }); - }; - return { - onPointerDown, - onPointerMove, - onPointerUp - }; - }, [editor, handle]); - return events; -} - -// node_modules/@tldraw/editor/dist-esm/lib/hooks/useTLStore.mjs -var import_react44 = __toESM(require_react(), 1); -function useTLStore(opts) { - const [current, setCurrent] = (0, import_react44.useState)(() => ({ store: createTLStore(opts), opts })); - if (!areObjectsShallowEqual(current.opts, opts)) { - const next = { store: createTLStore(opts), opts }; - setCurrent(next); - return next.store; - } - return current.store; -} - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/geometry-constants.mjs -var SPACING = 20; -var MIN_COUNT = 8; -function getVerticesCountForLength(length, spacing = SPACING) { - return Math.max(MIN_COUNT, Math.ceil(length / spacing)); -} - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Arc2d.mjs -var Arc2d = class extends Geometry2d { - constructor(config) { - super({ ...config, isFilled: false, isClosed: false }); - __publicField(this, "_center"); - __publicField(this, "radius"); - __publicField(this, "start"); - __publicField(this, "end"); - __publicField(this, "largeArcFlag"); - __publicField(this, "sweepFlag"); - __publicField(this, "measure"); - __publicField(this, "angleStart"); - __publicField(this, "angleEnd"); - const { center, sweepFlag, largeArcFlag, start, end } = config; - if (start.equals(end)) - throw Error(`Arc must have different start and end points.`); - this.angleStart = Vec.Angle(center, start); - this.angleEnd = Vec.Angle(center, end); - this.radius = Vec.Dist(center, start); - this.measure = getArcMeasure(this.angleStart, this.angleEnd, sweepFlag, largeArcFlag); - this.start = start; - this.end = end; - this.sweepFlag = sweepFlag; - this.largeArcFlag = largeArcFlag; - this._center = center; - } - nearestPoint(point) { - const { _center, measure, radius, angleEnd, angleStart, start: A, end: B } = this; - const t2 = getPointInArcT(measure, angleStart, angleEnd, _center.angle(point)); - if (t2 <= 0) - return A; - if (t2 >= 1) - return B; - const P = _center.clone().add(point.clone().sub(_center).uni().mul(radius)); - let nearest; - let dist = Infinity; - let d; - for (const p of [A, B, P]) { - d = Vec.Dist2(point, p); - if (d < dist) { - nearest = p; - dist = d; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - hitTestLineSegment(A, B) { - const { _center, radius, measure, angleStart, angleEnd } = this; - const intersection = intersectLineSegmentCircle(A, B, _center, radius); - if (intersection === null) - return false; - return intersection.some((p) => { - const result = getPointInArcT(measure, angleStart, angleEnd, _center.angle(p)); - return result >= 0 && result <= 1; - }); - } - getVertices() { - const { _center, measure, length, radius, angleStart } = this; - const vertices = []; - for (let i = 0, n = getVerticesCountForLength(Math.abs(length)); i < n + 1; i++) { - const t2 = i / n * measure; - const angle = angleStart + t2; - vertices.push(getPointOnCircle(_center, radius, angle)); - } - return vertices; - } - getSvgPathData(first = true) { - const { start, end, radius, largeArcFlag, sweepFlag } = this; - return `${first ? `M${start.toFixed()}` : ``} A${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.toFixed()}`; - } - getLength() { - return this.measure * this.radius; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Circle2d.mjs -var Circle2d = class extends Geometry2d { - constructor(config) { - super({ isClosed: true, ...config }); - __publicField(this, "_center"); - __publicField(this, "radius"); - __publicField(this, "x"); - __publicField(this, "y"); - this.config = config; - const { x = 0, y = 0, radius } = config; - this.x = x; - this.y = y; - this._center = new Vec(radius + x, radius + y); - this.radius = radius; - } - getBounds() { - return new Box(this.x, this.y, this.radius * 2, this.radius * 2); - } - getVertices() { - const { _center, radius } = this; - const perimeter = PI2 * radius; - const vertices = []; - for (let i = 0, n = getVerticesCountForLength(perimeter); i < n; i++) { - const angle = i / n * PI2; - vertices.push(getPointOnCircle(_center, radius, angle)); - } - return vertices; - } - nearestPoint(point) { - const { _center, radius } = this; - if (_center.equals(point)) - return Vec.AddXY(_center, radius, 0); - return _center.clone().add(point.clone().sub(_center).uni().mul(radius)); - } - hitTestLineSegment(A, B, distance = 0) { - const { _center, radius } = this; - return intersectLineSegmentCircle(A, B, _center, radius + distance) !== null; - } - getSvgPathData() { - const { _center, radius } = this; - return `M${_center.x + radius},${_center.y} a${radius},${radius} 0 1,0 ${radius * 2},0a${radius},${radius} 0 1,0 -${radius * 2},0`; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs -var CubicBezier2d = class extends Polyline2d { - constructor(config) { - const { start: a, cp1: b, cp2: c, end: d } = config; - super({ ...config, points: [a, d] }); - __publicField(this, "a"); - __publicField(this, "b"); - __publicField(this, "c"); - __publicField(this, "d"); - this.a = a; - this.b = b; - this.c = c; - this.d = d; - } - getVertices() { - const vertices = []; - const { a, b, c, d } = this; - for (let i = 0, n = 10; i <= n; i++) { - const t2 = i / n; - vertices.push(new Vec((1 - t2) * (1 - t2) * (1 - t2) * a.x + 3 * ((1 - t2) * (1 - t2)) * t2 * b.x + 3 * (1 - t2) * (t2 * t2) * c.x + t2 * t2 * t2 * d.x, (1 - t2) * (1 - t2) * (1 - t2) * a.y + 3 * ((1 - t2) * (1 - t2)) * t2 * b.y + 3 * (1 - t2) * (t2 * t2) * c.y + t2 * t2 * t2 * d.y)); - } - return vertices; - } - midPoint() { - return CubicBezier2d.GetAtT(this, 0.5); - } - nearestPoint(A) { - let nearest; - let dist = Infinity; - let d; - let p; - for (const edge of this.segments) { - p = edge.nearestPoint(A); - d = Vec.Dist2(p, A); - if (d < dist) { - nearest = p; - dist = d; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - getSvgPathData(first = true) { - const { a, b, c, d } = this; - return `${first ? `M ${a.toFixed()} ` : ``} C${b.toFixed()} ${c.toFixed()} ${d.toFixed()}`; - } - static GetAtT(segment, t2) { - const { a, b, c, d } = segment; - return new Vec((1 - t2) * (1 - t2) * (1 - t2) * a.x + 3 * ((1 - t2) * (1 - t2)) * t2 * b.x + 3 * (1 - t2) * (t2 * t2) * c.x + t2 * t2 * t2 * d.x, (1 - t2) * (1 - t2) * (1 - t2) * a.y + 3 * ((1 - t2) * (1 - t2)) * t2 * b.y + 3 * (1 - t2) * (t2 * t2) * c.y + t2 * t2 * t2 * d.y); - } - getLength(precision = 32) { - let n1, p1 = this.a, length = 0; - for (let i = 1; i <= precision; i++) { - n1 = CubicBezier2d.GetAtT(this, i / precision); - length += Vec.Dist(p1, n1); - p1 = n1; - } - return length; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs -var CubicSpline2d = class extends Geometry2d { - constructor(config) { - super({ ...config, isClosed: false, isFilled: false }); - __publicField(this, "points"); - __publicField(this, "_segments"); - const { points } = config; - this.points = points; - } - get segments() { - if (!this._segments) { - this._segments = []; - const { points } = this; - const len = points.length; - const last3 = len - 2; - const k = 1.25; - for (let i = 0; i < len - 1; i++) { - const p0 = i === 0 ? points[0] : points[i - 1]; - const p1 = points[i]; - const p2 = points[i + 1]; - const p3 = i === last3 ? p2 : points[i + 2]; - const start = p1, cp1 = i === 0 ? p0 : new Vec(p1.x + (p2.x - p0.x) / 6 * k, p1.y + (p2.y - p0.y) / 6 * k), cp2 = i === last3 ? p2 : new Vec(p2.x - (p3.x - p1.x) / 6 * k, p2.y - (p3.y - p1.y) / 6 * k), end = p2; - this._segments.push(new CubicBezier2d({ start, cp1, cp2, end })); - } - } - return this._segments; - } - getLength() { - return this.segments.reduce((acc, segment) => acc + segment.length, 0); - } - getVertices() { - const vertices = this.segments.reduce((acc, segment) => { - return acc.concat(segment.vertices); - }, []); - vertices.push(this.points[this.points.length - 1]); - return vertices; - } - nearestPoint(A) { - let nearest; - let dist = Infinity; - let d; - let p; - for (const segment of this.segments) { - p = segment.nearestPoint(A); - d = Vec.Dist2(p, A); - if (d < dist) { - nearest = p; - dist = d; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - hitTestLineSegment(A, B) { - return this.segments.some((segment) => segment.hitTestLineSegment(A, B)); - } - getSvgPathData() { - let d = this.segments.reduce((d2, segment, i) => { - return d2 + segment.getSvgPathData(i === 0); - }, ""); - if (this.isClosed) { - d += "Z"; - } - return d; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Ellipse2d.mjs -var Ellipse2d = class extends Geometry2d { - constructor(config) { - super({ ...config, isClosed: true }); - __publicField(this, "w"); - __publicField(this, "h"); - __publicField(this, "_edges"); - this.config = config; - const { width, height } = config; - this.w = width; - this.h = height; - } - get edges() { - if (!this._edges) { - const { vertices } = this; - this._edges = []; - for (let i = 0, n = vertices.length; i < n; i++) { - const start = vertices[i]; - const end = vertices[(i + 1) % n]; - this._edges.push(new Edge2d({ start, end })); - } - } - return this._edges; - } - getVertices() { - const w = Math.max(1, this.w); - const h = Math.max(1, this.h); - const cx = w / 2; - const cy = h / 2; - const q = Math.pow(cx - cy, 2) / Math.pow(cx + cy, 2); - const p = PI * (cx + cy) * (1 + 3 * q / (10 + Math.sqrt(4 - 3 * q))); - const len = getVerticesCountForLength(p); - const step = PI2 / len; - const a = Math.cos(step); - const b = Math.sin(step); - let sin = 0; - let cos = 1; - let ts = 0; - let tc = 1; - const vertices = Array(len); - for (let i = 0; i < len; i++) { - vertices[i] = new Vec(cx + cx * cos, cy + cy * sin); - ts = b * cos + a * sin; - tc = a * cos - b * sin; - sin = ts; - cos = tc; - } - return vertices; - } - nearestPoint(A) { - let nearest; - let dist = Infinity; - let d; - let p; - for (const edge of this.edges) { - p = edge.nearestPoint(A); - d = Vec.Dist2(p, A); - if (d < dist) { - nearest = p; - dist = d; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - hitTestLineSegment(A, B) { - return this.edges.some((edge) => edge.hitTestLineSegment(A, B)); - } - getBounds() { - return new Box(0, 0, this.w, this.h); - } - getLength() { - const { w, h } = this; - const cx = w / 2; - const cy = h / 2; - const rx = Math.max(0, cx); - const ry = Math.max(0, cy); - return perimeterOfEllipse(rx, ry); - } - getSvgPathData(first = false) { - const { w, h } = this; - const cx = w / 2; - const cy = h / 2; - const rx = Math.max(0, cx); - const ry = Math.max(0, cy); - return `${first ? `M${cx - rx},${cy}` : ``} a${rx},${ry},0,1,1,${rx * 2},0a${rx},${ry},0,1,1,-${rx * 2},0`; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/primitives/geometry/Stadium2d.mjs -var Stadium2d = class extends Geometry2d { - constructor(config) { - super({ ...config, isClosed: true }); - __publicField(this, "w"); - __publicField(this, "h"); - __publicField(this, "a"); - __publicField(this, "b"); - __publicField(this, "c"); - __publicField(this, "d"); - this.config = config; - const { width: w, height: h } = config; - this.w = w; - this.h = h; - if (h > w) { - const r = w / 2; - this.a = new Arc2d({ - start: new Vec(0, r), - end: new Vec(w, r), - center: new Vec(w / 2, r), - sweepFlag: 1, - largeArcFlag: 1 - }); - this.b = new Edge2d({ start: new Vec(w, r), end: new Vec(w, h - r) }); - this.c = new Arc2d({ - start: new Vec(w, h - r), - end: new Vec(0, h - r), - center: new Vec(w / 2, h - r), - sweepFlag: 1, - largeArcFlag: 1 - }); - this.d = new Edge2d({ start: new Vec(0, h - r), end: new Vec(0, r) }); - } else { - const r = h / 2; - this.a = new Arc2d({ - start: new Vec(r, h), - end: new Vec(r, 0), - center: new Vec(r, r), - sweepFlag: 1, - largeArcFlag: 1 - }); - this.b = new Edge2d({ start: new Vec(r, 0), end: new Vec(w - r, 0) }); - this.c = new Arc2d({ - start: new Vec(w - r, 0), - end: new Vec(w - r, h), - center: new Vec(w - r, r), - sweepFlag: 1, - largeArcFlag: 1 - }); - this.d = new Edge2d({ start: new Vec(w - r, h), end: new Vec(r, h) }); - } - } - nearestPoint(A) { - let nearest; - let dist = Infinity; - let _d; - let p; - const { a, b, c, d } = this; - for (const part of [a, b, c, d]) { - p = part.nearestPoint(A); - _d = Vec.Dist2(p, A); - if (_d < dist) { - nearest = p; - dist = _d; - } - } - if (!nearest) - throw Error("nearest point not found"); - return nearest; - } - hitTestLineSegment(A, B) { - const { a, b, c, d } = this; - return [a, b, c, d].some((edge) => edge.hitTestLineSegment(A, B)); - } - getVertices() { - const { a, b, c, d } = this; - return [a, b, c, d].reduce((a2, p) => { - a2.push(...p.vertices); - return a2; - }, []); - } - getBounds() { - return new Box(0, 0, this.w, this.h); - } - getLength() { - const { h, w } = this; - if (h > w) - return (PI * (w / 2) + (h - w)) * 2; - else - return (PI * (h / 2) + (w - h)) * 2; - } - getSvgPathData() { - const { a, b, c, d } = this; - return [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(" ") + " Z"; - } -}; - -// node_modules/@tldraw/editor/dist-esm/lib/utils/sync/hardReset.mjs -async function hardReset({ shouldReload = true } = {}) { - clearSessionStorage(); - for (const instance of LocalIndexedDb.connectedInstances) { - await instance.close(); - } - await Promise.all(getAllIndexDbNames().map((db) => deleteDB(db))); - clearLocalStorage(); - if (shouldReload) { - window.location.reload(); - } -} -if (typeof window !== "undefined") { - if (false) { - ; - window.hardReset = hardReset; - } - ; - window.__tldraw__hardReset = hardReset; -} - -// node_modules/@tldraw/editor/dist-esm/lib/utils/window-open.mjs -function openWindow(url, target = "_blank") { - runtime.openWindow(url, target); -} - -// node_modules/tldraw/dist-esm/lib/Tldraw.mjs -var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1); -var import_react116 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawHandles.mjs -var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); -function TldrawHandles({ children }) { - const editor = useEditor(); - const shouldDisplayHandles = useValue("shouldDisplayHandles", () => { - if (editor.isInAny("select.idle", "select.pointing_handle", "select.pointing_shape")) { - return true; - } - if (editor.isInAny("select.editing_shape")) { - const onlySelectedShape = editor.getOnlySelectedShape(); - return onlySelectedShape && editor.isShapeOfType(onlySelectedShape, "note"); - } - return false; - }, [editor]); - if (!shouldDisplayHandles) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("svg", { className: "tl-user-handles tl-overlays__item", children }); -} - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawScribble.mjs -var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); -var import_classnames13 = __toESM(require_classnames(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/freehand/getStrokeOutlinePoints.mjs -var { PI: PI3 } = Math; -var FIXED_PI = PI3 + 1e-4; -function getStrokeOutlineTracks(strokePoints, options = {}) { - const { size: size4 = 16, smoothing = 0.5 } = options; - if (strokePoints.length === 0 || size4 <= 0) { - return { left: [], right: [] }; - } - const firstStrokePoint = strokePoints[0]; - const lastStrokePoint = strokePoints[strokePoints.length - 1]; - const totalLength = lastStrokePoint.runningLength; - const minDistance = Math.pow(size4 * smoothing, 2); - const leftPts = []; - const rightPts = []; - let prevVector = strokePoints[0].vector; - let pl = strokePoints[0].point; - let pr = pl; - let tl = pl; - let tr = pr; - let isPrevPointSharpCorner = false; - let strokePoint; - for (let i = 0; i < strokePoints.length; i++) { - strokePoint = strokePoints[i]; - const { point, vector } = strokePoints[i]; - const prevDpr = strokePoint.vector.dpr(prevVector); - const nextVector = (i < strokePoints.length - 1 ? strokePoints[i + 1] : strokePoints[i]).vector; - const nextDpr = i < strokePoints.length - 1 ? nextVector.dpr(strokePoint.vector) : 1; - const isPointSharpCorner = prevDpr < 0 && !isPrevPointSharpCorner; - const isNextPointSharpCorner = nextDpr !== null && nextDpr < 0.2; - if (isPointSharpCorner || isNextPointSharpCorner) { - if (nextDpr > -0.62 && totalLength - strokePoint.runningLength > strokePoint.radius) { - const offset22 = prevVector.clone().mul(strokePoint.radius); - const cpr = prevVector.clone().cpr(nextVector); - if (cpr < 0) { - tl = Vec.Add(point, offset22); - tr = Vec.Sub(point, offset22); - } else { - tl = Vec.Sub(point, offset22); - tr = Vec.Add(point, offset22); - } - leftPts.push(tl); - rightPts.push(tr); - } else { - const offset22 = prevVector.clone().mul(strokePoint.radius).per(); - const start = Vec.Sub(strokePoint.input, offset22); - for (let step = 1 / 13, t2 = 0; t2 < 1; t2 += step) { - tl = Vec.RotWith(start, strokePoint.input, FIXED_PI * t2); - leftPts.push(tl); - tr = Vec.RotWith(start, strokePoint.input, FIXED_PI + FIXED_PI * -t2); - rightPts.push(tr); - } - } - pl = tl; - pr = tr; - if (isNextPointSharpCorner) { - isPrevPointSharpCorner = true; - } - continue; - } - isPrevPointSharpCorner = false; - if (strokePoint === firstStrokePoint || strokePoint === lastStrokePoint) { - const offset22 = Vec.Per(vector).mul(strokePoint.radius); - leftPts.push(Vec.Sub(point, offset22)); - rightPts.push(Vec.Add(point, offset22)); - continue; - } - const offset4 = Vec.Lrp(nextVector, vector, nextDpr).per().mul(strokePoint.radius); - tl = Vec.Sub(point, offset4); - if (i <= 1 || Vec.Dist2(pl, tl) > minDistance) { - leftPts.push(tl); - pl = tl; - } - tr = Vec.Add(point, offset4); - if (i <= 1 || Vec.Dist2(pr, tr) > minDistance) { - rightPts.push(tr); - pr = tr; - } - prevVector = vector; - continue; - } - return { - left: leftPts, - right: rightPts - }; -} -function getStrokeOutlinePoints(strokePoints, options = {}) { - const { size: size4 = 16, start = {}, end = {}, last: isComplete = false } = options; - const { cap: capStart = true } = start; - const { cap: capEnd = true } = end; - if (strokePoints.length === 0 || size4 <= 0) { - return []; - } - const firstStrokePoint = strokePoints[0]; - const lastStrokePoint = strokePoints[strokePoints.length - 1]; - const totalLength = lastStrokePoint.runningLength; - const taperStart = start.taper === false ? 0 : start.taper === true ? Math.max(size4, totalLength) : start.taper; - const taperEnd = end.taper === false ? 0 : end.taper === true ? Math.max(size4, totalLength) : end.taper; - const { left: leftPts, right: rightPts } = getStrokeOutlineTracks(strokePoints, options); - const firstPoint = firstStrokePoint.point; - const lastPoint = strokePoints.length > 1 ? strokePoints[strokePoints.length - 1].point : Vec.AddXY(firstStrokePoint.point, 1, 1); - if (strokePoints.length === 1) { - if (!(taperStart || taperEnd) || isComplete) { - const start2 = Vec.Add(firstPoint, Vec.Sub(firstPoint, lastPoint).uni().per().mul(-firstStrokePoint.radius)); - const dotPts = []; - for (let step = 1 / 13, t2 = step; t2 <= 1; t2 += step) { - dotPts.push(Vec.RotWith(start2, firstPoint, FIXED_PI * 2 * t2)); - } - return dotPts; - } - } - const startCap = []; - if (taperStart || taperEnd && strokePoints.length === 1) { - } else if (capStart) { - for (let step = 1 / 8, t2 = step; t2 <= 1; t2 += step) { - const pt = Vec.RotWith(rightPts[0], firstPoint, FIXED_PI * t2); - startCap.push(pt); - } - } else { - const cornersVector = Vec.Sub(leftPts[0], rightPts[0]); - const offsetA = Vec.Mul(cornersVector, 0.5); - const offsetB = Vec.Mul(cornersVector, 0.51); - startCap.push(Vec.Sub(firstPoint, offsetA), Vec.Sub(firstPoint, offsetB), Vec.Add(firstPoint, offsetB), Vec.Add(firstPoint, offsetA)); - } - const endCap = []; - const direction = lastStrokePoint.vector.clone().per().neg(); - if (taperEnd || taperStart && strokePoints.length === 1) { - endCap.push(lastPoint); - } else if (capEnd) { - const start2 = Vec.Add(lastPoint, Vec.Mul(direction, lastStrokePoint.radius)); - for (let step = 1 / 29, t2 = step; t2 < 1; t2 += step) { - endCap.push(Vec.RotWith(start2, lastPoint, FIXED_PI * 3 * t2)); - } - } else { - endCap.push(Vec.Add(lastPoint, Vec.Mul(direction, lastStrokePoint.radius)), Vec.Add(lastPoint, Vec.Mul(direction, lastStrokePoint.radius * 0.99)), Vec.Sub(lastPoint, Vec.Mul(direction, lastStrokePoint.radius * 0.99)), Vec.Sub(lastPoint, Vec.Mul(direction, lastStrokePoint.radius))); - } - return leftPts.concat(endCap, rightPts.reverse(), startCap); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs -var MIN_START_PRESSURE = 0.025; -var MIN_END_PRESSURE = 0.01; -function getStrokePoints(rawInputPoints, options = {}) { - const { streamline = 0.5, size: size4 = 16, simulatePressure = false } = options; - if (rawInputPoints.length === 0) - return []; - const t2 = 0.15 + (1 - streamline) * 0.85; - let pts = rawInputPoints.map(Vec.From); - let pointsRemovedFromNearEnd = 0; - if (!simulatePressure) { - let pt2 = pts[0]; - while (pt2) { - if (pt2.z >= MIN_START_PRESSURE) - break; - pts.shift(); - pt2 = pts[0]; - } - } - if (!simulatePressure) { - let pt2 = pts[pts.length - 1]; - while (pt2) { - if (pt2.z >= MIN_END_PRESSURE) - break; - pts.pop(); - pt2 = pts[pts.length - 1]; - } - } - if (pts.length === 0) - return [ - { - point: Vec.From(rawInputPoints[0]), - input: Vec.From(rawInputPoints[0]), - pressure: simulatePressure ? 0.5 : 0.15, - vector: new Vec(1, 1), - distance: 0, - runningLength: 0, - radius: 1 - } - ]; - let pt = pts[1]; - while (pt) { - if (Vec.Dist2(pt, pts[0]) > (size4 / 3) ** 2) - break; - pts[0].z = Math.max(pts[0].z, pt.z); - pts.splice(1, 1); - pt = pts[1]; - } - const last3 = pts.pop(); - pt = pts[pts.length - 1]; - while (pt) { - if (Vec.Dist2(pt, last3) > (size4 / 3) ** 2) - break; - pts.pop(); - pt = pts[pts.length - 1]; - pointsRemovedFromNearEnd++; - } - pts.push(last3); - const isComplete = options.last || !options.simulatePressure || pts.length > 1 && Vec.Dist2(pts[pts.length - 1], pts[pts.length - 2]) < size4 ** 2 || pointsRemovedFromNearEnd > 0; - if (pts.length === 2 && options.simulatePressure) { - const last22 = pts[1]; - pts = pts.slice(0, -1); - for (let i = 1; i < 5; i++) { - const next = Vec.Lrp(pts[0], last22, i / 4); - next.z = (pts[0].z + (last22.z - pts[0].z)) * i / 4; - pts.push(next); - } - } - const strokePoints = [ - { - point: pts[0], - input: pts[0], - pressure: simulatePressure ? 0.5 : pts[0].z, - vector: new Vec(1, 1), - distance: 0, - runningLength: 0, - radius: 1 - } - ]; - let totalLength = 0; - let prev = strokePoints[0]; - let point, distance; - if (isComplete && streamline > 0) { - pts.push(pts[pts.length - 1].clone()); - } - for (let i = 1, n = pts.length; i < n; i++) { - point = !t2 || options.last && i === n - 1 ? pts[i].clone() : pts[i].clone().lrp(prev.point, 1 - t2); - if (prev.point.equals(point)) - continue; - distance = Vec.Dist(point, prev.point); - totalLength += distance; - if (i < 4 && totalLength < size4) { - continue; - } - prev = { - input: pts[i], - point, - pressure: simulatePressure ? 0.5 : pts[i].z, - vector: Vec.Sub(prev.point, point).uni(), - distance, - runningLength: totalLength, - radius: 1 - }; - strokePoints.push(prev); - } - if (strokePoints[1]?.vector) { - strokePoints[0].vector = strokePoints[1].vector.clone(); - } - if (totalLength < 1) { - const maxPressureAmongPoints = Math.max(0.5, ...strokePoints.map((s) => s.pressure)); - strokePoints.forEach((s) => s.pressure = maxPressureAmongPoints); - } - return strokePoints; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs -var { min } = Math; -var RATE_OF_PRESSURE_CHANGE = 0.275; -function setStrokePointRadii(strokePoints, options) { - const { - size: size4 = 16, - thinning = 0.5, - simulatePressure = true, - easing = (t2) => t2, - start = {}, - end = {} - } = options; - const { easing: taperStartEase = EASINGS.easeOutQuad } = start; - const { easing: taperEndEase = EASINGS.easeOutCubic } = end; - const totalLength = strokePoints[strokePoints.length - 1].runningLength; - let firstRadius; - let prevPressure = strokePoints[0].pressure; - let strokePoint; - if (!simulatePressure && totalLength < size4) { - const max2 = strokePoints.reduce((max22, curr) => Math.max(max22, curr.pressure), 0.5); - strokePoints.forEach((sp) => { - sp.pressure = max2; - sp.radius = size4 * easing(0.5 - thinning * (0.5 - sp.pressure)); - }); - return strokePoints; - } else { - let p; - for (let i = 0, n = strokePoints.length; i < n; i++) { - strokePoint = strokePoints[i]; - if (strokePoint.runningLength > size4 * 5) - break; - const sp = min(1, strokePoint.distance / size4); - if (simulatePressure) { - const rp = min(1, 1 - sp); - p = min(1, prevPressure + (rp - prevPressure) * (sp * RATE_OF_PRESSURE_CHANGE)); - } else { - p = min(1, prevPressure + (strokePoint.pressure - prevPressure) * 0.5); - } - prevPressure = prevPressure + (p - prevPressure) * 0.5; - } - for (let i = 0; i < strokePoints.length; i++) { - strokePoint = strokePoints[i]; - if (thinning) { - let { pressure } = strokePoint; - const sp = min(1, strokePoint.distance / size4); - if (simulatePressure) { - const rp = min(1, 1 - sp); - pressure = min(1, prevPressure + (rp - prevPressure) * (sp * RATE_OF_PRESSURE_CHANGE)); - } else { - pressure = min(1, prevPressure + (pressure - prevPressure) * (sp * RATE_OF_PRESSURE_CHANGE)); - } - strokePoint.radius = size4 * easing(0.5 - thinning * (0.5 - pressure)); - prevPressure = pressure; - } else { - strokePoint.radius = size4 / 2; - } - if (firstRadius === void 0) { - firstRadius = strokePoint.radius; - } - } - } - const taperStart = start.taper === false ? 0 : start.taper === true ? Math.max(size4, totalLength) : start.taper; - const taperEnd = end.taper === false ? 0 : end.taper === true ? Math.max(size4, totalLength) : end.taper; - if (taperStart || taperEnd) { - for (let i = 0; i < strokePoints.length; i++) { - strokePoint = strokePoints[i]; - const { runningLength } = strokePoint; - const ts = runningLength < taperStart ? taperStartEase(runningLength / taperStart) : 1; - const te = totalLength - runningLength < taperEnd ? taperEndEase((totalLength - runningLength) / taperEnd) : 1; - strokePoint.radius = Math.max(0.01, strokePoint.radius * Math.min(ts, te)); - } - } - return strokePoints; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/freehand/getStroke.mjs -function getStroke(points, options = {}) { - return getStrokeOutlinePoints(setStrokePointRadii(getStrokePoints(points, options), options), options); -} - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawScribble.mjs -function TldrawScribble({ scribble, zoom, color, opacity, className }) { - if (!scribble.points.length) - return null; - const stroke = getStroke(scribble.points, { - size: scribble.size / zoom, - start: { taper: scribble.taper, easing: EASINGS.linear }, - last: scribble.state === "stopping", - simulatePressure: false, - streamline: 0.32 - }); - let d; - if (stroke.length < 4) { - const r = scribble.size / zoom / 2; - const { x, y } = scribble.points[scribble.points.length - 1]; - d = `M ${x - r},${y} a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 ${-r * 2},0`; - } else { - d = getSvgPathFromPoints(stroke); - } - return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { className: className ? (0, import_classnames13.default)("tl-overlays__item", className) : className, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { - className: "tl-scribble", - d, - fill: color ?? `var(--color-${scribble.color})`, - opacity: opacity ?? scribble.opacity - }) }); -} - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawSelectionBackground.mjs -var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); -var TldrawSelectionBackground = ({ bounds, rotation }) => { - const editor = useEditor(); - const shouldDisplay = useValue("should display", () => editor.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.pointing_shape", "select.pointing_selection", "text.resizing"), [editor]); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(DefaultSelectionBackground, { bounds, rotation }); -}; - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawSelectionForeground.mjs -var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); -var import_classnames15 = __toESM(require_classnames(), 1); -var import_react45 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useReadonly.mjs -function useReadonly() { - const editor = useEditor(); - return useValue("isReadonlyMode", () => editor.getInstanceState().isReadonly, [editor]); -} - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawCropHandles.mjs -var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); -var import_classnames14 = __toESM(require_classnames(), 1); -function TldrawCropHandles({ - size: size4, - width, - height, - hideAlternateHandles -}) { - const cropStrokeWidth = toDomPrecision(size4 / 3); - const offset4 = cropStrokeWidth / 2; - return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("svg", { className: "tl-overlays__item", children: [ - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("polyline", { - className: "tl-corner-crop-handle", - points: ` - ${toDomPrecision(0 - offset4)},${toDomPrecision(size4)} - ${toDomPrecision(0 - offset4)},${toDomPrecision(0 - offset4)} - ${toDomPrecision(size4)},${toDomPrecision(0 - offset4)}`, - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.top_left", - "aria-label": "top_left handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { - className: (0, import_classnames14.default)("tl-corner-crop-edge-handle", { - "tl-hidden": hideAlternateHandles - }), - x1: toDomPrecision(width / 2 - size4), - y1: toDomPrecision(0 - offset4), - x2: toDomPrecision(width / 2 + size4), - y2: toDomPrecision(0 - offset4), - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.top", - "aria-label": "top handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("polyline", { - className: (0, import_classnames14.default)("tl-corner-crop-handle", { - "tl-hidden": hideAlternateHandles - }), - points: ` - ${toDomPrecision(width - size4)},${toDomPrecision(0 - offset4)} - ${toDomPrecision(width + offset4)},${toDomPrecision(0 - offset4)} - ${toDomPrecision(width + offset4)},${toDomPrecision(size4)}`, - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.top_right", - "aria-label": "top_right handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { - className: (0, import_classnames14.default)("tl-corner-crop-edge-handle", { - "tl-hidden": hideAlternateHandles - }), - x1: toDomPrecision(width + offset4), - y1: toDomPrecision(height / 2 - size4), - x2: toDomPrecision(width + offset4), - y2: toDomPrecision(height / 2 + size4), - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.right", - "aria-label": "right handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("polyline", { - className: "tl-corner-crop-handle", - points: ` - ${toDomPrecision(width + offset4)},${toDomPrecision(height - size4)} - ${toDomPrecision(width + offset4)},${toDomPrecision(height + offset4)} - ${toDomPrecision(width - size4)},${toDomPrecision(height + offset4)}`, - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.bottom_right", - "aria-label": "bottom_right handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { - className: (0, import_classnames14.default)("tl-corner-crop-edge-handle", { - "tl-hidden": hideAlternateHandles - }), - x1: toDomPrecision(width / 2 - size4), - y1: toDomPrecision(height + offset4), - x2: toDomPrecision(width / 2 + size4), - y2: toDomPrecision(height + offset4), - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.bottom", - "aria-label": "bottom handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("polyline", { - className: (0, import_classnames14.default)("tl-corner-crop-handle", { - "tl-hidden": hideAlternateHandles - }), - points: ` - ${toDomPrecision(0 + size4)},${toDomPrecision(height + offset4)} - ${toDomPrecision(0 - offset4)},${toDomPrecision(height + offset4)} - ${toDomPrecision(0 - offset4)},${toDomPrecision(height - size4)}`, - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.bottom_left", - "aria-label": "bottom_left handle" - }), - /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { - className: (0, import_classnames14.default)("tl-corner-crop-edge-handle", { - "tl-hidden": hideAlternateHandles - }), - x1: toDomPrecision(0 - offset4), - y1: toDomPrecision(height / 2 - size4), - x2: toDomPrecision(0 - offset4), - y2: toDomPrecision(height / 2 + size4), - strokeWidth: cropStrokeWidth, - "data-testid": "selection.crop.left", - "aria-label": "left handle" - }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawSelectionForeground.mjs -var TldrawSelectionForeground = track(function TldrawSelectionForeground2({ - bounds, - rotation -}) { - const editor = useEditor(); - const rSvg = (0, import_react45.useRef)(null); - const isReadonlyMode = useReadonly(); - const topEvents = useSelectionEvents("top"); - const rightEvents = useSelectionEvents("right"); - const bottomEvents = useSelectionEvents("bottom"); - const leftEvents = useSelectionEvents("left"); - const topLeftEvents = useSelectionEvents("top_left"); - const topRightEvents = useSelectionEvents("top_right"); - const bottomRightEvents = useSelectionEvents("bottom_right"); - const bottomLeftEvents = useSelectionEvents("bottom_left"); - const isDefaultCursor = !editor.getIsMenuOpen() && editor.getInstanceState().cursor.type === "default"; - const isCoarsePointer = editor.getInstanceState().isCoarsePointer; - const onlyShape = editor.getOnlySelectedShape(); - const isLockedShape = onlyShape && editor.isShapeOrAncestorLocked(onlyShape); - const expandOutlineBy = onlyShape ? editor.getShapeUtil(onlyShape).expandSelectionOutlinePx(onlyShape) : 0; - useTransform(rSvg, bounds?.x, bounds?.y, 1, editor.getSelectionRotation(), { - x: -expandOutlineBy, - y: -expandOutlineBy - }); - if (!bounds) - return null; - bounds = bounds.clone().expandBy(expandOutlineBy).zeroFix(); - const zoom = editor.getZoomLevel(); - const isChangingStyle = editor.getInstanceState().isChangingStyle; - const width = bounds.width; - const height = bounds.height; - const size4 = 8 / zoom; - const isTinyX = width < size4 * 2; - const isTinyY = height < size4 * 2; - const isSmallX = width < size4 * 4; - const isSmallY = height < size4 * 4; - const isSmallCropX = width < size4 * 5; - const isSmallCropY = height < size4 * 5; - const mobileHandleMultiplier = isCoarsePointer ? 1.75 : 1; - const targetSize = 6 / zoom * mobileHandleMultiplier; - const targetSizeX = (isSmallX ? targetSize / 2 : targetSize) * (mobileHandleMultiplier * 0.75); - const targetSizeY = (isSmallY ? targetSize / 2 : targetSize) * (mobileHandleMultiplier * 0.75); - const showSelectionBounds = (onlyShape ? !editor.getShapeUtil(onlyShape).hideSelectionBoundsFg(onlyShape) : true) && !isChangingStyle; - let shouldDisplayBox = showSelectionBounds && editor.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.pointing_canvas", "select.pointing_selection", "select.pointing_shape", "select.crop.idle", "select.crop.pointing_crop", "select.crop.pointing_crop_handle", "select.pointing_resize_handle") || showSelectionBounds && editor.isIn("select.resizing") && onlyShape && editor.isShapeOfType(onlyShape, "text"); - if (onlyShape && shouldDisplayBox) { - if (editor.environment.isFirefox && editor.isShapeOfType(onlyShape, "embed")) { - shouldDisplayBox = false; - } - } - const showCropHandles = editor.isInAny("select.crop.idle", "select.crop.pointing_crop", "select.crop.pointing_crop_handle") && !isChangingStyle && !isReadonlyMode; - const shouldDisplayControls = editor.isInAny("select.idle", "select.pointing_selection", "select.pointing_shape", "select.crop.idle") && !isChangingStyle && !isReadonlyMode; - const showCornerRotateHandles = !isCoarsePointer && !(isTinyX || isTinyY) && (shouldDisplayControls || showCropHandles) && (onlyShape ? !editor.getShapeUtil(onlyShape).hideRotateHandle(onlyShape) : true) && !isLockedShape; - const showMobileRotateHandle = isCoarsePointer && (!isSmallX || !isSmallY) && (shouldDisplayControls || showCropHandles) && (onlyShape ? !editor.getShapeUtil(onlyShape).hideRotateHandle(onlyShape) : true) && !isLockedShape; - const showResizeHandles = shouldDisplayControls && (onlyShape ? editor.getShapeUtil(onlyShape).canResize(onlyShape) && !editor.getShapeUtil(onlyShape).hideResizeHandles(onlyShape) : true) && !showCropHandles && !isLockedShape; - const hideAlternateCornerHandles = isTinyX || isTinyY; - const showOnlyOneHandle = isTinyX && isTinyY; - const hideAlternateCropHandles = isSmallCropX || isSmallCropY; - const showHandles = showResizeHandles || showCropHandles; - const hideRotateCornerHandles = !showCornerRotateHandles; - const hideMobileRotateHandle = !shouldDisplayControls || !showMobileRotateHandle; - const hideTopLeftCorner = !shouldDisplayControls || !showHandles; - const hideTopRightCorner = !shouldDisplayControls || !showHandles || hideAlternateCornerHandles; - const hideBottomLeftCorner = !shouldDisplayControls || !showHandles || hideAlternateCornerHandles; - const hideBottomRightCorner = !shouldDisplayControls || !showHandles || showOnlyOneHandle && !showCropHandles; - let hideVerticalEdgeTargets = true; - let hideHorizontalEdgeTargets = true; - if (showCropHandles) { - hideVerticalEdgeTargets = hideAlternateCropHandles; - hideHorizontalEdgeTargets = hideAlternateCropHandles; - } else if (showResizeHandles) { - hideVerticalEdgeTargets = hideAlternateCornerHandles || showOnlyOneHandle || isCoarsePointer; - const isMobileAndTextShape = isCoarsePointer && onlyShape && onlyShape.type === "text"; - hideHorizontalEdgeTargets = hideVerticalEdgeTargets && !isMobileAndTextShape; - } - const textHandleHeight = Math.min(24 / zoom, height - targetSizeY * 3); - const showTextResizeHandles = shouldDisplayControls && isCoarsePointer && onlyShape && editor.isShapeOfType(onlyShape, "text") && textHandleHeight * zoom >= 4; - return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { className: "tl-overlays__item tl-selection__fg", "data-testid": "selection-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("g", { ref: rSvg, children: [ - shouldDisplayBox && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: "tl-selection__fg__outline", - width: toDomPrecision(width), - height: toDomPrecision(height) - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RotateCornerHandle, { - "data-testid": "selection.rotate.top-left", - cx: 0, - cy: 0, - targetSize, - corner: "top_left_rotate", - cursor: isDefaultCursor ? getCursor("nwse-rotate", rotation) : void 0, - isHidden: hideRotateCornerHandles - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RotateCornerHandle, { - "data-testid": "selection.rotate.top-right", - cx: width + targetSize * 3, - cy: 0, - targetSize, - corner: "top_right_rotate", - cursor: isDefaultCursor ? getCursor("nesw-rotate", rotation) : void 0, - isHidden: hideRotateCornerHandles - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RotateCornerHandle, { - "data-testid": "selection.rotate.bottom-left", - cx: 0, - cy: height + targetSize * 3, - targetSize, - corner: "bottom_left_rotate", - cursor: isDefaultCursor ? getCursor("swne-rotate", rotation) : void 0, - isHidden: hideRotateCornerHandles - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RotateCornerHandle, { - "data-testid": "selection.rotate.bottom-right", - cx: width + targetSize * 3, - cy: height + targetSize * 3, - targetSize, - corner: "bottom_right_rotate", - cursor: isDefaultCursor ? getCursor("senw-rotate", rotation) : void 0, - isHidden: hideRotateCornerHandles - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MobileRotateHandle, { - "data-testid": "selection.rotate.mobile", - cx: isSmallX ? -targetSize * 1.5 : width / 2, - cy: isSmallX ? height / 2 : -targetSize * 1.5, - size: size4, - isHidden: hideMobileRotateHandle - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideVerticalEdgeTargets - }), - "data-testid": "selection.resize.top", - "aria-label": "top target", - pointerEvents: "all", - x: 0, - y: toDomPrecision(0 - (isSmallY ? targetSizeY * 2 : targetSizeY)), - width: toDomPrecision(width), - height: toDomPrecision(Math.max(1, targetSizeY * 2)), - style: isDefaultCursor ? { cursor: getCursor("ns-resize", rotation) } : void 0, - ...topEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideHorizontalEdgeTargets - }), - "data-testid": "selection.resize.right", - "aria-label": "right target", - pointerEvents: "all", - x: toDomPrecision(width - (isSmallX ? 0 : targetSizeX)), - y: 0, - height: toDomPrecision(height), - width: toDomPrecision(Math.max(1, targetSizeX * 2)), - style: isDefaultCursor ? { cursor: getCursor("ew-resize", rotation) } : void 0, - ...rightEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideVerticalEdgeTargets - }), - "data-testid": "selection.resize.bottom", - "aria-label": "bottom target", - pointerEvents: "all", - x: 0, - y: toDomPrecision(height - (isSmallY ? 0 : targetSizeY)), - width: toDomPrecision(width), - height: toDomPrecision(Math.max(1, targetSizeY * 2)), - style: isDefaultCursor ? { cursor: getCursor("ns-resize", rotation) } : void 0, - ...bottomEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideHorizontalEdgeTargets - }), - "data-testid": "selection.resize.left", - "aria-label": "left target", - pointerEvents: "all", - x: toDomPrecision(0 - (isSmallX ? targetSizeX * 2 : targetSizeX)), - y: 0, - height: toDomPrecision(height), - width: toDomPrecision(Math.max(1, targetSizeX * 2)), - style: isDefaultCursor ? { cursor: getCursor("ew-resize", rotation) } : void 0, - ...leftEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideTopLeftCorner - }), - "data-testid": "selection.target.top-left", - "aria-label": "top-left target", - pointerEvents: "all", - x: toDomPrecision(0 - (isSmallX ? targetSizeX * 2 : targetSizeX * 1.5)), - y: toDomPrecision(0 - (isSmallY ? targetSizeY * 2 : targetSizeY * 1.5)), - width: toDomPrecision(targetSizeX * 3), - height: toDomPrecision(targetSizeY * 3), - style: isDefaultCursor ? { cursor: getCursor("nwse-resize", rotation) } : void 0, - ...topLeftEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideTopRightCorner - }), - "data-testid": "selection.target.top-right", - "aria-label": "top-right target", - pointerEvents: "all", - x: toDomPrecision(width - (isSmallX ? 0 : targetSizeX * 1.5)), - y: toDomPrecision(0 - (isSmallY ? targetSizeY * 2 : targetSizeY * 1.5)), - width: toDomPrecision(targetSizeX * 3), - height: toDomPrecision(targetSizeY * 3), - style: isDefaultCursor ? { cursor: getCursor("nesw-resize", rotation) } : void 0, - ...topRightEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideBottomRightCorner - }), - "data-testid": "selection.target.bottom-right", - "aria-label": "bottom-right target", - pointerEvents: "all", - x: toDomPrecision(width - (isSmallX ? targetSizeX : targetSizeX * 1.5)), - y: toDomPrecision(height - (isSmallY ? targetSizeY : targetSizeY * 1.5)), - width: toDomPrecision(targetSizeX * 3), - height: toDomPrecision(targetSizeY * 3), - style: isDefaultCursor ? { cursor: getCursor("nwse-resize", rotation) } : void 0, - ...bottomRightEvents - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", { - "tl-hidden": hideBottomLeftCorner - }), - "data-testid": "selection.target.bottom-left", - "aria-label": "bottom-left target", - pointerEvents: "all", - x: toDomPrecision(0 - (isSmallX ? targetSizeX * 3 : targetSizeX * 1.5)), - y: toDomPrecision(height - (isSmallY ? 0 : targetSizeY * 1.5)), - width: toDomPrecision(targetSizeX * 3), - height: toDomPrecision(targetSizeY * 3), - style: isDefaultCursor ? { cursor: getCursor("nesw-resize", rotation) } : void 0, - ...bottomLeftEvents - }), - showResizeHandles && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - "data-testid": "selection.resize.top-left", - className: (0, import_classnames15.default)("tl-corner-handle", { - "tl-hidden": hideTopLeftCorner - }), - "aria-label": "top_left handle", - x: toDomPrecision(0 - size4 / 2), - y: toDomPrecision(0 - size4 / 2), - width: toDomPrecision(size4), - height: toDomPrecision(size4) - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - "data-testid": "selection.resize.top-right", - className: (0, import_classnames15.default)("tl-corner-handle", { - "tl-hidden": hideTopRightCorner - }), - "aria-label": "top_right handle", - x: toDomPrecision(width - size4 / 2), - y: toDomPrecision(0 - size4 / 2), - width: toDomPrecision(size4), - height: toDomPrecision(size4) - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - "data-testid": "selection.resize.bottom-right", - className: (0, import_classnames15.default)("tl-corner-handle", { - "tl-hidden": hideBottomRightCorner - }), - "aria-label": "bottom_right handle", - x: toDomPrecision(width - size4 / 2), - y: toDomPrecision(height - size4 / 2), - width: toDomPrecision(size4), - height: toDomPrecision(size4) - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - "data-testid": "selection.resize.bottom-left", - className: (0, import_classnames15.default)("tl-corner-handle", { - "tl-hidden": hideBottomLeftCorner - }), - "aria-label": "bottom_left handle", - x: toDomPrecision(0 - size4 / 2), - y: toDomPrecision(height - size4 / 2), - width: toDomPrecision(size4), - height: toDomPrecision(size4) - }) - ] }), - showTextResizeHandles && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - "data-testid": "selection.text-resize.left.handle", - className: "tl-text-handle", - "aria-label": "bottom_left handle", - x: toDomPrecision(0 - size4 / 4), - y: toDomPrecision(height / 2 - textHandleHeight / 2), - rx: size4 / 4, - width: toDomPrecision(size4 / 2), - height: toDomPrecision(textHandleHeight) - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - "data-testid": "selection.text-resize.right.handle", - className: "tl-text-handle", - "aria-label": "bottom_left handle", - rx: size4 / 4, - x: toDomPrecision(width - size4 / 4), - y: toDomPrecision(height / 2 - textHandleHeight / 2), - width: toDomPrecision(size4 / 2), - height: toDomPrecision(textHandleHeight) - }) - ] }), - showCropHandles && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TldrawCropHandles, { - ...{ - size: size4, - width, - height, - hideAlternateHandles: hideAlternateCropHandles - } - }) - ] }) }); -}); -var RotateCornerHandle = function RotateCornerHandle2({ - cx, - cy, - targetSize, - corner, - cursor, - isHidden: isHidden2, - "data-testid": testId -}) { - const events = useSelectionEvents(corner); - return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("rect", { - className: (0, import_classnames15.default)("tl-transparent", "tl-rotate-corner", { "tl-hidden": isHidden2 }), - "data-testid": testId, - "aria-label": `${corner} target`, - pointerEvents: "all", - x: toDomPrecision(cx - targetSize * 3), - y: toDomPrecision(cy - targetSize * 3), - width: toDomPrecision(Math.max(1, targetSize * 3)), - height: toDomPrecision(Math.max(1, targetSize * 3)), - cursor, - ...events - }); -}; -var SQUARE_ROOT_PI = Math.sqrt(Math.PI); -var MobileRotateHandle = function RotateHandle({ - cx, - cy, - size: size4, - isHidden: isHidden2, - "data-testid": testId -}) { - const events = useSelectionEvents("mobile_rotate"); - const editor = useEditor(); - const zoom = useValue("zoom level", () => editor.getZoomLevel(), [editor]); - const bgRadius = Math.max(14 * (1 / zoom), 20 / Math.max(1, zoom)); - return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("g", { children: [ - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("circle", { - "data-testid": testId, - pointerEvents: "all", - className: (0, import_classnames15.default)("tl-transparent", "tl-mobile-rotate__bg", { "tl-hidden": isHidden2 }), - cx, - cy, - r: bgRadius, - ...events - }), - /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("circle", { - className: (0, import_classnames15.default)("tl-mobile-rotate__fg", { "tl-hidden": isHidden2 }), - cx, - cy, - r: size4 / SQUARE_ROOT_PI - }) - ] }); -}; - -// node_modules/tldraw/dist-esm/lib/canvas/TldrawShapeIndicators.mjs -var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); -function TldrawShapeIndicators() { - const editor = useEditor(); - const isInSelectState = useValue("is in a valid select state", () => { - return editor.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.editing_shape", "select.pointing_shape", "select.pointing_selection", "select.pointing_handle"); - }, [editor]); - if (!isInSelectState) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DefaultShapeIndicators, {}); -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/straight-arrow.mjs -function getStraightArrowInfo(editor, shape, bindings) { - const { arrowheadStart, arrowheadEnd } = shape.props; - const terminalsInArrowSpace = getArrowTerminalsInArrowSpace(editor, shape, bindings); - const a = terminalsInArrowSpace.start.clone(); - const b = terminalsInArrowSpace.end.clone(); - const c = Vec.Med(a, b); - if (Vec.Equals(a, b)) { - return { - bindings, - isStraight: true, - start: { - handle: a, - point: a, - arrowhead: shape.props.arrowheadStart - }, - end: { - handle: b, - point: b, - arrowhead: shape.props.arrowheadEnd - }, - middle: c, - isValid: false, - length: 0 - }; - } - const uAB = Vec.Sub(b, a).uni(); - const startShapeInfo = getBoundShapeInfoForTerminal(editor, shape, "start"); - const endShapeInfo = getBoundShapeInfoForTerminal(editor, shape, "end"); - const arrowPageTransform = editor.getShapePageTransform(shape); - updateArrowheadPointWithBoundShape(b, terminalsInArrowSpace.start, arrowPageTransform, endShapeInfo); - updateArrowheadPointWithBoundShape(a, terminalsInArrowSpace.end, arrowPageTransform, startShapeInfo); - let offsetA = 0; - let offsetB = 0; - let strokeOffsetA = 0; - let strokeOffsetB = 0; - let minLength = MIN_ARROW_LENGTH * shape.props.scale; - const isSelfIntersection = startShapeInfo && endShapeInfo && startShapeInfo.shape === endShapeInfo.shape; - const relationship = startShapeInfo && endShapeInfo ? getBoundShapeRelationships(editor, startShapeInfo.shape.id, endShapeInfo.shape.id) : "safe"; - if (relationship === "safe" && startShapeInfo && endShapeInfo && !isSelfIntersection && !startShapeInfo.isExact && !endShapeInfo.isExact) { - if (endShapeInfo.didIntersect && !startShapeInfo.didIntersect) { - if (startShapeInfo.isClosed) { - a.setTo(b.clone().add(uAB.clone().mul(MIN_ARROW_LENGTH * shape.props.scale))); - } - } else if (!endShapeInfo.didIntersect) { - if (endShapeInfo.isClosed) { - b.setTo(a.clone().sub(uAB.clone().mul(MIN_ARROW_LENGTH * shape.props.scale))); - } - } - } - const distance = Vec.Sub(b, a); - const u = Vec.Len(distance) ? distance.uni() : Vec.From(distance); - const didFlip = !Vec.Equals(u, uAB); - if (!isSelfIntersection) { - if (relationship !== "start-contains-end" && startShapeInfo && arrowheadStart !== "none" && !startShapeInfo.isExact) { - strokeOffsetA = STROKE_SIZES[shape.props.size] / 2 + ("size" in startShapeInfo.shape.props ? STROKE_SIZES[startShapeInfo.shape.props.size] / 2 : 0); - offsetA = (BOUND_ARROW_OFFSET + strokeOffsetA) * shape.props.scale; - minLength += strokeOffsetA * shape.props.scale; - } - if (relationship !== "end-contains-start" && endShapeInfo && arrowheadEnd !== "none" && !endShapeInfo.isExact) { - strokeOffsetB = STROKE_SIZES[shape.props.size] / 2 + ("size" in endShapeInfo.shape.props ? STROKE_SIZES[endShapeInfo.shape.props.size] / 2 : 0); - offsetB = (BOUND_ARROW_OFFSET + strokeOffsetB) * shape.props.scale; - minLength += strokeOffsetB * shape.props.scale; - } - } - const tA = a.clone().add(u.clone().mul(offsetA * (didFlip ? -1 : 1))); - const tB = b.clone().sub(u.clone().mul(offsetB * (didFlip ? -1 : 1))); - if (Vec.DistMin(tA, tB, minLength)) { - if (offsetA !== 0 && offsetB !== 0) { - offsetA *= -1.5; - offsetB *= -1.5; - } else if (offsetA !== 0) { - offsetA *= -1; - } else if (offsetB !== 0) { - offsetB *= -1; - } else { - } - } - a.add(u.clone().mul(offsetA * (didFlip ? -1 : 1))); - b.sub(u.clone().mul(offsetB * (didFlip ? -1 : 1))); - if (didFlip) { - if (startShapeInfo && endShapeInfo) { - b.setTo(Vec.Add(a, u.clone().mul(-MIN_ARROW_LENGTH * shape.props.scale))); - } - c.setTo(Vec.Med(terminalsInArrowSpace.start, terminalsInArrowSpace.end)); - } else { - c.setTo(Vec.Med(a, b)); - } - const length = Vec.Dist(a, b); - return { - bindings, - isStraight: true, - start: { - handle: terminalsInArrowSpace.start, - point: a, - arrowhead: shape.props.arrowheadStart - }, - end: { - handle: terminalsInArrowSpace.end, - point: b, - arrowhead: shape.props.arrowheadEnd - }, - middle: c, - isValid: length > 0, - length - }; -} -function updateArrowheadPointWithBoundShape(point, opposite, arrowPageTransform, targetShapeInfo) { - if (targetShapeInfo === void 0) { - return; - } - if (targetShapeInfo.isExact) { - return; - } - const pageFrom = Mat.applyToPoint(arrowPageTransform, opposite); - const pageTo = Mat.applyToPoint(arrowPageTransform, point); - const targetFrom = Mat.applyToPoint(Mat.Inverse(targetShapeInfo.transform), pageFrom); - const targetTo = Mat.applyToPoint(Mat.Inverse(targetShapeInfo.transform), pageTo); - const isClosed = targetShapeInfo.isClosed; - const fn = isClosed ? intersectLineSegmentPolygon : intersectLineSegmentPolyline; - const intersection = fn(targetFrom, targetTo, targetShapeInfo.outline); - let targetInt; - if (intersection !== null) { - targetInt = intersection.sort((p1, p2) => Vec.Dist2(p1, targetFrom) - Vec.Dist2(p2, targetFrom))[0] ?? (isClosed ? void 0 : targetTo); - } - if (targetInt === void 0) { - return; - } - const pageInt = Mat.applyToPoint(targetShapeInfo.transform, targetInt); - const arrowInt = Mat.applyToPoint(Mat.Inverse(arrowPageTransform), pageInt); - point.setTo(arrowInt); - targetShapeInfo.didIntersect = true; -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/curved-arrow.mjs -function getCurvedArrowInfo(editor, shape, bindings) { - const { arrowheadEnd, arrowheadStart } = shape.props; - const bend = shape.props.bend; - if (Math.abs(bend) > Math.abs(shape.props.bend * (WAY_TOO_BIG_ARROW_BEND_FACTOR * shape.props.scale))) { - return getStraightArrowInfo(editor, shape, bindings); - } - const terminalsInArrowSpace = getArrowTerminalsInArrowSpace(editor, shape, bindings); - const med = Vec.Med(terminalsInArrowSpace.start, terminalsInArrowSpace.end); - const distance = Vec.Sub(terminalsInArrowSpace.end, terminalsInArrowSpace.start); - const u = Vec.Len(distance) ? distance.uni() : Vec.From(distance); - const middle = Vec.Add(med, u.per().mul(-bend)); - const startShapeInfo = getBoundShapeInfoForTerminal(editor, shape, "start"); - const endShapeInfo = getBoundShapeInfoForTerminal(editor, shape, "end"); - const a = terminalsInArrowSpace.start.clone(); - const b = terminalsInArrowSpace.end.clone(); - const c = middle.clone(); - if (Vec.Equals(a, b)) { - return { - bindings, - isStraight: true, - start: { - handle: a, - point: a, - arrowhead: shape.props.arrowheadStart - }, - end: { - handle: b, - point: b, - arrowhead: shape.props.arrowheadEnd - }, - middle: c, - isValid: false, - length: 0 - }; - } - const isClockwise = shape.props.bend < 0; - const distFn = isClockwise ? clockwiseAngleDist : counterClockwiseAngleDist; - const handleArc = getArcInfo(a, b, c); - const handle_aCA = Vec.Angle(handleArc.center, a); - const handle_aCB = Vec.Angle(handleArc.center, b); - const handle_dAB = distFn(handle_aCA, handle_aCB); - if (handleArc.length === 0 || handleArc.size === 0 || !isSafeFloat(handleArc.length) || !isSafeFloat(handleArc.size)) { - return getStraightArrowInfo(editor, shape, bindings); - } - const tempA = a.clone(); - const tempB = b.clone(); - const tempC = c.clone(); - const arrowPageTransform = editor.getShapePageTransform(shape); - let offsetA = 0; - let offsetB = 0; - let minLength = MIN_ARROW_LENGTH * shape.props.scale; - if (startShapeInfo && !startShapeInfo.isExact) { - const startInPageSpace = Mat.applyToPoint(arrowPageTransform, tempA); - const centerInPageSpace = Mat.applyToPoint(arrowPageTransform, handleArc.center); - const endInPageSpace = Mat.applyToPoint(arrowPageTransform, tempB); - const inverseTransform = Mat.Inverse(startShapeInfo.transform); - const startInStartShapeLocalSpace = Mat.applyToPoint(inverseTransform, startInPageSpace); - const centerInStartShapeLocalSpace = Mat.applyToPoint(inverseTransform, centerInPageSpace); - const endInStartShapeLocalSpace = Mat.applyToPoint(inverseTransform, endInPageSpace); - const { isClosed } = startShapeInfo; - const fn = isClosed ? intersectCirclePolygon : intersectCirclePolyline; - let point; - let intersections = fn(centerInStartShapeLocalSpace, handleArc.radius, startShapeInfo.outline); - if (intersections) { - const angleToStart = centerInStartShapeLocalSpace.angle(startInStartShapeLocalSpace); - const angleToEnd = centerInStartShapeLocalSpace.angle(endInStartShapeLocalSpace); - const dAB2 = distFn(angleToStart, angleToEnd); - intersections = intersections.filter((pt) => distFn(angleToStart, centerInStartShapeLocalSpace.angle(pt)) <= dAB2); - const targetDist = dAB2 * 0.25; - intersections.sort(isClosed ? (p0, p1) => Math.abs(distFn(angleToStart, centerInStartShapeLocalSpace.angle(p0)) - targetDist) < Math.abs(distFn(angleToStart, centerInStartShapeLocalSpace.angle(p1)) - targetDist) ? -1 : 1 : (p0, p1) => distFn(angleToStart, centerInStartShapeLocalSpace.angle(p0)) < distFn(angleToStart, centerInStartShapeLocalSpace.angle(p1)) ? -1 : 1); - point = intersections[0] ?? (isClosed ? void 0 : startInStartShapeLocalSpace); - } else { - point = isClosed ? void 0 : startInStartShapeLocalSpace; - } - if (point) { - tempA.setTo(editor.getPointInShapeSpace(shape, Mat.applyToPoint(startShapeInfo.transform, point))); - startShapeInfo.didIntersect = true; - if (arrowheadStart !== "none") { - const strokeOffset = STROKE_SIZES[shape.props.size] / 2 + ("size" in startShapeInfo.shape.props ? STROKE_SIZES[startShapeInfo.shape.props.size] / 2 : 0); - offsetA = (BOUND_ARROW_OFFSET + strokeOffset) * shape.props.scale; - minLength += strokeOffset * shape.props.scale; - } - } - } - if (endShapeInfo && !endShapeInfo.isExact) { - const startInPageSpace = Mat.applyToPoint(arrowPageTransform, tempA); - const endInPageSpace = Mat.applyToPoint(arrowPageTransform, tempB); - const centerInPageSpace = Mat.applyToPoint(arrowPageTransform, handleArc.center); - const inverseTransform = Mat.Inverse(endShapeInfo.transform); - const startInEndShapeLocalSpace = Mat.applyToPoint(inverseTransform, startInPageSpace); - const centerInEndShapeLocalSpace = Mat.applyToPoint(inverseTransform, centerInPageSpace); - const endInEndShapeLocalSpace = Mat.applyToPoint(inverseTransform, endInPageSpace); - const isClosed = endShapeInfo.isClosed; - const fn = isClosed ? intersectCirclePolygon : intersectCirclePolyline; - let point; - let intersections = fn(centerInEndShapeLocalSpace, handleArc.radius, endShapeInfo.outline); - if (intersections) { - const angleToStart = centerInEndShapeLocalSpace.angle(startInEndShapeLocalSpace); - const angleToEnd = centerInEndShapeLocalSpace.angle(endInEndShapeLocalSpace); - const dAB2 = distFn(angleToStart, angleToEnd); - const targetDist = dAB2 * 0.75; - intersections = intersections.filter((pt) => distFn(angleToStart, centerInEndShapeLocalSpace.angle(pt)) <= dAB2); - intersections.sort(isClosed ? (p0, p1) => Math.abs(distFn(angleToStart, centerInEndShapeLocalSpace.angle(p0)) - targetDist) < Math.abs(distFn(angleToStart, centerInEndShapeLocalSpace.angle(p1)) - targetDist) ? -1 : 1 : (p0, p1) => distFn(angleToStart, centerInEndShapeLocalSpace.angle(p0)) < distFn(angleToStart, centerInEndShapeLocalSpace.angle(p1)) ? -1 : 1); - if (intersections[0]) { - point = intersections[0]; - } else { - point = isClosed ? void 0 : endInEndShapeLocalSpace; - } - } else { - point = isClosed ? void 0 : endInEndShapeLocalSpace; - } - if (point) { - tempB.setTo(editor.getPointInShapeSpace(shape, Mat.applyToPoint(endShapeInfo.transform, point))); - endShapeInfo.didIntersect = true; - if (arrowheadEnd !== "none") { - const strokeOffset = STROKE_SIZES[shape.props.size] / 2 + ("size" in endShapeInfo.shape.props ? STROKE_SIZES[endShapeInfo.shape.props.size] / 2 : 0); - offsetB = (BOUND_ARROW_OFFSET + strokeOffset) * shape.props.scale; - minLength += strokeOffset * shape.props.scale; - } - } - } - let aCA = Vec.Angle(handleArc.center, tempA); - let aCB = Vec.Angle(handleArc.center, tempB); - let dAB = distFn(aCA, aCB); - let lAB = dAB * handleArc.radius; - const tA = tempA.clone(); - const tB = tempB.clone(); - if (offsetA !== 0) { - tA.setTo(handleArc.center).add(Vec.FromAngle(aCA + dAB * (offsetA / lAB * (isClockwise ? 1 : -1))).mul(handleArc.radius)); - } - if (offsetB !== 0) { - tB.setTo(handleArc.center).add(Vec.FromAngle(aCB + dAB * (offsetB / lAB * (isClockwise ? -1 : 1))).mul(handleArc.radius)); - } - if (Vec.DistMin(tA, tB, minLength)) { - if (offsetA !== 0 && offsetB !== 0) { - offsetA *= -1.5; - offsetB *= -1.5; - } else if (offsetA !== 0) { - offsetA *= -2; - } else if (offsetB !== 0) { - offsetB *= -2; - } else { - } - } - if (offsetA !== 0) { - tempA.setTo(handleArc.center).add(Vec.FromAngle(aCA + dAB * (offsetA / lAB * (isClockwise ? 1 : -1))).mul(handleArc.radius)); - } - if (offsetB !== 0) { - tempB.setTo(handleArc.center).add(Vec.FromAngle(aCB + dAB * (offsetB / lAB * (isClockwise ? -1 : 1))).mul(handleArc.radius)); - } - if (startShapeInfo && endShapeInfo && !startShapeInfo.isExact && !endShapeInfo.isExact) { - aCA = Vec.Angle(handleArc.center, tempA); - aCB = Vec.Angle(handleArc.center, tempB); - dAB = distFn(aCA, aCB); - lAB = dAB * handleArc.radius; - const relationship = getBoundShapeRelationships(editor, startShapeInfo.shape.id, endShapeInfo.shape.id); - if (relationship === "double-bound" && lAB < 30) { - tempA.setTo(a); - tempB.setTo(b); - tempC.setTo(c); - } else if (relationship === "safe") { - if (startShapeInfo && !startShapeInfo.didIntersect) { - tempA.setTo(a); - } - if (endShapeInfo && !endShapeInfo.didIntersect || distFn(handle_aCA, aCA) > distFn(handle_aCA, aCB)) { - tempB.setTo(handleArc.center).add(Vec.FromAngle(aCA + dAB * (Math.min(0.9, MIN_ARROW_LENGTH * shape.props.scale / lAB) * (isClockwise ? 1 : -1))).mul(handleArc.radius)); - } - } - } - placeCenterHandle(handleArc.center, handleArc.radius, tempA, tempB, tempC, handle_dAB, isClockwise); - if (tempA.equals(tempB)) { - tempA.setTo(tempC.clone().addXY(1, 1)); - tempB.setTo(tempC.clone().subXY(1, 1)); - } - a.setTo(tempA); - b.setTo(tempB); - c.setTo(tempC); - const bodyArc = getArcInfo(a, b, c); - return { - bindings, - isStraight: false, - start: { - point: a, - handle: terminalsInArrowSpace.start, - arrowhead: shape.props.arrowheadStart - }, - end: { - point: b, - handle: terminalsInArrowSpace.end, - arrowhead: shape.props.arrowheadEnd - }, - middle: c, - handleArc, - bodyArc, - isValid: bodyArc.length !== 0 && isFinite(bodyArc.center.x) && isFinite(bodyArc.center.y) - }; -} -function getArcInfo(a, b, c) { - const center = centerOfCircleFromThreePoints(a, b, c); - const radius = Vec.Dist(center, a); - const sweepFlag = +Vec.Clockwise(a, c, b); - const ab = ((a.y - b.y) ** 2 + (a.x - b.x) ** 2) ** 0.5; - const bc = ((b.y - c.y) ** 2 + (b.x - c.x) ** 2) ** 0.5; - const ca = ((c.y - a.y) ** 2 + (c.x - a.x) ** 2) ** 0.5; - const theta = Math.acos((bc * bc + ca * ca - ab * ab) / (2 * bc * ca)) * 2; - const largeArcFlag = +(PI > theta); - const size4 = (PI2 - theta) * (sweepFlag ? 1 : -1); - const length = size4 * radius; - return { - center, - radius, - size: size4, - length, - largeArcFlag, - sweepFlag - }; -} -function placeCenterHandle(center, radius, tempA, tempB, tempC, originalArcLength, isClockwise) { - const aCA = Vec.Angle(center, tempA); - const aCB = Vec.Angle(center, tempB); - let dAB = clockwiseAngleDist(aCA, aCB); - if (!isClockwise) - dAB = PI2 - dAB; - tempC.setTo(center).add(Vec.FromAngle(aCA + dAB * (0.5 * (isClockwise ? 1 : -1))).mul(radius)); - if (dAB > originalArcLength) { - tempC.rotWith(center, PI); - const t2 = tempB.clone(); - tempB.setTo(tempA); - tempA.setTo(t2); - } -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/shared.mjs -var MIN_ARROW_BEND = 8; -function getIsArrowStraight(shape) { - return Math.abs(shape.props.bend) < MIN_ARROW_BEND * shape.props.scale; -} -function getBoundShapeInfoForTerminal(editor, arrow4, terminalName) { - const binding = editor.getBindingsFromShape(arrow4, "arrow").find((b) => b.props.terminal === terminalName); - if (!binding) - return; - const boundShape = editor.getShape(binding.toId); - if (!boundShape) - return; - const transform = editor.getShapePageTransform(boundShape); - const geometry = editor.getShapeGeometry(boundShape); - const outline = geometry instanceof Group2d ? geometry.children[0].vertices : geometry.vertices; - return { - shape: boundShape, - transform, - isClosed: geometry.isClosed, - isExact: binding.props.isExact, - didIntersect: false, - outline - }; -} -function getArrowTerminalInArrowSpace(editor, arrowPageTransform, binding, forceImprecise) { - const boundShape = editor.getShape(binding.toId); - if (!boundShape) { - return new Vec(0, 0); - } else { - const { point, size: size4 } = editor.getShapeGeometry(boundShape).bounds; - const shapePoint = Vec.Add(point, Vec.MulV(binding.props.isPrecise || forceImprecise ? binding.props.normalizedAnchor : { x: 0.5, y: 0.5 }, size4)); - const pagePoint = Mat.applyToPoint(editor.getShapePageTransform(boundShape), shapePoint); - const arrowPoint = Mat.applyToPoint(Mat.Inverse(arrowPageTransform), pagePoint); - return arrowPoint; - } -} -function getArrowBindings(editor, shape) { - const bindings = editor.getBindingsFromShape(shape, "arrow"); - return { - start: bindings.find((b) => b.props.terminal === "start"), - end: bindings.find((b) => b.props.terminal === "end") - }; -} -var arrowInfoCache = createComputedCache("arrow info", (editor, shape) => { - const bindings = getArrowBindings(editor, shape); - return getIsArrowStraight(shape) ? getStraightArrowInfo(editor, shape, bindings) : getCurvedArrowInfo(editor, shape, bindings); -}); -function getArrowInfo(editor, shape) { - const id = typeof shape === "string" ? shape : shape.id; - return arrowInfoCache.get(editor, id); -} -function getArrowTerminalsInArrowSpace(editor, shape, bindings) { - const arrowPageTransform = editor.getShapePageTransform(shape); - const boundShapeRelationships = getBoundShapeRelationships(editor, bindings.start?.toId, bindings.end?.toId); - const start = bindings.start ? getArrowTerminalInArrowSpace(editor, arrowPageTransform, bindings.start, boundShapeRelationships === "double-bound" || boundShapeRelationships === "start-contains-end") : Vec.From(shape.props.start); - const end = bindings.end ? getArrowTerminalInArrowSpace(editor, arrowPageTransform, bindings.end, boundShapeRelationships === "double-bound" || boundShapeRelationships === "end-contains-start") : Vec.From(shape.props.end); - return { start, end }; -} -function createOrUpdateArrowBinding(editor, arrow4, target, props) { - const arrowId = typeof arrow4 === "string" ? arrow4 : arrow4.id; - const targetId = typeof target === "string" ? target : target.id; - const existingMany = editor.getBindingsFromShape(arrowId, "arrow").filter((b) => b.props.terminal === props.terminal); - if (existingMany.length > 1) { - editor.deleteBindings(existingMany.slice(1)); - } - const existing = existingMany[0]; - if (existing) { - editor.updateBinding({ - ...existing, - toId: targetId, - props - }); - } else { - editor.createBinding({ - type: "arrow", - fromId: arrowId, - toId: targetId, - props - }); - } -} -function removeArrowBinding(editor, arrow4, terminal) { - const existing = editor.getBindingsFromShape(arrow4, "arrow").filter((b) => b.props.terminal === terminal); - editor.deleteBindings(existing); -} -var MIN_ARROW_LENGTH = 10; -var BOUND_ARROW_OFFSET = 10; -var WAY_TOO_BIG_ARROW_BEND_FACTOR = 10; -var STROKE_SIZES = { - s: 2, - m: 3.5, - l: 5, - xl: 10 -}; -function getBoundShapeRelationships(editor, startShapeId, endShapeId) { - if (!startShapeId || !endShapeId) - return "safe"; - if (startShapeId === endShapeId) - return "double-bound"; - const startBounds = editor.getShapePageBounds(startShapeId); - const endBounds = editor.getShapePageBounds(endShapeId); - if (startBounds && endBounds) { - if (startBounds.contains(endBounds)) - return "start-contains-end"; - if (endBounds.contains(startBounds)) - return "end-contains-start"; - } - return "safe"; -} - -// node_modules/tldraw/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs -var ArrowBindingUtil = class extends BindingUtil { - getDefaultProps() { - return { - isPrecise: false, - isExact: false, - normalizedAnchor: { x: 0.5, y: 0.5 } - }; - } - onAfterCreate({ binding }) { - arrowDidUpdate(this.editor, this.editor.getShape(binding.fromId)); - } - onAfterChange({ bindingAfter }) { - arrowDidUpdate(this.editor, this.editor.getShape(bindingAfter.fromId)); - } - onAfterChangeFromShape({ - shapeAfter - }) { - arrowDidUpdate(this.editor, shapeAfter); - } - onAfterChangeToShape({ binding }) { - reparentArrow(this.editor, binding.fromId); - } - onBeforeIsolateFromShape({ - binding - }) { - const arrow4 = this.editor.getShape(binding.fromId); - if (!arrow4) - return; - updateArrowTerminal({ - editor: this.editor, - arrow: arrow4, - terminal: binding.props.terminal - }); - } -}; -__publicField(ArrowBindingUtil, "type", "arrow"); -__publicField(ArrowBindingUtil, "props", arrowBindingProps); -__publicField(ArrowBindingUtil, "migrations", arrowBindingMigrations); -function reparentArrow(editor, arrowId) { - const arrow4 = editor.getShape(arrowId); - if (!arrow4) - return; - const bindings = getArrowBindings(editor, arrow4); - const { start, end } = bindings; - const startShape = start ? editor.getShape(start.toId) : void 0; - const endShape = end ? editor.getShape(end.toId) : void 0; - const parentPageId = editor.getAncestorPageId(arrow4); - if (!parentPageId) - return; - let nextParentId; - if (startShape && endShape) { - nextParentId = editor.findCommonAncestor([startShape, endShape]) ?? parentPageId; - } else if (startShape || endShape) { - const bindingParentId = (startShape || endShape)?.parentId; - if (bindingParentId && bindingParentId === arrow4.parentId) { - nextParentId = arrow4.parentId; - } else { - nextParentId = parentPageId; - } - } else { - return; - } - if (nextParentId && nextParentId !== arrow4.parentId) { - editor.reparentShapes([arrowId], nextParentId); - } - const reparentedArrow = editor.getShape(arrowId); - if (!reparentedArrow) - throw Error("no reparented arrow"); - const startSibling = editor.getShapeNearestSibling(reparentedArrow, startShape); - const endSibling = editor.getShapeNearestSibling(reparentedArrow, endShape); - let highestSibling; - if (startSibling && endSibling) { - highestSibling = startSibling.index > endSibling.index ? startSibling : endSibling; - } else if (startSibling && !endSibling) { - highestSibling = startSibling; - } else if (endSibling && !startSibling) { - highestSibling = endSibling; - } else { - return; - } - let finalIndex; - const higherSiblings = editor.getSortedChildIdsForParent(highestSibling.parentId).map((id) => editor.getShape(id)).filter((sibling) => sibling.index > highestSibling.index); - if (higherSiblings.length) { - const nextHighestNonArrowSibling = higherSiblings.find((sibling) => sibling.type !== "arrow"); - if (reparentedArrow.index > highestSibling.index && (!nextHighestNonArrowSibling || reparentedArrow.index < nextHighestNonArrowSibling.index)) { - return; - } - finalIndex = getIndexBetween(highestSibling.index, higherSiblings[0].index); - } else { - finalIndex = getIndexAbove(highestSibling.index); - } - if (finalIndex !== reparentedArrow.index) { - editor.updateShapes([{ id: arrowId, type: "arrow", index: finalIndex }]); - } -} -function arrowDidUpdate(editor, arrow4) { - const bindings = getArrowBindings(editor, arrow4); - for (const handle of ["start", "end"]) { - const binding = bindings[handle]; - if (!binding) - continue; - const boundShape = editor.getShape(binding.toId); - const isShapeInSamePageAsArrow = editor.getAncestorPageId(arrow4) === editor.getAncestorPageId(boundShape); - if (!boundShape || !isShapeInSamePageAsArrow) { - updateArrowTerminal({ editor, arrow: arrow4, terminal: handle, unbind: true }); - } - } - reparentArrow(editor, arrow4.id); -} -function updateArrowTerminal({ - editor, - arrow: arrow4, - terminal, - unbind: unbind2 = false, - useHandle = false -}) { - const info2 = getArrowInfo(editor, arrow4); - if (!info2) { - throw new Error("expected arrow info"); - } - const startPoint = useHandle ? info2.start.handle : info2.start.point; - const endPoint = useHandle ? info2.end.handle : info2.end.point; - const point = terminal === "start" ? startPoint : endPoint; - const update = { - id: arrow4.id, - type: "arrow", - props: { - [terminal]: { x: point.x, y: point.y }, - bend: arrow4.props.bend - } - }; - if (!info2.isStraight) { - const newStart = terminal === "start" ? startPoint : info2.start.handle; - const newEnd = terminal === "end" ? endPoint : info2.end.handle; - const newMidPoint = Vec.Med(newStart, newEnd); - const lineSegment = Vec.Sub(newStart, newEnd).per().uni().mul(info2.handleArc.radius * 2 * Math.sign(arrow4.props.bend)); - const intersections = intersectLineSegmentCircle(info2.handleArc.center, Vec.Add(newMidPoint, lineSegment), info2.handleArc.center, info2.handleArc.radius); - assert(intersections?.length === 1); - const bend = Vec.Dist(newMidPoint, intersections[0]) * Math.sign(arrow4.props.bend); - if (!approximately(bend, update.props.bend)) { - update.props.bend = bend; - } - } - editor.updateShape(update); - if (unbind2) { - removeArrowBinding(editor, arrow4, terminal); - } -} - -// node_modules/tldraw/dist-esm/lib/defaultBindingUtils.mjs -var defaultBindingUtils = [ArrowBindingUtil]; - -// node_modules/tldraw/dist-esm/lib/shapes/shared/default-shape-constants.mjs -var TEXT_PROPS = { - lineHeight: 1.35, - fontWeight: "normal", - fontVariant: "normal", - fontStyle: "normal", - padding: "0px" -}; -var STROKE_SIZES2 = { - s: 2, - m: 3.5, - l: 5, - xl: 10 -}; -var FONT_SIZES = { - s: 18, - m: 24, - l: 36, - xl: 44 -}; -var LABEL_FONT_SIZES = { - s: 18, - m: 22, - l: 26, - xl: 32 -}; -var ARROW_LABEL_FONT_SIZES = { - s: 18, - m: 20, - l: 24, - xl: 28 -}; -var FONT_FAMILIES = { - draw: "var(--tl-font-draw)", - sans: "var(--tl-font-sans)", - serif: "var(--tl-font-serif)", - mono: "var(--tl-font-mono)" -}; -var LABEL_TO_ARROW_PADDING = 20; -var ARROW_LABEL_PADDING = 4.25; -var LABEL_PADDING = 16; - -// node_modules/canvas-size/dist/canvas-size.esm.js -function _iterableToArrayLimit(arr, i) { - var _i = arr == null ? null : typeof Symbol != "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; - if (_i != null) { - var _s, _e, _x, _r, _arr = [], _n = true, _d = false; - try { - if (_x = (_i = _i.call(arr)).next, i === 0) { - if (Object(_i) !== _i) - return; - _n = false; - } else - for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = true) - ; - } catch (err) { - _d = true, _e = err; - } finally { - try { - if (!_n && _i.return != null && (_r = _i.return(), Object(_r) !== _r)) - return; - } finally { - if (_d) - throw _e; - } - } - return _arr; - } -} -function ownKeys(object2, enumerableOnly) { - var keys = Object.keys(object2); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object2); - enumerableOnly && (symbols = symbols.filter(function(sym) { - return Object.getOwnPropertyDescriptor(object2, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - return keys; -} -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), true).forEach(function(key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - return target; -} -function _defineProperty(obj, key, value) { - key = _toPropertyKey(key); - if (key in obj) { - Object.defineProperty(obj, key, { - value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} -function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) - return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) - continue; - target[key] = source[key]; - } - return target; -} -function _objectWithoutProperties(source, excluded) { - if (source == null) - return {}; - var target = _objectWithoutPropertiesLoose(source, excluded); - var key, i; - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - for (i = 0; i < sourceSymbolKeys.length; i++) { - key = sourceSymbolKeys[i]; - if (excluded.indexOf(key) >= 0) - continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key)) - continue; - target[key] = source[key]; - } - } - return target; -} -function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); -} -function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); -} -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) - return _arrayLikeToArray(arr); -} -function _arrayWithHoles(arr) { - if (Array.isArray(arr)) - return arr; -} -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) - return Array.from(iter); -} -function _unsupportedIterableToArray(o, minLen) { - if (!o) - return; - if (typeof o === "string") - return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) - n = o.constructor.name; - if (n === "Map" || n === "Set") - return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) - return _arrayLikeToArray(o, minLen); -} -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) - len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) - arr2[i] = arr[i]; - return arr2; -} -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -function _toPrimitive(input, hint) { - if (typeof input !== "object" || input === null) - return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== void 0) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") - return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} -function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return typeof key === "symbol" ? key : String(key); -} -function canvasTest(settings) { - var size4 = settings.sizes.shift(); - var width = Math.max(Math.ceil(size4[0]), 1); - var height = Math.max(Math.ceil(size4[1]), 1); - var fill = [width - 1, height - 1, 1, 1]; - var job = Date.now(); - var isWorker = typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope; - var cropCvs, testCvs; - if (isWorker) { - cropCvs = new OffscreenCanvas(1, 1); - testCvs = new OffscreenCanvas(width, height); - } else { - cropCvs = document.createElement("canvas"); - cropCvs.width = 1; - cropCvs.height = 1; - testCvs = document.createElement("canvas"); - testCvs.width = width; - testCvs.height = height; - } - var cropCtx = cropCvs.getContext("2d"); - var testCtx = testCvs.getContext("2d"); - if (testCtx) { - testCtx.fillRect.apply(testCtx, fill); - cropCtx.drawImage(testCvs, width - 1, height - 1, 1, 1, 0, 0, 1, 1); - } - var isTestPass = cropCtx && cropCtx.getImageData(0, 0, 1, 1).data[3] !== 0; - var benchmark = Date.now() - job; - [cropCvs, testCvs].forEach(function(cvs) { - cvs.height = 0; - cvs.width = 0; - }); - if (isWorker) { - postMessage({ - width, - height, - benchmark, - isTestPass - }); - if (!isTestPass && settings.sizes.length) { - canvasTest(settings); - } - } else if (isTestPass) { - settings.onSuccess(width, height, benchmark); - } else { - settings.onError(width, height, benchmark); - if (settings.sizes.length) { - canvasTest(settings); - } - } - return isTestPass; -} -var testSizes = { - area: [16384, 14188, 11402, 11180, 10836, 8192, 4096, 1], - height: [8388607, 65535, 32767, 16384, 8192, 4096, 1], - width: [4194303, 65535, 32767, 16384, 8192, 4096, 1] -}; -var _excluded = ["onError", "onSuccess"]; -var defaults = { - max: null, - min: 1, - sizes: [], - step: 1024, - usePromise: false, - useWorker: false, - onError: Function.prototype, - onSuccess: Function.prototype -}; -var workerJobs = {}; -function createSizesArray(settings) { - var isArea = settings.width === settings.height; - var isWidth = settings.height === 1; - var isHeight = settings.width === 1; - var sizes = []; - if (!settings.width || !settings.height) { - settings.sizes.forEach(function(testSize2) { - var width2 = isArea || isWidth ? testSize2 : 1; - var height2 = isArea || isHeight ? testSize2 : 1; - sizes.push([width2, height2]); - }); - } else { - var testMin = settings.min || defaults.min; - var testStep = settings.step || defaults.step; - var testSize = Math.max(settings.width, settings.height); - while (testSize >= testMin) { - var width = isArea || isWidth ? testSize : 1; - var height = isArea || isHeight ? testSize : 1; - sizes.push([width, height]); - testSize -= testStep; - } - } - return sizes; -} -function handleMethod(settings) { - var hasCanvasSupport = window && "HTMLCanvasElement" in window; - var hasOffscreenCanvasSupport = window && "OffscreenCanvas" in window; - var jobID = Date.now(); - var _onError = settings.onError, _onSuccess = settings.onSuccess, settingsWithoutCallbacks = _objectWithoutProperties(settings, _excluded); - var worker = null; - if (!hasCanvasSupport) { - return false; - } - if (settings.useWorker && hasOffscreenCanvasSupport) { - var js = "\n var canvasTest = ".concat(canvasTest.toString(), ";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "); - var blob = new Blob([js], { - type: "application/javascript" - }); - var blobURL = URL.createObjectURL(blob); - worker = new Worker(blobURL); - URL.revokeObjectURL(blobURL); - worker.onmessage = function(e) { - var _e$data = e.data, width = _e$data.width, height = _e$data.height, benchmark = _e$data.benchmark, isTestPass = _e$data.isTestPass; - if (isTestPass) { - workerJobs[jobID].onSuccess(width, height, benchmark); - delete workerJobs[jobID]; - } else { - workerJobs[jobID].onError(width, height, benchmark); - } - }; - } - if (settings.usePromise) { - return new Promise(function(resolve, reject) { - var promiseSettings = _objectSpread2(_objectSpread2({}, settings), {}, { - onError: function onError2(width, height, benchmark) { - var isLastTest; - if (settings.sizes.length === 0) { - isLastTest = true; - } else { - var _settings$sizes$slice = settings.sizes.slice(-1), _settings$sizes$slice2 = _slicedToArray(_settings$sizes$slice, 1), _settings$sizes$slice3 = _slicedToArray(_settings$sizes$slice2[0], 2), lastWidth = _settings$sizes$slice3[0], lastHeight = _settings$sizes$slice3[1]; - isLastTest = width === lastWidth && height === lastHeight; - } - _onError(width, height, benchmark); - if (isLastTest) { - reject({ - width, - height, - benchmark - }); - } - }, - onSuccess: function onSuccess2(width, height, benchmark) { - _onSuccess(width, height, benchmark); - resolve({ - width, - height, - benchmark - }); - } - }); - if (worker) { - var onError = promiseSettings.onError, onSuccess = promiseSettings.onSuccess; - workerJobs[jobID] = { - onError, - onSuccess - }; - worker.postMessage(settingsWithoutCallbacks); - } else { - canvasTest(promiseSettings); - } - }); - } else { - if (worker) { - workerJobs[jobID] = { - onError: _onError, - onSuccess: _onSuccess - }; - worker.postMessage(settingsWithoutCallbacks); - } else { - return canvasTest(settings); - } - } -} -var canvasSize = { - maxArea: function maxArea() { - var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - var sizes = createSizesArray({ - width: options.max, - height: options.max, - min: options.min, - step: options.step, - sizes: _toConsumableArray(testSizes.area) - }); - var settings = _objectSpread2(_objectSpread2(_objectSpread2({}, defaults), options), {}, { - sizes - }); - return handleMethod(settings); - }, - maxHeight: function maxHeight() { - var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - var sizes = createSizesArray({ - width: 1, - height: options.max, - min: options.min, - step: options.step, - sizes: _toConsumableArray(testSizes.height) - }); - var settings = _objectSpread2(_objectSpread2(_objectSpread2({}, defaults), options), {}, { - sizes - }); - return handleMethod(settings); - }, - maxWidth: function maxWidth() { - var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - var sizes = createSizesArray({ - width: options.max, - height: 1, - min: options.min, - step: options.step, - sizes: _toConsumableArray(testSizes.width) - }); - var settings = _objectSpread2(_objectSpread2(_objectSpread2({}, defaults), options), {}, { - sizes - }); - return handleMethod(settings); - }, - test: function test() { - var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - var settings = _objectSpread2(_objectSpread2({}, defaults), options); - settings.sizes = _toConsumableArray(settings.sizes); - if (settings.width && settings.height) { - settings.sizes = [[settings.width, settings.height]]; - } - return handleMethod(settings); - } -}; - -// node_modules/tldraw/dist-esm/lib/shapes/shared/getBrowserCanvasMaxSize.mjs -var maxSizePromise = null; -function getBrowserCanvasMaxSize() { - if (!maxSizePromise) { - maxSizePromise = calculateBrowserCanvasMaxSize(); - } - return maxSizePromise; -} -async function calculateBrowserCanvasMaxSize() { - const maxWidth2 = await canvasSize.maxWidth({ usePromise: true }); - const maxHeight2 = await canvasSize.maxHeight({ usePromise: true }); - const maxArea2 = await canvasSize.maxArea({ usePromise: true }); - return { - maxWidth: maxWidth2.width, - maxHeight: maxHeight2.height, - maxArea: maxArea2.width * maxArea2.height - }; -} -var MAX_SAFE_CANVAS_DIMENSION = 8192; -var MAX_SAFE_CANVAS_AREA = 4096 * 4096; -async function clampToBrowserMaxCanvasSize(width, height) { - if (width <= MAX_SAFE_CANVAS_DIMENSION && height <= MAX_SAFE_CANVAS_DIMENSION && width * height <= MAX_SAFE_CANVAS_AREA) { - return [width, height]; - } - const { maxWidth: maxWidth2, maxHeight: maxHeight2, maxArea: maxArea2 } = await getBrowserCanvasMaxSize(); - const aspectRatio = width / height; - if (width > maxWidth2) { - width = maxWidth2; - height = width / aspectRatio; - } - if (height > maxHeight2) { - height = maxHeight2; - width = height * aspectRatio; - } - if (width * height > maxArea2) { - const ratio = Math.sqrt(maxArea2 / (width * height)); - width *= ratio; - height *= ratio; - } - return [width, height]; -} - -// node_modules/tldraw/dist-esm/lib/utils/embeds/embeds.mjs -function escapeStringRegexp(string2) { - if (typeof string2 !== "string") { - throw new TypeError("Expected a string"); - } - return string2.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d"); -} -function matchEmbedUrl(url) { - const host = new URL(url).host.replace("www.", ""); - for (const localEmbedDef of EMBED_DEFINITIONS) { - if (checkHostnames(localEmbedDef.hostnames, host)) { - const originalUrl = localEmbedDef.fromEmbedUrl(url); - if (originalUrl) { - return { - definition: localEmbedDef, - url: originalUrl, - embedUrl: url - }; - } - } - } -} -var globlikeRegExp = (input) => { - return input.split("*").map((str) => escapeStringRegexp(str)).join(".+"); -}; -var checkHostnames = (hostnames, targetHostname) => { - return !!hostnames.find((hostname) => { - const re = new RegExp(globlikeRegExp(hostname)); - return targetHostname.match(re); - }); -}; -function matchUrl(url) { - const host = new URL(url).host.replace("www.", ""); - for (const localEmbedDef of EMBED_DEFINITIONS) { - if (checkHostnames(localEmbedDef.hostnames, host)) { - const embedUrl = localEmbedDef.toEmbedUrl(url); - if (embedUrl) { - return { - definition: localEmbedDef, - embedUrl, - url - }; - } - } - } -} -function getEmbedInfoUnsafely(inputUrl) { - const result = matchUrl(inputUrl) ?? matchEmbedUrl(inputUrl); - return result; -} -function getEmbedInfo(inputUrl) { - try { - return getEmbedInfoUnsafely(inputUrl); - } catch (e) { - console.error(e); - } - return void 0; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/TextHelpers.mjs -var INDENT = " "; -var _TextHelpers = class { - static insertTextFirefox(field, text) { - field.setRangeText(text, field.selectionStart || 0, field.selectionEnd || 0, "end"); - field.dispatchEvent(new InputEvent("input", { - data: text, - inputType: "insertText", - isComposing: false - })); - } - static insert(field, text) { - const document2 = field.ownerDocument; - const initialFocus = document2.activeElement; - if (initialFocus !== field) { - field.focus(); - } - if (!document2.execCommand("insertText", false, text)) { - _TextHelpers.insertTextFirefox(field, text); - } - if (initialFocus === document2.body) { - field.blur(); - } else if (initialFocus instanceof HTMLElement && initialFocus !== field) { - initialFocus.focus(); - } - } - static set(field, text) { - field.select(); - _TextHelpers.insert(field, text); - } - static getSelection(field) { - const { selectionStart, selectionEnd } = field; - return field.value.slice(selectionStart ? selectionStart : void 0, selectionEnd ? selectionEnd : void 0); - } - static wrapSelection(field, wrap2, wrapEnd) { - const { selectionStart, selectionEnd } = field; - const selection = _TextHelpers.getSelection(field); - _TextHelpers.insert(field, wrap2 + selection + (wrapEnd ?? wrap2)); - field.selectionStart = (selectionStart || 0) + wrap2.length; - field.selectionEnd = (selectionEnd || 0) + wrap2.length; - } - static replace(field, searchValue, replacer) { - let drift = 0; - field.value.replace(searchValue, (...args) => { - const matchStart = drift + args[args.length - 2]; - const matchLength = args[0].length; - field.selectionStart = matchStart; - field.selectionEnd = matchStart + matchLength; - const replacement = typeof replacer === "string" ? replacer : replacer(...args); - _TextHelpers.insert(field, replacement); - field.selectionStart = matchStart; - drift += replacement.length - matchLength; - return replacement; - }); - } - static findLineEnd(value, currentEnd) { - const lastLineStart = value.lastIndexOf("\n", currentEnd - 1) + 1; - if (value.charAt(lastLineStart) !== " ") { - return currentEnd; - } - return lastLineStart + 1; - } - static indent(element) { - const { selectionStart, selectionEnd, value } = element; - const selectedContrast = value.slice(selectionStart, selectionEnd); - const lineBreakCount = /\n/g.exec(selectedContrast)?.length; - if (lineBreakCount && lineBreakCount > 0) { - const firstLineStart = value.lastIndexOf("\n", selectionStart - 1) + 1; - const newSelection = element.value.slice(firstLineStart, selectionEnd - 1); - const indentedText = newSelection.replace(/^|\n/g, `$&${INDENT}`); - const replacementsCount = indentedText.length - newSelection.length; - element.setSelectionRange(firstLineStart, selectionEnd - 1); - _TextHelpers.insert(element, indentedText); - element.setSelectionRange(selectionStart + 1, selectionEnd + replacementsCount); - } else { - _TextHelpers.insert(element, INDENT); - } - } - static unindent(element) { - const { selectionStart, selectionEnd, value } = element; - const firstLineStart = value.lastIndexOf("\n", selectionStart - 1) + 1; - const minimumSelectionEnd = _TextHelpers.findLineEnd(value, selectionEnd); - const newSelection = element.value.slice(firstLineStart, minimumSelectionEnd); - const indentedText = newSelection.replace(/(^|\n)(\t| {1,2})/g, "$1"); - const replacementsCount = newSelection.length - indentedText.length; - element.setSelectionRange(firstLineStart, minimumSelectionEnd); - _TextHelpers.insert(element, indentedText); - const firstLineIndentation = /\t| {1,2}/.exec(value.slice(firstLineStart, selectionStart)); - const difference = firstLineIndentation ? firstLineIndentation[0].length : 0; - const newSelectionStart = selectionStart - difference; - element.setSelectionRange(selectionStart - difference, Math.max(newSelectionStart, selectionEnd - replacementsCount)); - } - static indentCE(element) { - const selection = window.getSelection(); - const value = element.innerText; - const selectionStart = getCaretIndex(element) ?? 0; - const selectionEnd = getCaretIndex(element) ?? 0; - const selectedContrast = value.slice(selectionStart, selectionEnd); - const lineBreakCount = /\n/g.exec(selectedContrast)?.length; - if (lineBreakCount && lineBreakCount > 0) { - const firstLineStart = value.lastIndexOf("\n", selectionStart - 1) + 1; - const newSelection = value.slice(firstLineStart, selectionEnd - 1); - const indentedText = newSelection.replace(/^|\n/g, `$&${INDENT}`); - const replacementsCount = indentedText.length - newSelection.length; - if (selection) { - selection.setBaseAndExtent(element, selectionStart + 1, element, selectionEnd + replacementsCount); - } - } else { - const selection2 = window.getSelection(); - element.innerText = value.slice(0, selectionStart) + INDENT + value.slice(selectionStart); - selection2?.setBaseAndExtent(element, selectionStart + 1, element, selectionStart + 2); - } - } - static unindentCE(element) { - const selection = window.getSelection(); - const value = element.innerText; - const selectionStart = getCaretIndex(element) ?? 0; - const selectionEnd = getCaretIndex(element) ?? 0; - const firstLineStart = value.lastIndexOf("\n", selectionStart - 1) + 1; - const minimumSelectionEnd = _TextHelpers.findLineEnd(value, selectionEnd); - const newSelection = value.slice(firstLineStart, minimumSelectionEnd); - const indentedText = newSelection.replace(/(^|\n)(\t| {1,2})/g, "$1"); - const replacementsCount = newSelection.length - indentedText.length; - if (selection) { - selection.setBaseAndExtent(element, firstLineStart, element, minimumSelectionEnd); - const firstLineIndentation = /\t| {1,2}/.exec(value.slice(firstLineStart, selectionStart)); - const difference = firstLineIndentation ? firstLineIndentation[0].length : 0; - const newSelectionStart = selectionStart - difference; - selection.setBaseAndExtent(element, selectionStart - difference, element, Math.max(newSelectionStart, selectionEnd - replacementsCount)); - } - } - static normalizeText(text) { - return text.replace(_TextHelpers.fixNewLines, "\n"); - } - static normalizeTextForDom(text) { - return text.replace(_TextHelpers.fixNewLines, "\n").split("\n").map((x) => x || " ").join("\n"); - } -}; -var TextHelpers = _TextHelpers; -__publicField(TextHelpers, "fixNewLines", /\r?\n|\r/g); -function getCaretIndex(element) { - if (typeof window.getSelection === "undefined") - return; - const selection = window.getSelection(); - if (!selection) - return; - let position = 0; - if (selection.rangeCount !== 0) { - const range = selection.getRangeAt(0); - const preCaretRange = range.cloneRange(); - preCaretRange.selectNodeContents(element); - preCaretRange.setEnd(range.endContainer, range.endOffset); - position = preCaretRange.toString().length; - } - return position; -} - -// node_modules/tldraw/dist-esm/lib/utils/text/text.mjs -var rtlRegex = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/; -function isRightToLeftLanguage(text) { - return rtlRegex.test(text); -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs -var Idle2 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - __publicField(this, "onKeyUp", (info2) => { - if (info2.key === "Enter") { - if (this.editor.getInstanceState().isReadonly) - return null; - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape && this.editor.getShapeUtil(onlySelectedShape).canEdit(onlySelectedShape)) { - this.editor.setCurrentTool("select"); - this.editor.setEditingShape(onlySelectedShape.id); - this.editor.root.getCurrent()?.transition("editing_shape", { - ...info2, - target: "shape", - shape: onlySelectedShape - }); - } - } - }); - } -}; -__publicField(Idle2, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs -var Pointing2 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shape"); - __publicField(this, "markId", ""); - __publicField(this, "onEnter", () => { - this.didTimeout = false; - const target = this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, { - filter: (targetShape) => { - return !targetShape.isLocked && this.editor.canBindShapes({ fromShape: "arrow", toShape: targetShape, binding: "arrow" }); - }, - margin: 0, - hitInside: true, - renderingOnly: true - }); - if (!target) { - this.createArrowShape(); - } else { - this.editor.setHintingShapes([target.id]); - } - this.startPreciseTimeout(); - }); - __publicField(this, "onExit", () => { - this.shape = void 0; - this.editor.setHintingShapes([]); - this.clearPreciseTimeout(); - }); - __publicField(this, "onPointerMove", () => { - if (this.editor.inputs.isDragging) { - if (!this.shape) { - this.createArrowShape(); - } - if (!this.shape) - throw Error(`expected shape`); - this.updateArrowShapeEndHandle(); - this.editor.setCurrentTool("select.dragging_handle", { - shape: this.shape, - handle: { id: "end", type: "vertex", index: "a3", x: 0, y: 0 }, - isCreating: true, - onInteractionEnd: "arrow" - }); - } - }); - __publicField(this, "onPointerUp", () => { - this.cancel(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - __publicField(this, "preciseTimeout", -1); - __publicField(this, "didTimeout", false); - } - cancel() { - if (this.shape) { - this.editor.bailToMark(this.markId); - } - this.editor.setHintingShapes([]); - this.parent.transition("idle"); - } - createArrowShape() { - const { originPagePoint } = this.editor.inputs; - const id = createShapeId(); - this.markId = `creating:${id}`; - this.editor.mark(this.markId); - this.editor.createShape({ - id, - type: "arrow", - x: originPagePoint.x, - y: originPagePoint.y, - props: { - scale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1 - } - }); - const shape = this.editor.getShape(id); - if (!shape) - throw Error(`expected shape`); - const handles = this.editor.getShapeHandles(shape); - if (!handles) - throw Error(`expected handles for arrow`); - const util = this.editor.getShapeUtil("arrow"); - const initial = this.shape; - const startHandle = handles.find((h) => h.id === "start"); - const change = util.onHandleDrag?.(shape, { - handle: { ...startHandle, x: 0, y: 0 }, - isPrecise: true, - initial - }); - if (change) { - this.editor.updateShapes([change]); - } - this.shape = this.editor.getShape(id); - this.editor.select(id); - } - updateArrowShapeEndHandle() { - const shape = this.shape; - if (!shape) - throw Error(`expected shape`); - const handles = this.editor.getShapeHandles(shape); - if (!handles) - throw Error(`expected handles for arrow`); - { - const util = this.editor.getShapeUtil("arrow"); - const initial = this.shape; - const startHandle = handles.find((h) => h.id === "start"); - const change = util.onHandleDrag?.(shape, { - handle: { ...startHandle, x: 0, y: 0 }, - isPrecise: this.didTimeout, - initial - }); - if (change) { - this.editor.updateShapes([change]); - } - } - { - const util = this.editor.getShapeUtil("arrow"); - const initial = this.shape; - const point = this.editor.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint); - const endHandle = handles.find((h) => h.id === "end"); - const change = util.onHandleDrag?.(this.editor.getShape(shape), { - handle: { ...endHandle, x: point.x, y: point.y }, - isPrecise: false, - initial - }); - if (change) { - this.editor.updateShapes([change]); - } - } - this.shape = this.editor.getShape(shape.id); - } - startPreciseTimeout() { - this.preciseTimeout = this.editor.timers.setTimeout(() => { - if (!this.getIsActive()) - return; - this.didTimeout = true; - }, 320); - } - clearPreciseTimeout() { - clearTimeout(this.preciseTimeout); - } -}; -__publicField(Pointing2, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/ArrowShapeTool.mjs -var ArrowShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "arrow"); - } -}; -__publicField(ArrowShapeTool, "id", "arrow"); -__publicField(ArrowShapeTool, "initial", "idle"); -__publicField(ArrowShapeTool, "children", () => [Idle2, Pointing2]); - -// node_modules/tldraw/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs -var Drawing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "initialShape"); - __publicField(this, "shapeType", this.parent.id === "highlight" ? "highlight" : "draw"); - __publicField(this, "util", this.editor.getShapeUtil(this.shapeType)); - __publicField(this, "isPen", false); - __publicField(this, "isPenOrStylus", false); - __publicField(this, "segmentMode", "free"); - __publicField(this, "didJustShiftClickToExtendPreviousShapeLine", false); - __publicField(this, "pagePointWhereCurrentSegmentChanged", {}); - __publicField(this, "pagePointWhereNextSegmentChanged", null); - __publicField(this, "lastRecordedPoint", {}); - __publicField(this, "mergeNextPoint", false); - __publicField(this, "currentLineLength", 0); - __publicField(this, "canDraw", false); - __publicField(this, "markId", null); - __publicField(this, "onEnter", (info2) => { - this.markId = null; - this.info = info2; - this.canDraw = !this.editor.getIsMenuOpen(); - this.lastRecordedPoint = this.editor.inputs.currentPagePoint.clone(); - if (this.canDraw) { - this.startShape(); - } - }); - __publicField(this, "onPointerMove", () => { - const { inputs } = this.editor; - if (this.isPen && !inputs.isPen) { - if (this.markId) { - this.editor.bailToMark(this.markId); - this.startShape(); - return; - } - } else { - if (!this.canDraw && inputs.isDragging) { - this.startShape(); - this.canDraw = true; - } - } - if (this.canDraw) { - if (this.isPenOrStylus) { - if (Vec.Dist(inputs.currentPagePoint, this.lastRecordedPoint) >= 1 / this.editor.getZoomLevel()) { - this.lastRecordedPoint = inputs.currentPagePoint.clone(); - this.mergeNextPoint = false; - } else { - this.mergeNextPoint = true; - } - } else { - this.mergeNextPoint = false; - } - this.updateDrawingShape(); - } - }); - __publicField(this, "onKeyDown", (info2) => { - if (info2.key === "Shift") { - switch (this.segmentMode) { - case "free": { - this.segmentMode = "starting_straight"; - this.pagePointWhereNextSegmentChanged = this.editor.inputs.currentPagePoint.clone(); - break; - } - case "starting_free": { - this.segmentMode = "starting_straight"; - } - } - } - this.updateDrawingShape(); - }); - __publicField(this, "onKeyUp", (info2) => { - if (info2.key === "Shift") { - this.editor.snaps.clearIndicators(); - switch (this.segmentMode) { - case "straight": { - this.segmentMode = "starting_free"; - this.pagePointWhereNextSegmentChanged = this.editor.inputs.currentPagePoint.clone(); - break; - } - case "starting_straight": { - this.pagePointWhereNextSegmentChanged = null; - this.segmentMode = "free"; - break; - } - } - } - this.updateDrawingShape(); - }); - __publicField(this, "onExit", () => { - this.editor.snaps.clearIndicators(); - this.pagePointWhereCurrentSegmentChanged = this.editor.inputs.currentPagePoint.clone(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - if (this.editor.inputs.isDragging) { - return; - } - if (this.markId) { - this.editor.bailToMark(this.markId); - } - this.cancel(); - }); - } - canClose() { - return this.shapeType !== "highlight"; - } - getIsClosed(segments, size4, scale) { - if (!this.canClose()) - return false; - const strokeWidth = STROKE_SIZES2[size4]; - const firstPoint = segments[0].points[0]; - const lastSegment = segments[segments.length - 1]; - const lastPoint = lastSegment.points[lastSegment.points.length - 1]; - return firstPoint !== lastPoint && this.currentLineLength > strokeWidth * 4 * scale && Vec.DistMin(firstPoint, lastPoint, strokeWidth * 2 * scale); - } - startShape() { - const { - inputs: { originPagePoint, isPen } - } = this.editor; - this.markId = "draw start " + uniqueId(); - this.editor.mark(this.markId); - const { z = 0.5 } = this.info.point; - this.isPen = isPen; - this.isPenOrStylus = isPen || z > 0 && z < 0.5 || z > 0.5 && z < 1; - const pressure = this.isPenOrStylus ? z * 1.25 : 0.5; - this.segmentMode = this.editor.inputs.shiftKey ? "straight" : "free"; - this.didJustShiftClickToExtendPreviousShapeLine = false; - this.lastRecordedPoint = originPagePoint.clone(); - if (this.initialShape) { - const shape = this.editor.getShape(this.initialShape.id); - if (shape && this.segmentMode === "straight") { - this.didJustShiftClickToExtendPreviousShapeLine = true; - const prevSegment = last(shape.props.segments); - if (!prevSegment) - throw Error("Expected a previous segment!"); - const prevPoint = last(prevSegment.points); - if (!prevPoint) - throw Error("Expected a previous point!"); - const { x, y } = this.editor.getPointInShapeSpace(shape, originPagePoint).toFixed(); - const newSegment = { - type: this.segmentMode, - points: [ - { - x: prevPoint.x, - y: prevPoint.y, - z: +pressure.toFixed(2) - }, - { - x, - y, - z: +pressure.toFixed(2) - } - ] - }; - const prevPointPageSpace = Mat.applyToPoint(this.editor.getShapePageTransform(shape.id), prevPoint); - this.pagePointWhereCurrentSegmentChanged = prevPointPageSpace; - this.pagePointWhereNextSegmentChanged = null; - const segments = [...shape.props.segments, newSegment]; - if (this.currentLineLength < STROKE_SIZES2[shape.props.size] * 4) { - this.currentLineLength = this.getLineLength(segments); - } - const shapePartial = { - id: shape.id, - type: this.shapeType, - props: { - segments - } - }; - if (this.canClose()) { - ; - shapePartial.props.isClosed = this.getIsClosed(segments, shape.props.size, shape.props.scale); - } - this.editor.updateShapes([shapePartial]); - return; - } - } - this.pagePointWhereCurrentSegmentChanged = originPagePoint.clone(); - const id = createShapeId(); - this.editor.createShapes([ - { - id, - type: this.shapeType, - x: originPagePoint.x, - y: originPagePoint.y, - props: { - isPen: this.isPenOrStylus, - scale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1, - segments: [ - { - type: this.segmentMode, - points: [ - { - x: 0, - y: 0, - z: +pressure.toFixed(2) - } - ] - } - ] - } - } - ]); - this.currentLineLength = 0; - this.initialShape = this.editor.getShape(id); - } - updateDrawingShape() { - const { initialShape } = this; - const { inputs } = this.editor; - if (!initialShape) - return; - const { - id, - props: { size: size4, scale } - } = initialShape; - const shape = this.editor.getShape(id); - if (!shape) - return; - const { segments } = shape.props; - const { x, y, z } = this.editor.getPointInShapeSpace(shape, inputs.currentPagePoint).toFixed(); - const pressure = this.isPenOrStylus ? +(inputs.currentPagePoint.z * 1.25).toFixed(2) : 0.5; - const newPoint = { x, y, z: pressure }; - switch (this.segmentMode) { - case "starting_straight": { - const { pagePointWhereNextSegmentChanged } = this; - if (pagePointWhereNextSegmentChanged === null) { - throw Error("We should have a point where the segment changed"); - } - const hasMovedFarEnough = Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.currentPagePoint) > this.editor.options.dragDistanceSquared; - if (hasMovedFarEnough) { - this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone(); - this.pagePointWhereNextSegmentChanged = null; - this.segmentMode = "straight"; - const prevSegment = last(segments); - if (!prevSegment) - throw Error("Expected a previous segment!"); - const prevLastPoint = last(prevSegment.points); - if (!prevLastPoint) - throw Error("Expected a previous last point!"); - let newSegment; - const newLastPoint = this.editor.getPointInShapeSpace(shape, this.pagePointWhereCurrentSegmentChanged).toFixed().toJson(); - if (prevSegment.type === "straight") { - this.currentLineLength += Vec.Dist(prevLastPoint, newLastPoint); - newSegment = { - type: "straight", - points: [{ ...prevLastPoint }, newLastPoint] - }; - const transform = this.editor.getShapePageTransform(shape); - this.pagePointWhereCurrentSegmentChanged = Mat.applyToPoint(transform, prevLastPoint); - } else { - newSegment = { - type: "straight", - points: [newLastPoint, newPoint] - }; - } - const shapePartial = { - id, - type: this.shapeType, - props: { - segments: [...segments, newSegment] - } - }; - if (this.canClose()) { - ; - shapePartial.props.isClosed = this.getIsClosed(segments, size4, scale); - } - this.editor.updateShapes([shapePartial]); - } - break; - } - case "starting_free": { - const { pagePointWhereNextSegmentChanged } = this; - if (pagePointWhereNextSegmentChanged === null) { - throw Error("We should have a point where the segment changed"); - } - const hasMovedFarEnough = Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.currentPagePoint) > this.editor.options.dragDistanceSquared; - if (hasMovedFarEnough) { - this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone(); - this.pagePointWhereNextSegmentChanged = null; - this.segmentMode = "free"; - const newSegments = segments.slice(); - const prevStraightSegment = newSegments[newSegments.length - 1]; - const prevPoint = last(prevStraightSegment.points); - if (!prevPoint) { - throw Error("No previous point!"); - } - const newFreeSegment = { - type: "free", - points: [ - ...Vec.PointsBetween(prevPoint, newPoint, 6).map((p) => ({ - x: toFixed(p.x), - y: toFixed(p.y), - z: toFixed(p.z) - })) - ] - }; - const finalSegments = [...newSegments, newFreeSegment]; - if (this.currentLineLength < STROKE_SIZES2[shape.props.size] * 4) { - this.currentLineLength = this.getLineLength(finalSegments); - } - const shapePartial = { - id, - type: this.shapeType, - props: { - segments: finalSegments - } - }; - if (this.canClose()) { - ; - shapePartial.props.isClosed = this.getIsClosed(finalSegments, size4, scale); - } - this.editor.updateShapes([shapePartial]); - } - break; - } - case "straight": { - const newSegments = segments.slice(); - const newSegment = newSegments[newSegments.length - 1]; - const { pagePointWhereCurrentSegmentChanged } = this; - const { ctrlKey, currentPagePoint } = this.editor.inputs; - if (!pagePointWhereCurrentSegmentChanged) - throw Error("We should have a point where the segment changed"); - let pagePoint; - let shouldSnapToAngle = false; - if (this.didJustShiftClickToExtendPreviousShapeLine) { - if (this.editor.inputs.isDragging) { - shouldSnapToAngle = !ctrlKey; - this.didJustShiftClickToExtendPreviousShapeLine = false; - } else { - } - } else { - shouldSnapToAngle = !ctrlKey; - } - let newPoint2 = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed().toJson(); - let didSnap = false; - let snapSegment = void 0; - const shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey; - if (shouldSnap) { - if (newSegments.length > 2) { - let nearestPoint = void 0; - let minDistance = 8 / this.editor.getZoomLevel(); - for (let i = 0, n = segments.length - 2; i < n; i++) { - const segment = segments[i]; - if (!segment) - break; - if (segment.type === "free") - continue; - const first = segment.points[0]; - const lastPoint = last(segment.points); - if (!(first && lastPoint)) - continue; - const nearestPointOnSegment = Vec.NearestPointOnLineSegment(first, lastPoint, newPoint2); - if (Vec.DistMin(nearestPointOnSegment, newPoint2, minDistance)) { - nearestPoint = nearestPointOnSegment.toFixed().toJson(); - minDistance = Vec.Dist(nearestPointOnSegment, newPoint2); - snapSegment = segment; - break; - } - } - if (nearestPoint) { - didSnap = true; - newPoint2 = nearestPoint; - } - } - } - if (didSnap && snapSegment) { - const transform = this.editor.getShapePageTransform(shape); - const first = snapSegment.points[0]; - const lastPoint = last(snapSegment.points); - if (!lastPoint) - throw Error("Expected a last point!"); - const A = Mat.applyToPoint(transform, first); - const B = Mat.applyToPoint(transform, lastPoint); - const snappedPoint = Mat.applyToPoint(transform, newPoint2); - this.editor.snaps.setIndicators([ - { - id: uniqueId(), - type: "points", - points: [A, snappedPoint, B] - } - ]); - } else { - this.editor.snaps.clearIndicators(); - if (shouldSnapToAngle) { - const currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged, currentPagePoint); - const snappedAngle = snapAngle(currentAngle, 24); - const angleDiff = snappedAngle - currentAngle; - pagePoint = Vec.RotWith(currentPagePoint, pagePointWhereCurrentSegmentChanged, angleDiff); - } else { - pagePoint = currentPagePoint; - } - newPoint2 = this.editor.getPointInShapeSpace(shape, pagePoint).toFixed().toJson(); - } - this.currentLineLength += Vec.Dist(newSegment.points[0], newPoint2); - newSegments[newSegments.length - 1] = { - ...newSegment, - type: "straight", - points: [newSegment.points[0], newPoint2] - }; - const shapePartial = { - id, - type: this.shapeType, - props: { - segments: newSegments - } - }; - if (this.canClose()) { - ; - shapePartial.props.isClosed = this.getIsClosed(segments, size4, scale); - } - this.editor.updateShapes([shapePartial]); - break; - } - case "free": { - const newSegments = segments.slice(); - const newSegment = newSegments[newSegments.length - 1]; - const newPoints = [...newSegment.points]; - if (newPoints.length && this.mergeNextPoint) { - const { z: z2 } = newPoints[newPoints.length - 1]; - newPoints[newPoints.length - 1] = { - x: newPoint.x, - y: newPoint.y, - z: z2 ? Math.max(z2, newPoint.z) : newPoint.z - }; - } else { - this.currentLineLength += Vec.Dist(newPoints[newPoints.length - 1], newPoint); - newPoints.push(newPoint); - } - newSegments[newSegments.length - 1] = { - ...newSegment, - points: newPoints - }; - if (this.currentLineLength < STROKE_SIZES2[shape.props.size] * 4) { - this.currentLineLength = this.getLineLength(newSegments); - } - const shapePartial = { - id, - type: this.shapeType, - props: { - segments: newSegments - } - }; - if (this.canClose()) { - ; - shapePartial.props.isClosed = this.getIsClosed(newSegments, size4, scale); - } - this.editor.updateShapes([shapePartial]); - if (newPoints.length > this.editor.options.maxPointsPerDrawShape) { - this.editor.updateShapes([{ id, type: this.shapeType, props: { isComplete: true } }]); - const newShapeId = createShapeId(); - const props = this.editor.getShape(id).props; - this.editor.createShapes([ - { - id: newShapeId, - type: this.shapeType, - x: toFixed(inputs.currentPagePoint.x), - y: toFixed(inputs.currentPagePoint.y), - props: { - isPen: this.isPenOrStylus, - scale: props.scale, - segments: [ - { - type: "free", - points: [{ x: 0, y: 0, z: this.isPenOrStylus ? +(z * 1.25).toFixed() : 0.5 }] - } - ] - } - } - ]); - this.initialShape = structuredClone(this.editor.getShape(newShapeId)); - this.mergeNextPoint = false; - this.lastRecordedPoint = inputs.currentPagePoint.clone(); - this.currentLineLength = 0; - } - break; - } - } - } - getLineLength(segments) { - let length = 0; - for (const segment of segments) { - for (let i = 0; i < segment.points.length - 1; i++) { - const A = segment.points[i]; - const B = segment.points[i + 1]; - length += Vec.Dist2(B, A); - } - } - return Math.sqrt(length); - } - complete() { - if (!this.canDraw) { - this.cancel(); - return; - } - const { initialShape } = this; - if (!initialShape) - return; - this.editor.updateShapes([ - { id: initialShape.id, type: initialShape.type, props: { isComplete: true } } - ]); - this.parent.transition("idle"); - } - cancel() { - this.parent.transition("idle", this.info); - } -}; -__publicField(Drawing, "id", "drawing"); - -// node_modules/tldraw/dist-esm/lib/shapes/draw/toolStates/Idle.mjs -var Idle3 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("drawing", info2); - }); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle3, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/shapes/draw/DrawShapeTool.mjs -var DrawShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "draw"); - __publicField(this, "onExit", () => { - const drawingState = this.children["drawing"]; - drawingState.initialShape = void 0; - }); - } -}; -__publicField(DrawShapeTool, "id", "draw"); -__publicField(DrawShapeTool, "initial", "idle"); -__publicField(DrawShapeTool, "isLockable", false); -__publicField(DrawShapeTool, "children", () => [Idle3, Drawing]); - -// node_modules/tldraw/dist-esm/lib/shapes/frame/FrameShapeTool.mjs -var FrameShapeTool = class extends BaseBoxShapeTool { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "frame"); - __publicField(this, "onCreate", (shape) => { - if (!shape) - return; - const bounds = this.editor.getShapePageBounds(shape); - const shapesToAddToFrame = []; - const ancestorIds = this.editor.getShapeAncestors(shape).map((shape2) => shape2.id); - this.editor.getSortedChildIdsForParent(shape.parentId).map((siblingShapeId) => { - const siblingShape = this.editor.getShape(siblingShapeId); - if (!siblingShape) - return; - if (siblingShape.id === shape.id) - return; - if (siblingShape.isLocked) - return; - const pageShapeBounds = this.editor.getShapePageBounds(siblingShape); - if (!pageShapeBounds) - return; - if (bounds.contains(pageShapeBounds)) { - if (canEnclose(siblingShape, ancestorIds, shape)) { - shapesToAddToFrame.push(siblingShape.id); - } - } - }); - this.editor.reparentShapes(shapesToAddToFrame, shape.id); - if (this.editor.getInstanceState().isToolLocked) { - this.editor.setCurrentTool("frame"); - } else { - this.editor.setCurrentTool("select.idle"); - } - }); - } -}; -__publicField(FrameShapeTool, "id", "frame"); -__publicField(FrameShapeTool, "initial", "idle"); -function canEnclose(shape, ancestorIds, frame2) { - if (ancestorIds.includes(shape.id)) { - return false; - } - if (shape.parentId === frame2.parentId) { - return true; - } - return false; -} - -// node_modules/tldraw/dist-esm/lib/shapes/geo/toolStates/Idle.mjs -var Idle4 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onKeyUp", (info2) => { - if (info2.key === "Enter") { - if (this.editor.getInstanceState().isReadonly) - return null; - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape && this.editor.getShapeUtil(onlySelectedShape).canEdit(onlySelectedShape)) { - this.editor.setCurrentTool("select"); - this.editor.setEditingShape(onlySelectedShape.id); - this.editor.root.getCurrent()?.transition("editing_shape", { - ...info2, - target: "shape", - shape: onlySelectedShape - }); - } - } - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle4, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs -var Pointing3 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "markId", ""); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - const { originPagePoint } = this.editor.inputs; - const id = createShapeId(); - this.markId = `creating:${id}`; - this.editor.mark(this.markId); - this.editor.createShapes([ - { - id, - type: "geo", - x: originPagePoint.x, - y: originPagePoint.y, - props: { - w: 1, - h: 1, - geo: this.editor.getStyleForNextShape(GeoShapeGeoStyle), - scale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1 - } - } - ]).select(id).setCurrentTool("select.resizing", { - ...info2, - target: "selection", - handle: "bottom_right", - isCreating: true, - creationCursorOffset: { x: 1, y: 1 }, - onInteractionEnd: "geo" - }); - } - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - complete() { - const { originPagePoint } = this.editor.inputs; - const id = createShapeId(); - this.markId = `creating:${id}`; - this.editor.mark(this.markId); - const scale = this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1; - const geo = this.editor.getStyleForNextShape(GeoShapeGeoStyle); - const size4 = geo === "star" ? { w: 200, h: 190 } : geo === "cloud" ? { w: 300, h: 180 } : { w: 200, h: 200 }; - this.editor.createShapes([ - { - id, - type: "geo", - x: originPagePoint.x, - y: originPagePoint.y, - props: { - geo: this.editor.getStyleForNextShape(GeoShapeGeoStyle), - scale, - ...size4 - } - } - ]); - const shape = this.editor.getShape(id); - if (!shape) - return; - const { w, h } = shape.props; - const delta = new Vec(w / 2, h / 2).mul(scale); - const parentTransform = this.editor.getShapeParentTransform(shape); - if (parentTransform) - delta.rot(-parentTransform.rotation()); - this.editor.select(id); - this.editor.updateShape({ - id: shape.id, - type: "geo", - x: shape.x - delta.x, - y: shape.y - delta.y, - props: { - geo: this.editor.getStyleForNextShape(GeoShapeGeoStyle), - w: w * scale, - h: h * scale - } - }); - if (this.editor.getInstanceState().isToolLocked) { - this.parent.transition("idle"); - } else { - this.editor.setCurrentTool("select", {}); - } - } - cancel() { - this.parent.transition("idle"); - } -}; -__publicField(Pointing3, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/shapes/geo/GeoShapeTool.mjs -var GeoShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "geo"); - } -}; -__publicField(GeoShapeTool, "id", "geo"); -__publicField(GeoShapeTool, "initial", "idle"); -__publicField(GeoShapeTool, "children", () => [Idle4, Pointing3]); - -// node_modules/tldraw/dist-esm/lib/shapes/highlight/HighlightShapeTool.mjs -var HighlightShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "highlight"); - __publicField(this, "onExit", () => { - const drawingState = this.children["drawing"]; - drawingState.initialShape = void 0; - }); - } -}; -__publicField(HighlightShapeTool, "id", "highlight"); -__publicField(HighlightShapeTool, "initial", "idle"); -__publicField(HighlightShapeTool, "children", () => [Idle3, Drawing]); -__publicField(HighlightShapeTool, "isLockable", false); - -// node_modules/tldraw/dist-esm/lib/shapes/line/toolStates/Idle.mjs -var Idle5 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeId", ""); - __publicField(this, "onEnter", (info2) => { - this.shapeId = info2.shapeId; - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onPointerDown", () => { - this.parent.transition("pointing", { shapeId: this.shapeId }); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle5, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/shapes/line/toolStates/Pointing.mjs -var MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES = 2; -var Pointing4 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shape", {}); - __publicField(this, "markId"); - __publicField(this, "onEnter", (info2) => { - const { inputs } = this.editor; - const { currentPagePoint } = inputs; - this.markId = void 0; - const shape = info2.shapeId && this.editor.getShape(info2.shapeId); - if (shape && inputs.shiftKey) { - this.markId = `creating:${shape.id}`; - this.editor.mark(this.markId); - this.shape = shape; - const handles = this.editor.getShapeHandles(this.shape); - if (!handles) - return; - const vertexHandles = handles.filter((h) => h.type === "vertex").sort(sortByIndex); - const endHandle = vertexHandles[vertexHandles.length - 1]; - const prevEndHandle = vertexHandles[vertexHandles.length - 2]; - const shapePagePoint = Mat.applyToPoint(this.editor.getShapeParentTransform(this.shape), new Vec(this.shape.x, this.shape.y)); - const nextPoint = Vec.Sub(currentPagePoint, shapePagePoint).addXY(0.1, 0.1); - const points = structuredClone(this.shape.props.points); - if (Vec.DistMin(endHandle, prevEndHandle, MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES) || Vec.DistMin(nextPoint, endHandle, MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES)) { - points[endHandle.id] = { - id: endHandle.id, - index: endHandle.index, - x: nextPoint.x, - y: nextPoint.y - }; - } else { - const nextIndex = getIndexAbove(endHandle.index); - points[nextIndex] = { - id: nextIndex, - index: nextIndex, - x: nextPoint.x, - y: nextPoint.y - }; - } - this.editor.updateShapes([ - { - id: this.shape.id, - type: this.shape.type, - props: { - points - } - } - ]); - } else { - const id = createShapeId(); - this.markId = `creating:${id}`; - this.editor.mark(this.markId); - this.editor.createShapes([ - { - id, - type: "line", - x: currentPagePoint.x, - y: currentPagePoint.y, - props: { - scale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1 - } - } - ]); - this.editor.select(id); - this.shape = this.editor.getShape(id); - } - }); - __publicField(this, "onPointerMove", () => { - if (!this.shape) - return; - if (this.editor.inputs.isDragging) { - const handles = this.editor.getShapeHandles(this.shape); - if (!handles) { - if (this.markId) - this.editor.bailToMark(this.markId); - throw Error("No handles found"); - } - const lastHandle = last(handles); - this.editor.setCurrentTool("select.dragging_handle", { - shape: this.shape, - isCreating: true, - handle: { ...lastHandle, x: lastHandle.x - 0.1, y: lastHandle.y - 0.1 }, - onInteractionEnd: "line" - }); - } - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.parent.transition("idle"); - if (this.markId) - this.editor.bailToMark(this.markId); - this.editor.snaps.clearIndicators(); - }); - } - complete() { - this.parent.transition("idle", { shapeId: this.shape.id }); - this.editor.snaps.clearIndicators(); - } - cancel() { - if (this.markId) - this.editor.bailToMark(this.markId); - this.parent.transition("idle", { shapeId: this.shape.id }); - this.editor.snaps.clearIndicators(); - } -}; -__publicField(Pointing4, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/shapes/line/LineShapeTool.mjs -var LineShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "line"); - } -}; -__publicField(LineShapeTool, "id", "line"); -__publicField(LineShapeTool, "initial", "idle"); -__publicField(LineShapeTool, "children", () => [Idle5, Pointing4]); - -// node_modules/tldraw/dist-esm/lib/shapes/note/toolStates/Idle.mjs -var Idle6 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle6, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/selectHelpers.mjs -function kickoutOccludedShapes(editor, shapeIds) { - const parentsToCheck = /* @__PURE__ */ new Set(); - for (const id of shapeIds) { - const shape = editor.getShape(id); - if (!shape) - continue; - if (editor.getShapeUtil(shape).onDragShapesOut) { - parentsToCheck.add(shape); - } - const parent = editor.getShape(shape.parentId); - if (!parent) - continue; - if (editor.getShapeUtil(parent).onDragShapesOut) { - parentsToCheck.add(parent); - } - } - const parentsWithKickedOutChildren = /* @__PURE__ */ new Map(); - for (const parent of parentsToCheck) { - const occludedChildren = getOccludedChildren(editor, parent); - if (occludedChildren.length) { - parentsWithKickedOutChildren.set(parent, occludedChildren); - } - } - for (const [parent, kickedOutChildrenIds] of parentsWithKickedOutChildren) { - const shapeUtil = editor.getShapeUtil(parent); - const kickedOutChildren = compact(kickedOutChildrenIds.map((id) => editor.getShape(id))); - shapeUtil.onDragShapesOut?.(parent, kickedOutChildren); - } -} -function getOccludedChildren(editor, parent) { - const childIds = editor.getSortedChildIdsForParent(parent.id); - if (childIds.length === 0) - return []; - const parentPageBounds = editor.getShapePageBounds(parent); - if (!parentPageBounds) - return []; - let parentGeometry; - let parentPageTransform; - let parentPageCorners; - const results = []; - for (const childId of childIds) { - const shapePageBounds = editor.getShapePageBounds(childId); - if (!shapePageBounds) { - continue; - } - if (!parentPageBounds.includes(shapePageBounds)) { - results.push(childId); - continue; - } - parentGeometry ?? (parentGeometry = editor.getShapeGeometry(parent)); - parentPageTransform ?? (parentPageTransform = editor.getShapePageTransform(parent)); - parentPageCorners ?? (parentPageCorners = parentPageTransform.applyToPoints(parentGeometry.vertices)); - const parentCornersInShapeSpace = editor.getShapePageTransform(childId).clone().invert().applyToPoints(parentPageCorners); - const { vertices, isClosed } = editor.getShapeGeometry(childId); - if (vertices.some((v) => pointInPolygon(v, parentCornersInShapeSpace))) { - continue; - } - if (isClosed) { - if (polygonsIntersect(parentCornersInShapeSpace, vertices)) { - continue; - } - } else if (polygonIntersectsPolyline(parentCornersInShapeSpace, vertices)) { - continue; - } - results.push(childId); - } - return results; -} -function startEditingShapeWithLabel(editor, shape, selectAll = false) { - editor.select(shape); - editor.setEditingShape(shape); - editor.setCurrentTool("select.editing_shape", { - target: "shape", - shape - }); - if (selectAll) { - editor.emit("select-all-text", { shapeId: shape.id }); - } - zoomToShapeIfOffscreen(editor); -} -var ZOOM_TO_SHAPE_PADDING = 16; -function zoomToShapeIfOffscreen(editor) { - const selectionPageBounds = editor.getSelectionPageBounds(); - const viewportPageBounds = editor.getViewportPageBounds(); - if (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) { - const eb = selectionPageBounds.clone().expandBy(ZOOM_TO_SHAPE_PADDING / editor.getZoomLevel()).expand(viewportPageBounds); - const nextBounds = viewportPageBounds.clone().translate({ - x: (eb.center.x - viewportPageBounds.center.x) * 2, - y: (eb.center.y - viewportPageBounds.center.y) * 2 - }); - editor.zoomToBounds(nextBounds, { - animation: { - duration: editor.options.animationMediumMs - }, - inset: 0 - }); - } -} - -// node_modules/tldraw/dist-esm/lib/shapes/note/noteHelpers.mjs -var CLONE_HANDLE_MARGIN = 0; -var NOTE_SIZE = 200; -var NOTE_CENTER_OFFSET = new Vec(NOTE_SIZE / 2, NOTE_SIZE / 2); -var NOTE_ADJACENT_POSITION_SNAP_RADIUS = 10; -var BASE_NOTE_POSITIONS = (editor) => [ - [ - ["a1"], - new Vec(NOTE_SIZE * 0.5, NOTE_SIZE * -0.5 - editor.options.adjacentShapeMargin) - ], - [ - ["a2"], - new Vec(NOTE_SIZE * 1.5 + editor.options.adjacentShapeMargin, NOTE_SIZE * 0.5) - ], - [ - ["a3"], - new Vec(NOTE_SIZE * 0.5, NOTE_SIZE * 1.5 + editor.options.adjacentShapeMargin) - ], - [ - ["a4"], - new Vec(NOTE_SIZE * -0.5 - editor.options.adjacentShapeMargin, NOTE_SIZE * 0.5) - ] -]; -function getBaseAdjacentNotePositions(editor, scale) { - if (scale === 1) - return BASE_NOTE_POSITIONS(editor); - const s = NOTE_SIZE * scale; - const m = editor.options.adjacentShapeMargin * scale; - return [ - [["a1"], new Vec(s * 0.5, s * -0.5 - m)], - [["a2"], new Vec(s * 1.5 + m, s * 0.5)], - [["a3"], new Vec(s * 0.5, s * 1.5 + m)], - [["a4"], new Vec(s * -0.5 - m, s * 0.5)] - ]; -} -function getNoteAdjacentPositions(editor, pagePoint, pageRotation, growY, extraHeight, scale) { - return Object.fromEntries(getBaseAdjacentNotePositions(editor, scale).map(([id, v], i) => { - const point = v.clone(); - if (i === 0 && extraHeight) { - point.y -= extraHeight; - } else if (i === 2 && growY) { - point.y += growY; - } - return [id, point.rot(pageRotation).add(pagePoint)]; - })); -} -function getAvailableNoteAdjacentPositions(editor, rotation, scale, extraHeight) { - const selectedShapeIds = new Set(editor.getSelectedShapeIds()); - const minSize = (NOTE_SIZE + editor.options.adjacentShapeMargin + extraHeight) ** 2; - const allCenters = /* @__PURE__ */ new Map(); - const positions = []; - for (const shape of editor.getCurrentPageShapes()) { - if (!editor.isShapeOfType(shape, "note") || scale !== shape.props.scale || selectedShapeIds.has(shape.id)) { - continue; - } - const transform = editor.getShapePageTransform(shape.id); - if (rotation !== transform.rotation()) - continue; - allCenters.set(shape, editor.getShapePageBounds(shape).center); - positions.push(...Object.values(getNoteAdjacentPositions(editor, transform.point(), rotation, shape.props.growY, extraHeight, scale))); - } - const len = positions.length; - let position; - for (const [shape, center] of allCenters) { - for (let i = 0; i < len; i++) { - position = positions[i]; - if (!position) - continue; - if (Vec.Dist2(center, position) > minSize) - continue; - if (editor.isPointInShape(shape, position)) { - positions[i] = void 0; - } - } - } - return compact(positions); -} -function getNoteShapeForAdjacentPosition(editor, shape, center, pageRotation, forceNew = false) { - let nextNote; - const allShapesOnPage = editor.getCurrentPageShapesSorted(); - const minDistance = (NOTE_SIZE + editor.options.adjacentShapeMargin ** 2) ** shape.props.scale; - for (let i = allShapesOnPage.length - 1; i >= 0; i--) { - const otherNote = allShapesOnPage[i]; - if (otherNote.type === "note" && otherNote.id !== shape.id) { - const otherBounds = editor.getShapePageBounds(otherNote); - if (otherBounds && Vec.Dist2(otherBounds.center, center) < minDistance && editor.isPointInShape(otherNote, center)) { - nextNote = otherNote; - break; - } - } - } - editor.complete(); - if (!nextNote || forceNew) { - editor.mark("creating note shape"); - const id = createShapeId(); - editor.createShape({ - id, - type: "note", - x: center.x, - y: center.y, - rotation: pageRotation, - opacity: shape.opacity, - props: { - ...shape.props, - text: "", - growY: 0, - fontSizeAdjustment: 0, - url: "" - } - }); - const createdShape = editor.getShape(id); - if (!createdShape) - return; - const topLeft = editor.getPointInParentSpace(createdShape, Vec.Sub(center, Vec.Rot(NOTE_CENTER_OFFSET.clone().mul(createdShape.props.scale), pageRotation))); - editor.updateShape({ - id, - type: "note", - x: topLeft.x, - y: topLeft.y - }); - nextNote = editor.getShape(id); - } - zoomToShapeIfOffscreen(editor); - return nextNote; -} - -// node_modules/tldraw/dist-esm/lib/shapes/note/toolStates/Pointing.mjs -var Pointing5 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "dragged", false); - __publicField(this, "info", {}); - __publicField(this, "wasFocusedOnEnter", false); - __publicField(this, "markId", ""); - __publicField(this, "shape", {}); - __publicField(this, "onEnter", () => { - const { editor } = this; - this.wasFocusedOnEnter = !editor.getIsMenuOpen(); - if (this.wasFocusedOnEnter) { - const id = createShapeId(); - this.markId = `creating:${id}`; - editor.mark(this.markId); - const center = this.editor.inputs.originPagePoint.clone(); - const offset4 = getNoteShapeAdjacentPositionOffset(this.editor, center, this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1); - if (offset4) { - center.sub(offset4); - } - this.shape = createNoteShape(this.editor, id, center); - } - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - if (!this.wasFocusedOnEnter) { - const id = createShapeId(); - const center = this.editor.inputs.originPagePoint.clone(); - const offset4 = getNoteShapeAdjacentPositionOffset(this.editor, center, this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1); - if (offset4) { - center.sub(offset4); - } - this.shape = createNoteShape(this.editor, id, center); - } - this.editor.setCurrentTool("select.translating", { - ...info2, - target: "shape", - shape: this.shape, - onInteractionEnd: "note", - isCreating: true, - onCreate: () => { - this.editor.setEditingShape(this.shape.id); - this.editor.setCurrentTool("select.editing_shape"); - } - }); - } - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - } - complete() { - if (this.wasFocusedOnEnter) { - if (this.editor.getInstanceState().isToolLocked) { - this.parent.transition("idle"); - } else { - this.editor.setEditingShape(this.shape.id); - this.editor.setCurrentTool("select.editing_shape", { - ...this.info, - target: "shape", - shape: this.shape - }); - } - } - } - cancel() { - this.editor.bailToMark(this.markId); - this.parent.transition("idle", this.info); - } -}; -__publicField(Pointing5, "id", "pointing"); -function getNoteShapeAdjacentPositionOffset(editor, center, scale) { - let min3 = NOTE_ADJACENT_POSITION_SNAP_RADIUS / editor.getZoomLevel(); - let offset4; - for (const pit of getAvailableNoteAdjacentPositions(editor, 0, scale, 0)) { - const deltaToPit = Vec.Sub(center, pit); - const dist = deltaToPit.len(); - if (dist < min3) { - min3 = dist; - offset4 = deltaToPit; - } - } - return offset4; -} -function createNoteShape(editor, id, center) { - editor.createShape({ - id, - type: "note", - x: center.x, - y: center.y, - props: { - scale: editor.user.getIsDynamicResizeMode() ? 1 / editor.getZoomLevel() : 1 - } - }).select(id); - const shape = editor.getShape(id); - const bounds = editor.getShapeGeometry(shape).bounds; - editor.updateShapes([ - { - id, - type: "note", - x: shape.x - bounds.width / 2, - y: shape.y - bounds.height / 2 - } - ]); - return editor.getShape(id); -} - -// node_modules/tldraw/dist-esm/lib/shapes/note/NoteShapeTool.mjs -var NoteShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "note"); - } -}; -__publicField(NoteShapeTool, "id", "note"); -__publicField(NoteShapeTool, "initial", "idle"); -__publicField(NoteShapeTool, "children", () => [Idle6, Pointing5]); - -// node_modules/tldraw/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs -function _updateHoveredShapeId(editor) { - const hitShape = editor.getShapeAtPoint(editor.inputs.currentPagePoint, { - hitInside: false, - hitLabels: false, - margin: editor.options.hitTestMargin / editor.getZoomLevel(), - renderingOnly: true - }); - if (!hitShape) - return editor.setHoveredShape(null); - let shapeToHover = void 0; - const outermostShape = editor.getOutermostSelectableShape(hitShape); - if (outermostShape === hitShape) { - shapeToHover = hitShape; - } else { - if (outermostShape.id === editor.getFocusedGroupId() || editor.getSelectedShapeIds().includes(outermostShape.id)) { - shapeToHover = hitShape; - } else { - shapeToHover = outermostShape; - } - } - return editor.setHoveredShape(shapeToHover.id); -} -var updateHoveredShapeId = (0, import_lodash.default)(_updateHoveredShapeId, false ? 0 : 32); - -// node_modules/tldraw/dist-esm/lib/shapes/text/toolStates/Idle.mjs -var Idle7 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerMove", (info2) => { - switch (info2.target) { - case "shape": - case "canvas": { - updateHoveredShapeId(this.editor); - } - } - }); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - __publicField(this, "onExit", () => { - updateHoveredShapeId.cancel(); - }); - __publicField(this, "onKeyDown", (info2) => { - if (info2.key === "Enter") { - if (this.editor.getInstanceState().isReadonly) - return null; - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape && this.editor.getShapeUtil(onlySelectedShape).canEdit(onlySelectedShape)) { - this.editor.setCurrentTool("select"); - this.editor.setEditingShape(onlySelectedShape.id); - this.editor.root.getCurrent()?.transition("editing_shape", { - ...info2, - target: "shape", - shape: onlySelectedShape - }); - } - } - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle7, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/shapes/text/toolStates/Pointing.mjs -var Pointing6 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shape"); - __publicField(this, "markId", ""); - __publicField(this, "onExit", () => { - this.editor.setHintingShapes([]); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - const { - inputs: { originPagePoint } - } = this.editor; - const id = createShapeId(); - this.markId = `creating:${id}`; - this.editor.mark(this.markId); - const shape = this.createTextShape(id, originPagePoint, false); - if (!shape) { - this.cancel(); - return; - } - this.shape = this.editor.getShape(shape); - this.editor.select(id); - this.editor.setCurrentTool("select.resizing", { - ...info2, - target: "selection", - handle: "right", - isCreating: true, - creationCursorOffset: { x: 18, y: 1 }, - onInteractionEnd: "text", - onCreate: () => { - this.editor.setEditingShape(shape.id); - this.editor.setCurrentTool("select.editing_shape"); - } - }); - } - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - complete() { - this.editor.mark("creating text shape"); - const id = createShapeId(); - const { currentPagePoint } = this.editor.inputs; - const shape = this.createTextShape(id, currentPagePoint, true); - if (!shape) - return; - this.editor.select(id); - this.editor.setEditingShape(id); - this.editor.setCurrentTool("select"); - this.editor.root.getCurrent()?.transition("editing_shape"); - } - cancel() { - this.parent.transition("idle"); - this.editor.bailToMark(this.markId); - } - createTextShape(id, point, autoSize) { - this.editor.createShape({ - id, - type: "text", - x: point.x, - y: point.y, - props: { - text: "", - autoSize, - w: 20, - scale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1 - } - }); - const shape = this.editor.getShape(id); - if (!shape) { - this.cancel(); - return; - } - const bounds = this.editor.getShapePageBounds(shape); - const delta = new Vec(); - if (autoSize) { - switch (shape.props.textAlign) { - case "start": { - delta.x = 0; - break; - } - case "middle": { - delta.x = -bounds.width / 2; - break; - } - case "end": { - delta.x = -bounds.width; - break; - } - } - } else { - delta.x = 0; - } - delta.y = -bounds.height / 2; - if (isShapeId(shape.parentId)) { - const transform = this.editor.getShapeParentTransform(shape); - delta.rot(-transform.rotation()); - } - this.editor.updateShape({ - ...shape, - x: shape.x + delta.x, - y: shape.y + delta.y - }); - return shape; - } -}; -__publicField(Pointing6, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/shapes/text/TextShapeTool.mjs -var TextShapeTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeType", "text"); - } -}; -__publicField(TextShapeTool, "id", "text"); -__publicField(TextShapeTool, "initial", "idle"); -__publicField(TextShapeTool, "children", () => [Idle7, Pointing6]); -__publicField(TextShapeTool, "isLockable", false); - -// node_modules/tldraw/dist-esm/lib/defaultShapeTools.mjs -var defaultShapeTools = [ - TextShapeTool, - DrawShapeTool, - GeoShapeTool, - NoteShapeTool, - LineShapeTool, - FrameShapeTool, - ArrowShapeTool, - HighlightShapeTool -]; - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs -var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); -var import_react51 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/ShapeFill.mjs -var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); -var import_react47 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs -var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); -var import_react46 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/useDefaultColorTheme.mjs -function useDefaultColorTheme() { - return getDefaultColorTheme({ isDarkMode: useIsDarkMode() }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs -function getFontDefForExport(fontStyle) { - return { - key: `${DefaultFontStyle.id}:${fontStyle}`, - getElement: async () => { - const font = findFont(fontStyle); - if (!font) - return null; - const url = font.$$_url; - const fontFaceRule = font.$$_fontface; - if (!url || !fontFaceRule) - return null; - const fontFile = await (await fetch2(url)).blob(); - const base64FontFile = await FileHelpers.blobToDataUrl(fontFile); - const newFontFaceRule = fontFaceRule.replace(url, base64FontFile); - return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("style", { children: newFontFaceRule }); - } - }; -} -function findFont(name) { - const fontFamily = DefaultFontFamilies[name]; - for (const font of document.fonts) { - if (fontFamily.includes(font.family)) { - return font; - } - } - return null; -} -function getFillDefForExport(fill) { - return { - key: `${DefaultFontStyle.id}:${fill}`, - getElement: async () => { - if (fill !== "pattern") - return null; - return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(HashPatternForExport, {}); - } - }; -} -function HashPatternForExport() { - const theme = useDefaultColorTheme(); - const t2 = 8 / 12; - return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("mask", { id: "hash_pattern_mask", children: [ - /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("rect", { x: "0", y: "0", width: "8", height: "8", fill: "white" }), - /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("g", { strokeLinecap: "round", stroke: "black", children: [ - /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("line", { x1: t2 * 1, y1: t2 * 3, x2: t2 * 3, y2: t2 * 1 }), - /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("line", { x1: t2 * 5, y1: t2 * 7, x2: t2 * 7, y2: t2 * 5 }), - /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("line", { x1: t2 * 9, y1: t2 * 11, x2: t2 * 11, y2: t2 * 9 }) - ] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("pattern", { - id: getHashPatternZoomName(1, theme.id), - width: "8", - height: "8", - patternUnits: "userSpaceOnUse", - children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("rect", { x: "0", y: "0", width: "8", height: "8", fill: theme.solid, mask: "url(#hash_pattern_mask)" }) - }) - ] }); -} -function getFillDefForCanvas() { - return { - key: `${DefaultFontStyle.id}:pattern`, - component: PatternFillDefForCanvas - }; -} -var TILE_PATTERN_SIZE = 8; -var generateImage = (dpr, currentZoom, darkMode) => { - return new Promise((resolve, reject) => { - const size4 = TILE_PATTERN_SIZE * currentZoom * dpr; - const canvasEl = document.createElement("canvas"); - canvasEl.width = size4; - canvasEl.height = size4; - const ctx = canvasEl.getContext("2d"); - if (!ctx) - return; - ctx.fillStyle = darkMode ? DefaultColorThemePalette.darkMode.solid : DefaultColorThemePalette.lightMode.solid; - ctx.fillRect(0, 0, size4, size4); - ctx.globalCompositeOperation = "destination-out"; - ctx.lineCap = "round"; - ctx.lineWidth = 1.25 * currentZoom * dpr; - const t2 = 8 / 12; - const s = (v) => v * currentZoom * dpr; - ctx.beginPath(); - ctx.moveTo(s(t2 * 1), s(t2 * 3)); - ctx.lineTo(s(t2 * 3), s(t2 * 1)); - ctx.moveTo(s(t2 * 5), s(t2 * 7)); - ctx.lineTo(s(t2 * 7), s(t2 * 5)); - ctx.moveTo(s(t2 * 9), s(t2 * 11)); - ctx.lineTo(s(t2 * 11), s(t2 * 9)); - ctx.stroke(); - canvasEl.toBlob((blob) => { - if (!blob || debugFlags.throwToBlob.get()) { - reject(); - } else { - resolve(blob); - } - }); - }); -}; -var canvasBlob = (size4, fn) => { - const canvas = document.createElement("canvas"); - canvas.width = size4[0]; - canvas.height = size4[1]; - const ctx = canvas.getContext("2d"); - if (!ctx) - return ""; - fn(ctx); - return canvas.toDataURL(); -}; -var defaultPixels = null; -function getDefaultPixels() { - if (!defaultPixels) { - defaultPixels = { - white: canvasBlob([1, 1], (ctx) => { - ctx.fillStyle = "#f8f9fa"; - ctx.fillRect(0, 0, 1, 1); - }), - black: canvasBlob([1, 1], (ctx) => { - ctx.fillStyle = "#212529"; - ctx.fillRect(0, 0, 1, 1); - }) - }; - } - return defaultPixels; -} -function getPatternLodForZoomLevel(zoom) { - return Math.ceil(Math.log2(Math.max(1, zoom))); -} -function getHashPatternZoomName(zoom, theme) { - const lod = getPatternLodForZoomLevel(zoom); - return `tldraw_hash_pattern_${theme}_${lod}`; -} -function getPatternLodsToGenerate(maxZoom) { - const levels = []; - const minLod = 0; - const maxLod = getPatternLodForZoomLevel(maxZoom); - for (let i = minLod; i <= maxLod; i++) { - levels.push(Math.pow(2, i)); - } - return levels; -} -function getDefaultPatterns(maxZoom) { - const defaultPixels2 = getDefaultPixels(); - return getPatternLodsToGenerate(maxZoom).flatMap((zoom) => [ - { zoom, url: defaultPixels2.white, theme: "light" }, - { zoom, url: defaultPixels2.black, theme: "dark" } - ]); -} -function usePattern() { - const editor = useEditor(); - const dpr = useValue("devicePixelRatio", () => editor.getInstanceState().devicePixelRatio, [ - editor - ]); - const maxZoom = useValue("maxZoom", () => Math.ceil(last(editor.getCameraOptions().zoomSteps)), [ - editor - ]); - const [isReady, setIsReady] = (0, import_react46.useState)(false); - const [backgroundUrls, setBackgroundUrls] = (0, import_react46.useState)(() => getDefaultPatterns(maxZoom)); - (0, import_react46.useEffect)(() => { - if (false) { - setIsReady(true); - return; - } - const promise = Promise.all(getPatternLodsToGenerate(maxZoom).flatMap((zoom) => [ - generateImage(dpr, zoom, false).then((blob) => ({ - zoom, - theme: "light", - url: URL.createObjectURL(blob) - })), - generateImage(dpr, zoom, true).then((blob) => ({ - zoom, - theme: "dark", - url: URL.createObjectURL(blob) - })) - ])); - let isCancelled = false; - promise.then((urls) => { - if (isCancelled) - return; - setBackgroundUrls(urls); - setIsReady(true); - }); - return () => { - isCancelled = true; - setIsReady(false); - promise.then((patterns) => { - for (const { url } of patterns) { - URL.revokeObjectURL(url); - } - }); - }; - }, [dpr, maxZoom]); - const defs = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: backgroundUrls.map((item) => { - const id = getHashPatternZoomName(item.zoom, item.theme); - return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("pattern", { - id, - width: TILE_PATTERN_SIZE, - height: TILE_PATTERN_SIZE, - patternUnits: "userSpaceOnUse", - children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("image", { href: item.url, width: TILE_PATTERN_SIZE, height: TILE_PATTERN_SIZE }) - }, id); - }) }); - return { defs, isReady }; -} -function PatternFillDefForCanvas() { - const editor = useEditor(); - const containerRef = (0, import_react46.useRef)(null); - const { defs, isReady } = usePattern(); - (0, import_react46.useEffect)(() => { - if (isReady && editor.environment.isSafari) { - const htmlLayer = findHtmlLayerParent(containerRef.current); - if (htmlLayer) { - editor.timers.requestAnimationFrame(() => { - htmlLayer.style.display = "none"; - editor.timers.requestAnimationFrame(() => { - htmlLayer.style.display = ""; - }); - }); - } - } - }, [editor, isReady]); - return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("g", { ref: containerRef, "data-testid": isReady ? "ready-pattern-fill-defs" : void 0, children: defs }); -} -function findHtmlLayerParent(element) { - if (element.classList.contains("tl-html-layer")) - return element; - if (element.parentElement) - return findHtmlLayerParent(element.parentElement); - return null; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/ShapeFill.mjs -var ShapeFill = import_react47.default.memo(function ShapeFill2({ - theme, - d, - color, - fill, - scale -}) { - switch (fill) { - case "none": { - return null; - } - case "solid": { - return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("path", { fill: theme[color].semi, d }); - } - case "semi": { - return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("path", { fill: theme.solid, d }); - } - case "fill": { - return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("path", { fill: theme[color].fill, d }); - } - case "pattern": { - return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PatternFill, { theme, color, fill, d, scale }); - } - } -}); -function PatternFill({ d, color, theme }) { - const editor = useEditor(); - const svgExport = useSvgExportContext(); - const zoomLevel = useValue("zoomLevel", () => editor.getZoomLevel(), [editor]); - const teenyTiny = editor.getZoomLevel() <= 0.18; - return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("path", { fill: theme[color].pattern, d }), - /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("path", { - fill: svgExport ? `url(#${getHashPatternZoomName(1, theme.id)})` : teenyTiny ? theme[color].semi : `url(#${getHashPatternZoomName(zoomLevel, theme.id)})`, - d - }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/SvgTextLabel.mjs -var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/createTextJsxFromSpans.mjs -var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); -function correctSpacesToNbsp(input) { - return input.replace(/\s/g, "\xA0"); -} -function createTextJsxFromSpans(editor, spans, opts) { - const { padding = 0 } = opts; - if (spans.length === 0) - return null; - const bounds = Box.From(spans[0].box); - for (const { box } of spans) { - bounds.union(box); - } - const offsetX = padding + (opts.offsetX ?? 0); - const offsetY = (opts.offsetY ?? 0) + opts.fontSize / 2 + (opts.verticalTextAlign === "start" ? padding : opts.verticalTextAlign === "end" ? opts.height - padding - bounds.height : (Math.ceil(opts.height) - bounds.height) / 2); - let currentLineTop = null; - const children = []; - for (const { text, box } of spans) { - const didBreakLine = currentLineTop !== null && box.y > currentLineTop; - if (didBreakLine) { - children.push(/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("tspan", { - alignmentBaseline: "mathematical", - x: offsetX, - y: box.y + offsetY, - children: "\n" - }, children.length)); - } - children.push(/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("tspan", { - alignmentBaseline: "mathematical", - x: box.x + offsetX, - y: box.y + offsetY, - unicodeBidi: "plaintext", - children: correctSpacesToNbsp(text) - }, children.length)); - currentLineTop = box.y; - } - return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("text", { - fontSize: opts.fontSize, - fontFamily: opts.fontFamily, - fontStyle: opts.fontStyle, - fontWeight: opts.fontWeight, - dominantBaseline: "mathematical", - alignmentBaseline: "mathematical", - stroke: opts.stroke, - strokeWidth: opts.strokeWidth, - fill: opts.fill, - children - }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/legacyProps.mjs -function getLegacyOffsetX(align, padding, spans, totalWidth) { - if ((align === "start-legacy" || align === "end-legacy") && spans.length !== 0) { - const spansBounds = Box.From(spans[0].box); - for (const { box } of spans) { - spansBounds.union(box); - } - if (align === "start-legacy") { - return (totalWidth - 2 * padding - spansBounds.width) / 2; - } else if (align === "end-legacy") { - return -(totalWidth - 2 * padding - spansBounds.width) / 2; - } - } -} -function isLegacyAlign(align) { - return align === "start-legacy" || align === "middle-legacy" || align === "end-legacy"; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/SvgTextLabel.mjs -function SvgTextLabel({ - fontSize, - font, - align, - verticalAlign, - text, - labelColor, - bounds, - padding = 16, - stroke = true -}) { - const editor = useEditor(); - const theme = useDefaultColorTheme(); - const opts = { - fontSize, - fontFamily: DefaultFontFamilies[font], - textAlign: align, - verticalTextAlign: verticalAlign, - width: Math.ceil(bounds.width), - height: Math.ceil(bounds.height), - padding, - lineHeight: TEXT_PROPS.lineHeight, - fontStyle: "normal", - fontWeight: "normal", - overflow: "wrap", - offsetX: 0, - offsetY: 0, - fill: labelColor, - stroke: void 0, - strokeWidth: void 0 - }; - const spans = editor.textMeasure.measureTextSpans(text, opts); - const offsetX = getLegacyOffsetX(align, padding, spans, bounds.width); - if (offsetX) { - opts.offsetX = offsetX; - } - opts.offsetX += bounds.x; - opts.offsetY += bounds.y; - const mainSpans = createTextJsxFromSpans(editor, spans, opts); - let outlineSpans = null; - if (stroke) { - opts.fill = theme.background; - opts.stroke = theme.background; - opts.strokeWidth = 2; - outlineSpans = createTextJsxFromSpans(editor, spans, opts); - } - return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [ - outlineSpans, - mainSpans - ] }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/TextLabel.mjs -var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); -var import_react50 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/text/TextArea.mjs -var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); -var import_react48 = __toESM(require_react(), 1); -var TextArea = (0, import_react48.forwardRef)(function TextArea2({ - isEditing, - text, - handleFocus, - handleChange, - handleKeyDown, - handleBlur, - handleInputPointerDown, - handleDoubleClick -}, ref) { - return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("textarea", { - ref, - className: "tl-text tl-text-input", - name: "text", - tabIndex: -1, - readOnly: !isEditing, - autoComplete: "off", - autoCapitalize: "off", - autoCorrect: "off", - autoSave: "off", - placeholder: "", - spellCheck: "true", - wrap: "off", - dir: "auto", - defaultValue: text, - onFocus: handleFocus, - onChange: handleChange, - onKeyDown: handleKeyDown, - onBlur: handleBlur, - onTouchEnd: stopEventPropagation, - onContextMenu: isEditing ? stopEventPropagation : void 0, - onPointerDown: handleInputPointerDown, - onDoubleClick: handleDoubleClick, - onDragStart: preventDefault - }); -}); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/useEditableText.mjs -var import_react49 = __toESM(require_react(), 1); -function useEditableText(id, type, text) { - const editor = useEditor(); - const rInput = (0, import_react49.useRef)(null); - const isEditing = useValue("isEditing", () => editor.getEditingShapeId() === id, [editor]); - const isEditingAnything = useValue("isEditingAnything", () => !!editor.getEditingShapeId(), [ - editor - ]); - (0, import_react49.useEffect)(() => { - function selectAllIfEditing({ shapeId }) { - if (shapeId === id) { - rInput.current?.select(); - } - } - editor.on("select-all-text", selectAllIfEditing); - return () => { - editor.off("select-all-text", selectAllIfEditing); - }; - }, [editor, id, isEditing]); - (0, import_react49.useEffect)(() => { - if (!isEditing) - return; - if (document.activeElement !== rInput.current) { - rInput.current?.focus(); - } - if (editor.getInstanceState().isCoarsePointer) { - rInput.current?.select(); - } - if (editor.environment.isSafari) { - rInput.current?.blur(); - rInput.current?.focus(); - } - }, [editor, isEditing]); - const handleKeyDown = (0, import_react49.useCallback)((e) => { - if (editor.getEditingShapeId() !== id) - return; - switch (e.key) { - case "Enter": { - if (e.ctrlKey || e.metaKey) { - editor.complete(); - } - break; - } - } - }, [editor, id]); - const handleChange = (0, import_react49.useCallback)((e) => { - if (editor.getEditingShapeId() !== id) - return; - let text2 = TextHelpers.normalizeText(e.currentTarget.value); - const untabbedText = text2.replace(/\t/g, INDENT); - if (untabbedText !== text2) { - const selectionStart = e.currentTarget.selectionStart; - e.currentTarget.value = untabbedText; - e.currentTarget.selectionStart = selectionStart + (untabbedText.length - text2.length); - e.currentTarget.selectionEnd = selectionStart + (untabbedText.length - text2.length); - text2 = untabbedText; - } - editor.updateShape({ - id, - type, - props: { text: text2 } - }); - }, [editor, id, type]); - const handleInputPointerDown = (0, import_react49.useCallback)((e) => { - editor.dispatch({ - ...getPointerInfo(e), - type: "pointer", - name: "pointer_down", - target: "shape", - shape: editor.getShape(id) - }); - stopEventPropagation(e); - }, [editor, id]); - return { - rInput, - handleFocus: noop, - handleBlur: noop, - handleKeyDown, - handleChange, - handleInputPointerDown, - handleDoubleClick: stopEventPropagation, - isEmpty: text.trim().length === 0, - isEditing, - isEditingAnything - }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/TextLabel.mjs -var TextLabel = import_react50.default.memo(function TextLabel2({ - id, - type, - text, - labelColor, - font, - fontSize, - lineHeight, - align, - verticalAlign, - wrap: wrap2, - isSelected, - padding = 0, - onKeyDown: handleKeyDownCustom, - classNamePrefix, - style, - textWidth, - textHeight -}) { - const { rInput, isEmpty, isEditing, isEditingAnything, ...editableTextRest } = useEditableText(id, type, text); - const [initialText, setInitialText] = (0, import_react50.useState)(text); - (0, import_react50.useEffect)(() => { - if (!isEditing) - setInitialText(text); - }, [isEditing, text]); - const finalText = TextHelpers.normalizeTextForDom(text); - const hasText = finalText.length > 0; - const legacyAlign = isLegacyAlign(align); - if (!isEditing && !hasText) { - return null; - } - const cssPrefix = classNamePrefix || "tl-text"; - return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { - className: `${cssPrefix}-label tl-text-wrapper`, - "data-font": font, - "data-align": align, - "data-hastext": !isEmpty, - "data-isediting": isEditing, - "data-iseditinganything": isEditingAnything, - "data-textwrap": !!wrap2, - "data-isselected": isSelected, - style: { - justifyContent: align === "middle" || legacyAlign ? "center" : align, - alignItems: verticalAlign === "middle" ? "center" : verticalAlign, - padding, - ...style - }, - children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { - className: `${cssPrefix}-label__inner tl-text-content__wrapper`, - style: { - fontSize, - lineHeight: Math.floor(fontSize * lineHeight) + "px", - minHeight: Math.floor(fontSize * lineHeight) + "px", - minWidth: Math.ceil(textWidth || 0), - color: labelColor, - width: textWidth ? Math.ceil(textWidth) : void 0, - height: textHeight ? Math.ceil(textHeight) : void 0 - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: `${cssPrefix} tl-text tl-text-content`, dir: "auto", children: finalText.split("\n").map((lineOfText, index2) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { dir: "auto", children: lineOfText }, index2)) }), - (isEditingAnything || isSelected) && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TextArea, { - ref: rInput, - text, - isEditing, - ...editableTextRest, - handleKeyDown: handleKeyDownCustom ?? editableTextRest.handleKeyDown - }, initialText) - ] - }) - }); -}); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/getPerfectDashProps.mjs -function getPerfectDashProps2(totalLength, strokeWidth, opts = {}) { - const { - closed = false, - snap = 1, - start = "outset", - end = "outset", - lengthRatio = 2, - style = "dashed" - } = opts; - let dashLength = 0; - let dashCount = 0; - let ratio = 1; - let gapLength = 0; - let strokeDashoffset = 0; - switch (style) { - case "dashed": { - ratio = 1; - dashLength = Math.min(strokeWidth * lengthRatio, totalLength / 4); - break; - } - case "dotted": { - ratio = 100; - dashLength = strokeWidth / ratio; - break; - } - default: { - return { - strokeDasharray: "none", - strokeDashoffset: "none" - }; - } - } - if (!closed) { - if (start === "outset") { - totalLength += dashLength / 2; - strokeDashoffset += dashLength / 2; - } else if (start === "skip") { - totalLength -= dashLength; - strokeDashoffset -= dashLength; - } - if (end === "outset") { - totalLength += dashLength / 2; - } else if (end === "skip") { - totalLength -= dashLength; - } - } - dashCount = Math.floor(totalLength / dashLength / (2 * ratio)); - dashCount -= dashCount % snap; - if (dashCount < 3 && style === "dashed") { - if (totalLength / strokeWidth < 4) { - dashLength = totalLength; - dashCount = 1; - gapLength = 0; - } else { - dashLength = totalLength * (1 / 3); - gapLength = totalLength * (1 / 3); - } - } else { - dashLength = totalLength / dashCount / (2 * ratio); - if (closed) { - strokeDashoffset = dashLength / 2; - gapLength = (totalLength - dashCount * dashLength) / dashCount; - } else { - gapLength = (totalLength - dashCount * dashLength) / Math.max(1, dashCount - 1); - } - } - return { - strokeDasharray: [dashLength, gapLength].join(" "), - strokeDashoffset: strokeDashoffset.toString() - }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/arrowLabel.mjs -var labelSizeCache = /* @__PURE__ */ new WeakMap(); -function getArrowLabelSize(editor, shape) { - const cachedSize = labelSizeCache.get(shape); - if (cachedSize) - return cachedSize; - const info2 = getArrowInfo(editor, shape); - let width = 0; - let height = 0; - const bodyGeom = info2.isStraight ? new Edge2d({ - start: Vec.From(info2.start.point), - end: Vec.From(info2.end.point) - }) : new Arc2d({ - center: Vec.Cast(info2.handleArc.center), - start: Vec.Cast(info2.start.point), - end: Vec.Cast(info2.end.point), - sweepFlag: info2.bodyArc.sweepFlag, - largeArcFlag: info2.bodyArc.largeArcFlag - }); - if (shape.props.text.trim()) { - const bodyBounds = bodyGeom.bounds; - const fontSize = getArrowLabelFontSize(shape); - const { w, h } = editor.textMeasure.measureText(shape.props.text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[shape.props.font], - fontSize, - maxWidth: null - }); - width = w; - height = h; - if (bodyBounds.width > bodyBounds.height) { - width = Math.max(Math.min(w, 64), Math.min(bodyBounds.width - 64, w)); - const { w: squishedWidth, h: squishedHeight } = editor.textMeasure.measureText(shape.props.text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[shape.props.font], - fontSize, - maxWidth: width - }); - width = squishedWidth; - height = squishedHeight; - } - if (width > 16 * fontSize) { - width = 16 * fontSize; - const { w: squishedWidth, h: squishedHeight } = editor.textMeasure.measureText(shape.props.text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[shape.props.font], - fontSize, - maxWidth: width - }); - width = squishedWidth; - height = squishedHeight; - } - } - const size4 = new Vec(width, height).addScalar(ARROW_LABEL_PADDING * 2 * shape.props.scale); - labelSizeCache.set(shape, size4); - return size4; -} -function getLabelToArrowPadding(shape) { - const strokeWidth = STROKE_SIZES2[shape.props.size]; - const labelToArrowPadding = (LABEL_TO_ARROW_PADDING + (strokeWidth - STROKE_SIZES2.s) * 2 + (strokeWidth === STROKE_SIZES2.xl ? 20 : 0)) * shape.props.scale; - return labelToArrowPadding; -} -function getStraightArrowLabelRange(editor, shape, info2) { - const labelSize = getArrowLabelSize(editor, shape); - const labelToArrowPadding = getLabelToArrowPadding(shape); - const startOffset = Vec.Nudge(info2.start.point, info2.end.point, labelToArrowPadding); - const endOffset = Vec.Nudge(info2.end.point, info2.start.point, labelToArrowPadding); - const intersectionPoints = intersectLineSegmentPolygon(startOffset, endOffset, Box.FromCenter(info2.middle, labelSize).corners); - if (!intersectionPoints || intersectionPoints.length !== 2) { - return { start: 0.5, end: 0.5 }; - } - let [startIntersect, endIntersect] = intersectionPoints; - if (Vec.Dist2(startIntersect, startOffset) > Vec.Dist2(endIntersect, startOffset)) { - ; - [endIntersect, startIntersect] = intersectionPoints; - } - const startConstrained = startOffset.add(Vec.Sub(info2.middle, startIntersect)); - const endConstrained = endOffset.add(Vec.Sub(info2.middle, endIntersect)); - const start = Vec.Dist(info2.start.point, startConstrained) / info2.length; - const end = Vec.Dist(info2.start.point, endConstrained) / info2.length; - return { start, end }; -} -function getCurvedArrowLabelRange(editor, shape, info2) { - const labelSize = getArrowLabelSize(editor, shape); - const labelToArrowPadding = getLabelToArrowPadding(shape); - const direction = Math.sign(shape.props.bend); - const labelToArrowPaddingRad = labelToArrowPadding / info2.handleArc.radius * direction; - const startOffsetAngle = Vec.Angle(info2.bodyArc.center, info2.start.point) - labelToArrowPaddingRad; - const endOffsetAngle = Vec.Angle(info2.bodyArc.center, info2.end.point) + labelToArrowPaddingRad; - const startOffset = getPointOnCircle(info2.bodyArc.center, info2.bodyArc.radius, startOffsetAngle); - const endOffset = getPointOnCircle(info2.bodyArc.center, info2.bodyArc.radius, endOffsetAngle); - const dbg = []; - const startIntersections = intersectArcPolygon(info2.bodyArc.center, info2.bodyArc.radius, startOffsetAngle, endOffsetAngle, direction, Box.FromCenter(startOffset, labelSize).corners); - dbg.push(new Polygon2d({ - points: Box.FromCenter(startOffset, labelSize).corners, - debugColor: "lime", - isFilled: false, - ignore: true - })); - const endIntersections = intersectArcPolygon(info2.bodyArc.center, info2.bodyArc.radius, startOffsetAngle, endOffsetAngle, direction, Box.FromCenter(endOffset, labelSize).corners); - dbg.push(new Polygon2d({ - points: Box.FromCenter(endOffset, labelSize).corners, - debugColor: "lime", - isFilled: false, - ignore: true - })); - for (const pt of [ - ...startIntersections ?? [], - ...endIntersections ?? [], - startOffset, - endOffset - ]) { - dbg.push(new Circle2d({ - x: pt.x - 3, - y: pt.y - 3, - radius: 3, - isFilled: false, - debugColor: "magenta", - ignore: true - })); - } - const startConstrained = (startIntersections && furthest(info2.start.point, startIntersections)) ?? info2.middle; - const endConstrained = (endIntersections && furthest(info2.end.point, endIntersections)) ?? info2.middle; - const startAngle = Vec.Angle(info2.bodyArc.center, info2.start.point); - const endAngle = Vec.Angle(info2.bodyArc.center, info2.end.point); - const constrainedStartAngle = Vec.Angle(info2.bodyArc.center, startConstrained); - const constrainedEndAngle = Vec.Angle(info2.bodyArc.center, endConstrained); - if (angleDistance(startAngle, constrainedStartAngle, direction) > angleDistance(startAngle, constrainedEndAngle, direction)) { - return { start: 0.5, end: 0.5, dbg }; - } - const fullDistance = angleDistance(startAngle, endAngle, direction); - const start = angleDistance(startAngle, constrainedStartAngle, direction) / fullDistance; - const end = angleDistance(startAngle, constrainedEndAngle, direction) / fullDistance; - return { start, end, dbg }; -} -function getArrowLabelPosition(editor, shape) { - let labelCenter; - const debugGeom = []; - const info2 = getArrowInfo(editor, shape); - const hasStartBinding = !!info2.bindings.start; - const hasEndBinding = !!info2.bindings.end; - const hasStartArrowhead = info2.start.arrowhead !== "none"; - const hasEndArrowhead = info2.end.arrowhead !== "none"; - if (info2.isStraight) { - const range = getStraightArrowLabelRange(editor, shape, info2); - let clampedPosition = clamp(shape.props.labelPosition, hasStartArrowhead || hasStartBinding ? range.start : 0, hasEndArrowhead || hasEndBinding ? range.end : 1); - clampedPosition = clampedPosition >= 0.48 && clampedPosition <= 0.52 ? 0.5 : clampedPosition; - labelCenter = Vec.Lrp(info2.start.point, info2.end.point, clampedPosition); - } else { - const range = getCurvedArrowLabelRange(editor, shape, info2); - if (range.dbg) - debugGeom.push(...range.dbg); - let clampedPosition = clamp(shape.props.labelPosition, hasStartArrowhead || hasStartBinding ? range.start : 0, hasEndArrowhead || hasEndBinding ? range.end : 1); - clampedPosition = clampedPosition >= 0.48 && clampedPosition <= 0.52 ? 0.5 : clampedPosition; - const labelAngle = interpolateArcAngles(Vec.Angle(info2.bodyArc.center, info2.start.point), Vec.Angle(info2.bodyArc.center, info2.end.point), Math.sign(shape.props.bend), clampedPosition); - labelCenter = getPointOnCircle(info2.bodyArc.center, info2.bodyArc.radius, labelAngle); - } - const labelSize = getArrowLabelSize(editor, shape); - return { box: Box.FromCenter(labelCenter, labelSize), debugGeom }; -} -function intersectArcPolygon(center, radius, angleStart, angleEnd, direction, polygon) { - const intersections = intersectCirclePolygon(center, radius, polygon); - const fullArcDistance = angleDistance(angleStart, angleEnd, direction); - return intersections?.filter((pt) => { - const pDistance = angleDistance(angleStart, Vec.Angle(center, pt), direction); - return pDistance >= 0 && pDistance <= fullArcDistance; - }); -} -function furthest(from, candidates) { - let furthest2 = null; - let furthestDist = -Infinity; - for (const candidate of candidates) { - const dist = Vec.Dist2(from, candidate); - if (dist > furthestDist) { - furthest2 = candidate; - furthestDist = dist; - } - } - return furthest2; -} -function interpolateArcAngles(angleStart, angleEnd, direction, t2) { - const dist = angleDistance(angleStart, angleEnd, direction); - return angleStart + dist * t2 * direction * -1; -} -function getArrowLabelFontSize(shape) { - return ARROW_LABEL_FONT_SIZES[shape.props.size] * shape.props.scale; -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/arrowheads.mjs -function getArrowPoints(info2, side, strokeWidth) { - const PT = side === "end" ? info2.end.point : info2.start.point; - const PB = side === "end" ? info2.start.point : info2.end.point; - const compareLength = info2.isStraight ? Vec.Dist(PB, PT) : Math.abs(info2.bodyArc.length); - const length = Math.max(Math.min(compareLength / 5, strokeWidth * 3), strokeWidth); - let P0; - if (info2.isStraight) { - P0 = Vec.Nudge(PT, PB, length); - } else { - const ints = intersectCircleCircle(PT, length, info2.handleArc.center, info2.handleArc.radius); - P0 = side === "end" ? info2.handleArc.sweepFlag ? ints[0] : ints[1] : info2.handleArc.sweepFlag ? ints[1] : ints[0]; - } - if (Vec.IsNaN(P0)) { - P0 = info2.start.point; - } - return { - point: PT, - int: P0 - }; -} -function getArrowhead({ point, int }) { - const PL = Vec.RotWith(int, point, PI / 6); - const PR = Vec.RotWith(int, point, -PI / 6); - return `M ${PL.x} ${PL.y} L ${point.x} ${point.y} L ${PR.x} ${PR.y}`; -} -function getTriangleHead({ point, int }) { - const PL = Vec.RotWith(int, point, PI / 6); - const PR = Vec.RotWith(int, point, -PI / 6); - return `M ${PL.x} ${PL.y} L ${point.x} ${point.y} L ${PR.x} ${PR.y} Z`; -} -function getInvertedTriangleHead({ point, int }) { - const d = Vec.Sub(int, point).div(2); - const PL = Vec.Add(point, Vec.Rot(d, HALF_PI)); - const PR = Vec.Sub(point, Vec.Rot(d, HALF_PI)); - return `M ${PL.x} ${PL.y} L ${int.x} ${int.y} L ${PR.x} ${PR.y} Z`; -} -function getDotHead({ point, int }) { - const A = Vec.Lrp(point, int, 0.45); - const r = Vec.Dist(A, point); - return `M ${A.x - r},${A.y} - a ${r},${r} 0 1,0 ${r * 2},0 - a ${r},${r} 0 1,0 -${r * 2},0 `; -} -function getDiamondHead({ point, int }) { - const PB = Vec.Lrp(point, int, 0.75); - const PL = Vec.RotWith(PB, point, PI / 4); - const PR = Vec.RotWith(PB, point, -PI / 4); - const PQ = Vec.Lrp(PL, PR, 0.5); - PQ.add(Vec.Sub(PQ, point)); - return `M ${PQ.x} ${PQ.y} L ${PL.x} ${PL.y} ${point.x} ${point.y} L ${PR.x} ${PR.y} Z`; -} -function getSquareHead({ int, point }) { - const PB = Vec.Lrp(point, int, 0.85); - const d = Vec.Sub(PB, point).div(2); - const PL1 = Vec.Add(point, Vec.Rot(d, HALF_PI)); - const PR1 = Vec.Sub(point, Vec.Rot(d, HALF_PI)); - const PL2 = Vec.Add(PB, Vec.Rot(d, HALF_PI)); - const PR2 = Vec.Sub(PB, Vec.Rot(d, HALF_PI)); - return `M ${PL1.x} ${PL1.y} L ${PL2.x} ${PL2.y} L ${PR2.x} ${PR2.y} L ${PR1.x} ${PR1.y} Z`; -} -function getBarHead({ int, point }) { - const d = Vec.Sub(int, point).div(2); - const PL = Vec.Add(point, Vec.Rot(d, HALF_PI)); - const PR = Vec.Sub(point, Vec.Rot(d, HALF_PI)); - return `M ${PL.x} ${PL.y} L ${PR.x} ${PR.y}`; -} -function getArrowheadPathForType(info2, side, strokeWidth) { - const type = side === "end" ? info2.end.arrowhead : info2.start.arrowhead; - if (type === "none") - return; - const points = getArrowPoints(info2, side, strokeWidth); - if (!points) - return; - switch (type) { - case "bar": - return getBarHead(points); - case "square": - return getSquareHead(points); - case "diamond": - return getDiamondHead(points); - case "dot": - return getDotHead(points); - case "inverted": - return getInvertedTriangleHead(points); - case "arrow": - return getArrowhead(points); - case "triangle": - return getTriangleHead(points); - } - return ""; -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/arrowpaths.mjs -function getCurvedArrowHandlePath(info2) { - const { - start, - end, - handleArc: { radius, largeArcFlag, sweepFlag } - } = info2; - return `M${start.handle.x},${start.handle.y} A${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.handle.x},${end.handle.y}`; -} -function getSolidCurvedArrowPath(info2) { - const { - start, - end, - bodyArc: { radius, largeArcFlag, sweepFlag } - } = info2; - return `M${start.point.x},${start.point.y} A${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.point.x},${end.point.y}`; -} -function getArrowPath(start, end) { - return `M${start.x},${start.y}L${end.x},${end.y}`; -} -function getStraightArrowHandlePath(info2) { - return getArrowPath(info2.start.handle, info2.end.handle); -} -function getSolidStraightArrowPath(info2) { - return getArrowPath(info2.start.point, info2.end.point); -} - -// node_modules/tldraw/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs -var globalRenderIndex = 0; -var ArrowShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canEdit", () => true); - __publicField(this, "canSnap", () => false); - __publicField(this, "hideResizeHandles", () => true); - __publicField(this, "hideRotateHandle", () => true); - __publicField(this, "hideSelectionBoundsBg", () => true); - __publicField(this, "hideSelectionBoundsFg", () => true); - __publicField(this, "canBeLaidOut", (shape) => { - const bindings = getArrowBindings(this.editor, shape); - return !bindings.start && !bindings.end; - }); - __publicField(this, "onHandleDrag", (shape, { handle, isPrecise }) => { - const handleId = handle.id; - const bindings = getArrowBindings(this.editor, shape); - if (handleId === "middle") { - const { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, bindings); - const delta = Vec.Sub(end, start); - const v = Vec.Per(delta); - const med = Vec.Med(end, start); - const A = Vec.Sub(med, v); - const B = Vec.Add(med, v); - const point2 = Vec.NearestPointOnLineSegment(A, B, handle, false); - let bend = Vec.Dist(point2, med); - if (Vec.Clockwise(point2, end, med)) - bend *= -1; - return { id: shape.id, type: shape.type, props: { bend } }; - } - const update = { id: shape.id, type: "arrow", props: {} }; - const currentBinding = bindings[handleId]; - const otherHandleId = handleId === "start" ? "end" : "start"; - const otherBinding = bindings[otherHandleId]; - if (this.editor.inputs.ctrlKey) { - removeArrowBinding(this.editor, shape, handleId); - update.props[handleId] = { - x: handle.x, - y: handle.y - }; - return update; - } - const point = this.editor.getShapePageTransform(shape.id).applyToPoint(handle); - const target = this.editor.getShapeAtPoint(point, { - hitInside: true, - hitFrameInside: true, - margin: 0, - filter: (targetShape) => { - return !targetShape.isLocked && this.editor.canBindShapes({ fromShape: shape, toShape: targetShape, binding: "arrow" }); - } - }); - if (!target) { - removeArrowBinding(this.editor, shape, handleId); - update.props[handleId] = { - x: handle.x, - y: handle.y - }; - return update; - } - const targetGeometry = this.editor.getShapeGeometry(target); - const targetBounds = Box.ZeroFix(targetGeometry.bounds); - const pageTransform = this.editor.getShapePageTransform(update.id); - const pointInPageSpace = pageTransform.applyToPoint(handle); - const pointInTargetSpace = this.editor.getPointInShapeSpace(target, pointInPageSpace); - let precise2 = isPrecise; - if (!precise2) { - if (!currentBinding || currentBinding && target.id !== currentBinding.toId) { - precise2 = this.editor.inputs.pointerVelocity.len() < 0.5; - } - } - if (!isPrecise) { - if (!targetGeometry.isClosed) { - precise2 = true; - } - if (otherBinding && target.id === otherBinding.toId && otherBinding.props.isPrecise) { - precise2 = true; - } - } - const normalizedAnchor = { - x: (pointInTargetSpace.x - targetBounds.minX) / targetBounds.width, - y: (pointInTargetSpace.y - targetBounds.minY) / targetBounds.height - }; - if (precise2) { - if (Vec.Dist(pointInTargetSpace, targetBounds.center) < Math.max(4, Math.min(Math.min(targetBounds.width, targetBounds.height) * 0.15, 16)) / this.editor.getZoomLevel()) { - normalizedAnchor.x = 0.5; - normalizedAnchor.y = 0.5; - } - } - const b = { - terminal: handleId, - normalizedAnchor, - isPrecise: precise2, - isExact: this.editor.inputs.altKey - }; - createOrUpdateArrowBinding(this.editor, shape, target.id, b); - this.editor.setHintingShapes([target.id]); - const newBindings = getArrowBindings(this.editor, shape); - if (newBindings.start && newBindings.end && newBindings.start.toId === newBindings.end.toId) { - if (Vec.Equals(newBindings.start.props.normalizedAnchor, newBindings.end.props.normalizedAnchor)) { - createOrUpdateArrowBinding(this.editor, shape, newBindings.end.toId, { - ...newBindings.end.props, - normalizedAnchor: { - x: newBindings.end.props.normalizedAnchor.x + 0.05, - y: newBindings.end.props.normalizedAnchor.y - } - }); - } - } - return update; - }); - __publicField(this, "onTranslateStart", (shape) => { - const bindings = getArrowBindings(this.editor, shape); - const terminalsInArrowSpace = getArrowTerminalsInArrowSpace(this.editor, shape, bindings); - const shapePageTransform = this.editor.getShapePageTransform(shape.id); - const selectedShapeIds = this.editor.getSelectedShapeIds(); - if (bindings.start && (selectedShapeIds.includes(bindings.start.toId) || this.editor.isAncestorSelected(bindings.start.toId)) || bindings.end && (selectedShapeIds.includes(bindings.end.toId) || this.editor.isAncestorSelected(bindings.end.toId))) { - return; - } - shapeAtTranslationStart.set(shape, { - pagePosition: shapePageTransform.applyToPoint(shape), - terminalBindings: mapObjectMapValues(terminalsInArrowSpace, (terminalName, point) => { - const binding = bindings[terminalName]; - if (!binding) - return null; - return { - binding, - shapePosition: point, - pagePosition: shapePageTransform.applyToPoint(point) - }; - }) - }); - if (bindings.start) { - updateArrowTerminal({ - editor: this.editor, - arrow: shape, - terminal: "start", - useHandle: true - }); - shape = this.editor.getShape(shape.id); - } - if (bindings.end) { - updateArrowTerminal({ - editor: this.editor, - arrow: shape, - terminal: "end", - useHandle: true - }); - } - for (const handleName of ["start", "end"]) { - const binding = bindings[handleName]; - if (!binding) - continue; - this.editor.updateBinding({ - ...binding, - props: { ...binding.props, isPrecise: true } - }); - } - return; - }); - __publicField(this, "onTranslate", (initialShape, shape) => { - const atTranslationStart = shapeAtTranslationStart.get(initialShape); - if (!atTranslationStart) - return; - const shapePageTransform = this.editor.getShapePageTransform(shape.id); - const pageDelta = Vec.Sub(shapePageTransform.applyToPoint(shape), atTranslationStart.pagePosition); - for (const terminalBinding of Object.values(atTranslationStart.terminalBindings)) { - if (!terminalBinding) - continue; - const newPagePoint = Vec.Add(terminalBinding.pagePosition, Vec.Mul(pageDelta, 0.5)); - const newTarget = this.editor.getShapeAtPoint(newPagePoint, { - hitInside: true, - hitFrameInside: true, - margin: 0, - filter: (targetShape) => { - return !targetShape.isLocked && this.editor.canBindShapes({ fromShape: shape, toShape: targetShape, binding: "arrow" }); - } - }); - if (newTarget?.id === terminalBinding.binding.toId) { - const targetBounds = Box.ZeroFix(this.editor.getShapeGeometry(newTarget).bounds); - const pointInTargetSpace = this.editor.getPointInShapeSpace(newTarget, newPagePoint); - const normalizedAnchor = { - x: (pointInTargetSpace.x - targetBounds.minX) / targetBounds.width, - y: (pointInTargetSpace.y - targetBounds.minY) / targetBounds.height - }; - createOrUpdateArrowBinding(this.editor, shape, newTarget.id, { - ...terminalBinding.binding.props, - normalizedAnchor, - isPrecise: true - }); - } else { - removeArrowBinding(this.editor, shape, terminalBinding.binding.props.terminal); - } - } - }); - __publicField(this, "_resizeInitialBindings", new WeakCache()); - __publicField(this, "onResize", (shape, info2) => { - const { scaleX, scaleY } = info2; - const bindings = this._resizeInitialBindings.get(shape, () => getArrowBindings(this.editor, shape)); - const terminals = getArrowTerminalsInArrowSpace(this.editor, shape, bindings); - const { start, end } = structuredClone(shape.props); - let { bend } = shape.props; - if (!bindings.start) { - start.x = terminals.start.x * scaleX; - start.y = terminals.start.y * scaleY; - } - if (!bindings.end) { - end.x = terminals.end.x * scaleX; - end.y = terminals.end.y * scaleY; - } - const mx = Math.abs(scaleX); - const my = Math.abs(scaleY); - const startNormalizedAnchor = bindings?.start ? Vec.From(bindings.start.props.normalizedAnchor) : null; - const endNormalizedAnchor = bindings?.end ? Vec.From(bindings.end.props.normalizedAnchor) : null; - if (scaleX < 0 && scaleY >= 0) { - if (bend !== 0) { - bend *= -1; - bend *= Math.max(mx, my); - } - if (startNormalizedAnchor) { - startNormalizedAnchor.x = 1 - startNormalizedAnchor.x; - } - if (endNormalizedAnchor) { - endNormalizedAnchor.x = 1 - endNormalizedAnchor.x; - } - } else if (scaleX >= 0 && scaleY < 0) { - if (bend !== 0) { - bend *= -1; - bend *= Math.max(mx, my); - } - if (startNormalizedAnchor) { - startNormalizedAnchor.y = 1 - startNormalizedAnchor.y; - } - if (endNormalizedAnchor) { - endNormalizedAnchor.y = 1 - endNormalizedAnchor.y; - } - } else if (scaleX >= 0 && scaleY >= 0) { - if (bend !== 0) { - bend *= Math.max(mx, my); - } - } else if (scaleX < 0 && scaleY < 0) { - if (bend !== 0) { - bend *= Math.max(mx, my); - } - if (startNormalizedAnchor) { - startNormalizedAnchor.x = 1 - startNormalizedAnchor.x; - startNormalizedAnchor.y = 1 - startNormalizedAnchor.y; - } - if (endNormalizedAnchor) { - endNormalizedAnchor.x = 1 - endNormalizedAnchor.x; - endNormalizedAnchor.y = 1 - endNormalizedAnchor.y; - } - } - if (bindings.start && startNormalizedAnchor) { - createOrUpdateArrowBinding(this.editor, shape, bindings.start.toId, { - ...bindings.start.props, - normalizedAnchor: startNormalizedAnchor.toJson() - }); - } - if (bindings.end && endNormalizedAnchor) { - createOrUpdateArrowBinding(this.editor, shape, bindings.end.toId, { - ...bindings.end.props, - normalizedAnchor: endNormalizedAnchor.toJson() - }); - } - const next = { - props: { - start, - end, - bend - } - }; - return next; - }); - __publicField(this, "onDoubleClickHandle", (shape, handle) => { - switch (handle.id) { - case "start": { - return { - id: shape.id, - type: shape.type, - props: { - ...shape.props, - arrowheadStart: shape.props.arrowheadStart === "none" ? "arrow" : "none" - } - }; - } - case "end": { - return { - id: shape.id, - type: shape.type, - props: { - ...shape.props, - arrowheadEnd: shape.props.arrowheadEnd === "none" ? "arrow" : "none" - } - }; - } - } - }); - __publicField(this, "onEditEnd", (shape) => { - const { - id, - type, - props: { text } - } = shape; - if (text.trimEnd() !== shape.props.text) { - this.editor.updateShapes([ - { - id, - type, - props: { - text: text.trimEnd() - } - } - ]); - } - }); - } - canBind({ toShapeType }) { - return toShapeType !== "arrow"; - } - getDefaultProps() { - return { - dash: "draw", - size: "m", - fill: "none", - color: "black", - labelColor: "black", - bend: 0, - start: { x: 0, y: 0 }, - end: { x: 2, y: 0 }, - arrowheadStart: "none", - arrowheadEnd: "arrow", - text: "", - labelPosition: 0.5, - font: "draw", - scale: 1 - }; - } - getGeometry(shape) { - const info2 = getArrowInfo(this.editor, shape); - const debugGeom = []; - const bodyGeom = info2.isStraight ? new Edge2d({ - start: Vec.From(info2.start.point), - end: Vec.From(info2.end.point) - }) : new Arc2d({ - center: Vec.Cast(info2.handleArc.center), - start: Vec.Cast(info2.start.point), - end: Vec.Cast(info2.end.point), - sweepFlag: info2.bodyArc.sweepFlag, - largeArcFlag: info2.bodyArc.largeArcFlag - }); - let labelGeom; - if (shape.props.text.trim()) { - const labelPosition = getArrowLabelPosition(this.editor, shape); - debugGeom.push(...labelPosition.debugGeom); - labelGeom = new Rectangle2d({ - x: labelPosition.box.x, - y: labelPosition.box.y, - width: labelPosition.box.w, - height: labelPosition.box.h, - isFilled: true, - isLabel: true - }); - } - return new Group2d({ - children: [...labelGeom ? [bodyGeom, labelGeom] : [bodyGeom], ...debugGeom] - }); - } - getHandles(shape) { - const info2 = getArrowInfo(this.editor, shape); - return [ - { - id: "start", - type: "vertex", - index: "a0", - x: info2.start.handle.x, - y: info2.start.handle.y - }, - { - id: "middle", - type: "virtual", - index: "a2", - x: info2.middle.x, - y: info2.middle.y - }, - { - id: "end", - type: "vertex", - index: "a3", - x: info2.end.handle.x, - y: info2.end.handle.y - } - ].filter(Boolean); - } - component(shape) { - const theme = useDefaultColorTheme(); - const onlySelectedShape = this.editor.getOnlySelectedShape(); - const shouldDisplayHandles = this.editor.isInAny("select.idle", "select.pointing_handle", "select.dragging_handle", "select.translating", "arrow.dragging") && !this.editor.getInstanceState().isReadonly; - const info2 = getArrowInfo(this.editor, shape); - if (!info2?.isValid) - return null; - const labelPosition = getArrowLabelPosition(this.editor, shape); - const isSelected = shape.id === this.editor.getOnlySelectedShapeId(); - const isEditing = this.editor.getEditingShapeId() === shape.id; - const showArrowLabel = isEditing || shape.props.text; - return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SVGContainer, { id: shape.id, style: { minWidth: 50, minHeight: 50 }, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowSvg, { - shape, - shouldDisplayHandles: shouldDisplayHandles && onlySelectedShape?.id === shape.id - }) }), - showArrowLabel && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TextLabel, { - id: shape.id, - classNamePrefix: "tl-arrow", - type: "arrow", - font: shape.props.font, - fontSize: getArrowLabelFontSize(shape), - lineHeight: TEXT_PROPS.lineHeight, - align: "middle", - verticalAlign: "middle", - text: shape.props.text, - labelColor: theme[shape.props.labelColor].solid, - textWidth: labelPosition.box.w, - isSelected, - padding: 0, - style: { - transform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)` - } - }) - ] }); - } - indicator(shape) { - const isEditing = useIsEditing(shape.id); - const info2 = getArrowInfo(this.editor, shape); - if (!info2) - return null; - const { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, info2?.bindings); - const geometry = this.editor.getShapeGeometry(shape); - const bounds = geometry.bounds; - const labelGeometry = shape.props.text.trim() ? geometry.children[1] : null; - if (Vec.Equals(start, end)) - return null; - const strokeWidth = STROKE_SIZES2[shape.props.size] * shape.props.scale; - const as = info2.start.arrowhead && getArrowheadPathForType(info2, "start", strokeWidth); - const ae = info2.end.arrowhead && getArrowheadPathForType(info2, "end", strokeWidth); - const path = info2.isStraight ? getSolidStraightArrowPath(info2) : getSolidCurvedArrowPath(info2); - const includeMask = as && info2.start.arrowhead !== "arrow" || ae && info2.end.arrowhead !== "arrow" || !!labelGeometry; - const maskId = (shape.id + "_clip").replace(":", "_"); - if (isEditing && labelGeometry) { - return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: toDomPrecision(labelGeometry.x), - y: toDomPrecision(labelGeometry.y), - width: labelGeometry.w, - height: labelGeometry.h, - rx: 3.5 * shape.props.scale, - ry: 3.5 * shape.props.scale - }); - } - return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("g", { children: [ - includeMask && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("mask", { id: maskId, children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: bounds.minX - 100, - y: bounds.minY - 100, - width: bounds.w + 200, - height: bounds.h + 200, - fill: "white" - }), - labelGeometry && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: toDomPrecision(labelGeometry.x), - y: toDomPrecision(labelGeometry.y), - width: labelGeometry.w, - height: labelGeometry.h, - fill: "black", - rx: 3.5 * shape.props.scale, - ry: 3.5 * shape.props.scale - }), - as && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { - d: as, - fill: info2.start.arrowhead === "arrow" ? "none" : "black", - stroke: "none" - }), - ae && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { - d: ae, - fill: info2.end.arrowhead === "arrow" ? "none" : "black", - stroke: "none" - }) - ] }) }), - /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("g", { ...includeMask ? { mask: `url(#${maskId})` } : void 0, children: [ - includeMask && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: bounds.minX - 100, - y: bounds.minY - 100, - width: bounds.width + 200, - height: bounds.height + 200, - opacity: 0 - }), - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: path }) - ] }), - as && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: as }), - ae && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: ae }), - labelGeometry && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: toDomPrecision(labelGeometry.x), - y: toDomPrecision(labelGeometry.y), - width: labelGeometry.w, - height: labelGeometry.h, - rx: 3.5, - ry: 3.5 - }) - ] }); - } - toSvg(shape, ctx) { - ctx.addExportDef(getFillDefForExport(shape.props.fill)); - if (shape.props.text) - ctx.addExportDef(getFontDefForExport(shape.props.font)); - const theme = getDefaultColorTheme(ctx); - const scaleFactor = 1 / shape.props.scale; - return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("g", { transform: `scale(${scaleFactor})`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowSvg, { shape, shouldDisplayHandles: false }), - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SvgTextLabel, { - fontSize: getArrowLabelFontSize(shape), - font: shape.props.font, - align: "middle", - verticalAlign: "middle", - text: shape.props.text, - labelColor: theme[shape.props.labelColor].solid, - bounds: getArrowLabelPosition(this.editor, shape).box, - padding: 4 * shape.props.scale - }) - ] }); - } - getCanvasSvgDefs() { - return [ - getFillDefForCanvas(), - { - key: `arrow:dot`, - component: ArrowheadDotDef - }, - { - key: `arrow:cross`, - component: ArrowheadCrossDef - } - ]; - } - getInterpolatedProps(startShape, endShape, progress) { - return { - ...endShape.props, - start: { - x: lerp(startShape.props.start.x, endShape.props.start.x, progress), - y: lerp(startShape.props.start.y, endShape.props.start.y, progress) - }, - end: { - x: lerp(startShape.props.end.x, endShape.props.end.x, progress), - y: lerp(startShape.props.end.y, endShape.props.end.y, progress) - }, - bend: lerp(startShape.props.bend, endShape.props.bend, progress), - labelPosition: lerp(startShape.props.labelPosition, endShape.props.labelPosition, progress) - }; - } -}; -__publicField(ArrowShapeUtil, "type", "arrow"); -__publicField(ArrowShapeUtil, "props", arrowShapeProps); -__publicField(ArrowShapeUtil, "migrations", arrowShapeMigrations); -function getLength(editor, shape) { - const info2 = getArrowInfo(editor, shape); - return info2.isStraight ? Vec.Dist(info2.start.handle, info2.end.handle) : Math.abs(info2.handleArc.length); -} -var ArrowSvg = track(function ArrowSvg2({ - shape, - shouldDisplayHandles -}) { - const editor = useEditor(); - const theme = useDefaultColorTheme(); - const info2 = getArrowInfo(editor, shape); - const bounds = Box.ZeroFix(editor.getShapeGeometry(shape).bounds); - const bindings = getArrowBindings(editor, shape); - const changeIndex = import_react51.default.useMemo(() => { - return editor.environment.isSafari ? globalRenderIndex += 1 : 0; - }, [shape]); - if (!info2?.isValid) - return null; - const strokeWidth = STROKE_SIZES2[shape.props.size] * shape.props.scale; - const as = info2.start.arrowhead && getArrowheadPathForType(info2, "start", strokeWidth); - const ae = info2.end.arrowhead && getArrowheadPathForType(info2, "end", strokeWidth); - const path = info2.isStraight ? getSolidStraightArrowPath(info2) : getSolidCurvedArrowPath(info2); - let handlePath = null; - if (shouldDisplayHandles) { - const sw = 2 / editor.getZoomLevel(); - const { strokeDasharray: strokeDasharray2, strokeDashoffset: strokeDashoffset2 } = getPerfectDashProps2(getLength(editor, shape), sw, { - end: "skip", - start: "skip", - lengthRatio: 2.5 - }); - handlePath = bindings.start || bindings.end ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { - className: "tl-arrow-hint", - d: info2.isStraight ? getStraightArrowHandlePath(info2) : getCurvedArrowHandlePath(info2), - strokeDasharray: strokeDasharray2, - strokeDashoffset: strokeDashoffset2, - strokeWidth: sw, - markerStart: bindings.start ? bindings.start.props.isExact ? "" : bindings.start.props.isPrecise ? "url(#arrowhead-cross)" : "url(#arrowhead-dot)" : "", - markerEnd: bindings.end ? bindings.end.props.isExact ? "" : bindings.end.props.isPrecise ? "url(#arrowhead-cross)" : "url(#arrowhead-dot)" : "", - opacity: 0.16 - }) : null; - } - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(info2.isStraight ? info2.length : Math.abs(info2.bodyArc.length), strokeWidth, { - style: shape.props.dash - }); - const labelPosition = getArrowLabelPosition(editor, shape); - const maskStartArrowhead = !(info2.start.arrowhead === "none" || info2.start.arrowhead === "arrow"); - const maskEndArrowhead = !(info2.end.arrowhead === "none" || info2.end.arrowhead === "arrow"); - const maskId = (shape.id + "_clip_" + changeIndex).replace(":", "_"); - return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("mask", { id: maskId, children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: toDomPrecision(-100 + bounds.minX), - y: toDomPrecision(-100 + bounds.minY), - width: toDomPrecision(bounds.width + 200), - height: toDomPrecision(bounds.height + 200), - fill: "white" - }), - shape.props.text.trim() && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: labelPosition.box.x, - y: labelPosition.box.y, - width: labelPosition.box.w, - height: labelPosition.box.h, - fill: "black", - rx: 4, - ry: 4 - }), - as && maskStartArrowhead && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: as, fill: info2.start.arrowhead === "arrow" ? "none" : "black", stroke: "none" }), - ae && maskEndArrowhead && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: ae, fill: info2.end.arrowhead === "arrow" ? "none" : "black", stroke: "none" }) - ] }) }), - /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("g", { - fill: "none", - stroke: theme[shape.props.color].solid, - strokeWidth, - strokeLinejoin: "round", - strokeLinecap: "round", - pointerEvents: "none", - children: [ - handlePath, - /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("g", { mask: `url(#${maskId})`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("rect", { - x: toDomPrecision(bounds.minX - 100), - y: toDomPrecision(bounds.minY - 100), - width: toDomPrecision(bounds.width + 200), - height: toDomPrecision(bounds.height + 200), - opacity: 0 - }), - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: path, strokeDasharray, strokeDashoffset }) - ] }), - as && maskStartArrowhead && shape.props.fill !== "none" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ShapeFill, { - theme, - d: as, - color: shape.props.color, - fill: shape.props.fill, - scale: shape.props.scale - }), - ae && maskEndArrowhead && shape.props.fill !== "none" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ShapeFill, { - theme, - d: ae, - color: shape.props.color, - fill: shape.props.fill, - scale: shape.props.scale - }), - as && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: as }), - ae && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: ae }) - ] - }) - ] }); -}); -var shapeAtTranslationStart = /* @__PURE__ */ new WeakMap(); -function ArrowheadDotDef() { - return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("marker", { id: "arrowhead-dot", className: "tl-arrow-hint", refX: "3.0", refY: "3.0", orient: "0", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("circle", { cx: "3", cy: "3", r: "2", strokeDasharray: "100%" }) }); -} -function ArrowheadCrossDef() { - return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("marker", { id: "arrowhead-cross", className: "tl-arrow-hint", refX: "3.0", refY: "3.0", orient: "auto", children: [ - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("line", { x1: "1.5", y1: "1.5", x2: "4.5", y2: "4.5", strokeDasharray: "100%" }), - /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("line", { x1: "1.5", y1: "4.5", x2: "4.5", y2: "1.5", strokeDasharray: "100%" }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs -var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/HyperlinkButton.mjs -var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); -var import_classnames16 = __toESM(require_classnames(), 1); -var LINK_ICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E"; -function HyperlinkButton({ url, zoomLevel }) { - return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("a", { - className: (0, import_classnames16.default)("tl-hyperlink-button", { - "tl-hyperlink-button__hidden": zoomLevel < 0.32 - }), - href: url, - target: "_blank", - rel: "noopener noreferrer", - onPointerDown: stopEventPropagation, - onPointerUp: stopEventPropagation, - title: url, - draggable: false, - children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { - className: "tl-hyperlink__icon", - style: { - mask: `url("${LINK_ICON}") center 100% / 100% no-repeat`, - WebkitMask: `url("${LINK_ICON}") center 100% / 100% no-repeat` - } - }) - }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/icons-editor.mjs -var LINK_ICON2 = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E"; - -// node_modules/tldraw/dist-esm/lib/shapes/shared/rotated-box-shadow.mjs -var ROTATING_BOX_SHADOWS = [ - { - offsetX: 0, - offsetY: 2, - blur: 4, - spread: 0, - color: "#00000029" - }, - { - offsetX: 0, - offsetY: 3, - blur: 6, - spread: 0, - color: "#0000001f" - } -]; -function getRotatedBoxShadow(rotation) { - const cssStrings = ROTATING_BOX_SHADOWS.map((shadow) => { - const { offsetX, offsetY, blur, spread, color } = shadow; - const vec = new Vec(offsetX, offsetY); - const { x, y } = vec.rot(-rotation); - return `${x}px ${y}px ${blur}px ${spread}px ${color}`; - }); - return cssStrings.join(", "); -} - -// node_modules/tldraw/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs -var BOOKMARK_WIDTH = 300; -var BOOKMARK_HEIGHT = 320; -var BOOKMARK_JUST_URL_HEIGHT = 46; -var SHORT_BOOKMARK_HEIGHT = 101; -var BookmarkShapeUtil = class extends BaseBoxShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canResize", () => false); - __publicField(this, "hideSelectionBoundsFg", () => true); - __publicField(this, "onBeforeCreate", (next) => { - return getBookmarkSize(this.editor, next); - }); - __publicField(this, "onBeforeUpdate", (prev, shape) => { - if (prev.props.url !== shape.props.url) { - if (!validation_exports.linkUrl.isValid(shape.props.url)) { - return { ...shape, props: { ...shape.props, url: prev.props.url } }; - } else { - updateBookmarkAssetOnUrlChange(this.editor, shape); - } - } - if (prev.props.assetId !== shape.props.assetId) { - return getBookmarkSize(this.editor, shape); - } - }); - } - getDefaultProps() { - return { - url: "", - w: BOOKMARK_WIDTH, - h: BOOKMARK_HEIGHT, - assetId: null - }; - } - component(shape) { - const asset = shape.props.assetId ? this.editor.getAsset(shape.props.assetId) : null; - const pageRotation = this.editor.getShapePageTransform(shape).rotation(); - const address = getHumanReadableAddress(shape); - return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(HTMLContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { - className: "tl-bookmark__container", - style: { - boxShadow: getRotatedBoxShadow(pageRotation), - maxHeight: shape.props.h - }, - children: [ - (!asset || asset.props.image) && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "tl-bookmark__image_container", children: [ - asset ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("img", { - className: "tl-bookmark__image", - draggable: false, - referrerPolicy: "strict-origin-when-cross-origin", - src: asset?.props.image, - alt: asset?.props.title || "" - }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "tl-bookmark__placeholder" }), - asset?.props.image && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(HyperlinkButton, { url: shape.props.url, zoomLevel: this.editor.getZoomLevel() }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "tl-bookmark__copy_container", children: [ - asset?.props.title ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h2", { className: "tl-bookmark__heading", children: asset.props.title }) : null, - asset?.props.description && asset?.props.image ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "tl-bookmark__description", children: asset.props.description }) : null, - /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("a", { - className: "tl-bookmark__link", - href: shape.props.url || "", - target: "_blank", - rel: "noopener noreferrer", - onPointerDown: stopEventPropagation, - onPointerUp: stopEventPropagation, - onClick: stopEventPropagation, - children: [ - asset?.props.favicon ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("img", { - className: "tl-bookmark__favicon", - src: asset?.props.favicon, - referrerPolicy: "strict-origin-when-cross-origin", - alt: `favicon of ${address}` - }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { - className: "tl-hyperlink__icon", - style: { - mask: `url("${LINK_ICON2}") center 100% / 100% no-repeat`, - WebkitMask: `url("${LINK_ICON2}") center 100% / 100% no-repeat` - } - }), - /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { children: address }) - ] - }) - ] }) - ] - }) }); - } - indicator(shape) { - return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("rect", { - width: toDomPrecision(shape.props.w), - height: toDomPrecision(shape.props.h), - rx: "6", - ry: "6" - }); - } -}; -__publicField(BookmarkShapeUtil, "type", "bookmark"); -__publicField(BookmarkShapeUtil, "props", bookmarkShapeProps); -__publicField(BookmarkShapeUtil, "migrations", bookmarkShapeMigrations); -function getBookmarkSize(editor, shape) { - const asset = shape.props.assetId ? editor.getAsset(shape.props.assetId) : null; - let h = BOOKMARK_HEIGHT; - if (asset) { - if (!asset.props.image) { - if (!asset.props.title) { - h = BOOKMARK_JUST_URL_HEIGHT; - } else { - h = SHORT_BOOKMARK_HEIGHT; - } - } - } - return { - ...shape, - props: { - ...shape.props, - h - } - }; -} -var getHumanReadableAddress = (shape) => { - try { - const url = new URL(shape.props.url); - return url.hostname.replace(/^www\./, ""); - } catch (e) { - return shape.props.url; - } -}; -function updateBookmarkAssetOnUrlChange(editor, shape) { - const { url } = shape.props; - const assetId = AssetRecordType.createId(getHashForString(url)); - if (editor.getAsset(assetId)) { - if (shape.props.assetId !== assetId) { - editor.updateShapes([ - { - id: shape.id, - type: shape.type, - props: { assetId } - } - ]); - } - } else { - editor.updateShapes([ - { - id: shape.id, - type: shape.type, - props: { assetId: null } - } - ]); - createBookmarkAssetOnUrlChange(editor, shape); - } -} -var createBookmarkAssetOnUrlChange = debounce(async (editor, shape) => { - if (editor.isDisposed) - return; - const { url } = shape.props; - const asset = await editor.getAssetForExternalContent({ type: "url", url }); - if (!asset) { - return; - } - editor.run(() => { - editor.createAssets([asset]); - editor.updateShapes([ - { - id: shape.id, - type: shape.type, - props: { assetId: asset.id } - } - ]); - }); -}, 500); - -// node_modules/tldraw/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs -var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/freehand/svg.mjs -function getSvgPathFromStrokePoints(points, closed = false) { - const len = points.length; - if (len < 2) { - return ""; - } - let a = points[0].point; - let b = points[1].point; - if (len === 2) { - return `M${precise(a)}L${precise(b)}`; - } - let result = ""; - for (let i = 2, max2 = len - 1; i < max2; i++) { - a = points[i].point; - b = points[i + 1].point; - result += average(a, b); - } - if (closed) { - return `M${average(points[0].point, points[1].point)}Q${precise(points[1].point)}${average(points[1].point, points[2].point)}T${result}${average(points[len - 1].point, points[0].point)}${average(points[0].point, points[1].point)}Z`; - } else { - return `M${precise(points[0].point)}Q${precise(points[1].point)}${average(points[1].point, points[2].point)}${points.length > 3 ? "T" : ""}${result}L${precise(points[len - 1].point)}`; - } -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/freehand/svgInk.mjs -function svgInk(rawInputPoints, options = {}) { - const { start = {}, end = {} } = options; - const { cap: capStart = true } = start; - const { cap: capEnd = true } = end; - assert(!start.taper && !end.taper, "cap taper not supported here"); - assert(!start.easing && !end.easing, "cap easing not supported here"); - assert(capStart && capEnd, "cap must be true"); - const points = getStrokePoints(rawInputPoints, options); - setStrokePointRadii(points, options); - const partitions = partitionAtElbows(points); - let svg = ""; - for (const partition2 of partitions) { - svg += renderPartition(partition2, options); - } - return svg; -} -function partitionAtElbows(points) { - if (points.length <= 2) - return [points]; - const result = []; - let currentPartition = [points[0]]; - let prevV = Vec.Sub(points[1].point, points[0].point).uni(); - let nextV; - let dpr; - let prevPoint, thisPoint, nextPoint; - for (let i = 1, n = points.length; i < n - 1; i++) { - prevPoint = points[i - 1]; - thisPoint = points[i]; - nextPoint = points[i + 1]; - nextV = Vec.Sub(nextPoint.point, thisPoint.point).uni(); - dpr = Vec.Dpr(prevV, nextV); - prevV = nextV; - if (dpr < -0.8) { - const elbowPoint = { - ...thisPoint, - point: thisPoint.input - }; - currentPartition.push(elbowPoint); - result.push(cleanUpPartition(currentPartition)); - currentPartition = [elbowPoint]; - continue; - } - currentPartition.push(thisPoint); - if (dpr > 0.7) { - continue; - } - if ((Vec.Dist2(prevPoint.point, thisPoint.point) + Vec.Dist2(thisPoint.point, nextPoint.point)) / ((prevPoint.radius + thisPoint.radius + nextPoint.radius) / 3) ** 2 < 1.5) { - currentPartition.push(thisPoint); - result.push(cleanUpPartition(currentPartition)); - currentPartition = [thisPoint]; - continue; - } - } - currentPartition.push(points[points.length - 1]); - result.push(cleanUpPartition(currentPartition)); - return result; -} -function cleanUpPartition(partition2) { - const startPoint = partition2[0]; - let nextPoint; - while (partition2.length > 2) { - nextPoint = partition2[1]; - if (Vec.Dist2(startPoint.point, nextPoint.point) < ((startPoint.radius + nextPoint.radius) / 2 * 0.5) ** 2) { - partition2.splice(1, 1); - } else { - break; - } - } - const endPoint = partition2[partition2.length - 1]; - let prevPoint; - while (partition2.length > 2) { - prevPoint = partition2[partition2.length - 2]; - if (Vec.Dist2(endPoint.point, prevPoint.point) < ((endPoint.radius + prevPoint.radius) / 2 * 0.5) ** 2) { - partition2.splice(partition2.length - 2, 1); - } else { - break; - } - } - if (partition2.length > 1) { - partition2[0] = { - ...partition2[0], - vector: Vec.Sub(partition2[0].point, partition2[1].point).uni() - }; - partition2[partition2.length - 1] = { - ...partition2[partition2.length - 1], - vector: Vec.Sub(partition2[partition2.length - 2].point, partition2[partition2.length - 1].point).uni() - }; - } - return partition2; -} -function circlePath(cx, cy, r) { - return "M " + cx + " " + cy + " m -" + r + ", 0 a " + r + "," + r + " 0 1,1 " + r * 2 + ",0 a " + r + "," + r + " 0 1,1 -" + r * 2 + ",0"; -} -function renderPartition(strokePoints, options = {}) { - if (strokePoints.length === 0) - return ""; - if (strokePoints.length === 1) { - return circlePath(strokePoints[0].point.x, strokePoints[0].point.y, strokePoints[0].radius); - } - const { left, right } = getStrokeOutlineTracks(strokePoints, options); - right.reverse(); - let svg = `M${precise(left[0])}T`; - for (let i = 1; i < left.length; i++) { - svg += average(left[i - 1], left[i]); - } - { - const point = strokePoints[strokePoints.length - 1]; - const radius = point.radius; - const direction = point.vector.clone().per().neg(); - const arcStart = Vec.Add(point.point, Vec.Mul(direction, radius)); - const arcEnd = Vec.Add(point.point, Vec.Mul(direction, -radius)); - svg += `${precise(arcStart)}A${toDomPrecision(radius)},${toDomPrecision(radius)} 0 0 1 ${precise(arcEnd)}T`; - } - for (let i = 1; i < right.length; i++) { - svg += average(right[i - 1], right[i]); - } - { - const point = strokePoints[0]; - const radius = point.radius; - const direction = point.vector.clone().per(); - const arcStart = Vec.Add(point.point, Vec.Mul(direction, radius)); - const arcEnd = Vec.Add(point.point, Vec.Mul(direction, -radius)); - svg += `${precise(arcStart)}A${toDomPrecision(radius)},${toDomPrecision(radius)} 0 0 1 ${precise(arcEnd)}Z`; - } - return svg; -} - -// node_modules/tldraw/dist-esm/lib/shapes/draw/getPath.mjs -var PEN_EASING = (t2) => t2 * 0.65 + SIN(t2 * PI / 2) * 0.35; -var simulatePressureSettings = (strokeWidth) => { - return { - size: strokeWidth, - thinning: 0.5, - streamline: modulate(strokeWidth, [9, 16], [0.64, 0.74], true), - smoothing: 0.62, - easing: EASINGS.easeOutSine, - simulatePressure: true - }; -}; -var realPressureSettings = (strokeWidth) => { - return { - size: 1 + strokeWidth * 1.2, - thinning: 0.62, - streamline: 0.62, - smoothing: 0.62, - simulatePressure: false, - easing: PEN_EASING - }; -}; -var solidSettings = (strokeWidth) => { - return { - size: strokeWidth, - thinning: 0, - streamline: modulate(strokeWidth, [9, 16], [0.64, 0.74], true), - smoothing: 0.62, - simulatePressure: false, - easing: EASINGS.linear - }; -}; -var solidRealPressureSettings = (strokeWidth) => { - return { - size: strokeWidth, - thinning: 0, - streamline: 0.62, - smoothing: 0.62, - simulatePressure: false, - easing: EASINGS.linear - }; -}; -function getHighlightFreehandSettings({ - strokeWidth, - showAsComplete -}) { - return { - size: 1 + strokeWidth, - thinning: 0, - streamline: 0.5, - smoothing: 0.5, - simulatePressure: false, - easing: EASINGS.easeOutSine, - last: showAsComplete - }; -} -function getFreehandOptions(shapeProps, strokeWidth, forceComplete, forceSolid) { - const last3 = shapeProps.isComplete || forceComplete; - if (forceSolid) { - if (shapeProps.isPen) { - return { ...solidRealPressureSettings(strokeWidth), last: last3 }; - } else { - return { ...solidSettings(strokeWidth), last: last3 }; - } - } - if (shapeProps.dash === "draw") { - if (shapeProps.isPen) { - return { ...realPressureSettings(strokeWidth), last: last3 }; - } else { - return { ...simulatePressureSettings(strokeWidth), last: last3 }; - } - } - return { ...solidSettings(strokeWidth), last: last3 }; -} -function getPointsFromSegments(segments) { - const points = []; - for (const segment of segments) { - if (segment.type === "free" || segment.points.length < 2) { - points.push(...segment.points.map(Vec.Cast)); - } else { - const pointsToInterpolate = Math.max(4, Math.floor(Vec.Dist(segment.points[0], segment.points[1]) / 16)); - points.push(...Vec.PointsBetween(segment.points[0], segment.points[1], pointsToInterpolate)); - } - } - return points; -} -function getDrawShapeStrokeDashArray(shape, strokeWidth) { - return { - draw: "none", - solid: `none`, - dotted: `0.1 ${strokeWidth * 2}`, - dashed: `${strokeWidth * 2} ${strokeWidth * 2}` - }[shape.props.dash]; -} - -// node_modules/tldraw/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs -var DrawShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "hideResizeHandles", (shape) => getIsDot(shape)); - __publicField(this, "hideRotateHandle", (shape) => getIsDot(shape)); - __publicField(this, "hideSelectionBoundsFg", (shape) => getIsDot(shape)); - __publicField(this, "onResize", (shape, info2) => { - const { scaleX, scaleY } = info2; - const newSegments = []; - for (const segment of shape.props.segments) { - newSegments.push({ - ...segment, - points: segment.points.map(({ x, y, z }) => { - return { - x: toFixed(scaleX * x), - y: toFixed(scaleY * y), - z - }; - }) - }); - } - return { - props: { - segments: newSegments - } - }; - }); - } - getDefaultProps() { - return { - segments: [], - color: "black", - fill: "none", - dash: "draw", - size: "m", - isComplete: false, - isClosed: false, - isPen: false, - scale: 1 - }; - } - getGeometry(shape) { - const points = getPointsFromSegments(shape.props.segments); - const sw = (STROKE_SIZES2[shape.props.size] + 1) * shape.props.scale; - if (shape.props.segments.length === 1) { - const box = Box.FromPoints(points); - if (box.width < sw * 2 && box.height < sw * 2) { - return new Circle2d({ - x: -sw, - y: -sw, - radius: sw, - isFilled: true - }); - } - } - const strokePoints = getStrokePoints(points, getFreehandOptions(shape.props, sw, shape.props.isPen, true)).map((p) => p.point); - if (shape.props.isClosed) { - return new Polygon2d({ - points: strokePoints, - isFilled: shape.props.fill !== "none" - }); - } - return new Polyline2d({ - points: strokePoints - }); - } - component(shape) { - return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(SVGContainer, { id: shape.id, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(DrawShapeSvg, { shape, zoomLevel: this.editor.getZoomLevel() }) }); - } - indicator(shape) { - const allPointsFromSegments = getPointsFromSegments(shape.props.segments); - let sw = (STROKE_SIZES2[shape.props.size] + 1) * shape.props.scale; - const zoomLevel = this.editor.getZoomLevel(); - const forceSolid = zoomLevel < 0.5 && zoomLevel < 1.5 / sw; - if (!forceSolid && !shape.props.isPen && shape.props.dash === "draw" && allPointsFromSegments.length === 1) { - sw += rng(shape.id)() * (sw / 6); - } - const showAsComplete = shape.props.isComplete || last(shape.props.segments)?.type === "straight"; - const options = getFreehandOptions(shape.props, sw, showAsComplete, true); - const strokePoints = getStrokePoints(allPointsFromSegments, options); - const solidStrokePath = strokePoints.length > 1 ? getSvgPathFromStrokePoints(strokePoints, shape.props.isClosed) : getDot(allPointsFromSegments[0], sw); - return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: solidStrokePath }); - } - toSvg(shape, ctx) { - ctx.addExportDef(getFillDefForExport(shape.props.fill)); - const scaleFactor = 1 / shape.props.scale; - return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("g", { transform: `scale(${scaleFactor})`, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(DrawShapeSvg, { shape, zoomLevel: 1 }) }); - } - getCanvasSvgDefs() { - return [getFillDefForCanvas()]; - } - expandSelectionOutlinePx(shape) { - const multiplier = shape.props.dash === "draw" ? 1.6 : 1; - return STROKE_SIZES2[shape.props.size] * multiplier / 2 * shape.props.scale; - } -}; -__publicField(DrawShapeUtil, "type", "draw"); -__publicField(DrawShapeUtil, "props", drawShapeProps); -__publicField(DrawShapeUtil, "migrations", drawShapeMigrations); -function getDot(point, sw) { - const r = (sw + 1) * 0.5; - return `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${r * 2},0`; -} -function getIsDot(shape) { - return shape.props.segments.length === 1 && shape.props.segments[0].points.length < 2; -} -function DrawShapeSvg({ shape, zoomLevel }) { - const theme = useDefaultColorTheme(); - const allPointsFromSegments = getPointsFromSegments(shape.props.segments); - const showAsComplete = shape.props.isComplete || last(shape.props.segments)?.type === "straight"; - let sw = (STROKE_SIZES2[shape.props.size] + 1) * shape.props.scale; - const forceSolid = zoomLevel < 0.5 && zoomLevel < 1.5 / sw; - if (!forceSolid && !shape.props.isPen && shape.props.dash === "draw" && allPointsFromSegments.length === 1) { - sw += rng(shape.id)() * (sw / 6); - } - const options = getFreehandOptions(shape.props, sw, showAsComplete, forceSolid); - if (!forceSolid && shape.props.dash === "draw") { - return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [ - shape.props.isClosed && shape.props.fill && allPointsFromSegments.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ShapeFill, { - d: getSvgPathFromStrokePoints(getStrokePoints(allPointsFromSegments, options), shape.props.isClosed), - theme, - color: shape.props.color, - fill: shape.props.isClosed ? shape.props.fill : "none", - scale: shape.props.scale - }) : null, - /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { - d: svgInk(allPointsFromSegments, options), - strokeLinecap: "round", - fill: theme[shape.props.color].solid - }) - ] }); - } - const strokePoints = getStrokePoints(allPointsFromSegments, options); - const isDot = strokePoints.length < 2; - const solidStrokePath = isDot ? getDot(allPointsFromSegments[0], 0) : getSvgPathFromStrokePoints(strokePoints, shape.props.isClosed); - return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ShapeFill, { - d: solidStrokePath, - theme, - color: shape.props.color, - fill: isDot || shape.props.isClosed ? shape.props.fill : "none", - scale: shape.props.scale - }), - /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { - d: solidStrokePath, - strokeLinecap: "round", - fill: isDot ? theme[shape.props.color].solid : "none", - stroke: theme[shape.props.color].solid, - strokeWidth: sw, - strokeDasharray: isDot ? "none" : getDrawShapeStrokeDashArray(shape, sw), - strokeDashoffset: "0" - }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs -var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); -var import_react52 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/resizeBox.mjs -function resizeBox2(shape, info2, opts = {}) { - const { newPoint, handle, scaleX, scaleY } = info2; - const { minWidth = 1, maxWidth: maxWidth2 = Infinity, minHeight = 1, maxHeight: maxHeight2 = Infinity } = opts; - let w = shape.props.w * scaleX; - let h = shape.props.h * scaleY; - const offset4 = new Vec(0, 0); - if (w > 0) { - if (w < minWidth) { - switch (handle) { - case "top_left": - case "left": - case "bottom_left": { - offset4.x = w - minWidth; - break; - } - case "top": - case "bottom": { - offset4.x = (w - minWidth) / 2; - break; - } - default: { - offset4.x = 0; - } - } - w = minWidth; - } - } else { - offset4.x = w; - w = -w; - if (w < minWidth) { - switch (handle) { - case "top_left": - case "left": - case "bottom_left": { - offset4.x = -w; - break; - } - default: { - offset4.x = -minWidth; - } - } - w = minWidth; - } - } - if (h > 0) { - if (h < minHeight) { - switch (handle) { - case "top_left": - case "top": - case "top_right": { - offset4.y = h - minHeight; - break; - } - case "right": - case "left": { - offset4.y = (h - minHeight) / 2; - break; - } - default: { - offset4.y = 0; - } - } - h = minHeight; - } - } else { - offset4.y = h; - h = -h; - if (h < minHeight) { - switch (handle) { - case "top_left": - case "top": - case "top_right": { - offset4.y = -h; - break; - } - default: { - offset4.y = -minHeight; - } - } - h = minHeight; - } - } - const { x, y } = offset4.rot(shape.rotation).add(newPoint); - return { - x, - y, - props: { - w: Math.min(maxWidth2, w), - h: Math.min(maxHeight2, h) - } - }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs -var getSandboxPermissions = (permissions) => { - return Object.entries(permissions).filter(([_perm, isEnabled]) => isEnabled).map(([perm]) => perm).join(" "); -}; -var EmbedShapeUtil = class extends BaseBoxShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "hideSelectionBoundsFg", (shape) => !this.canResize(shape)); - __publicField(this, "canEdit", () => true); - __publicField(this, "canResize", (shape) => { - return !!getEmbedInfo(shape.props.url)?.definition?.doesResize; - }); - __publicField(this, "canEditInReadOnly", () => true); - __publicField(this, "isAspectRatioLocked", (shape) => { - const embedInfo = getEmbedInfo(shape.props.url); - return embedInfo?.definition.isAspectRatioLocked ?? false; - }); - __publicField(this, "onResize", (shape, info2) => { - const isAspectRatioLocked = this.isAspectRatioLocked(shape); - const embedInfo = getEmbedInfo(shape.props.url); - let minWidth = embedInfo?.definition.minWidth ?? 200; - let minHeight = embedInfo?.definition.minHeight ?? 200; - if (isAspectRatioLocked) { - const aspectRatio = shape.props.w / shape.props.h; - if (aspectRatio > 1) { - minWidth *= aspectRatio; - } else { - minHeight /= aspectRatio; - } - } - return resizeBox2(shape, info2, { minWidth, minHeight }); - }); - } - getDefaultProps() { - return { - w: 300, - h: 300, - url: "" - }; - } - component(shape) { - const { w, h, url } = shape.props; - const isEditing = useIsEditing(shape.id); - const embedInfo = (0, import_react52.useMemo)(() => getEmbedInfoUnsafely(url), [url]); - const isHoveringWhileEditingSameShape = useValue("is hovering", () => { - const { editingShapeId, hoveredShapeId } = this.editor.getCurrentPageState(); - if (editingShapeId && hoveredShapeId !== editingShapeId) { - const editingShape = this.editor.getShape(editingShapeId); - if (editingShape && this.editor.isShapeOfType(editingShape, "embed")) { - return true; - } - } - return false; - }, []); - const pageRotation = this.editor.getShapePageTransform(shape).rotation(); - const isInteractive = isEditing || isHoveringWhileEditingSameShape; - const isIframe = typeof window !== "undefined" && (window !== window.top || window.self !== window.parent); - if (isIframe && embedInfo?.definition.type === "tldraw") - return null; - if (embedInfo?.definition.type === "github_gist") { - const idFromGistUrl = embedInfo.url.split("/").pop(); - if (!idFromGistUrl) - throw Error("No gist id!"); - return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HTMLContainer, { className: "tl-embed-container", id: shape.id, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Gist, { - id: idFromGistUrl, - width: toDomPrecision(w), - height: toDomPrecision(h), - isInteractive, - pageRotation - }) }); - } - const sandbox = getSandboxPermissions({ - ...embedShapePermissionDefaults, - ...embedInfo?.definition.overridePermissions ?? {} - }); - return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HTMLContainer, { className: "tl-embed-container", id: shape.id, children: embedInfo?.definition ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("iframe", { - className: "tl-embed", - sandbox, - src: embedInfo.embedUrl, - width: toDomPrecision(w), - height: toDomPrecision(h), - draggable: false, - frameBorder: "0", - referrerPolicy: "no-referrer-when-downgrade", - style: { - border: 0, - pointerEvents: isInteractive ? "auto" : "none", - zIndex: isInteractive ? "" : "-1", - boxShadow: getRotatedBoxShadow(pageRotation), - borderRadius: embedInfo?.definition.overrideOutlineRadius ?? 8, - background: embedInfo?.definition.backgroundColor - } - }) : null }); - } - indicator(shape) { - const embedInfo = (0, import_react52.useMemo)(() => getEmbedInfo(shape.props.url), [shape.props.url]); - return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("rect", { - width: toDomPrecision(shape.props.w), - height: toDomPrecision(shape.props.h), - rx: embedInfo?.definition.overrideOutlineRadius ?? 8, - ry: embedInfo?.definition.overrideOutlineRadius ?? 8 - }); - } -}; -__publicField(EmbedShapeUtil, "type", "embed"); -__publicField(EmbedShapeUtil, "props", embedShapeProps); -__publicField(EmbedShapeUtil, "migrations", embedShapeMigrations); -function Gist({ - id, - file, - isInteractive, - width, - height, - style, - pageRotation -}) { - return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("iframe", { - className: "tl-embed", - draggable: false, - width: toDomPrecision(width), - height: toDomPrecision(height), - frameBorder: "0", - scrolling: "no", - seamless: true, - referrerPolicy: "no-referrer-when-downgrade", - style: { - ...style, - pointerEvents: isInteractive ? "all" : "none", - zIndex: isInteractive ? "" : "-1", - boxShadow: getRotatedBoxShadow(pageRotation) - }, - srcDoc: ` - <html> - <head> - <base target="_blank"> - </head> - <body> - <script src=${`https://gist.github.com/${id}.js${file ? `?file=${file}` : ""}`}><\/script> - <style type="text/css"> - * { margin: 0px; } - table { height: 100%; background-color: red; } - .gist { background-color: none; height: 100%; } - .gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; } - </style> - </body> - </html>` - }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs -var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); -var import_classnames17 = __toESM(require_classnames(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/frame/components/FrameHeading.mjs -var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); -var import_react54 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs -var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); -var import_react53 = __toESM(require_react(), 1); -var FrameLabelInput = (0, import_react53.forwardRef)(({ id, name, isEditing }, ref) => { - const editor = useEditor(); - const handleKeyDown = (0, import_react53.useCallback)((e) => { - if (e.key === "Enter" && !e.nativeEvent.isComposing) { - stopEventPropagation(e); - e.currentTarget.blur(); - editor.setEditingShape(null); - } - }, [editor]); - const handleBlur = (0, import_react53.useCallback)((e) => { - const shape = editor.getShape(id); - if (!shape) - return; - const name2 = shape.props.name; - const value = e.currentTarget.value.trim(); - if (name2 === value) - return; - editor.updateShapes([ - { - id, - type: "frame", - props: { name: value } - } - ]); - }, [id, editor]); - const handleChange = (0, import_react53.useCallback)((e) => { - const shape = editor.getShape(id); - if (!shape) - return; - const name2 = shape.props.name; - const value = e.currentTarget.value; - if (name2 === value) - return; - editor.updateShapes([ - { - id, - type: "frame", - props: { name: value } - } - ]); - }, [id, editor]); - return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: `tl-frame-label ${isEditing ? "tl-frame-label__editing" : ""}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("input", { - className: "tl-frame-name-input", - ref, - style: { display: isEditing ? void 0 : "none" }, - value: name, - autoFocus: true, - onKeyDown: handleKeyDown, - onBlur: handleBlur, - onChange: handleChange - }), - defaultEmptyAs(name, "Frame") + String.fromCharCode(8203) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/shapes/frame/components/FrameHeading.mjs -var FrameHeading = function FrameHeading2({ - id, - name, - width, - height -}) { - const editor = useEditor(); - const pageRotation = useValue("shape rotation", () => canonicalizeRotation(editor.getShapePageTransform(id).rotation()), [editor, id]); - const isEditing = useIsEditing(id); - const rInput = (0, import_react54.useRef)(null); - const handlePointerDown = (0, import_react54.useCallback)((e) => { - const event = getPointerInfo(e); - e.preventDefault(); - if (editor.getEditingShapeId() === id) - return; - editor.dispatch({ - type: "pointer", - name: "pointer_down", - target: "shape", - shape: editor.getShape(id), - ...event - }); - }, [editor, id]); - (0, import_react54.useEffect)(() => { - const el = rInput.current; - if (el && isEditing) { - el.focus(); - el.select(); - } - }, [rInput, isEditing]); - const offsetRotation = pageRotation + Math.PI / 4; - const scaledRotation = (offsetRotation * (2 / Math.PI) + 4) % 4; - const labelSide = ["top", "left", "bottom", "right"][Math.floor(scaledRotation)]; - let labelTranslate; - switch (labelSide) { - case "top": - labelTranslate = ``; - break; - case "right": - labelTranslate = `translate(${toDomPrecision(width)}px, 0px) rotate(90deg)`; - break; - case "bottom": - labelTranslate = `translate(${toDomPrecision(width)}px, ${toDomPrecision(height)}px) rotate(180deg)`; - break; - case "left": - labelTranslate = `translate(0px, ${toDomPrecision(height)}px) rotate(270deg)`; - break; - } - return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { - className: "tl-frame-heading", - style: { - overflow: isEditing ? "visible" : "hidden", - maxWidth: `calc(var(--tl-zoom) * ${labelSide === "top" || labelSide === "bottom" ? Math.ceil(width) : Math.ceil(height)}px + var(--space-5))`, - bottom: "100%", - transform: `${labelTranslate} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))` - }, - onPointerDown: handlePointerDown, - children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "tl-frame-heading-hit-area", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(FrameLabelInput, { ref: rInput, id, name, isEditing }) }) - }); -}; - -// node_modules/tldraw/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs -function defaultEmptyAs(str, dflt) { - if (str.match(/^\s*$/)) { - return dflt; - } - return str; -} -var FrameShapeUtil = class extends BaseBoxShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canEdit", () => true); - __publicField(this, "canReceiveNewChildrenOfType", (shape, _type) => { - return !shape.isLocked; - }); - __publicField(this, "canDropShapes", (shape, _shapes) => { - return !shape.isLocked; - }); - __publicField(this, "onDragShapesOver", (frame2, shapes) => { - if (!shapes.every((child) => child.parentId === frame2.id)) { - this.editor.reparentShapes(shapes, frame2.id); - } - }); - __publicField(this, "onDragShapesOut", (_shape, shapes) => { - const parent = this.editor.getShape(_shape.parentId); - const isInGroup = parent && this.editor.isShapeOfType(parent, "group"); - if (isInGroup) { - this.editor.reparentShapes(shapes, parent.id); - } else { - this.editor.reparentShapes(shapes, this.editor.getCurrentPageId()); - } - }); - __publicField(this, "onResize", (shape, info2) => { - return resizeBox(shape, info2); - }); - } - getDefaultProps() { - return { w: 160 * 2, h: 90 * 2, name: "" }; - } - getGeometry(shape) { - return new Rectangle2d({ - width: shape.props.w, - height: shape.props.h, - isFilled: false - }); - } - component(shape) { - const bounds = this.editor.getShapeGeometry(shape).bounds; - const theme = useDefaultColorTheme(); - const isCreating = useValue("is creating this shape", () => { - const resizingState = this.editor.getStateDescendant("select.resizing"); - if (!resizingState) - return false; - if (!resizingState.getIsActive()) - return false; - const info2 = resizingState?.info; - if (!info2) - return false; - return info2.isCreating && this.editor.getOnlySelectedShapeId() === shape.id; - }, [shape.id]); - return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SVGContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("rect", { - className: (0, import_classnames17.default)("tl-frame__body", { "tl-frame__creating": isCreating }), - width: bounds.width, - height: bounds.height, - fill: theme.solid, - stroke: theme.text - }) }), - isCreating ? null : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(FrameHeading, { - id: shape.id, - name: shape.props.name, - width: bounds.width, - height: bounds.height - }) - ] }); - } - toSvg(shape, ctx) { - const theme = getDefaultColorTheme({ isDarkMode: ctx.isDarkMode }); - const pageRotation = canonicalizeRotation(this.editor.getShapePageTransform(shape.id).rotation()); - const offsetRotation = pageRotation + Math.PI / 4; - const scaledRotation = (offsetRotation * (2 / Math.PI) + 4) % 4; - const labelSide = Math.floor(scaledRotation); - let labelTranslate; - switch (labelSide) { - case 0: - labelTranslate = ``; - break; - case 3: - labelTranslate = `translate(${toDomPrecision(shape.props.w)}, 0) rotate(90)`; - break; - case 2: - labelTranslate = `translate(${toDomPrecision(shape.props.w)}, ${toDomPrecision(shape.props.h)}) rotate(180)`; - break; - case 1: - labelTranslate = `translate(0, ${toDomPrecision(shape.props.h)}) rotate(270)`; - break; - default: - throw Error("labelSide out of bounds"); - } - const opts = { - fontSize: 12, - fontFamily: "Inter, sans-serif", - textAlign: "start", - width: shape.props.w, - height: 32, - padding: 0, - lineHeight: 1, - fontStyle: "normal", - fontWeight: "normal", - overflow: "truncate-ellipsis", - verticalTextAlign: "middle" - }; - const spans = this.editor.textMeasure.measureTextSpans(defaultEmptyAs(shape.props.name, "Frame") + String.fromCharCode(8203), opts); - const firstSpan = spans[0]; - const lastSpan = last(spans); - const labelTextWidth = lastSpan.box.w + lastSpan.box.x - firstSpan.box.x; - const text = createTextJsxFromSpans(this.editor, spans, { - offsetY: -opts.height - 2, - ...opts - }); - return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("rect", { - width: shape.props.w, - height: shape.props.h, - fill: theme.solid, - stroke: theme.black.solid, - strokeWidth: 1, - rx: 1, - ry: 1 - }), - /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("g", { transform: labelTranslate, children: [ - /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("rect", { - x: -8, - y: -opts.height - 4, - width: labelTextWidth + 16, - height: opts.height, - fill: theme.background, - rx: 4, - ry: 4 - }), - text - ] }) - ] }); - } - indicator(shape) { - const bounds = this.editor.getShapeGeometry(shape).bounds; - return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("rect", { - width: toDomPrecision(bounds.width), - height: toDomPrecision(bounds.height), - className: `tl-frame-indicator` - }); - } - providesBackgroundForChildren() { - return true; - } -}; -__publicField(FrameShapeUtil, "type", "frame"); -__publicField(FrameShapeUtil, "props", frameShapeProps); -__publicField(FrameShapeUtil, "migrations", frameShapeMigrations); - -// node_modules/tldraw/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs -var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs -var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/geo/geo-shape-helpers.mjs -function getOvalPerimeter(h, w) { - if (h > w) - return (PI * (w / 2) + (h - w)) * 2; - else - return (PI * (h / 2) + (w - h)) * 2; -} -function getHeartPath(w, h) { - return getHeartParts(w, h).map((c, i) => c.getSvgPathData(i === 0)).join(" ") + " Z"; -} -function getDrawHeartPath(w, h, sw, id) { - const o = w / 4; - const k = h / 4; - const random = rng(id); - const mutDistance = sw * 0.75; - const mut = (v) => v.addXY(random() * mutDistance, random() * mutDistance); - const A = new Vec(w / 2, h); - const B = new Vec(0, k * 1.2); - const C = new Vec(w / 2, k * 0.9); - const D = new Vec(w, k * 1.2); - const Am = mut(new Vec(w / 2, h)); - const Bm = mut(new Vec(0, k * 1.2)); - const Cm = mut(new Vec(w / 2, k * 0.9)); - const Dm = mut(new Vec(w, k * 1.2)); - const parts = [ - new CubicBezier2d({ - start: A, - cp1: new Vec(o * 1.5, k * 3), - cp2: new Vec(0, k * 2.5), - end: B - }), - new CubicBezier2d({ - start: B, - cp1: new Vec(0, -k * 0.32), - cp2: new Vec(o * 1.85, -k * 0.32), - end: C - }), - new CubicBezier2d({ - start: C, - cp1: new Vec(o * 2.15, -k * 0.32), - cp2: new Vec(w, -k * 0.32), - end: D - }), - new CubicBezier2d({ - start: D, - cp1: new Vec(w, k * 2.5), - cp2: new Vec(o * 2.5, k * 3), - end: Am - }), - new CubicBezier2d({ - start: Am, - cp1: new Vec(o * 1.5, k * 3), - cp2: new Vec(0, k * 2.5), - end: Bm - }), - new CubicBezier2d({ - start: Bm, - cp1: new Vec(0, -k * 0.32), - cp2: new Vec(o * 1.85, -k * 0.32), - end: Cm - }), - new CubicBezier2d({ - start: Cm, - cp1: new Vec(o * 2.15, -k * 0.32), - cp2: new Vec(w, -k * 0.32), - end: Dm - }), - new CubicBezier2d({ - start: Dm, - cp1: new Vec(w, k * 2.5), - cp2: new Vec(o * 2.5, k * 3), - end: A - }) - ]; - return parts.map((c, i) => c.getSvgPathData(i === 0)).join(" ") + " Z"; -} -function getHeartParts(w, h) { - const o = w / 4; - const k = h / 4; - return [ - new CubicBezier2d({ - start: new Vec(w / 2, h), - cp1: new Vec(o * 1.5, k * 3), - cp2: new Vec(0, k * 2.5), - end: new Vec(0, k * 1.2) - }), - new CubicBezier2d({ - start: new Vec(0, k * 1.2), - cp1: new Vec(0, -k * 0.32), - cp2: new Vec(o * 1.85, -k * 0.32), - end: new Vec(w / 2, k * 0.9) - }), - new CubicBezier2d({ - start: new Vec(w / 2, k * 0.9), - cp1: new Vec(o * 2.15, -k * 0.32), - cp2: new Vec(w, -k * 0.32), - end: new Vec(w, k * 1.2) - }), - new CubicBezier2d({ - start: new Vec(w, k * 1.2), - cp1: new Vec(w, k * 2.5), - cp2: new Vec(o * 2.5, k * 3), - end: new Vec(w / 2, h) - }) - ]; -} -function getEllipseStrokeOptions(strokeWidth) { - return { - size: 1 + strokeWidth, - thinning: 0.25, - end: { taper: strokeWidth }, - start: { taper: strokeWidth }, - streamline: 0, - smoothing: 1, - simulatePressure: false - }; -} -function getEllipseStrokePoints(id, width, height, strokeWidth) { - const getRandom = rng(id); - const rx = width / 2; - const ry = height / 2; - const perimeter = perimeterOfEllipse(rx, ry); - const points = []; - const start = PI2 * getRandom(); - const length = PI2 + HALF_PI / 2 + Math.abs(getRandom()) * HALF_PI; - const count3 = Math.max(16, perimeter / 10); - for (let i = 0; i < count3; i++) { - const t2 = i / (count3 - 1); - const r = start + t2 * length; - const c = Math.cos(r); - const s = Math.sin(r); - points.push(new Vec(rx * c + width * 0.5 + 0.05 * getRandom(), ry * s + height / 2 + 0.05 * getRandom(), Math.min(1, 0.5 + Math.abs(0.5 - (getRandom() > 0 ? EASINGS.easeInOutSine(t2) : EASINGS.easeInExpo(t2))) / 2))); - } - return getStrokePoints(points, getEllipseStrokeOptions(strokeWidth)); -} -function getEllipseDrawIndicatorPath(id, width, height, strokeWidth) { - return getSvgPathFromStrokePoints(getEllipseStrokePoints(id, width, height, strokeWidth)); -} -function getRoundedInkyPolygonPath(points) { - let polylineA = `M`; - const len = points.length; - let p0; - let p1; - let p2; - for (let i = 0, n = len; i < n; i += 3) { - p0 = points[i]; - p1 = points[i + 1]; - p2 = points[i + 2]; - polylineA += `${precise(p0)}L${precise(p1)}Q${precise(p2)}`; - } - polylineA += `${precise(points[0])}`; - return polylineA; -} -function getRoundedPolygonPoints(id, outline, offset4, roundness, passes) { - const results = []; - const random = rng(id); - let p0 = outline[0]; - let p1; - const len = outline.length; - for (let i = 0, n = len * passes; i < n; i++) { - p1 = Vec.AddXY(outline[(i + 1) % len], random() * offset4, random() * offset4); - const delta = Vec.Sub(p1, p0); - const distance = Vec.Len(delta); - const vector = Vec.Div(delta, distance).mul(Math.min(distance / 4, roundness)); - results.push(Vec.Add(p0, vector), Vec.Add(p1, vector.neg()), p1); - p0 = p1; - } - return results; -} -function getPillPoints(width, height, numPoints) { - const radius = Math.min(width, height) / 2; - const longSide = Math.max(width, height) - radius * 2; - const circumference = Math.PI * (radius * 2) + 2 * longSide; - const spacing = circumference / numPoints; - const sections = width > height ? [ - { - type: "straight", - start: new Vec(radius, 0), - delta: new Vec(1, 0) - }, - { - type: "arc", - center: new Vec(width - radius, radius), - startAngle: -PI / 2 - }, - { - type: "straight", - start: new Vec(width - radius, height), - delta: new Vec(-1, 0) - }, - { - type: "arc", - center: new Vec(radius, radius), - startAngle: PI / 2 - } - ] : [ - { - type: "straight", - start: new Vec(width, radius), - delta: new Vec(0, 1) - }, - { - type: "arc", - center: new Vec(radius, height - radius), - startAngle: 0 - }, - { - type: "straight", - start: new Vec(0, height - radius), - delta: new Vec(0, -1) - }, - { - type: "arc", - center: new Vec(radius, radius), - startAngle: PI - } - ]; - let sectionOffset = 0; - const points = []; - for (let i = 0; i < numPoints; i++) { - const section = sections[0]; - if (section.type === "straight") { - points.push(Vec.Add(section.start, Vec.Mul(section.delta, sectionOffset))); - } else { - points.push(getPointOnCircle(section.center, radius, section.startAngle + sectionOffset / radius)); - } - sectionOffset += spacing; - let sectionLength = section.type === "straight" ? longSide : PI * radius; - while (sectionOffset > sectionLength) { - sectionOffset -= sectionLength; - sections.push(sections.shift()); - sectionLength = sections[0].type === "straight" ? longSide : PI * radius; - } - } - return points; -} -var SIZES = { - s: 50, - m: 70, - l: 100, - xl: 130 -}; -var BUMP_PROTRUSION = 0.2; -function getCloudArcs(width, height, seed, size4) { - const getRandom = rng(seed); - const pillCircumference = getOvalPerimeter(width, height); - const numBumps = Math.max(Math.ceil(pillCircumference / SIZES[size4]), 6, Math.ceil(pillCircumference / Math.min(width, height))); - const targetBumpProtrusion = pillCircumference / numBumps * BUMP_PROTRUSION; - const innerWidth = Math.max(width - targetBumpProtrusion * 2, 1); - const innerHeight = Math.max(height - targetBumpProtrusion * 2, 1); - const innerCircumference = getOvalPerimeter(innerWidth, innerHeight); - const distanceBetweenPointsOnPerimeter = innerCircumference / numBumps; - const paddingX = (width - innerWidth) / 2; - const paddingY = (height - innerHeight) / 2; - const bumpPoints = getPillPoints(innerWidth, innerHeight, numBumps).map((p) => { - return p.addXY(paddingX, paddingY); - }); - const maxWiggleX = width < 20 ? 0 : targetBumpProtrusion * 0.3; - const maxWiggleY = height < 20 ? 0 : targetBumpProtrusion * 0.3; - const wiggledPoints = bumpPoints.slice(0); - for (let i = 0; i < Math.floor(numBumps / 2); i++) { - wiggledPoints[i] = Vec.AddXY(wiggledPoints[i], getRandom() * maxWiggleX, getRandom() * maxWiggleY); - wiggledPoints[numBumps - i - 1] = Vec.AddXY(wiggledPoints[numBumps - i - 1], getRandom() * maxWiggleX, getRandom() * maxWiggleY); - } - const arcs = []; - for (let i = 0; i < wiggledPoints.length; i++) { - const j = i === wiggledPoints.length - 1 ? 0 : i + 1; - const leftWigglePoint = wiggledPoints[i]; - const rightWigglePoint = wiggledPoints[j]; - const leftPoint = bumpPoints[i]; - const rightPoint = bumpPoints[j]; - const distanceBetweenOriginalPoints = Vec.Dist(leftPoint, rightPoint); - const curvatureOffset = distanceBetweenPointsOnPerimeter - distanceBetweenOriginalPoints; - const distanceBetweenWigglePoints = Vec.Dist(leftWigglePoint, rightWigglePoint); - const relativeSize = distanceBetweenWigglePoints / distanceBetweenOriginalPoints; - const finalDistance = (Math.max(paddingX, paddingY) + curvatureOffset) * relativeSize; - const arcPoint = Vec.Lrp(leftPoint, rightPoint, 0.5).add(Vec.Sub(rightPoint, leftPoint).uni().per().mul(finalDistance)); - if (arcPoint.x < 0) { - arcPoint.x = 0; - } else if (arcPoint.x > width) { - arcPoint.x = width; - } - if (arcPoint.y < 0) { - arcPoint.y = 0; - } else if (arcPoint.y > height) { - arcPoint.y = height; - } - const center = centerOfCircleFromThreePoints(leftWigglePoint, rightWigglePoint, arcPoint); - const radius = Vec.Dist(center ? center : Vec.Average([leftWigglePoint, rightWigglePoint]), leftWigglePoint); - arcs.push({ - leftPoint: leftWigglePoint, - rightPoint: rightWigglePoint, - arcPoint, - center, - radius - }); - } - return arcs; -} -function cloudOutline(width, height, seed, size4) { - const path = []; - const arcs = getCloudArcs(width, height, seed, size4); - for (const { center, radius, leftPoint, rightPoint } of arcs) { - path.push(...getPointsOnArc(leftPoint, rightPoint, center, radius, 10)); - } - return path; -} -function getCloudPath(width, height, seed, size4) { - const arcs = getCloudArcs(width, height, seed, size4); - let path = `M${arcs[0].leftPoint.toFixed()}`; - for (const { leftPoint, rightPoint, radius, center } of arcs) { - if (center === null) { - path += ` L${rightPoint.toFixed()}`; - continue; - } - const arc = Vec.Clockwise(leftPoint, rightPoint, center) ? "0" : "1"; - path += ` A${toDomPrecision(radius)},${toDomPrecision(radius)} 0 ${arc},1 ${rightPoint.toFixed()}`; - } - path += " Z"; - return path; -} -var DRAW_OFFSETS = { - s: 0.5, - m: 0.7, - l: 0.9, - xl: 1.6 -}; -function inkyCloudSvgPath(width, height, seed, size4) { - const getRandom = rng(seed); - const mutMultiplier = DRAW_OFFSETS[size4]; - const arcs = getCloudArcs(width, height, seed, size4); - const avgArcLengthSquared = arcs.reduce((sum, arc) => sum + Vec.Dist2(arc.leftPoint, arc.rightPoint), 0) / arcs.length; - const shouldMutatePoints = avgArcLengthSquared > (mutMultiplier * 15) ** 2; - const mutPoint = shouldMutatePoints ? (p) => p.addXY(getRandom() * mutMultiplier * 2, getRandom() * mutMultiplier * 2) : (p) => p; - let pathA = `M${arcs[0].leftPoint.toFixed()}`; - let leftMutPoint = mutPoint(arcs[0].leftPoint); - let pathB = `M${leftMutPoint.toFixed()}`; - for (const { leftPoint, center, rightPoint, radius, arcPoint } of arcs) { - if (center === null) { - pathA += ` L${rightPoint.toFixed()}`; - const rightMutPoint2 = mutPoint(rightPoint); - pathB += ` L${rightMutPoint2.toFixed()}`; - leftMutPoint = rightMutPoint2; - continue; - } - const arc = Vec.Clockwise(leftPoint, rightPoint, center) ? "0" : "1"; - pathA += ` A${toDomPrecision(radius)},${toDomPrecision(radius)} 0 ${arc},1 ${rightPoint.toFixed()}`; - const rightMutPoint = mutPoint(rightPoint); - const mutArcPoint = mutPoint(arcPoint); - const mutCenter = centerOfCircleFromThreePoints(leftMutPoint, rightMutPoint, mutArcPoint); - if (!Number.isFinite(mutCenter.x) || !Number.isFinite(mutCenter.y)) { - pathB += ` L${rightMutPoint.toFixed()}`; - leftMutPoint = rightMutPoint; - continue; - } - const mutRadius = Math.abs(Vec.Dist(mutCenter, leftMutPoint)); - pathB += ` A${toDomPrecision(mutRadius)},${toDomPrecision(mutRadius)} 0 ${arc},1 ${rightMutPoint.toFixed()}`; - leftMutPoint = rightMutPoint; - } - return pathA + pathB + " Z"; -} - -// node_modules/tldraw/dist-esm/lib/shapes/geo/getLines.mjs -function getLines(props, sw) { - switch (props.geo) { - case "x-box": { - return getXBoxLines(props.w, props.h, sw, props.dash); - } - case "check-box": { - return getCheckBoxLines(props.w, props.h); - } - default: { - return void 0; - } - } -} -function getXBoxLines(w, h, sw, dash) { - const inset = dash === "draw" ? 0.62 : 0; - if (dash === "dashed") { - return [ - [new Vec(0, 0), new Vec(w / 2, h / 2)], - [new Vec(w, h), new Vec(w / 2, h / 2)], - [new Vec(0, h), new Vec(w / 2, h / 2)], - [new Vec(w, 0), new Vec(w / 2, h / 2)] - ]; - } - const clampX = (x) => Math.max(0, Math.min(w, x)); - const clampY = (y) => Math.max(0, Math.min(h, y)); - return [ - [ - new Vec(clampX(sw * inset), clampY(sw * inset)), - new Vec(clampX(w - sw * inset), clampY(h - sw * inset)) - ], - [ - new Vec(clampX(sw * inset), clampY(h - sw * inset)), - new Vec(clampX(w - sw * inset), clampY(sw * inset)) - ] - ]; -} -function getCheckBoxLines(w, h) { - const size4 = Math.min(w, h) * 0.82; - const ox = (w - size4) / 2; - const oy = (h - size4) / 2; - const clampX = (x) => Math.max(0, Math.min(w, x)); - const clampY = (y) => Math.max(0, Math.min(h, y)); - return [ - [ - new Vec(clampX(ox + size4 * 0.25), clampY(oy + size4 * 0.52)), - new Vec(clampX(ox + size4 * 0.45), clampY(oy + size4 * 0.82)) - ], - [ - new Vec(clampX(ox + size4 * 0.45), clampY(oy + size4 * 0.82)), - new Vec(clampX(ox + size4 * 0.82), clampY(oy + size4 * 0.22)) - ] - ]; -} - -// node_modules/tldraw/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs -function GeoShapeBody({ shape, shouldScale }) { - const scaleToUse = shouldScale ? shape.props.scale : 1; - const editor = useEditor(); - const theme = useDefaultColorTheme(); - const { id, props } = shape; - const { w, color, fill, dash, growY, size: size4 } = props; - const strokeWidth = STROKE_SIZES2[size4] * scaleToUse; - const h = props.h + growY; - switch (props.geo) { - case "cloud": { - if (dash === "solid") { - const d = getCloudPath(w, h, id, size4); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } else if (dash === "draw") { - const d = inkyCloudSvgPath(w, h, id, size4); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } else { - const d = getCloudPath(w, h, id, size4); - const arcs = getCloudArcs(w, h, id, size4); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("g", { - strokeWidth, - stroke: theme[color].solid, - fill: "none", - pointerEvents: "all", - children: arcs.map(({ leftPoint, rightPoint, center, radius }, i) => { - const arcLength = center ? radius * canonicalizeRotation(canonicalizeRotation(Vec.Angle(center, rightPoint)) - canonicalizeRotation(Vec.Angle(center, leftPoint))) : Vec.Dist(leftPoint, rightPoint); - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(arcLength, strokeWidth, { - style: dash, - start: "outset", - end: "outset" - }); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { - d: center ? `M${leftPoint.x},${leftPoint.y}A${radius},${radius},0,0,1,${rightPoint.x},${rightPoint.y}` : `M${leftPoint.x},${leftPoint.y}L${rightPoint.x},${rightPoint.y}`, - strokeDasharray, - strokeDashoffset - }, i); - }) - }) - ] }); - } - } - case "ellipse": { - const geometry = shouldScale ? editor.getShapeGeometry(shape) : editor.getShapeUtil(shape).getGeometry(shape); - const d = geometry.getSvgPathData(true); - if (dash === "dashed" || dash === "dotted") { - const perimeter = geometry.length; - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(perimeter < 64 ? perimeter * 2 : perimeter, strokeWidth, { - style: dash, - snap: 4, - closed: true - }); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { - d, - strokeWidth, - fill: "none", - stroke: theme[color].solid, - strokeDasharray, - strokeDashoffset - }) - ] }); - } else { - const geometry2 = shouldScale ? editor.getShapeGeometry(shape) : editor.getShapeUtil(shape).getGeometry(shape); - const d2 = geometry2.getSvgPathData(true); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d: d2, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d: d2, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } - } - case "oval": { - const geometry = shouldScale ? editor.getShapeGeometry(shape) : editor.getShapeUtil(shape).getGeometry(shape); - const d = geometry.getSvgPathData(true); - if (dash === "dashed" || dash === "dotted") { - const perimeter = geometry.getLength(); - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(perimeter < 64 ? perimeter * 2 : perimeter, strokeWidth, { - style: dash, - snap: 4, - start: "outset", - end: "outset", - closed: true - }); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { - d, - strokeWidth, - fill: "none", - stroke: theme[color].solid, - strokeDasharray, - strokeDashoffset - }) - ] }); - } else { - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } - } - case "heart": { - if (dash === "dashed" || dash === "dotted" || dash === "solid") { - const d = getHeartPath(w, h); - const curves = getHeartParts(w, h); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - curves.map((c, i) => { - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(c.length, strokeWidth, { - style: dash, - snap: 1, - start: "outset", - end: "outset", - closed: true - }); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { - d: c.getSvgPathData(), - strokeWidth, - fill: "none", - stroke: theme[color].solid, - strokeDasharray, - strokeDashoffset, - pointerEvents: "all" - }, `curve_${i}`); - }) - ] }); - } else { - const d = getDrawHeartPath(w, h, strokeWidth, shape.id); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } - } - default: { - const geometry = shouldScale ? editor.getShapeGeometry(shape) : editor.getShapeUtil(shape).getGeometry(shape); - const outline = geometry instanceof Group2d ? geometry.children[0].vertices : geometry.vertices; - const lines = getLines(shape.props, strokeWidth); - if (dash === "solid") { - let d = "M" + outline[0] + "L" + outline.slice(1) + "Z"; - if (lines) { - for (const [A, B] of lines) { - d += `M${A.x},${A.y}L${B.x},${B.y}`; - } - } - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } else if (dash === "dashed" || dash === "dotted") { - const d = "M" + outline[0] + "L" + outline.slice(1) + "Z"; - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { theme, d, color, fill, scale: scaleToUse }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("g", { - strokeWidth, - stroke: theme[color].solid, - fill: "none", - pointerEvents: "all", - children: [ - Array.from(Array(outline.length)).map((_, i) => { - const A = Vec.ToFixed(outline[i]); - const B = Vec.ToFixed(outline[(i + 1) % outline.length]); - const dist = Vec.Dist(A, B); - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(dist, strokeWidth, { - style: dash, - start: "outset", - end: "outset" - }); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("line", { - x1: A.x, - y1: A.y, - x2: B.x, - y2: B.y, - strokeDasharray, - strokeDashoffset - }, i); - }), - lines && lines.map(([A, B], i) => { - const dist = Vec.Dist(A, B); - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(dist, strokeWidth, { - style: dash, - start: "skip", - end: "skip", - snap: dash === "dotted" ? 4 : void 0 - }); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { - d: `M${A.x},${A.y}L${B.x},${B.y}`, - stroke: theme[color].solid, - strokeWidth, - fill: "none", - strokeDasharray, - strokeDashoffset - }, `line_fg_${i}`); - }) - ] - }) - ] }); - } else if (dash === "draw") { - let d = getRoundedInkyPolygonPath(getRoundedPolygonPoints(id, outline, strokeWidth / 3, strokeWidth * 2, 2)); - if (lines) { - for (const [A, B] of lines) { - d += `M${A.toFixed()}L${B.toFixed()}`; - } - } - const innerPathData = getRoundedInkyPolygonPath(getRoundedPolygonPoints(id, outline, 0, strokeWidth * 2, 1)); - return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ShapeFill, { - theme, - d: innerPathData, - color, - fill, - scale: scaleToUse - }), - /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("path", { d, stroke: theme[color].solid, strokeWidth, fill: "none" }) - ] }); - } - } - } -} - -// node_modules/tldraw/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs -var MIN_SIZE_WITH_LABEL = 17 * 3; -var GeoShapeUtil = class extends BaseBoxShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canEdit", () => true); - __publicField(this, "onEditEnd", (shape) => { - const { - id, - type, - props: { text } - } = shape; - if (text.trimEnd() !== shape.props.text) { - this.editor.updateShapes([ - { - id, - type, - props: { - text: text.trimEnd() - } - } - ]); - } - }); - __publicField(this, "onResize", (shape, { handle, newPoint, scaleX, scaleY, initialShape }) => { - const unscaledInitialW = initialShape.props.w / initialShape.props.scale; - const unscaledInitialH = initialShape.props.h / initialShape.props.scale; - const unscaledGrowY = initialShape.props.growY / initialShape.props.scale; - let unscaledW = unscaledInitialW * scaleX; - let unscaledH = (unscaledInitialH + unscaledGrowY) * scaleY; - let overShrinkX = 0; - let overShrinkY = 0; - const min3 = MIN_SIZE_WITH_LABEL; - if (shape.props.text.trim()) { - let newW = Math.max(Math.abs(unscaledW), min3); - let newH = Math.max(Math.abs(unscaledH), min3); - if (newW < min3 && newH === min3) - newW = min3; - if (newW === min3 && newH < min3) - newH = min3; - const unscaledLabelSize = getUnscaledLabelSize(this.editor, { - ...shape, - props: { - ...shape.props, - w: newW * shape.props.scale, - h: newH * shape.props.scale - } - }); - const nextW = Math.max(Math.abs(unscaledW), unscaledLabelSize.w) * Math.sign(unscaledW); - const nextH = Math.max(Math.abs(unscaledH), unscaledLabelSize.h) * Math.sign(unscaledH); - overShrinkX = Math.abs(nextW) - Math.abs(unscaledW); - overShrinkY = Math.abs(nextH) - Math.abs(unscaledH); - unscaledW = nextW; - unscaledH = nextH; - } - const scaledW = unscaledW * shape.props.scale; - const scaledH = unscaledH * shape.props.scale; - const offset4 = new Vec(0, 0); - if (scaleX < 0) { - offset4.x += scaledW; - } - if (handle === "left" || handle === "top_left" || handle === "bottom_left") { - offset4.x += scaleX < 0 ? overShrinkX : -overShrinkX; - } - if (scaleY < 0) { - offset4.y += scaledH; - } - if (handle === "top" || handle === "top_left" || handle === "top_right") { - offset4.y += scaleY < 0 ? overShrinkY : -overShrinkY; - } - const { x, y } = offset4.rot(shape.rotation).add(newPoint); - return { - x, - y, - props: { - w: Math.max(Math.abs(scaledW), 1), - h: Math.max(Math.abs(scaledH), 1), - growY: 0 - } - }; - }); - __publicField(this, "onBeforeCreate", (shape) => { - if (!shape.props.text) { - if (shape.props.growY) { - return { - ...shape, - props: { - ...shape.props, - growY: 0 - } - }; - } else { - return; - } - } - const unscaledPrevHeight = shape.props.h / shape.props.scale; - const unscaledNextHeight = getUnscaledLabelSize(this.editor, shape).h; - let growY = null; - if (unscaledNextHeight > unscaledPrevHeight) { - growY = unscaledNextHeight - unscaledPrevHeight; - } else { - if (shape.props.growY) { - growY = 0; - } - } - if (growY !== null) { - return { - ...shape, - props: { - ...shape.props, - growY: growY * shape.props.scale - } - }; - } - }); - __publicField(this, "onBeforeUpdate", (prev, next) => { - const prevText = prev.props.text; - const nextText = next.props.text; - if (prevText === nextText && prev.props.font === next.props.font && prev.props.size === next.props.size) { - return; - } - if (prevText && !nextText) { - return { - ...next, - props: { - ...next.props, - growY: 0 - } - }; - } - const unscaledPrevWidth = prev.props.w / prev.props.scale; - const unscaledPrevHeight = prev.props.h / prev.props.scale; - const unscaledPrevGrowY = prev.props.growY / prev.props.scale; - const unscaledNextLabelSize = getUnscaledLabelSize(this.editor, next); - if (!prevText && nextText && nextText.length === 1) { - let unscaledW = Math.max(unscaledPrevWidth, unscaledNextLabelSize.w); - let unscaledH = Math.max(unscaledPrevHeight, unscaledNextLabelSize.h); - const min3 = MIN_SIZE_WITH_LABEL; - if (unscaledPrevWidth < min3 && unscaledPrevHeight < min3) { - unscaledW = Math.max(unscaledW, min3); - unscaledH = Math.max(unscaledH, min3); - unscaledW = Math.max(unscaledW, unscaledH); - unscaledH = Math.max(unscaledW, unscaledH); - } - return { - ...next, - props: { - ...next.props, - w: unscaledW * next.props.scale, - h: unscaledH * next.props.scale, - growY: 0 - } - }; - } - let growY = null; - if (unscaledNextLabelSize.h > unscaledPrevHeight) { - growY = unscaledNextLabelSize.h - unscaledPrevHeight; - } else { - if (unscaledPrevGrowY) { - growY = 0; - } - } - if (growY !== null) { - const unscaledNextWidth = next.props.w / next.props.scale; - return { - ...next, - props: { - ...next.props, - growY: growY * next.props.scale, - w: Math.max(unscaledNextWidth, unscaledNextLabelSize.w) * next.props.scale - } - }; - } - if (unscaledNextLabelSize.w > unscaledPrevWidth) { - return { - ...next, - props: { - ...next.props, - w: unscaledNextLabelSize.w * next.props.scale - } - }; - } - }); - __publicField(this, "onDoubleClick", (shape) => { - if (this.editor.inputs.altKey) { - switch (shape.props.geo) { - case "rectangle": { - return { - ...shape, - props: { - geo: "check-box" - } - }; - } - case "check-box": { - return { - ...shape, - props: { - geo: "rectangle" - } - }; - } - } - } - return; - }); - } - getDefaultProps() { - return { - w: 100, - h: 100, - geo: "rectangle", - color: "black", - labelColor: "black", - fill: "none", - dash: "draw", - size: "m", - font: "draw", - text: "", - align: "middle", - verticalAlign: "middle", - growY: 0, - url: "", - scale: 1 - }; - } - getGeometry(shape) { - const w = Math.max(1, shape.props.w); - const h = Math.max(1, shape.props.h + shape.props.growY); - const cx = w / 2; - const cy = h / 2; - const isFilled = shape.props.fill !== "none"; - let body; - switch (shape.props.geo) { - case "cloud": { - body = new Polygon2d({ - points: cloudOutline(w, h, shape.id, shape.props.size), - isFilled - }); - break; - } - case "triangle": { - body = new Polygon2d({ - points: [new Vec(cx, 0), new Vec(w, h), new Vec(0, h)], - isFilled - }); - break; - } - case "diamond": { - body = new Polygon2d({ - points: [new Vec(cx, 0), new Vec(w, cy), new Vec(cx, h), new Vec(0, cy)], - isFilled - }); - break; - } - case "pentagon": { - body = new Polygon2d({ - points: getPolygonVertices(w, h, 5), - isFilled - }); - break; - } - case "hexagon": { - body = new Polygon2d({ - points: getPolygonVertices(w, h, 6), - isFilled - }); - break; - } - case "octagon": { - body = new Polygon2d({ - points: getPolygonVertices(w, h, 8), - isFilled - }); - break; - } - case "ellipse": { - body = new Ellipse2d({ - width: w, - height: h, - isFilled - }); - break; - } - case "oval": { - body = new Stadium2d({ - width: w, - height: h, - isFilled - }); - break; - } - case "star": { - const sides2 = 5; - const step = PI2 / sides2 / 2; - const rightMostIndex = Math.floor(sides2 / 4) * 2; - const leftMostIndex = sides2 * 2 - rightMostIndex; - const topMostIndex = 0; - const bottomMostIndex = Math.floor(sides2 / 2) * 2; - const maxX = Math.cos(-HALF_PI + rightMostIndex * step) * w / 2; - const minX = Math.cos(-HALF_PI + leftMostIndex * step) * w / 2; - const minY = Math.sin(-HALF_PI + topMostIndex * step) * h / 2; - const maxY = Math.sin(-HALF_PI + bottomMostIndex * step) * h / 2; - const diffX = w - Math.abs(maxX - minX); - const diffY = h - Math.abs(maxY - minY); - const offsetX = w / 2 + minX - (w / 2 - maxX); - const offsetY = h / 2 + minY - (h / 2 - maxY); - const ratio = 1; - const cx2 = (w - offsetX) / 2; - const cy2 = (h - offsetY) / 2; - const ox = (w + diffX) / 2; - const oy = (h + diffY) / 2; - const ix = ox * ratio / 2; - const iy = oy * ratio / 2; - body = new Polygon2d({ - points: Array.from(Array(sides2 * 2)).map((_, i) => { - const theta = -HALF_PI + i * step; - return new Vec(cx2 + (i % 2 ? ix : ox) * Math.cos(theta), cy2 + (i % 2 ? iy : oy) * Math.sin(theta)); - }), - isFilled - }); - break; - } - case "rhombus": { - const offset4 = Math.min(w * 0.38, h * 0.38); - body = new Polygon2d({ - points: [new Vec(offset4, 0), new Vec(w, 0), new Vec(w - offset4, h), new Vec(0, h)], - isFilled - }); - break; - } - case "rhombus-2": { - const offset4 = Math.min(w * 0.38, h * 0.38); - body = new Polygon2d({ - points: [new Vec(0, 0), new Vec(w - offset4, 0), new Vec(w, h), new Vec(offset4, h)], - isFilled - }); - break; - } - case "trapezoid": { - const offset4 = Math.min(w * 0.38, h * 0.38); - body = new Polygon2d({ - points: [new Vec(offset4, 0), new Vec(w - offset4, 0), new Vec(w, h), new Vec(0, h)], - isFilled - }); - break; - } - case "arrow-right": { - const ox = Math.min(w, h) * 0.38; - const oy = h * 0.16; - body = new Polygon2d({ - points: [ - new Vec(0, oy), - new Vec(w - ox, oy), - new Vec(w - ox, 0), - new Vec(w, h / 2), - new Vec(w - ox, h), - new Vec(w - ox, h - oy), - new Vec(0, h - oy) - ], - isFilled - }); - break; - } - case "arrow-left": { - const ox = Math.min(w, h) * 0.38; - const oy = h * 0.16; - body = new Polygon2d({ - points: [ - new Vec(ox, 0), - new Vec(ox, oy), - new Vec(w, oy), - new Vec(w, h - oy), - new Vec(ox, h - oy), - new Vec(ox, h), - new Vec(0, h / 2) - ], - isFilled - }); - break; - } - case "arrow-up": { - const ox = w * 0.16; - const oy = Math.min(w, h) * 0.38; - body = new Polygon2d({ - points: [ - new Vec(w / 2, 0), - new Vec(w, oy), - new Vec(w - ox, oy), - new Vec(w - ox, h), - new Vec(ox, h), - new Vec(ox, oy), - new Vec(0, oy) - ], - isFilled - }); - break; - } - case "arrow-down": { - const ox = w * 0.16; - const oy = Math.min(w, h) * 0.38; - body = new Polygon2d({ - points: [ - new Vec(ox, 0), - new Vec(w - ox, 0), - new Vec(w - ox, h - oy), - new Vec(w, h - oy), - new Vec(w / 2, h), - new Vec(0, h - oy), - new Vec(ox, h - oy) - ], - isFilled - }); - break; - } - case "check-box": - case "x-box": - case "rectangle": { - body = new Rectangle2d({ - width: w, - height: h, - isFilled - }); - break; - } - case "heart": { - const parts = getHeartParts(w, h); - const points = parts.reduce((acc, part) => { - acc.push(...part.vertices); - return acc; - }, []); - body = new Polygon2d({ - points, - isFilled - }); - break; - } - default: { - exhaustiveSwitchError(shape.props.geo); - } - } - const unscaledlabelSize = getUnscaledLabelSize(this.editor, shape); - const unscaledW = w / shape.props.scale; - const unscaledH = h / shape.props.scale; - const unscaledminWidth = Math.min(100, unscaledW / 2); - const unscaledMinHeight = Math.min(LABEL_FONT_SIZES[shape.props.size] * TEXT_PROPS.lineHeight + LABEL_PADDING * 2, unscaledH / 2); - const unscaledLabelWidth = Math.min(unscaledW, Math.max(unscaledlabelSize.w, Math.min(unscaledminWidth, Math.max(1, unscaledW - 8)))); - const unscaledLabelHeight = Math.min(unscaledH, Math.max(unscaledlabelSize.h, Math.min(unscaledMinHeight, Math.max(1, unscaledH - 8)))); - const lines = getLines(shape.props, STROKE_SIZES2[shape.props.size] * shape.props.scale); - const edges = lines ? lines.map((line) => new Polyline2d({ points: line })) : []; - return new Group2d({ - children: [ - body, - new Rectangle2d({ - x: shape.props.align === "start" ? 0 : shape.props.align === "end" ? (unscaledW - unscaledLabelWidth) * shape.props.scale : (unscaledW - unscaledLabelWidth) / 2 * shape.props.scale, - y: shape.props.verticalAlign === "start" ? 0 : shape.props.verticalAlign === "end" ? (unscaledH - unscaledLabelHeight) * shape.props.scale : (unscaledH - unscaledLabelHeight) / 2 * shape.props.scale, - width: unscaledLabelWidth * shape.props.scale, - height: unscaledLabelHeight * shape.props.scale, - isFilled: true, - isLabel: true - }), - ...edges - ] - }); - } - getHandleSnapGeometry(shape) { - const geometry = this.getGeometry(shape); - const outline = geometry.children[0]; - switch (shape.props.geo) { - case "arrow-down": - case "arrow-left": - case "arrow-right": - case "arrow-up": - case "check-box": - case "diamond": - case "hexagon": - case "octagon": - case "pentagon": - case "rectangle": - case "rhombus": - case "rhombus-2": - case "star": - case "trapezoid": - case "triangle": - case "x-box": - return { outline, points: [...outline.getVertices(), geometry.bounds.center] }; - case "cloud": - case "ellipse": - case "heart": - case "oval": - return { outline, points: [geometry.bounds.center] }; - default: - exhaustiveSwitchError(shape.props.geo); - } - } - component(shape) { - const { id, type, props } = shape; - const { fill, font, align, verticalAlign, size: size4, text } = props; - const isSelected = shape.id === this.editor.getOnlySelectedShapeId(); - const theme = useDefaultColorTheme(); - const isEditingAnything = this.editor.getEditingShapeId() !== null; - const showHtmlContainer = isEditingAnything || shape.props.text; - return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(SVGContainer, { id, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(GeoShapeBody, { shape, shouldScale: true }) }), - showHtmlContainer && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(HTMLContainer, { - style: { - overflow: "hidden", - width: shape.props.w, - height: shape.props.h + props.growY - }, - children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(TextLabel, { - id, - type, - font, - fontSize: LABEL_FONT_SIZES[size4] * shape.props.scale, - lineHeight: TEXT_PROPS.lineHeight, - padding: LABEL_PADDING * shape.props.scale, - fill, - align, - verticalAlign, - text, - isSelected, - labelColor: theme[props.labelColor].solid, - wrap: true - }) - }), - shape.props.url && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(HyperlinkButton, { url: shape.props.url, zoomLevel: this.editor.getZoomLevel() }) - ] }); - } - indicator(shape) { - const { id, props } = shape; - const { w, size: size4 } = props; - const h = props.h + props.growY; - const strokeWidth = STROKE_SIZES2[size4]; - const geometry = this.editor.getShapeGeometry(shape); - switch (props.geo) { - case "ellipse": { - if (props.dash === "draw") { - return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: getEllipseDrawIndicatorPath(id, w, h, strokeWidth) }); - } - return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: geometry.getSvgPathData(true) }); - } - case "heart": { - return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: getHeartPath(w, h) }); - } - case "oval": { - return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: geometry.getSvgPathData(true) }); - } - case "cloud": { - return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: getCloudPath(w, h, id, size4) }); - } - default: { - const geometry2 = this.editor.getShapeGeometry(shape); - const outline = geometry2 instanceof Group2d ? geometry2.children[0].vertices : geometry2.vertices; - let path; - if (props.dash === "draw") { - const polygonPoints = getRoundedPolygonPoints(id, outline, 0, strokeWidth * 2 * shape.props.scale, 1); - path = getRoundedInkyPolygonPath(polygonPoints); - } else { - path = "M" + outline[0] + "L" + outline.slice(1) + "Z"; - } - const lines = getLines(shape.props, strokeWidth); - if (lines) { - for (const [A, B] of lines) { - path += `M${A.x},${A.y}L${B.x},${B.y}`; - } - } - return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: path }); - } - } - } - toSvg(shape, ctx) { - const newShape = { - ...shape, - props: { - ...shape.props, - w: shape.props.w / shape.props.scale, - h: shape.props.h / shape.props.scale - } - }; - const props = newShape.props; - ctx.addExportDef(getFillDefForExport(props.fill)); - let textEl; - if (props.text) { - ctx.addExportDef(getFontDefForExport(props.font)); - const theme = getDefaultColorTheme(ctx); - const bounds = new Box(0, 0, props.w, props.h + props.growY); - textEl = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(SvgTextLabel, { - fontSize: LABEL_FONT_SIZES[props.size], - font: props.font, - align: props.align, - verticalAlign: props.verticalAlign, - text: props.text, - labelColor: theme[props.labelColor].solid, - bounds, - padding: 16 - }); - } - return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(GeoShapeBody, { shouldScale: false, shape: newShape }), - textEl - ] }); - } - getCanvasSvgDefs() { - return [getFillDefForCanvas()]; - } -}; -__publicField(GeoShapeUtil, "type", "geo"); -__publicField(GeoShapeUtil, "props", geoShapeProps); -__publicField(GeoShapeUtil, "migrations", geoShapeMigrations); -function getUnscaledLabelSize(editor, shape) { - const { text, font, size: size4, w } = shape.props; - if (!text) { - return { w: 0, h: 0 }; - } - const minSize = editor.textMeasure.measureText("w", { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[font], - fontSize: LABEL_FONT_SIZES[size4], - maxWidth: 100 - }); - const sizes = { - s: 2, - m: 3.5, - l: 5, - xl: 10 - }; - const textSize = editor.textMeasure.measureText(text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[font], - fontSize: LABEL_FONT_SIZES[size4], - minWidth: minSize.w, - maxWidth: Math.max(0, Math.ceil(minSize.w + sizes[size4]), Math.ceil(w / shape.props.scale - LABEL_PADDING * 2)) - }); - return { - w: textSize.w + LABEL_PADDING * 2, - h: textSize.h + LABEL_PADDING * 2 - }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs -var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/useColorSpace.mjs -var import_react55 = __toESM(require_react(), 1); -function useColorSpace() { - const [supportsP3, setSupportsP3] = (0, import_react55.useState)(false); - (0, import_react55.useEffect)(() => { - const supportsSyntax = CSS.supports("color", "color(display-p3 1 1 1)"); - const query = matchMedia("(color-gamut: p3)"); - setSupportsP3(supportsSyntax && query.matches); - const onChange = () => setSupportsP3(supportsSyntax && query.matches); - query.addEventListener("change", onChange); - return () => query.removeEventListener("change", onChange); - }, []); - const forceSrgb = useValue(debugFlags.forceSrgb); - return forceSrgb || !supportsP3 ? "srgb" : "p3"; -} - -// node_modules/tldraw/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs -var OVERLAY_OPACITY = 0.35; -var UNDERLAY_OPACITY = 0.82; -var HighlightShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "hideResizeHandles", (shape) => getIsDot2(shape)); - __publicField(this, "hideRotateHandle", (shape) => getIsDot2(shape)); - __publicField(this, "hideSelectionBoundsFg", (shape) => getIsDot2(shape)); - __publicField(this, "onResize", (shape, info2) => { - const { scaleX, scaleY } = info2; - const newSegments = []; - for (const segment of shape.props.segments) { - newSegments.push({ - ...segment, - points: segment.points.map(({ x, y, z }) => { - return { - x: scaleX * x, - y: scaleY * y, - z - }; - }) - }); - } - return { - props: { - segments: newSegments - } - }; - }); - } - getDefaultProps() { - return { - segments: [], - color: "black", - size: "m", - isComplete: false, - isPen: false, - scale: 1 - }; - } - getGeometry(shape) { - const strokeWidth = getStrokeWidth(shape); - if (getIsDot2(shape)) { - return new Circle2d({ - x: -strokeWidth / 2, - y: -strokeWidth / 2, - radius: strokeWidth / 2, - isFilled: true - }); - } - const { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, true); - const opts = getHighlightFreehandSettings({ strokeWidth: sw, showAsComplete: true }); - setStrokePointRadii(strokePoints, opts); - return new Polygon2d({ - points: getStrokeOutlinePoints(strokePoints, opts), - isFilled: true - }); - } - component(shape) { - const forceSolid = useHighlightForceSolid(this.editor, shape); - const strokeWidth = getStrokeWidth(shape); - return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(SVGContainer, { id: shape.id, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(HighlightRenderer, { - shape, - forceSolid, - strokeWidth, - opacity: OVERLAY_OPACITY - }) }); - } - backgroundComponent(shape) { - const forceSolid = useHighlightForceSolid(this.editor, shape); - const strokeWidth = getStrokeWidth(shape); - return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(SVGContainer, { id: shape.id, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(HighlightRenderer, { - shape, - forceSolid, - strokeWidth, - opacity: UNDERLAY_OPACITY - }) }); - } - indicator(shape) { - const forceSolid = useHighlightForceSolid(this.editor, shape); - const strokeWidth = getStrokeWidth(shape); - const { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, forceSolid); - const allPointsFromSegments = getPointsFromSegments(shape.props.segments); - let strokePath; - if (strokePoints.length < 2) { - strokePath = getIndicatorDot(allPointsFromSegments[0], sw); - } else { - strokePath = getSvgPathFromStrokePoints(strokePoints, false); - } - return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: strokePath }); - } - toSvg(shape) { - const strokeWidth = getStrokeWidth(shape); - const forceSolid = strokeWidth < 1.5; - const scaleFactor = 1 / shape.props.scale; - return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("g", { transform: `scale(${scaleFactor})`, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(HighlightRenderer, { - forceSolid, - strokeWidth, - shape, - opacity: OVERLAY_OPACITY - }) }); - } - toBackgroundSvg(shape) { - const strokeWidth = getStrokeWidth(shape); - const forceSolid = strokeWidth < 1.5; - const scaleFactor = 1 / shape.props.scale; - return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("g", { transform: `scale(${scaleFactor})`, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(HighlightRenderer, { - forceSolid, - strokeWidth, - shape, - opacity: UNDERLAY_OPACITY - }) }); - } -}; -__publicField(HighlightShapeUtil, "type", "highlight"); -__publicField(HighlightShapeUtil, "props", highlightShapeProps); -__publicField(HighlightShapeUtil, "migrations", highlightShapeMigrations); -function getShapeDot(point) { - const r = 0.1; - return `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${r * 2},0`; -} -function getIndicatorDot(point, sw) { - const r = sw / 2; - return `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${r * 2},0`; -} -function getHighlightStrokePoints(shape, strokeWidth, forceSolid) { - const allPointsFromSegments = getPointsFromSegments(shape.props.segments); - const showAsComplete = shape.props.isComplete || last(shape.props.segments)?.type === "straight"; - let sw = strokeWidth; - if (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) { - sw += rng(shape.id)() * (strokeWidth / 6); - } - const options = getHighlightFreehandSettings({ - strokeWidth: sw, - showAsComplete - }); - const strokePoints = getStrokePoints(allPointsFromSegments, options); - return { strokePoints, sw }; -} -function getStrokeWidth(shape) { - return FONT_SIZES[shape.props.size] * 1.12 * shape.props.scale; -} -function getIsDot2(shape) { - return shape.props.segments.length === 1 && shape.props.segments[0].points.length < 2; -} -function HighlightRenderer({ - strokeWidth, - forceSolid, - shape, - opacity -}) { - const theme = useDefaultColorTheme(); - const allPointsFromSegments = getPointsFromSegments(shape.props.segments); - let sw = strokeWidth; - if (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) { - sw += rng(shape.id)() * (sw / 6); - } - const options = getHighlightFreehandSettings({ - strokeWidth: sw, - showAsComplete: shape.props.isComplete || last(shape.props.segments)?.type === "straight" - }); - const strokePoints = getStrokePoints(allPointsFromSegments, options); - const solidStrokePath = strokePoints.length > 1 ? getSvgPathFromStrokePoints(strokePoints, false) : getShapeDot(shape.props.segments[0].points[0]); - const colorSpace = useColorSpace(); - const color = theme[shape.props.color].highlight[colorSpace]; - return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { - d: solidStrokePath, - strokeLinecap: "round", - fill: "none", - pointerEvents: "all", - stroke: color, - strokeWidth: sw, - opacity - }); -} -function useHighlightForceSolid(editor, shape) { - return useValue("forceSolid", () => { - const sw = getStrokeWidth(shape); - const zoomLevel = editor.getZoomLevel(); - if (sw / zoomLevel < 1.5) { - return true; - } - return false; - }, [editor]); -} - -// node_modules/tldraw/dist-esm/lib/shapes/image/ImageShapeUtil.mjs -var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1); -var import_classnames18 = __toESM(require_classnames(), 1); -var import_react58 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/BrokenAssetIcon.mjs -var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); -function BrokenAssetIcon() { - return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("svg", { - width: "15", - height: "15", - viewBox: "0 0 30 30", - xmlns: "http://www.w3.org/2000/svg", - fill: "none", - stroke: "currentColor", - strokeLinecap: "round", - strokeLinejoin: "round", - children: [ - /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M3,11 L3,3 11,3", strokeWidth: "2" }), - /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M19,27 L27,27 L27,19", strokeWidth: "2" }), - /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M27,3 L3,27", strokeWidth: "2" }) - ] - }); -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/useAsset.mjs -var import_react56 = __toESM(require_react(), 1); -function useAsset(shapeId, assetId, width) { - const editor = useEditor(); - const [url, setUrl] = (0, import_react56.useState)(null); - const asset = assetId ? editor.getAsset(assetId) : null; - const culledShapes = editor.getCulledShapes(); - const isCulled = culledShapes.has(shapeId); - const didAlreadyResolve = (0, import_react56.useRef)(false); - (0, import_react56.useEffect)(() => { - if (url) - didAlreadyResolve.current = true; - }, [url]); - const shapeScale = asset && "w" in asset.props ? width / asset.props.w : 1; - const screenScale = useValue("zoom level", () => editor.getZoomLevel() * shapeScale, [ - editor, - shapeScale - ]); - (0, import_react56.useEffect)(() => { - if (isCulled) - return; - let isCancelled = false; - const timer = editor.timers.setTimeout(async () => { - const resolvedUrl = await editor.resolveAssetUrl(assetId, { - screenScale - }); - if (!isCancelled) - setUrl(resolvedUrl); - }, didAlreadyResolve.current ? 500 : 0); - return () => { - clearTimeout(timer); - isCancelled = true; - }; - }, [assetId, asset?.props.src, isCulled, screenScale, editor]); - return { asset, url }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs -var import_react57 = __toESM(require_react(), 1); -function usePrefersReducedMotion() { - const [prefersReducedMotion, setPrefersReducedMotion] = (0, import_react57.useState)(false); - (0, import_react57.useEffect)(() => { - if (typeof window === "undefined" || !("matchMedia" in window)) - return; - const mql = window.matchMedia("(prefers-reduced-motion: reduce)"); - const handler = () => { - setPrefersReducedMotion(mql.matches); - }; - handler(); - mql.addEventListener("change", handler); - return () => mql.removeEventListener("change", handler); - }, []); - return prefersReducedMotion; -} - -// node_modules/tldraw/dist-esm/lib/shapes/image/ImageShapeUtil.mjs -async function getDataURIFromURL(url) { - const response = await fetch2(url); - const blob = await response.blob(); - return FileHelpers.blobToDataUrl(blob); -} -var ImageShapeUtil = class extends BaseBoxShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "isAspectRatioLocked", () => true); - __publicField(this, "canCrop", () => true); - __publicField(this, "onResize", (shape, info2) => { - let resized = resizeBox(shape, info2); - const { flipX, flipY } = info2.initialShape.props; - resized = { - ...resized, - props: { - ...resized.props, - flipX: info2.scaleX < 0 !== flipX, - flipY: info2.scaleY < 0 !== flipY - } - }; - return resized; - }); - __publicField(this, "onDoubleClick", (shape) => { - const asset = shape.props.assetId ? this.editor.getAsset(shape.props.assetId) : void 0; - if (!asset) - return; - const canPlay = asset.props.src && this.isAnimated(shape); - if (!canPlay) - return; - this.editor.updateShapes([ - { - type: "image", - id: shape.id, - props: { - playing: !shape.props.playing - } - } - ]); - }); - __publicField(this, "onDoubleClickEdge", (shape) => { - const props = shape.props; - if (!props) - return; - if (this.editor.getCroppingShapeId() !== shape.id) { - return; - } - const crop = structuredClone(props.crop) || { - topLeft: { x: 0, y: 0 }, - bottomRight: { x: 1, y: 1 } - }; - const w = 1 / (crop.bottomRight.x - crop.topLeft.x) * shape.props.w; - const h = 1 / (crop.bottomRight.y - crop.topLeft.y) * shape.props.h; - const pointDelta = new Vec(crop.topLeft.x * w, crop.topLeft.y * h).rot(shape.rotation); - const partial = { - id: shape.id, - type: shape.type, - x: shape.x - pointDelta.x, - y: shape.y - pointDelta.y, - props: { - crop: { - topLeft: { x: 0, y: 0 }, - bottomRight: { x: 1, y: 1 } - }, - w, - h - } - }; - this.editor.updateShapes([partial]); - }); - } - getDefaultProps() { - return { - w: 100, - h: 100, - assetId: null, - playing: true, - url: "", - crop: null, - flipX: false, - flipY: false - }; - } - isAnimated(shape) { - const asset = shape.props.assetId ? this.editor.getAsset(shape.props.assetId) : void 0; - if (!asset) - return false; - return "mimeType" in asset.props && MediaHelpers.isAnimatedImageType(asset?.props.mimeType) || "isAnimated" in asset.props && asset.props.isAnimated; - } - component(shape) { - const isCropping = this.editor.getCroppingShapeId() === shape.id; - const prefersReducedMotion = usePrefersReducedMotion(); - const [staticFrameSrc, setStaticFrameSrc] = (0, import_react58.useState)(""); - const [loadedSrc, setLoadedSrc] = (0, import_react58.useState)(""); - const isSelected = shape.id === this.editor.getOnlySelectedShapeId(); - const { asset, url } = useAsset(shape.id, shape.props.assetId, shape.props.w); - (0, import_react58.useEffect)(() => { - if (url) { - let cancelled = false; - const image = Image(); - image.onload = () => { - if (cancelled) - return; - setLoadedSrc(url); - }; - image.src = url; - return () => { - cancelled = true; - }; - } - }, [url, shape]); - (0, import_react58.useEffect)(() => { - if (url && this.isAnimated(shape)) { - let cancelled = false; - const image = Image(); - image.onload = () => { - if (cancelled) - return; - const canvas = document.createElement("canvas"); - canvas.width = image.width; - canvas.height = image.height; - const ctx = canvas.getContext("2d"); - if (!ctx) - return; - ctx.drawImage(image, 0, 0); - setStaticFrameSrc(canvas.toDataURL()); - setLoadedSrc(url); - }; - image.crossOrigin = "anonymous"; - image.src = url; - return () => { - cancelled = true; - }; - } - }, [prefersReducedMotion, url, shape]); - if (asset?.type === "bookmark") { - throw Error("Bookmark assets can't be rendered as images"); - } - const showCropPreview = isSelected && isCropping && this.editor.isIn("select.crop"); - const reduceMotion = prefersReducedMotion && (asset?.props.mimeType?.includes("video") || this.isAnimated(shape)); - const containerStyle = getCroppedContainerStyle(shape); - if (!asset?.props.src) { - return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(HTMLContainer, { - id: shape.id, - style: { - overflow: "hidden", - width: shape.props.w, - height: shape.props.h, - color: "var(--color-text-3)", - backgroundColor: asset ? "transparent" : "var(--color-low)", - border: asset ? "none" : "1px solid var(--color-low-border)" - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "tl-image-container", style: containerStyle, children: asset ? null : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(BrokenAssetIcon, {}) }), - "url" in shape.props && shape.props.url && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(HyperlinkButton, { url: shape.props.url, zoomLevel: this.editor.getZoomLevel() }) - ] - }); - } - if (!loadedSrc) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [ - showCropPreview && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("img", { - className: "tl-image", - crossOrigin: this.isAnimated(shape) ? "anonymous" : void 0, - src: !shape.props.playing || reduceMotion ? staticFrameSrc : loadedSrc, - referrerPolicy: "strict-origin-when-cross-origin", - style: { - opacity: 0.1 - }, - draggable: false - }) }), - /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(HTMLContainer, { - id: shape.id, - style: { overflow: "hidden", width: shape.props.w, height: shape.props.h }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "tl-image-container", style: containerStyle, children: [ - /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("img", { - className: (0, import_classnames18.default)("tl-image", { - "tl-flip-x": shape.props.flipX && !shape.props.flipY, - "tl-flip-y": shape.props.flipY && !shape.props.flipX, - "tl-flip-xy": shape.props.flipY && shape.props.flipX - }), - crossOrigin: this.isAnimated(shape) ? "anonymous" : void 0, - src: !shape.props.playing || reduceMotion ? staticFrameSrc : loadedSrc, - referrerPolicy: "strict-origin-when-cross-origin", - draggable: false - }), - this.isAnimated(shape) && !shape.props.playing && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "tl-image__tg", children: "GIF" }) - ] }), - shape.props.url && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(HyperlinkButton, { url: shape.props.url, zoomLevel: this.editor.getZoomLevel() }) - ] - }) - ] }); - } - indicator(shape) { - const isCropping = this.editor.getCroppingShapeId() === shape.id; - if (isCropping) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("rect", { width: toDomPrecision(shape.props.w), height: toDomPrecision(shape.props.h) }); - } - async toSvg(shape) { - if (!shape.props.assetId) - return null; - const asset = this.editor.getAsset(shape.props.assetId); - if (!asset) - return null; - let src = await this.editor.resolveAssetUrl(shape.props.assetId, { - shouldResolveToOriginal: true - }); - if (!src) - return null; - if (src.startsWith("blob:") || src.startsWith("http") || src.startsWith("/") || src.startsWith("./")) { - src = await getDataURIFromURL(src) || ""; - } - const containerStyle = getCroppedContainerStyle(shape); - const crop = shape.props.crop; - if (containerStyle.transform && crop) { - const { transform, width, height } = containerStyle; - const croppedWidth = (crop.bottomRight.x - crop.topLeft.x) * width; - const croppedHeight = (crop.bottomRight.y - crop.topLeft.y) * height; - const points = [ - new Vec(0, 0), - new Vec(croppedWidth, 0), - new Vec(croppedWidth, croppedHeight), - new Vec(0, croppedHeight) - ]; - const cropClipId = `cropClipPath_${shape.id.replace(":", "_")}`; - return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("clipPath", { id: cropClipId, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("polygon", { points: points.map((p) => `${p.x},${p.y}`).join(" ") }) }) }), - /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("g", { clipPath: `url(#${cropClipId})`, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("image", { href: src, width, height, style: { transform } }) }) - ] }); - } else { - return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("image", { href: src, width: shape.props.w, height: shape.props.h }); - } - } -}; -__publicField(ImageShapeUtil, "type", "image"); -__publicField(ImageShapeUtil, "props", imageShapeProps); -__publicField(ImageShapeUtil, "migrations", imageShapeMigrations); -function getCroppedContainerStyle(shape) { - const crop = shape.props.crop; - const topLeft = crop?.topLeft; - if (!topLeft) { - return { - width: shape.props.w, - height: shape.props.h - }; - } - const w = 1 / (crop.bottomRight.x - crop.topLeft.x) * shape.props.w; - const h = 1 / (crop.bottomRight.y - crop.topLeft.y) * shape.props.h; - const offsetX = -topLeft.x * w; - const offsetY = -topLeft.y * h; - return { - transform: `translate(${offsetX}px, ${offsetY}px)`, - width: w, - height: h - }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/line/LineShapeUtil.mjs -var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/line/components/getLinePath.mjs -function getLineDrawFreehandOptions(strokeWidth) { - return { - size: strokeWidth, - thinning: 0.4, - streamline: 0, - smoothing: 0.5, - simulatePressure: true, - last: true - }; -} -function getLineStrokePoints(shape, spline, strokeWidth) { - const points = spline.vertices; - const options = getLineDrawFreehandOptions(strokeWidth); - return getStrokePoints(points, options); -} -function getLineDrawStrokeOutlinePoints(shape, spline, strokeWidth) { - const options = getLineDrawFreehandOptions(strokeWidth); - return getStrokeOutlinePoints(setStrokePointRadii(getLineStrokePoints(shape, spline, strokeWidth), options), options); -} -function getLineDrawPath(shape, spline, strokeWidth) { - const stroke = getLineDrawStrokeOutlinePoints(shape, spline, strokeWidth); - return getSvgPathFromPoints(stroke); -} -function getLineIndicatorPath(shape, spline, strokeWidth) { - if (shape.props.dash === "draw") { - const strokePoints = getLineStrokePoints(shape, spline, strokeWidth); - return getSvgPathFromStrokePoints(strokePoints); - } - return spline.getSvgPathData(); -} - -// node_modules/tldraw/dist-esm/lib/shapes/line/line-helpers.mjs -function getDrawLinePathData(id, outline, strokeWidth) { - let innerPathData = `M ${precise(outline[0])}L`; - let outerPathData2 = `M ${precise(outline[0])}L`; - const offset4 = strokeWidth / 3; - const roundness = strokeWidth * 2; - const random = rng(id); - let p0 = outline[0]; - let p1; - let s0 = outline[0]; - let s1; - const len = outline.length; - for (let i = 0, n = len - 1; i < n; i++) { - p1 = outline[i + 1]; - s1 = Vec.AddXY(outline[i + 1], random() * offset4, random() * offset4); - const delta = Vec.Sub(p1, p0); - const distance = Vec.Len(delta); - const vector = Vec.Div(delta, distance).mul(Math.min(distance / 4, roundness)); - const q0 = Vec.Add(p0, vector); - const q1 = Vec.Add(p1, vector.neg()); - const sDelta = Vec.Sub(s1, s0); - const sDistance = Vec.Len(sDelta); - const sVector = Vec.Div(sDelta, sDistance).mul(Math.min(sDistance / 4, roundness)); - const sq0 = Vec.Add(s0, sVector); - const sq1 = Vec.Add(s1, sVector.neg()); - if (i === n - 1) { - innerPathData += `${precise(q0)}L ${precise(p1)}`; - outerPathData2 += `${precise(sq0)}L ${precise(s1)}`; - } else { - innerPathData += `${precise(q0)}L ${precise(q1)}Q ${precise(p1)}`; - outerPathData2 += `${precise(sq0)}L ${precise(sq1)}Q ${precise(s1)}`; - p0 = p1; - s0 = s1; - } - } - return [innerPathData, innerPathData + outerPathData2]; -} - -// node_modules/tldraw/dist-esm/lib/shapes/line/LineShapeUtil.mjs -var handlesCache = new WeakCache(); -var LineShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "hideResizeHandles", () => true); - __publicField(this, "hideRotateHandle", () => true); - __publicField(this, "hideSelectionBoundsFg", () => true); - __publicField(this, "hideSelectionBoundsBg", () => true); - __publicField(this, "onResize", (shape, info2) => { - const { scaleX, scaleY } = info2; - return { - props: { - points: mapObjectMapValues(shape.props.points, (_, { id, index: index2, x, y }) => ({ - id, - index: index2, - x: x * scaleX, - y: y * scaleY - })) - } - }; - }); - __publicField(this, "onHandleDrag", (shape, { handle }) => { - if (handle.type !== "vertex") - return; - return { - ...shape, - props: { - ...shape.props, - points: { - ...shape.props.points, - [handle.id]: { id: handle.id, index: handle.index, x: handle.x, y: handle.y } - } - } - }; - }); - } - getDefaultProps() { - const [start, end] = getIndices(2); - return { - dash: "draw", - size: "m", - color: "black", - spline: "line", - points: { - [start]: { id: start, index: start, x: 0, y: 0 }, - [end]: { id: end, index: end, x: 0.1, y: 0.1 } - }, - scale: 1 - }; - } - getGeometry(shape) { - return getGeometryForLineShape(shape); - } - getHandles(shape) { - return handlesCache.get(shape.props, () => { - const spline = getGeometryForLineShape(shape); - const points = linePointsToArray(shape); - const results = points.map((point) => ({ - ...point, - id: point.index, - type: "vertex", - canSnap: true - })); - for (let i = 0; i < points.length - 1; i++) { - const index2 = getIndexBetween(points[i].index, points[i + 1].index); - const segment = spline.segments[i]; - const point = segment.midPoint(); - results.push({ - id: index2, - type: "create", - index: index2, - x: point.x, - y: point.y, - canSnap: true - }); - } - return results.sort(sortByIndex); - }); - } - component(shape) { - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SVGContainer, { id: shape.id, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(LineShapeSvg, { shape }) }); - } - indicator(shape) { - const strokeWidth = STROKE_SIZES2[shape.props.size] * shape.props.scale; - const spline = getGeometryForLineShape(shape); - const { dash } = shape.props; - let path; - if (shape.props.spline === "line") { - const outline = spline.points; - if (dash === "solid" || dash === "dotted" || dash === "dashed") { - path = "M" + outline[0] + "L" + outline.slice(1); - } else { - const [innerPathData] = getDrawLinePathData(shape.id, outline, strokeWidth); - path = innerPathData; - } - } else { - path = getLineIndicatorPath(shape, spline, strokeWidth); - } - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { d: path }); - } - toSvg(shape) { - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(LineShapeSvg, { shouldScale: true, shape }); - } - getHandleSnapGeometry(shape) { - const points = linePointsToArray(shape); - return { - points, - getSelfSnapPoints: (handle) => { - const index2 = this.getHandles(shape).filter((h) => h.type === "vertex").findIndex((h) => h.id === handle.id); - return points.filter((_, i) => Math.abs(i - index2) > 1).map(Vec.From); - }, - getSelfSnapOutline: (handle) => { - const index2 = this.getHandles(shape).filter((h) => h.type === "vertex").findIndex((h) => h.id === handle.id); - const segments = getGeometryForLineShape(shape).segments.filter((_, i) => i !== index2 - 1 && i !== index2); - if (!segments.length) - return null; - return new Group2d({ children: segments }); - } - }; - } - getInterpolatedProps(startShape, endShape, progress) { - const startPoints = linePointsToArray(startShape); - const endPoints = linePointsToArray(endShape); - const pointsToUseStart = []; - const pointsToUseEnd = []; - let index2 = ZERO_INDEX_KEY; - if (startPoints.length > endPoints.length) { - for (let i = 0; i < startPoints.length; i++) { - pointsToUseStart[i] = { ...startPoints[i] }; - if (endPoints[i] === void 0) { - pointsToUseEnd[i] = { ...endPoints[endPoints.length - 1], id: index2 }; - } else { - pointsToUseEnd[i] = { ...endPoints[i], id: index2 }; - } - index2 = getIndexAbove(index2); - } - } else if (endPoints.length > startPoints.length) { - for (let i = 0; i < endPoints.length; i++) { - pointsToUseEnd[i] = { ...endPoints[i] }; - if (startPoints[i] === void 0) { - pointsToUseStart[i] = { - ...startPoints[startPoints.length - 1], - id: index2 - }; - } else { - pointsToUseStart[i] = { ...startPoints[i], id: index2 }; - } - index2 = getIndexAbove(index2); - } - } else { - for (let i = 0; i < endPoints.length; i++) { - pointsToUseStart[i] = startPoints[i]; - pointsToUseEnd[i] = endPoints[i]; - } - } - return { - ...endShape.props, - points: Object.fromEntries(pointsToUseStart.map((point, i) => { - const endPoint = pointsToUseEnd[i]; - return [ - point.id, - { - ...point, - x: lerp(point.x, endPoint.x, progress), - y: lerp(point.y, endPoint.y, progress) - } - ]; - })) - }; - } -}; -__publicField(LineShapeUtil, "type", "line"); -__publicField(LineShapeUtil, "props", lineShapeProps); -__publicField(LineShapeUtil, "migrations", lineShapeMigrations); -function linePointsToArray(shape) { - return Object.values(shape.props.points).sort(sortByIndex); -} -function getGeometryForLineShape(shape) { - const points = linePointsToArray(shape).map(Vec.From); - switch (shape.props.spline) { - case "cubic": { - return new CubicSpline2d({ points }); - } - case "line": { - return new Polyline2d({ points }); - } - } -} -function LineShapeSvg({ - shape, - shouldScale = false -}) { - const theme = useDefaultColorTheme(); - const spline = getGeometryForLineShape(shape); - const { dash, color, size: size4 } = shape.props; - const scaleFactor = 1 / shape.props.scale; - const scale = shouldScale ? scaleFactor : 1; - const strokeWidth = STROKE_SIZES2[size4] * shape.props.scale; - if (shape.props.spline === "line") { - if (dash === "solid") { - const outline = spline.points; - const pathData = "M" + outline[0] + "L" + outline.slice(1); - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { - d: pathData, - stroke: theme[color].solid, - strokeWidth, - fill: "none", - transform: `scale(${scale})` - }); - } - if (dash === "dashed" || dash === "dotted") { - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("g", { stroke: theme[color].solid, strokeWidth, transform: `scale(${scale})`, children: spline.segments.map((segment, i) => { - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(segment.length, strokeWidth, { - style: dash, - start: i > 0 ? "outset" : "none", - end: i < spline.segments.length - 1 ? "outset" : "none" - }); - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { - strokeDasharray, - strokeDashoffset, - d: segment.getSvgPathData(true), - fill: "none" - }, i); - }) }); - } - if (dash === "draw") { - const outline = spline.points; - const [_, outerPathData] = getDrawLinePathData(shape.id, outline, strokeWidth); - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { - d: outerPathData, - stroke: theme[color].solid, - strokeWidth, - fill: "none", - transform: `scale(${scale})` - }); - } - } - if (shape.props.spline === "cubic") { - const splinePath = spline.getSvgPathData(); - if (dash === "solid") { - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { - strokeWidth, - stroke: theme[color].solid, - fill: "none", - d: splinePath, - transform: `scale(${scale})` - }); - } - if (dash === "dashed" || dash === "dotted") { - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("g", { stroke: theme[color].solid, strokeWidth, transform: `scale(${scale})`, children: spline.segments.map((segment, i) => { - const { strokeDasharray, strokeDashoffset } = getPerfectDashProps2(segment.length, strokeWidth, { - style: dash, - start: i > 0 ? "outset" : "none", - end: i < spline.segments.length - 1 ? "outset" : "none" - }); - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { - strokeDasharray, - strokeDashoffset, - d: segment.getSvgPathData(), - fill: "none" - }, i); - }) }); - } - if (dash === "draw") { - return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("path", { - d: getLineDrawPath(shape, spline, strokeWidth), - strokeWidth: 1, - stroke: theme[color].solid, - fill: theme[color].solid, - transform: `scale(${scale})` - }); - } - } -} - -// node_modules/tldraw/dist-esm/lib/shapes/note/NoteShapeUtil.mjs -var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); -var import_react60 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useTranslation/useTranslation.mjs -var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); -var React16 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/context/asset-urls.mjs -var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1); -var import_react59 = __toESM(require_react(), 1); -var AssetUrlsContext = (0, import_react59.createContext)(null); -function AssetUrlsProvider({ - assetUrls, - children -}) { - (0, import_react59.useEffect)(() => { - for (const src of Object.values(assetUrls.icons)) { - const image = Image(); - image.src = src; - image.decode(); - } - for (const src of Object.values(assetUrls.embedIcons)) { - const image = Image(); - image.src = src; - image.decode(); - } - }, [assetUrls]); - return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(AssetUrlsContext.Provider, { value: assetUrls, children }); -} -function useAssetUrls() { - const assetUrls = (0, import_react59.useContext)(AssetUrlsContext); - if (!assetUrls) { - throw new Error("useAssetUrls must be used within an AssetUrlsProvider"); - } - return assetUrls; -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs -var DEFAULT_TRANSLATION = { - "action.convert-to-bookmark": "Convert to Bookmark", - "action.convert-to-embed": "Convert to Embed", - "action.open-embed-link": "Open link", - "action.align-bottom": "Align bottom", - "action.align-center-horizontal": "Align horizontally", - "action.align-center-vertical": "Align vertically", - "action.align-center-horizontal.short": "Align H", - "action.align-center-vertical.short": "Align V", - "action.align-left": "Align left", - "action.align-right": "Align right", - "action.align-top": "Align top", - "action.back-to-content": "Back to content", - "action.bring-forward": "Bring forward", - "action.bring-to-front": "Bring to front", - "action.copy-as-json.short": "JSON", - "action.copy-as-json": "Copy as JSON", - "action.copy-as-png.short": "PNG", - "action.copy-as-png": "Copy as PNG", - "action.copy-as-svg.short": "SVG", - "action.copy-as-svg": "Copy as SVG", - "action.copy": "Copy", - "action.cut": "Cut", - "action.delete": "Delete", - "action.unlock-all": "Unlock all", - "action.distribute-horizontal": "Distribute horizontally", - "action.distribute-vertical": "Distribute vertically", - "action.distribute-horizontal.short": "Distribute H", - "action.distribute-vertical.short": "Distribute V", - "action.duplicate": "Duplicate", - "action.edit-link": "Edit link", - "action.exit-pen-mode": "Exit pen mode", - "action.export-as-json.short": "JSON", - "action.export-as-json": "Export as JSON", - "action.export-as-png.short": "PNG", - "action.export-as-png": "Export as PNG", - "action.export-as-svg.short": "SVG", - "action.export-as-svg": "Export as SVG", - "action.export-all-as-json.short": "JSON", - "action.export-all-as-json": "Export as JSON", - "action.export-all-as-png.short": "PNG", - "action.export-all-as-png": "Export as PNG", - "action.export-all-as-svg.short": "SVG", - "action.export-all-as-svg": "Export as SVG", - "action.fit-frame-to-content": "Fit to content", - "action.flip-horizontal": "Flip horizontally", - "action.flip-vertical": "Flip vertically", - "action.flip-horizontal.short": "Flip H", - "action.flip-vertical.short": "Flip V", - "action.fork-project": "Fork this project", - "action.fork-project-on-tldraw": "Fork project on tldraw", - "action.group": "Group", - "action.insert-embed": "Insert embed", - "action.insert-media": "Upload media", - "action.leave-shared-project": "Leave shared project", - "action.new-project": "New project", - "action.new-shared-project": "New shared project", - "action.open-cursor-chat": "Cursor chat", - "action.open-file": "Open file", - "action.pack": "Pack", - "action.paste": "Paste", - "action.paste-error-title": "Pasting failed", - "action.paste-error-description": "Could not paste due to missing clipboard permissions. Please enable the permissions and try again.", - "action.print": "Print", - "action.redo": "Redo", - "action.remove-frame": "Remove frame", - "action.rename": "Rename", - "action.rotate-ccw": "Rotate counterclockwise", - "action.rotate-cw": "Rotate clockwise", - "action.save-copy": "Save a copy", - "action.select-all": "Select all", - "action.select-none": "Select none", - "action.send-backward": "Send backward", - "action.send-to-back": "Send to back", - "action.share-project": "Share this project", - "action.stack-horizontal": "Stack horizontally", - "action.stack-vertical": "Stack vertically", - "action.stack-horizontal.short": "Stack H", - "action.stack-vertical.short": "Stack V", - "action.stop-following": "Stop following", - "action.stretch-horizontal": "Stretch horizontally", - "action.stretch-vertical": "Stretch vertically", - "action.stretch-horizontal.short": "Stretch H", - "action.stretch-vertical.short": "Stretch V", - "action.toggle-auto-size": "Toggle auto size", - "action.toggle-dark-mode.menu": "Dark mode", - "action.toggle-dark-mode": "Toggle dark mode", - "action.toggle-paste-at-cursor.menu": "Paste at cursor", - "action.toggle-paste-at-cursor": "Toggle paste at cursor", - "action.toggle-wrap-mode.menu": "Select on wrap", - "action.toggle-wrap-mode": "Toggle Select on wrap", - "action.toggle-reduce-motion.menu": "Reduce motion", - "action.toggle-reduce-motion": "Toggle reduce motion", - "action.toggle-edge-scrolling.menu": "Edge scrolling", - "action.toggle-edge-scrolling": "Toggle edge scrolling", - "action.toggle-debug-mode.menu": "Debug mode", - "action.toggle-debug-mode": "Toggle debug mode", - "action.toggle-focus-mode.menu": "Focus mode", - "action.toggle-focus-mode": "Toggle focus mode", - "action.toggle-dynamic-size-mode.menu": "Dynamic size", - "action.toggle-dynamic-size-mode": "Toggle dynamic size", - "action.toggle-grid.menu": "Show grid", - "action.toggle-grid": "Toggle grid", - "action.toggle-lock": "Toggle locked", - "action.flatten-to-image": "Flatten", - "action.toggle-snap-mode.menu": "Always snap", - "action.toggle-snap-mode": "Toggle always snap", - "action.toggle-tool-lock.menu": "Tool lock", - "action.toggle-tool-lock": "Toggle tool lock", - "action.toggle-transparent.context-menu": "Transparent", - "action.toggle-transparent.menu": "Transparent", - "action.toggle-transparent": "Toggle transparent background", - "action.undo": "Undo", - "action.ungroup": "Ungroup", - "action.zoom-in": "Zoom in", - "action.zoom-out": "Zoom out", - "action.zoom-to-100": "Zoom to 100%", - "action.zoom-to-fit": "Zoom to fit", - "action.zoom-to-selection": "Zoom to selection", - "assets.files.size-too-big": "File size is too big", - "assets.files.type-not-allowed": "File type is not allowed", - "assets.files.upload-failed": "Upload failed", - "assets.url.failed": "Couldn't load URL preview", - "theme.dark": "Dark", - "theme.light": "Light", - "theme.system": "System", - "color-style.white": "White", - "color-style.black": "Black", - "color-style.blue": "Blue", - "color-style.green": "Green", - "color-style.grey": "Grey", - "color-style.light-blue": "Light blue", - "color-style.light-green": "Light green", - "color-style.light-red": "Light red", - "color-style.light-violet": "Light violet", - "color-style.orange": "Orange", - "color-style.red": "Red", - "color-style.violet": "Violet", - "color-style.yellow": "Yellow", - "fill-style.none": "None", - "document.default-name": "Untitled", - "fill-style.semi": "Semi", - "fill-style.solid": "Solid", - "fill-style.pattern": "Pattern", - "fill-style.fill": "Fill", - "dash-style.dashed": "Dashed", - "dash-style.dotted": "Dotted", - "dash-style.draw": "Draw", - "dash-style.solid": "Solid", - "size-style.s": "Small", - "size-style.m": "Medium", - "size-style.l": "Large", - "size-style.xl": "Extra large", - "opacity-style.0.1": "10%", - "opacity-style.0.25": "25%", - "opacity-style.0.5": "50%", - "opacity-style.0.75": "75%", - "opacity-style.1": "100%", - "font-style.draw": "Draw", - "font-style.sans": "Sans", - "font-style.serif": "Serif", - "font-style.mono": "Mono", - "align-style.start": "Start", - "align-style.middle": "Middle", - "align-style.end": "End", - "align-style.justify": "Justify", - "verticalAlign-style.start": "Top", - "verticalAlign-style.middle": "Middle", - "verticalAlign-style.end": "Bottom", - "geo-style.arrow-down": "Arrow down", - "geo-style.arrow-left": "Arrow left", - "geo-style.arrow-right": "Arrow right", - "geo-style.arrow-up": "Arrow up", - "geo-style.diamond": "Diamond", - "geo-style.ellipse": "Ellipse", - "geo-style.hexagon": "Hexagon", - "geo-style.octagon": "Octagon", - "geo-style.oval": "Oval", - "geo-style.cloud": "Cloud", - "geo-style.pentagon": "Pentagon", - "geo-style.rectangle": "Rectangle", - "geo-style.rhombus-2": "Rhombus 2", - "geo-style.rhombus": "Rhombus", - "geo-style.star": "Star", - "geo-style.trapezoid": "Trapezoid", - "geo-style.triangle": "Triangle", - "geo-style.x-box": "X box", - "geo-style.check-box": "Check box", - "arrowheadStart-style.none": "None", - "arrowheadStart-style.arrow": "Arrow", - "arrowheadStart-style.bar": "Bar", - "arrowheadStart-style.diamond": "Diamond", - "arrowheadStart-style.dot": "Dot", - "arrowheadStart-style.inverted": "Inverted", - "arrowheadStart-style.pipe": "Pipe", - "arrowheadStart-style.square": "Square", - "arrowheadStart-style.triangle": "Triangle", - "arrowheadEnd-style.none": "None", - "arrowheadEnd-style.arrow": "Arrow", - "arrowheadEnd-style.bar": "Bar", - "arrowheadEnd-style.diamond": "Diamond", - "arrowheadEnd-style.dot": "Dot", - "arrowheadEnd-style.inverted": "Inverted", - "arrowheadEnd-style.pipe": "Pipe", - "arrowheadEnd-style.square": "Square", - "arrowheadEnd-style.triangle": "Triangle", - "spline-style.line": "Line", - "spline-style.cubic": "Cubic", - "tool.select": "Select", - "tool.hand": "Hand", - "tool.draw": "Draw", - "tool.eraser": "Eraser", - "tool.arrow-down": "Arrow down", - "tool.arrow-left": "Arrow left", - "tool.arrow-right": "Arrow right", - "tool.arrow-up": "Arrow up", - "tool.arrow": "Arrow", - "tool.cloud": "Cloud", - "tool.diamond": "Diamond", - "tool.ellipse": "Ellipse", - "tool.hexagon": "Hexagon", - "tool.highlight": "Highlight", - "tool.line": "Line", - "tool.octagon": "Octagon", - "tool.oval": "Oval", - "tool.pentagon": "Pentagon", - "tool.rectangle": "Rectangle", - "tool.rhombus": "Rhombus", - "tool.star": "Star", - "tool.trapezoid": "Trapezoid", - "tool.triangle": "Triangle", - "tool.x-box": "X box", - "tool.check-box": "Check box", - "tool.asset": "Asset", - "tool.frame": "Frame", - "tool.note": "Note", - "tool.laser": "Laser", - "tool.embed": "Embed", - "tool.text": "Text", - "menu.title": "Menu", - "menu.theme": "Theme", - "menu.copy-as": "Copy as", - "menu.edit": "Edit", - "menu.export-as": "Export as", - "menu.file": "File", - "menu.language": "Language", - "menu.preferences": "Preferences", - "menu.help": "Help", - "menu.view": "View", - "context-menu.edit": "Edit", - "context-menu.arrange": "Arrange", - "context-menu.copy-as": "Copy as", - "context-menu.export-as": "Export as", - "context-menu.export-all-as": "Export", - "context-menu.move-to-page": "Move to page", - "context-menu.reorder": "Reorder", - "page-menu.title": "Pages", - "page-menu.create-new-page": "Create new page", - "page-menu.max-page-count-reached": "Max pages reached", - "page-menu.new-page-initial-name": "Page 1", - "page-menu.edit-start": "Edit", - "page-menu.edit-done": "Done", - "page-menu.go-to-page": "Go to page", - "page-menu.submenu.rename": "Rename", - "page-menu.submenu.duplicate-page": "Duplicate", - "page-menu.submenu.title": "Menu", - "page-menu.submenu.move-down": "Move down", - "page-menu.submenu.move-up": "Move up", - "page-menu.submenu.delete": "Delete", - "share-menu.title": "Share", - "share-menu.save-note": "Download this project to your computer as a .tldr file.", - "share-menu.fork-note": "Create a new shared project based on this snapshot.", - "share-menu.share-project": "Share this project", - "share-menu.default-project-name": "Shared Project", - "share-menu.copy-link": "Copy editor link", - "share-menu.readonly-link": "Read-only", - "share-menu.create-snapshot-link": "Copy snapshot link", - "share-menu.snapshot-link-note": "Capture and share this project as a read-only snapshot link.", - "share-menu.copy-readonly-link": "Copy viewer link", - "share-menu.offline-note": "Create a new shared project based on your current project.", - "share-menu.copy-link-note": "Anyone with the link will be able to view and edit this project.", - "share-menu.copy-readonly-link-note": "Anyone with the link will be able to access this project.", - "share-menu.project-too-large": "Sorry, this project can't be shared because it's too large. We're working on it!", - "share-menu.upload-failed": "Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.", - "share-menu.creating-project": "Creating the new project\u2026", - "share-menu.copied": "Copied link", - "status.offline": "Offline", - "status.online": "Online", - "people-menu.title": "People", - "people-menu.change-name": "Change name", - "people-menu.change-color": "Change color", - "people-menu.follow": "Following", - "people-menu.following": "Following", - "people-menu.leading": "Following You", - "people-menu.user": "(You)", - "people-menu.invite": "Invite others", - "help-menu.title": "Help and resources", - "help-menu.about": "About", - "help-menu.docs": "Documentation & API", - "help-menu.discord": "Discord", - "help-menu.github": "GitHub", - "help-menu.keyboard-shortcuts": "Keyboard shortcuts", - "help-menu.twitter": "Twitter", - "actions-menu.title": "Actions", - "edit-link-dialog.title": "Edit link", - "edit-link-dialog.invalid-url": "A link must be a valid URL.", - "edit-link-dialog.detail": "Links will open in a new tab.", - "edit-link-dialog.url": "URL", - "edit-link-dialog.clear": "Clear", - "edit-link-dialog.save": "Continue", - "edit-link-dialog.cancel": "Cancel", - "embed-dialog.title": "Insert embed", - "embed-dialog.back": "Back", - "embed-dialog.create": "Create", - "embed-dialog.cancel": "Cancel", - "embed-dialog.url": "URL", - "embed-dialog.instruction": "Paste in the site's URL to create the embed.", - "embed-dialog.invalid-url": "We could not create an embed from that URL.", - "edit-pages-dialog.move-down": "Move down", - "edit-pages-dialog.move-up": "Move up", - "shortcuts-dialog.title": "Keyboard shortcuts", - "shortcuts-dialog.edit": "Edit", - "shortcuts-dialog.file": "File", - "shortcuts-dialog.preferences": "Preferences", - "shortcuts-dialog.tools": "Tools", - "shortcuts-dialog.transform": "Transform", - "shortcuts-dialog.view": "View", - "shortcuts-dialog.collaboration": "Collaboration", - "home-project-dialog.title": "Home project", - "home-project-dialog.description": "This is your local home project. It's just for you!", - "rename-project-dialog.title": "Rename project", - "rename-project-dialog.cancel": "Cancel", - "rename-project-dialog.rename": "Rename", - "home-project-dialog.ok": "Ok", - "style-panel.title": "Styles", - "style-panel.align": "Align", - "style-panel.vertical-align": "Vertical align", - "style-panel.position": "Position", - "style-panel.arrowheads": "Arrows", - "style-panel.arrowhead-start": "Start", - "style-panel.arrowhead-end": "End", - "style-panel.color": "Color", - "style-panel.dash": "Dash", - "style-panel.fill": "Fill", - "style-panel.font": "Font", - "style-panel.geo": "Shape", - "style-panel.mixed": "Mixed", - "style-panel.opacity": "Opacity", - "style-panel.size": "Size", - "style-panel.spline": "Spline", - "tool-panel.drawing": "Drawing", - "tool-panel.shapes": "Shapes", - "tool-panel.more": "More", - "debug-panel.more": "More", - "navigation-zone.toggle-minimap": "Toggle minimap", - "navigation-zone.zoom": "Zoom", - "focus-mode.toggle-focus-mode": "Toggle focus mode", - "toast.close": "Close", - "file-system.file-open-error.title": "Could not open file", - "file-system.file-open-error.not-a-tldraw-file": "The file you tried to open doesn't look like a tldraw file.", - "file-system.file-open-error.file-format-version-too-new": "The file you tried to open is from a newer version of tldraw. Please reload the page and try again.", - "file-system.file-open-error.generic-corrupted-file": "The file you tried to open is corrupted.", - "file-system.confirm-open.title": "Overwrite current project?", - "file-system.confirm-open.description": "Opening a file will replace your current project and any unsaved changes will be lost. Are you sure you want to continue?", - "file-system.confirm-open.cancel": "Cancel", - "file-system.confirm-open.open": "Open file", - "file-system.confirm-open.dont-show-again": "Don't ask again", - "file-system.confirm-clear.title": "Clear current project?", - "file-system.confirm-clear.description": "Creating a new project will clear your current project and any unsaved changes will be lost. Are you sure you want to continue?", - "file-system.confirm-clear.cancel": "Cancel", - "file-system.confirm-clear.continue": "Continue", - "file-system.confirm-clear.dont-show-again": "Don't ask again", - "file-system.shared-document-file-open-error.title": "Could not open file", - "file-system.shared-document-file-open-error.description": "Opening files from shared projects is not supported.", - "sharing.confirm-leave.title": "Leave current project?", - "sharing.confirm-leave.description": "Are you sure you want to leave this shared project? You can return to it by navigating to its URL.", - "sharing.confirm-leave.cancel": "Cancel", - "sharing.confirm-leave.leave": "Leave", - "sharing.confirm-leave.dont-show-again": "Don't ask again", - "toast.error.export-fail.title": "Failed export", - "toast.error.export-fail.desc": "Failed to export image", - "toast.error.copy-fail.title": "Failed copy", - "toast.error.copy-fail.desc": "Failed to copy image", - "context.pages.new-page": "New page", - "vscode.file-open.desc": "We've updated this document to work with the current version of tldraw. If you'd like to keep the original version (which will work on old.tldraw.com), click below to create a backup.", - "vscode.file-open.open": "Continue", - "vscode.file-open.backup": "Backup", - "vscode.file-open.backup-saved": "Backup saved", - "vscode.file-open.backup-failed": "Backup failed: this is not a .tldr file.", - "vscode.file-open.dont-show-again": "Don't ask again", - "cursor-chat.type-to-chat": "Type to chat..." -}; - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useTranslation/translations.mjs -var RTL_LANGUAGES = /* @__PURE__ */ new Set(["ar", "fa", "he", "ur", "ku"]); -var EN_TRANSLATION = { - locale: "en", - label: "English", - messages: DEFAULT_TRANSLATION, - dir: "ltr" -}; -async function fetchTranslation(locale, assetUrls) { - const mainRes = await fetch2(assetUrls.translations.en); - if (!mainRes.ok) { - console.warn(`No main translations found.`); - return EN_TRANSLATION; - } - if (locale === "en") { - return EN_TRANSLATION; - } - const language = LANGUAGES.find((t2) => t2.locale === locale); - if (!language) { - console.warn(`No translation found for locale ${locale}`); - return EN_TRANSLATION; - } - const res = await fetch2(assetUrls.translations[language.locale]); - const messages = await res.json(); - if (!messages) { - console.warn(`No messages found for locale ${locale}`); - return EN_TRANSLATION; - } - const missing = []; - for (const key in EN_TRANSLATION.messages) { - if (!messages[key]) { - missing.push(key); - } - } - if (missing.length > 0 && false) { - console.warn(`Language ${locale}: missing messages for keys: -${missing.join("\n")}`); - } - return { - locale, - label: language.label, - dir: RTL_LANGUAGES.has(language.locale) ? "rtl" : "ltr", - messages: { ...EN_TRANSLATION.messages, ...messages } - }; -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useTranslation/useTranslation.mjs -var TranslationsContext = React16.createContext(null); -function useCurrentTranslation() { - const translations = React16.useContext(TranslationsContext); - if (!translations) { - throw new Error("useCurrentTranslation must be used inside of <TldrawUiContextProvider />"); - } - return translations; -} -var TranslationProvider = track(function TranslationProvider2({ - overrides, - children -}) { - const editor = useEditor(); - const locale = editor.user.getLocale(); - const getAssetUrl = useAssetUrls(); - const [currentTranslation, setCurrentTranslation] = React16.useState(() => { - if (overrides && overrides["en"]) { - return { - locale: "en", - label: "English", - dir: "ltr", - messages: { ...DEFAULT_TRANSLATION, ...overrides["en"] } - }; - } - return { - locale: "en", - label: "English", - dir: "ltr", - messages: DEFAULT_TRANSLATION - }; - }); - React16.useEffect(() => { - let isCancelled = false; - async function loadTranslation() { - const translation = await fetchTranslation(locale, getAssetUrl); - if (translation && !isCancelled) { - if (overrides && overrides[locale]) { - setCurrentTranslation({ - ...translation, - messages: { ...translation.messages, ...overrides[locale] } - }); - } else { - setCurrentTranslation(translation); - } - } - } - loadTranslation(); - return () => { - isCancelled = true; - }; - }, [getAssetUrl, locale, overrides]); - return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(TranslationsContext.Provider, { value: currentTranslation, children }); -}); -function useTranslation() { - const translation = useCurrentTranslation(); - return React16.useCallback(function msg2(id) { - return translation.messages[id] ?? id; - }, [translation]); -} -function untranslated(string2) { - return string2; -} - -// node_modules/tldraw/dist-esm/lib/shapes/note/NoteShapeUtil.mjs -var NoteShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canEdit", () => true); - __publicField(this, "hideResizeHandles", () => true); - __publicField(this, "hideSelectionBoundsFg", () => false); - __publicField(this, "onBeforeCreate", (next) => { - return getNoteSizeAdjustments(this.editor, next); - }); - __publicField(this, "onBeforeUpdate", (prev, next) => { - if (prev.props.text === next.props.text && prev.props.font === next.props.font && prev.props.size === next.props.size) { - return; - } - return getNoteSizeAdjustments(this.editor, next); - }); - __publicField(this, "onEditEnd", (shape) => { - const { - id, - type, - props: { text } - } = shape; - if (text.trimEnd() !== shape.props.text) { - this.editor.updateShapes([ - { - id, - type, - props: { - text: text.trimEnd() - } - } - ]); - } - }); - } - getDefaultProps() { - return { - color: "black", - size: "m", - text: "", - font: "draw", - align: "middle", - verticalAlign: "middle", - growY: 0, - fontSizeAdjustment: 0, - url: "", - scale: 1 - }; - } - getGeometry(shape) { - const { labelHeight, labelWidth } = getLabelSize(this.editor, shape); - const { scale } = shape.props; - const lh = labelHeight * scale; - const lw = labelWidth * scale; - const nw = NOTE_SIZE * scale; - const nh = getNoteHeight(shape); - return new Group2d({ - children: [ - new Rectangle2d({ width: nw, height: nh, isFilled: true }), - new Rectangle2d({ - x: shape.props.align === "start" ? 0 : shape.props.align === "end" ? nw - lw : (nw - lw) / 2, - y: shape.props.verticalAlign === "start" ? 0 : shape.props.verticalAlign === "end" ? nh - lh : (nh - lh) / 2, - width: lw, - height: lh, - isFilled: true, - isLabel: true - }) - ] - }); - } - getHandles(shape) { - const { scale } = shape.props; - const isCoarsePointer = this.editor.getInstanceState().isCoarsePointer; - if (isCoarsePointer) - return []; - const zoom = this.editor.getZoomLevel(); - if (zoom * scale < 0.25) - return []; - const nh = getNoteHeight(shape); - const nw = NOTE_SIZE * scale; - const offset4 = CLONE_HANDLE_MARGIN / zoom * scale; - if (zoom * scale < 0.5) { - return [ - { - id: "bottom", - index: "a3", - type: "clone", - x: nw / 2, - y: nh + offset4 - } - ]; - } - return [ - { - id: "top", - index: "a1", - type: "clone", - x: nw / 2, - y: -offset4 - }, - { - id: "right", - index: "a2", - type: "clone", - x: nw + offset4, - y: nh / 2 - }, - { - id: "bottom", - index: "a3", - type: "clone", - x: nw / 2, - y: nh + offset4 - }, - { - id: "left", - index: "a4", - type: "clone", - x: -offset4, - y: nh / 2 - } - ]; - } - component(shape) { - const { - id, - type, - props: { scale, color, font, size: size4, align, text, verticalAlign, fontSizeAdjustment } - } = shape; - const handleKeyDown = useNoteKeydownHandler(id); - const theme = useDefaultColorTheme(); - const nw = NOTE_SIZE * scale; - const nh = getNoteHeight(shape); - const rotation = useValue("shape rotation", () => this.editor.getShapePageTransform(id)?.rotation() ?? 0, [this.editor]); - const hideShadows = useValue("zoom", () => this.editor.getZoomLevel() < 0.35 / scale, [ - scale, - this.editor - ]); - const isSelected = shape.id === this.editor.getOnlySelectedShapeId(); - return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { - id, - className: "tl-note__container", - style: { - width: nw, - height: nh, - backgroundColor: theme[color].note.fill, - borderBottom: hideShadows ? `${3 * scale}px solid rgb(15, 23, 31, .2)` : `none`, - boxShadow: hideShadows ? "none" : getNoteShadow(shape.id, rotation, scale) - }, - children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TextLabel, { - id, - type, - font, - fontSize: (fontSizeAdjustment || LABEL_FONT_SIZES[size4]) * scale, - lineHeight: TEXT_PROPS.lineHeight, - align, - verticalAlign, - text, - isNote: true, - isSelected, - labelColor: theme[color].note.text, - wrap: true, - padding: 16 * scale, - onKeyDown: handleKeyDown - }) - }), - "url" in shape.props && shape.props.url && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(HyperlinkButton, { url: shape.props.url, zoomLevel: this.editor.getZoomLevel() }) - ] }); - } - indicator(shape) { - const { scale } = shape.props; - return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("rect", { - rx: scale, - width: toDomPrecision(NOTE_SIZE * scale), - height: toDomPrecision(getNoteHeight(shape)) - }); - } - toSvg(shape, ctx) { - if (shape.props.text) - ctx.addExportDef(getFontDefForExport(shape.props.font)); - const theme = getDefaultColorTheme({ isDarkMode: ctx.isDarkMode }); - const bounds = getBoundsForSVG(shape); - return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("rect", { x: 5, y: 5, rx: 1, width: NOTE_SIZE - 10, height: bounds.h, fill: "rgba(0,0,0,.1)" }), - /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("rect", { - rx: 1, - width: NOTE_SIZE, - height: bounds.h, - fill: theme[shape.props.color].note.fill - }), - /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(SvgTextLabel, { - fontSize: shape.props.fontSizeAdjustment || LABEL_FONT_SIZES[shape.props.size], - font: shape.props.font, - align: shape.props.align, - verticalAlign: shape.props.verticalAlign, - text: shape.props.text, - labelColor: theme[shape.props.color].note.text, - bounds, - stroke: false - }) - ] }); - } -}; -__publicField(NoteShapeUtil, "type", "note"); -__publicField(NoteShapeUtil, "props", noteShapeProps); -__publicField(NoteShapeUtil, "migrations", noteShapeMigrations); -function getNoteSizeAdjustments(editor, shape) { - const { labelHeight, fontSizeAdjustment } = getLabelSize(editor, shape); - const growY = Math.max(0, labelHeight - NOTE_SIZE); - if (growY !== shape.props.growY || fontSizeAdjustment !== shape.props.fontSizeAdjustment) { - return { - ...shape, - props: { - ...shape.props, - growY, - fontSizeAdjustment - } - }; - } -} -function getNoteLabelSize(editor, shape) { - const { text } = shape.props; - if (!text) { - const minHeight = LABEL_FONT_SIZES[shape.props.size] * TEXT_PROPS.lineHeight + LABEL_PADDING * 2; - return { labelHeight: minHeight, labelWidth: 100, fontSizeAdjustment: 0 }; - } - const unadjustedFontSize = LABEL_FONT_SIZES[shape.props.size]; - let fontSizeAdjustment = 0; - let iterations = 0; - let labelHeight = NOTE_SIZE; - let labelWidth = NOTE_SIZE; - const FUZZ = 1; - do { - fontSizeAdjustment = Math.min(unadjustedFontSize, unadjustedFontSize - iterations); - const nextTextSize = editor.textMeasure.measureText(text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[shape.props.font], - fontSize: fontSizeAdjustment, - maxWidth: NOTE_SIZE - LABEL_PADDING * 2 - FUZZ, - disableOverflowWrapBreaking: true - }); - labelHeight = nextTextSize.h + LABEL_PADDING * 2; - labelWidth = nextTextSize.w + LABEL_PADDING * 2; - if (fontSizeAdjustment <= 14) { - const nextTextSizeWithOverflowBreak = editor.textMeasure.measureText(text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[shape.props.font], - fontSize: fontSizeAdjustment, - maxWidth: NOTE_SIZE - LABEL_PADDING * 2 - FUZZ - }); - labelHeight = nextTextSizeWithOverflowBreak.h + LABEL_PADDING * 2; - labelWidth = nextTextSizeWithOverflowBreak.w + LABEL_PADDING * 2; - break; - } - if (nextTextSize.scrollWidth.toFixed(0) === nextTextSize.w.toFixed(0)) { - break; - } - } while (iterations++ < 50); - return { - labelHeight, - labelWidth, - fontSizeAdjustment - }; -} -var labelSizesForNote = new WeakCache(); -function getLabelSize(editor, shape) { - return labelSizesForNote.get(shape, () => getNoteLabelSize(editor, shape)); -} -function useNoteKeydownHandler(id) { - const editor = useEditor(); - const translation = useCurrentTranslation(); - return (0, import_react60.useCallback)((e) => { - const shape = editor.getShape(id); - if (!shape) - return; - const isTab = e.key === "Tab"; - const isCmdEnter = (e.metaKey || e.ctrlKey) && e.key === "Enter"; - if (isTab || isCmdEnter) { - e.preventDefault(); - const pageTransform = editor.getShapePageTransform(id); - const pageRotation = pageTransform.rotation(); - const isRTL2 = !!(translation.dir === "rtl" || isRightToLeftLanguage(shape.props.text)); - const offsetLength = (NOTE_SIZE + editor.options.adjacentShapeMargin + (isCmdEnter && !e.shiftKey ? shape.props.growY : 0)) * shape.props.scale; - const adjacentCenter = new Vec(isTab ? e.shiftKey != isRTL2 ? -1 : 1 : 0, isCmdEnter ? e.shiftKey ? -1 : 1 : 0).mul(offsetLength).add(NOTE_CENTER_OFFSET.clone().mul(shape.props.scale)).rot(pageRotation).add(pageTransform.point()); - const newNote = getNoteShapeForAdjacentPosition(editor, shape, adjacentCenter, pageRotation); - if (newNote) { - editor.mark("editing adjacent shape"); - startEditingShapeWithLabel(editor, newNote, true); - } - } - }, [id, editor, translation.dir]); -} -function getNoteHeight(shape) { - return (NOTE_SIZE + shape.props.growY) * shape.props.scale; -} -function getNoteShadow(id, rotation, scale) { - const random = rng(id); - const lift = Math.abs(random()) + 0.5; - const oy = Math.cos(rotation); - const a = 5 * scale; - const b = 4 * scale; - const c = 6 * scale; - const d = 7 * scale; - return `0px ${a - lift}px ${a}px -${a}px rgba(15, 23, 31, .6), - 0px ${(b + lift * d) * Math.max(0, oy)}px ${c + lift * d}px -${b + lift * c}px rgba(15, 23, 31, ${(0.3 + lift * 0.1).toFixed(2)}), - 0px ${48 * scale}px ${10 * scale}px -${10 * scale}px inset rgba(15, 23, 44, ${((0.022 + random() * 5e-3) * ((1 + oy) / 2)).toFixed(2)})`; -} -function getBoundsForSVG(shape) { - return new Box(0, 0, NOTE_SIZE, NOTE_SIZE + shape.props.growY); -} - -// node_modules/tldraw/dist-esm/lib/shapes/text/TextShapeUtil.mjs -var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); -var import_react61 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/shapes/shared/resizeScaled.mjs -function resizeScaled(shape, { - initialBounds, - scaleX, - scaleY, - newPoint -}) { - const scaleDelta = Math.max(0.01, Math.min(Math.abs(scaleX), Math.abs(scaleY))); - const offset4 = new Vec(0, 0); - if (scaleX < 0) { - offset4.x = -(initialBounds.width * scaleDelta); - } - if (scaleY < 0) { - offset4.y = -(initialBounds.height * scaleDelta); - } - const { x, y } = Vec.Add(newPoint, offset4.rot(shape.rotation)); - return { - x, - y, - props: { - scale: scaleDelta * shape.props.scale - } - }; -} - -// node_modules/tldraw/dist-esm/lib/shapes/text/TextShapeUtil.mjs -var sizeCache = new WeakCache(); -var TextShapeUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canEdit", () => true); - __publicField(this, "isAspectRatioLocked", () => true); - __publicField(this, "onResize", (shape, info2) => { - const { newPoint, initialBounds, initialShape, scaleX, handle } = info2; - if (info2.mode === "scale_shape" || handle !== "right" && handle !== "left") { - return { - id: shape.id, - type: shape.type, - ...resizeScaled(shape, info2) - }; - } else { - const nextWidth = Math.max(1, Math.abs(initialBounds.width * scaleX)); - const { x, y } = scaleX < 0 ? Vec.Sub(newPoint, Vec.FromAngle(shape.rotation).mul(nextWidth)) : newPoint; - return { - id: shape.id, - type: shape.type, - x, - y, - props: { - w: nextWidth / initialShape.props.scale, - autoSize: false - } - }; - } - }); - __publicField(this, "onEditEnd", (shape) => { - const { - id, - type, - props: { text } - } = shape; - const trimmedText = shape.props.text.trimEnd(); - if (trimmedText.length === 0) { - this.editor.deleteShapes([shape.id]); - } else { - if (trimmedText !== shape.props.text) { - this.editor.updateShapes([ - { - id, - type, - props: { - text: text.trimEnd() - } - } - ]); - } - } - }); - __publicField(this, "onBeforeUpdate", (prev, next) => { - if (!next.props.autoSize) - return; - const styleDidChange = prev.props.size !== next.props.size || prev.props.textAlign !== next.props.textAlign || prev.props.font !== next.props.font || prev.props.scale !== 1 && next.props.scale === 1; - const textDidChange = prev.props.text !== next.props.text; - if (!styleDidChange && !textDidChange) - return; - const boundsA = this.getMinDimensions(prev); - const boundsB = getTextSize(this.editor, next.props); - const wA = boundsA.width * prev.props.scale; - const hA = boundsA.height * prev.props.scale; - const wB = boundsB.width * next.props.scale; - const hB = boundsB.height * next.props.scale; - let delta; - switch (next.props.textAlign) { - case "middle": { - delta = new Vec((wB - wA) / 2, textDidChange ? 0 : (hB - hA) / 2); - break; - } - case "end": { - delta = new Vec(wB - wA, textDidChange ? 0 : (hB - hA) / 2); - break; - } - default: { - if (textDidChange) - break; - delta = new Vec(0, (hB - hA) / 2); - break; - } - } - if (delta) { - delta.rot(next.rotation); - const { x, y } = next; - return { - ...next, - x: x - delta.x, - y: y - delta.y, - props: { ...next.props, w: wB } - }; - } else { - return { - ...next, - props: { ...next.props, w: wB } - }; - } - }); - } - getDefaultProps() { - return { - color: "black", - size: "m", - w: 8, - text: "", - font: "draw", - textAlign: "start", - autoSize: true, - scale: 1 - }; - } - getMinDimensions(shape) { - return sizeCache.get(shape.props, (props) => getTextSize(this.editor, props)); - } - getGeometry(shape) { - const { scale } = shape.props; - const { width, height } = this.getMinDimensions(shape); - return new Rectangle2d({ - width: width * scale, - height: height * scale, - isFilled: true, - isLabel: true - }); - } - component(shape) { - const { - id, - props: { font, size: size4, text, color, scale, textAlign } - } = shape; - const { width, height } = this.getMinDimensions(shape); - const isSelected = shape.id === this.editor.getOnlySelectedShapeId(); - const theme = useDefaultColorTheme(); - const handleKeyDown = useTextShapeKeydownHandler(id); - return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(TextLabel, { - id, - classNamePrefix: "tl-text-shape", - type: "text", - font, - fontSize: FONT_SIZES[size4], - lineHeight: TEXT_PROPS.lineHeight, - align: textAlign, - verticalAlign: "middle", - text, - labelColor: theme[color].solid, - isSelected, - textWidth: width, - textHeight: height, - style: { - transform: `scale(${scale})`, - transformOrigin: "top left" - }, - wrap: true, - onKeyDown: handleKeyDown - }); - } - indicator(shape) { - const bounds = this.editor.getShapeGeometry(shape).bounds; - const editor = useEditor(); - if (shape.props.autoSize && editor.getEditingShapeId() === shape.id) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("rect", { width: toDomPrecision(bounds.width), height: toDomPrecision(bounds.height) }); - } - toSvg(shape, ctx) { - if (shape.props.text) - ctx.addExportDef(getFontDefForExport(shape.props.font)); - const bounds = this.editor.getShapeGeometry(shape).bounds; - const width = bounds.width / (shape.props.scale ?? 1); - const height = bounds.height / (shape.props.scale ?? 1); - const theme = getDefaultColorTheme(ctx); - return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(SvgTextLabel, { - fontSize: FONT_SIZES[shape.props.size], - font: shape.props.font, - align: shape.props.textAlign, - verticalAlign: "middle", - text: shape.props.text, - labelColor: theme[shape.props.color].solid, - bounds: new Box(0, 0, width, height), - padding: 0 - }); - } -}; -__publicField(TextShapeUtil, "type", "text"); -__publicField(TextShapeUtil, "props", textShapeProps); -__publicField(TextShapeUtil, "migrations", textShapeMigrations); -function getTextSize(editor, props) { - const { font, text, autoSize, size: size4, w } = props; - const minWidth = autoSize ? 16 : Math.max(16, w); - const fontSize = FONT_SIZES[size4]; - const cw = autoSize ? null : Math.floor(Math.max(minWidth, w)); - const result = editor.textMeasure.measureText(text, { - ...TEXT_PROPS, - fontFamily: FONT_FAMILIES[font], - fontSize, - maxWidth: cw - }); - if (autoSize) { - result.w += 1; - } - return { - width: Math.max(minWidth, result.w), - height: Math.max(fontSize, result.h) - }; -} -function useTextShapeKeydownHandler(id) { - const editor = useEditor(); - return (0, import_react61.useCallback)((e) => { - if (editor.getEditingShapeId() !== id) - return; - switch (e.key) { - case "Enter": { - if (e.ctrlKey || e.metaKey) { - editor.complete(); - } - break; - } - case "Tab": { - preventDefault(e); - if (e.shiftKey) { - TextHelpers.unindent(e.currentTarget); - } else { - TextHelpers.indent(e.currentTarget); - } - break; - } - } - }, [editor, id]); -} - -// node_modules/tldraw/dist-esm/lib/shapes/video/VideoShapeUtil.mjs -var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); -var import_react62 = __toESM(require_react(), 1); -var VideoShapeUtil = class extends BaseBoxShapeUtil { - constructor() { - super(...arguments); - __publicField(this, "canEdit", () => true); - __publicField(this, "isAspectRatioLocked", () => true); - } - getDefaultProps() { - return { - w: 100, - h: 100, - assetId: null, - time: 0, - playing: true, - url: "" - }; - } - component(shape) { - const { editor } = this; - const showControls = editor.getShapeGeometry(shape).bounds.w * editor.getZoomLevel() >= 110; - const { asset, url } = useAsset(shape.id, shape.props.assetId, shape.props.w); - const { time: time2, playing } = shape.props; - const isEditing = useIsEditing(shape.id); - const prefersReducedMotion = usePrefersReducedMotion(); - const rVideo = (0, import_react62.useRef)(null); - const handlePlay = (0, import_react62.useCallback)((e) => { - const video = e.currentTarget; - if (!video) - return; - editor.updateShapes([ - { - type: "video", - id: shape.id, - props: { - playing: true, - time: video.currentTime - } - } - ]); - }, [shape.id, editor]); - const handlePause = (0, import_react62.useCallback)((e) => { - const video = e.currentTarget; - if (!video) - return; - editor.updateShapes([ - { - type: "video", - id: shape.id, - props: { - playing: false, - time: video.currentTime - } - } - ]); - }, [shape.id, editor]); - const handleSetCurrentTime = (0, import_react62.useCallback)((e) => { - const video = e.currentTarget; - if (!video) - return; - if (isEditing) { - editor.updateShapes([ - { - type: "video", - id: shape.id, - props: { - time: video.currentTime - } - } - ]); - } - }, [isEditing, shape.id, editor]); - const [isLoaded, setIsLoaded] = (0, import_react62.useState)(false); - const handleLoadedData = (0, import_react62.useCallback)((e) => { - const video = e.currentTarget; - if (!video) - return; - if (time2 !== video.currentTime) { - video.currentTime = time2; - } - if (!playing) { - video.pause(); - } - setIsLoaded(true); - }, [playing, time2]); - (0, import_react62.useEffect)(() => { - const video = rVideo.current; - if (!video) - return; - if (isLoaded && !isEditing && time2 !== video.currentTime) { - video.currentTime = time2; - } - if (isEditing) { - if (document.activeElement !== video) { - video.focus(); - } - } - }, [isEditing, isLoaded, time2]); - (0, import_react62.useEffect)(() => { - if (prefersReducedMotion) { - const video = rVideo.current; - if (!video) - return; - video.pause(); - video.currentTime = 0; - } - }, [rVideo, prefersReducedMotion]); - return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(HTMLContainer, { - id: shape.id, - style: { - color: "var(--color-text-3)", - backgroundColor: asset ? "transparent" : "var(--color-low)", - border: asset ? "none" : "1px solid var(--color-low-border)" - }, - children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "tl-counter-scaled", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "tl-video-container", children: !asset?.props.src ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BrokenAssetIcon, {}) : url ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("video", { - ref: rVideo, - style: isEditing ? { pointerEvents: "all" } : void 0, - className: `tl-video tl-video-shape-${shape.id.split(":")[1]}`, - width: "100%", - height: "100%", - draggable: false, - playsInline: true, - autoPlay: true, - muted: true, - loop: true, - disableRemotePlayback: true, - disablePictureInPicture: true, - controls: isEditing && showControls, - onPlay: handlePlay, - onPause: handlePause, - onTimeUpdate: handleSetCurrentTime, - onLoadedData: handleLoadedData, - hidden: !isLoaded, - children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("source", { src: url }) - }) : null }) }) - }), - "url" in shape.props && shape.props.url && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(HyperlinkButton, { url: shape.props.url, zoomLevel: editor.getZoomLevel() }) - ] }); - } - indicator(shape) { - return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("rect", { width: toDomPrecision(shape.props.w), height: toDomPrecision(shape.props.h) }); - } - toSvg(shape) { - return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("image", { href: serializeVideo(shape.id), width: shape.props.w, height: shape.props.h }); - } -}; -__publicField(VideoShapeUtil, "type", "video"); -__publicField(VideoShapeUtil, "props", videoShapeProps); -__publicField(VideoShapeUtil, "migrations", videoShapeMigrations); -function serializeVideo(id) { - const splitId = id.split(":")[1]; - const video = document.querySelector(`.tl-video-shape-${splitId}`); - if (video) { - const canvas = document.createElement("canvas"); - canvas.width = video.videoWidth; - canvas.height = video.videoHeight; - canvas.getContext("2d").drawImage(video, 0, 0); - return canvas.toDataURL("image/png"); - } else - throw new Error("Video with not found when attempting serialization."); -} - -// node_modules/tldraw/dist-esm/lib/defaultShapeUtils.mjs -var defaultShapeUtils = [ - TextShapeUtil, - BookmarkShapeUtil, - DrawShapeUtil, - GeoShapeUtil, - NoteShapeUtil, - LineShapeUtil, - FrameShapeUtil, - ArrowShapeUtil, - HighlightShapeUtil, - EmbedShapeUtil, - ImageShapeUtil, - VideoShapeUtil -]; - -// node_modules/tldraw/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs -var Erasing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "scribbleId", "id"); - __publicField(this, "markId", ""); - __publicField(this, "excludedShapeIds", /* @__PURE__ */ new Set()); - __publicField(this, "onEnter", (info2) => { - this.markId = "erase scribble begin"; - this.editor.mark(this.markId); - this.info = info2; - const { originPagePoint } = this.editor.inputs; - this.excludedShapeIds = new Set(this.editor.getCurrentPageShapes().filter((shape) => { - if (this.editor.isShapeOrAncestorLocked(shape)) - return true; - if (this.editor.isShapeOfType(shape, "group") || this.editor.isShapeOfType(shape, "frame")) { - const pointInShapeShape = this.editor.getPointInShapeSpace(shape, originPagePoint); - const geometry = this.editor.getShapeGeometry(shape); - return geometry.bounds.containsPoint(pointInShapeShape); - } - return false; - }).map((shape) => shape.id)); - const scribble = this.editor.scribbles.addScribble({ - color: "muted-1", - size: 12 - }); - this.scribbleId = scribble.id; - this.update(); - }); - __publicField(this, "pushPointToScribble", () => { - const { x, y } = this.editor.inputs.currentPagePoint; - this.editor.scribbles.addPoint(this.scribbleId, x, y); - }); - __publicField(this, "onExit", () => { - this.editor.scribbles.stop(this.scribbleId); - }); - __publicField(this, "onPointerMove", () => { - this.update(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - } - update() { - const { editor, excludedShapeIds } = this; - const erasingShapeIds = editor.getErasingShapeIds(); - const zoomLevel = editor.getZoomLevel(); - const currentPageShapes = editor.getCurrentPageShapes(); - const { - inputs: { currentPagePoint, previousPagePoint } - } = editor; - this.pushPointToScribble(); - const erasing = new Set(erasingShapeIds); - const minDist = this.editor.options.hitTestMargin / zoomLevel; - for (const shape of currentPageShapes) { - if (editor.isShapeOfType(shape, "group")) - continue; - const pageMask = editor.getShapeMask(shape.id); - if (pageMask && !pointInPolygon(currentPagePoint, pageMask)) { - continue; - } - const geometry = editor.getShapeGeometry(shape); - const pageTransform = editor.getShapePageTransform(shape); - if (!geometry || !pageTransform) - continue; - const pt = pageTransform.clone().invert(); - const A = pt.applyToPoint(previousPagePoint); - const B = pt.applyToPoint(currentPagePoint); - const { bounds } = geometry; - if (bounds.minX - minDist > Math.max(A.x, B.x) || bounds.minY - minDist > Math.max(A.y, B.y) || bounds.maxX + minDist < Math.min(A.x, B.x) || bounds.maxY + minDist < Math.min(A.y, B.y)) { - continue; - } - if (geometry.hitTestLineSegment(A, B, minDist)) { - erasing.add(editor.getOutermostSelectableShape(shape).id); - } - } - this.editor.setErasingShapes([...erasing].filter((id) => !excludedShapeIds.has(id))); - } - complete() { - const { editor } = this; - editor.deleteShapes(editor.getCurrentPageState().erasingShapeIds); - editor.setErasingShapes([]); - this.parent.transition("idle"); - } - cancel() { - const { editor } = this; - editor.setErasingShapes([]); - editor.bailToMark(this.markId); - this.parent.transition("idle", this.info); - } -}; -__publicField(Erasing, "id", "erasing"); - -// node_modules/tldraw/dist-esm/lib/tools/EraserTool/childStates/Idle.mjs -var Idle8 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle8, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs -var Pointing7 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - const zoomLevel = this.editor.getZoomLevel(); - const currentPageShapesSorted = this.editor.getCurrentPageShapesSorted(); - const { - inputs: { currentPagePoint } - } = this.editor; - const erasing = /* @__PURE__ */ new Set(); - const initialSize = erasing.size; - for (let n = currentPageShapesSorted.length, i = n - 1; i >= 0; i--) { - const shape = currentPageShapesSorted[i]; - if (this.editor.isShapeOrAncestorLocked(shape) || this.editor.isShapeOfType(shape, "group")) { - continue; - } - if (this.editor.isPointInShape(shape, currentPagePoint, { - hitInside: false, - margin: this.editor.options.hitTestMargin / zoomLevel - })) { - const hitShape = this.editor.getOutermostSelectableShape(shape); - if (this.editor.isShapeOfType(hitShape, "frame") && erasing.size > initialSize) { - break; - } - erasing.add(hitShape.id); - } - } - this.editor.setErasingShapes([...erasing]); - }); - __publicField(this, "onLongPress", (info2) => { - this.startErasing(info2); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - this.startErasing(info2); - } - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - startErasing(info2) { - this.parent.transition("erasing", info2); - } - complete() { - const erasingShapeIds = this.editor.getErasingShapeIds(); - if (erasingShapeIds.length) { - this.editor.mark("erase end"); - this.editor.deleteShapes(erasingShapeIds); - } - this.editor.setErasingShapes([]); - this.parent.transition("idle"); - } - cancel() { - this.editor.setErasingShapes([]); - this.parent.transition("idle"); - } -}; -__publicField(Pointing7, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/tools/EraserTool/EraserTool.mjs -var EraserTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - } -}; -__publicField(EraserTool, "id", "eraser"); -__publicField(EraserTool, "initial", "idle"); -__publicField(EraserTool, "isLockable", false); -__publicField(EraserTool, "children", () => [Idle8, Pointing7, Erasing]); - -// node_modules/tldraw/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs -var Dragging = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "initialCamera", new Vec()); - __publicField(this, "onEnter", () => { - this.initialCamera = Vec.From(this.editor.getCamera()); - this.update(); - }); - __publicField(this, "onPointerMove", () => { - this.update(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.parent.transition("idle"); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - } - update() { - const { initialCamera, editor } = this; - const { currentScreenPoint, originScreenPoint } = editor.inputs; - const delta = Vec.Sub(currentScreenPoint, originScreenPoint).div(editor.getZoomLevel()); - if (delta.len2() === 0) - return; - editor.setCamera(initialCamera.clone().add(delta)); - } - complete() { - const { editor } = this; - const { pointerVelocity } = editor.inputs; - const velocityAtPointerUp = Math.min(pointerVelocity.len(), 2); - if (velocityAtPointerUp > 0.1) { - this.editor.slideCamera({ speed: velocityAtPointerUp, direction: pointerVelocity }); - } - this.parent.transition("idle"); - } -}; -__publicField(Dragging, "id", "dragging"); - -// node_modules/tldraw/dist-esm/lib/tools/HandTool/childStates/Idle.mjs -var Idle9 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "grab", rotation: 0 }); - }); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("pointing", info2); - }); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select"); - }); - } -}; -__publicField(Idle9, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs -var Pointing8 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - this.editor.stopCameraAnimation(); - this.editor.setCursor({ type: "grabbing", rotation: 0 }); - }); - __publicField(this, "onLongPress", () => { - this.startDragging(); - }); - __publicField(this, "onPointerMove", () => { - if (this.editor.inputs.isDragging) { - this.startDragging(); - } - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.complete(); - }); - } - startDragging() { - this.parent.transition("dragging"); - } - complete() { - this.parent.transition("idle"); - } -}; -__publicField(Pointing8, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/tools/HandTool/HandTool.mjs -var HandTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onDoubleClick", (info2) => { - if (info2.phase === "settle") { - const { currentScreenPoint } = this.editor.inputs; - this.editor.zoomIn(currentScreenPoint, { - animation: { duration: 220, easing: EASINGS.easeOutQuint } - }); - } - }); - __publicField(this, "onTripleClick", (info2) => { - if (info2.phase === "settle") { - const { currentScreenPoint } = this.editor.inputs; - this.editor.zoomOut(currentScreenPoint, { - animation: { duration: 320, easing: EASINGS.easeOutQuint } - }); - } - }); - __publicField(this, "onQuadrupleClick", (info2) => { - if (info2.phase === "settle") { - const zoomLevel = this.editor.getZoomLevel(); - const { - inputs: { currentScreenPoint } - } = this.editor; - if (zoomLevel === 1) { - this.editor.zoomToFit({ animation: { duration: 400, easing: EASINGS.easeOutQuint } }); - } else { - this.editor.resetZoom(currentScreenPoint, { - animation: { duration: 320, easing: EASINGS.easeOutQuint } - }); - } - } - }); - } -}; -__publicField(HandTool, "id", "hand"); -__publicField(HandTool, "initial", "idle"); -__publicField(HandTool, "isLockable", false); -__publicField(HandTool, "children", () => [Idle9, Pointing8, Dragging]); - -// node_modules/tldraw/dist-esm/lib/tools/LaserTool/childStates/Idle.mjs -var Idle10 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onPointerDown", (info2) => { - this.parent.transition("lasering", info2); - }); - } -}; -__publicField(Idle10, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs -var Lasering = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "scribbleId", "id"); - __publicField(this, "onEnter", () => { - const scribble = this.editor.scribbles.addScribble({ - color: "laser", - opacity: 0.7, - size: 4, - delay: 1200, - shrink: 0.05, - taper: true - }); - this.scribbleId = scribble.id; - this.pushPointToScribble(); - }); - __publicField(this, "onExit", () => { - this.editor.scribbles.stop(this.scribbleId); - }); - __publicField(this, "onPointerMove", () => { - this.pushPointToScribble(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "pushPointToScribble", () => { - const { x, y } = this.editor.inputs.currentPagePoint; - this.editor.scribbles.addPoint(this.scribbleId, x, y); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - } - complete() { - this.parent.transition("idle"); - } - cancel() { - this.parent.transition("idle"); - } -}; -__publicField(Lasering, "id", "lasering"); - -// node_modules/tldraw/dist-esm/lib/tools/LaserTool/LaserTool.mjs -var LaserTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "cross", rotation: 0 }); - }); - } -}; -__publicField(LaserTool, "id", "laser"); -__publicField(LaserTool, "initial", "idle"); -__publicField(LaserTool, "children", () => [Idle10, Lasering]); -__publicField(LaserTool, "isLockable", false); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs -var Brushing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "initialSelectedShapeIds", []); - __publicField(this, "excludedShapeIds", /* @__PURE__ */ new Set()); - __publicField(this, "isWrapMode", false); - __publicField(this, "initialStartShape", null); - __publicField(this, "onEnter", (info2) => { - const { altKey: altKey2, currentPagePoint } = this.editor.inputs; - this.isWrapMode = this.editor.user.getIsWrapMode(); - if (altKey2) { - this.parent.transition("scribble_brushing", info2); - return; - } - this.excludedShapeIds = new Set(this.editor.getCurrentPageShapes().filter((shape) => this.editor.isShapeOfType(shape, "group") || this.editor.isShapeOrAncestorLocked(shape)).map((shape) => shape.id)); - this.info = info2; - this.initialSelectedShapeIds = this.editor.getSelectedShapeIds().slice(); - this.initialStartShape = this.editor.getShapesAtPoint(currentPagePoint)[0]; - this.hitTestShapes(); - }); - __publicField(this, "onExit", () => { - this.initialSelectedShapeIds = []; - this.editor.updateInstanceState({ brush: null }); - }); - __publicField(this, "onTick", ({ elapsed }) => { - const { editor } = this; - editor.edgeScrollManager.updateEdgeScrolling(elapsed); - }); - __publicField(this, "onPointerMove", () => { - this.hitTestShapes(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", (info2) => { - this.editor.setSelectedShapes(this.initialSelectedShapeIds); - this.parent.transition("idle", info2); - }); - __publicField(this, "onKeyDown", (info2) => { - if (this.editor.inputs.altKey) { - this.parent.transition("scribble_brushing", info2); - } else { - this.hitTestShapes(); - } - }); - __publicField(this, "onKeyUp", () => { - this.hitTestShapes(); - }); - __publicField(this, "onInterrupt", () => { - this.editor.updateInstanceState({ brush: null }); - }); - } - complete() { - this.hitTestShapes(); - this.parent.transition("idle"); - } - hitTestShapes() { - const { editor, excludedShapeIds, isWrapMode } = this; - const { - inputs: { originPagePoint, currentPagePoint, shiftKey, ctrlKey } - } = editor; - const results = new Set(shiftKey ? this.initialSelectedShapeIds : []); - const isWrapping = isWrapMode ? !ctrlKey : ctrlKey; - const brush = Box.FromPoints([originPagePoint, currentPagePoint]); - const { corners } = brush; - let A, B, shape, pageBounds, pageTransform, localCorners; - const currentPageShapes = editor.getCurrentPageShapes(); - const currentPageId = editor.getCurrentPageId(); - testAllShapes: - for (let i = 0, n = currentPageShapes.length; i < n; i++) { - shape = currentPageShapes[i]; - if (excludedShapeIds.has(shape.id) || results.has(shape.id)) - continue testAllShapes; - pageBounds = editor.getShapePageBounds(shape); - if (!pageBounds) - continue testAllShapes; - if (brush.contains(pageBounds)) { - this.handleHit(shape, currentPagePoint, currentPageId, results, corners); - continue testAllShapes; - } - if (isWrapping || editor.isShapeOfType(shape, "frame")) { - continue testAllShapes; - } - if (brush.collides(pageBounds)) { - pageTransform = editor.getShapePageTransform(shape); - if (!pageTransform) - continue testAllShapes; - localCorners = pageTransform.clone().invert().applyToPoints(corners); - const geometry = editor.getShapeGeometry(shape); - hitTestBrushEdges: - for (let i2 = 0; i2 < 4; i2++) { - A = localCorners[i2]; - B = localCorners[(i2 + 1) % 4]; - if (geometry.hitTestLineSegment(A, B, 0)) { - this.handleHit(shape, currentPagePoint, currentPageId, results, corners); - break hitTestBrushEdges; - } - } - } - } - editor.getInstanceState().isCoarsePointer; - const currentBrush = editor.getInstanceState().brush; - if (!currentBrush || !brush.equals(currentBrush)) { - editor.updateInstanceState({ brush: { ...brush.toJson() } }); - } - const current = editor.getSelectedShapeIds(); - if (current.length !== results.size || current.some((id) => !results.has(id))) { - editor.setSelectedShapes(Array.from(results)); - } - } - handleHit(shape, currentPagePoint, currentPageId, results, corners) { - if (shape.parentId === currentPageId) { - results.add(shape.id); - return; - } - const selectedShape = this.editor.getOutermostSelectableShape(shape); - const pageMask = this.editor.getShapeMask(selectedShape.id); - if (pageMask && !polygonsIntersect(pageMask, corners) && !pointInPolygon(currentPagePoint, pageMask)) { - return; - } - results.add(selectedShape.id); - } -}; -__publicField(Brushing, "id", "brushing"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs -var CursorTypeMap = { - bottom: "ns-resize", - top: "ns-resize", - left: "ew-resize", - right: "ew-resize", - bottom_left: "nesw-resize", - bottom_right: "nwse-resize", - top_left: "nwse-resize", - top_right: "nesw-resize", - bottom_left_rotate: "swne-rotate", - bottom_right_rotate: "senw-rotate", - top_left_rotate: "nwse-rotate", - top_right_rotate: "nesw-rotate", - mobile_rotate: "grabbing" -}; -var PointingResizeHandle = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.updateCursor(); - }); - __publicField(this, "onPointerMove", () => { - if (this.editor.inputs.isDragging) { - this.startResizing(); - } - }); - __publicField(this, "onLongPress", () => { - this.startResizing(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - updateCursor() { - const selected = this.editor.getSelectedShapes(); - const cursorType = CursorTypeMap[this.info.handle]; - this.editor.setCursor({ - type: cursorType, - rotation: selected.length === 1 ? this.editor.getSelectionRotation() : 0 - }); - } - startResizing() { - if (this.editor.getInstanceState().isReadonly) - return; - this.parent.transition("resizing", this.info); - } - complete() { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } - cancel() { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } -}; -__publicField(PointingResizeHandle, "id", "pointing_resize_handle"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/crop-constants.mjs -var MIN_CROP_SIZE = 8; - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs -var Cropping = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "markId", ""); - __publicField(this, "snapshot", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.markId = "cropping"; - this.editor.mark(this.markId); - this.snapshot = this.createSnapshot(); - this.updateShapes(); - }); - __publicField(this, "onPointerMove", () => { - this.updateShapes(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "getDefaultCrop", () => ({ - topLeft: { x: 0, y: 0 }, - bottomRight: { x: 1, y: 1 } - })); - } - updateCursor() { - const selectedShape = this.editor.getSelectedShapes()[0]; - if (!selectedShape) - return; - const cursorType = CursorTypeMap[this.info.handle]; - this.editor.setCursor({ type: cursorType, rotation: this.editor.getSelectionRotation() }); - } - updateShapes() { - const { shape, cursorHandleOffset } = this.snapshot; - if (!shape) - return; - const util = this.editor.getShapeUtil("image"); - if (!util) - return; - const props = shape.props; - const currentPagePoint = this.editor.inputs.currentPagePoint.clone().sub(cursorHandleOffset); - const originPagePoint = this.editor.inputs.originPagePoint.clone().sub(cursorHandleOffset); - const change = currentPagePoint.clone().sub(originPagePoint).rot(-shape.rotation); - const crop = props.crop ?? this.getDefaultCrop(); - const newCrop = structuredClone(crop); - const newPoint = new Vec(shape.x, shape.y); - const pointDelta = new Vec(0, 0); - const w = 1 / (crop.bottomRight.x - crop.topLeft.x) * props.w; - const h = 1 / (crop.bottomRight.y - crop.topLeft.y) * props.h; - let hasCropChanged = false; - switch (this.info.handle) { - case "top": - case "top_left": - case "top_right": { - if (h < MIN_CROP_SIZE) - break; - hasCropChanged = true; - newCrop.topLeft.y = newCrop.topLeft.y + change.y / h; - const heightAfterCrop = h * (newCrop.bottomRight.y - newCrop.topLeft.y); - if (heightAfterCrop < MIN_CROP_SIZE) { - newCrop.topLeft.y = newCrop.bottomRight.y - MIN_CROP_SIZE / h; - pointDelta.y = (newCrop.topLeft.y - crop.topLeft.y) * h; - } else { - if (newCrop.topLeft.y <= 0) { - newCrop.topLeft.y = 0; - pointDelta.y = (newCrop.topLeft.y - crop.topLeft.y) * h; - } else { - pointDelta.y = change.y; - } - } - break; - } - case "bottom": - case "bottom_left": - case "bottom_right": { - if (h < MIN_CROP_SIZE) - break; - hasCropChanged = true; - newCrop.bottomRight.y = Math.min(1, newCrop.bottomRight.y + change.y / h); - const heightAfterCrop = h * (newCrop.bottomRight.y - newCrop.topLeft.y); - if (heightAfterCrop < MIN_CROP_SIZE) { - newCrop.bottomRight.y = newCrop.topLeft.y + MIN_CROP_SIZE / h; - } - break; - } - } - switch (this.info.handle) { - case "left": - case "top_left": - case "bottom_left": { - if (w < MIN_CROP_SIZE) - break; - hasCropChanged = true; - newCrop.topLeft.x = newCrop.topLeft.x + change.x / w; - const widthAfterCrop = w * (newCrop.bottomRight.x - newCrop.topLeft.x); - if (widthAfterCrop < MIN_CROP_SIZE) { - newCrop.topLeft.x = newCrop.bottomRight.x - MIN_CROP_SIZE / w; - pointDelta.x = (newCrop.topLeft.x - crop.topLeft.x) * w; - } else { - if (newCrop.topLeft.x <= 0) { - newCrop.topLeft.x = 0; - pointDelta.x = (newCrop.topLeft.x - crop.topLeft.x) * w; - } else { - pointDelta.x = change.x; - } - } - break; - } - case "right": - case "top_right": - case "bottom_right": { - if (w < MIN_CROP_SIZE) - break; - hasCropChanged = true; - newCrop.bottomRight.x = Math.min(1, newCrop.bottomRight.x + change.x / w); - const widthAfterCrop = w * (newCrop.bottomRight.x - newCrop.topLeft.x); - if (widthAfterCrop < MIN_CROP_SIZE) { - newCrop.bottomRight.x = newCrop.topLeft.x + MIN_CROP_SIZE / w; - } - break; - } - } - if (!hasCropChanged) - return; - newPoint.add(pointDelta.rot(shape.rotation)); - const partial = { - id: shape.id, - type: shape.type, - x: newPoint.x, - y: newPoint.y, - props: { - crop: newCrop, - w: (newCrop.bottomRight.x - newCrop.topLeft.x) * w, - h: (newCrop.bottomRight.y - newCrop.topLeft.y) * h - } - }; - this.editor.updateShapes([partial]); - this.updateCursor(); - } - complete() { - this.updateShapes(); - kickoutOccludedShapes(this.editor, [this.snapshot.shape.id]); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle"); - } - } - cancel() { - this.editor.bailToMark(this.markId); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle"); - } - } - createSnapshot() { - const selectionRotation = this.editor.getSelectionRotation(); - const { - inputs: { originPagePoint } - } = this.editor; - const shape = this.editor.getOnlySelectedShape(); - const selectionBounds = this.editor.getSelectionRotatedPageBounds(); - const dragHandlePoint = Vec.RotWith(selectionBounds.getHandlePoint(this.info.handle), selectionBounds.point, selectionRotation); - const cursorHandleOffset = Vec.Sub(originPagePoint, dragHandlePoint); - return { - shape, - cursorHandleOffset - }; - } -}; -__publicField(Cropping, "id", "cropping"); - -// node_modules/tldraw/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs -function getHitShapeOnCanvasPointerDown(editor, hitLabels = false) { - const zoomLevel = editor.getZoomLevel(); - const { - inputs: { currentPagePoint } - } = editor; - return editor.getShapeAtPoint(currentPagePoint, { - hitInside: false, - hitLabels, - margin: editor.options.hitTestMargin / zoomLevel, - renderingOnly: true - }) ?? editor.getSelectedShapeAtPoint(currentPagePoint); -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs -function getTranslateCroppedImageChange(editor, shape, delta) { - if (!shape) { - throw Error("Needs to translate a cropped shape!"); - } - const { crop: oldCrop } = shape.props; - if (!oldCrop) { - return; - } - const flatten = editor.inputs.shiftKey ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null; - if (flatten === "x") { - delta.x = 0; - } else if (flatten === "y") { - delta.y = 0; - } - delta.rot(-shape.rotation); - const w = 1 / (oldCrop.bottomRight.x - oldCrop.topLeft.x) * shape.props.w; - const h = 1 / (oldCrop.bottomRight.y - oldCrop.topLeft.y) * shape.props.h; - const yCrop = oldCrop.bottomRight.y - oldCrop.topLeft.y; - const xCrop = oldCrop.bottomRight.x - oldCrop.topLeft.x; - const newCrop = structuredClone(oldCrop); - newCrop.topLeft.x = Math.min(1 - xCrop, Math.max(0, newCrop.topLeft.x - delta.x / w)); - newCrop.topLeft.y = Math.min(1 - yCrop, Math.max(0, newCrop.topLeft.y - delta.y / h)); - newCrop.bottomRight.x = newCrop.topLeft.x + xCrop; - newCrop.bottomRight.y = newCrop.topLeft.y + yCrop; - const partial = { - id: shape.id, - type: shape.type, - props: { - crop: newCrop - } - }; - return partial; -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs -var Idle11 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - this.editor.setCursor({ type: "default", rotation: 0 }); - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape) { - this.editor.setCroppingShape(onlySelectedShape.id); - } - }); - __publicField(this, "onExit", () => { - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - __publicField(this, "onCancel", () => { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle", {}); - }); - __publicField(this, "onPointerDown", (info2) => { - if (this.editor.getIsMenuOpen()) - return; - if (info2.ctrlKey) { - this.cancel(); - this.editor.root.handleEvent(info2); - return; - } - switch (info2.target) { - case "canvas": { - const hitShape = getHitShapeOnCanvasPointerDown(this.editor); - if (hitShape && !this.editor.isShapeOfType(hitShape, "group")) { - this.onPointerDown({ - ...info2, - shape: hitShape, - target: "shape" - }); - return; - } - this.cancel(); - this.editor.root.handleEvent(info2); - break; - } - case "shape": { - if (info2.shape.id === this.editor.getCroppingShapeId()) { - this.editor.setCurrentTool("select.crop.pointing_crop", info2); - return; - } else { - if (this.editor.getShapeUtil(info2.shape)?.canCrop(info2.shape)) { - this.editor.setCroppingShape(info2.shape.id); - this.editor.setSelectedShapes([info2.shape.id]); - this.editor.setCurrentTool("select.crop.pointing_crop", info2); - } else { - this.cancel(); - this.editor.root.handleEvent(info2); - } - } - break; - } - case "selection": { - switch (info2.handle) { - case "mobile_rotate": - case "top_left_rotate": - case "top_right_rotate": - case "bottom_left_rotate": - case "bottom_right_rotate": { - this.editor.setCurrentTool("select.pointing_rotate_handle", { - ...info2, - onInteractionEnd: "select.crop.idle" - }); - break; - } - case "top": - case "right": - case "bottom": - case "left": - case "top_left": - case "top_right": - case "bottom_left": - case "bottom_right": { - this.editor.setCurrentTool("select.crop.pointing_crop_handle", { - ...info2, - onInteractionEnd: "select.crop.idle" - }); - break; - } - default: { - this.cancel(); - } - } - break; - } - } - }); - __publicField(this, "onDoubleClick", (info2) => { - if (this.editor.inputs.shiftKey || info2.phase !== "up") - return; - const croppingShapeId = this.editor.getCroppingShapeId(); - if (!croppingShapeId) - return; - const shape = this.editor.getShape(croppingShapeId); - if (!shape) - return; - const util = this.editor.getShapeUtil(shape); - if (!util) - return; - if (info2.target === "selection") { - util.onDoubleClickEdge?.(shape); - return; - } - this.cancel(); - this.editor.root.handleEvent(info2); - }); - __publicField(this, "onKeyDown", () => { - this.nudgeCroppingImage(false); - }); - __publicField(this, "onKeyRepeat", () => { - this.nudgeCroppingImage(true); - }); - __publicField(this, "onKeyUp", (info2) => { - switch (info2.code) { - case "Enter": { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle", {}); - break; - } - } - }); - } - cancel() { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle", {}); - } - nudgeCroppingImage(ephemeral = false) { - const { - editor: { - inputs: { keys } - } - } = this; - const shiftKey = keys.has("ShiftLeft"); - const delta = new Vec(0, 0); - if (keys.has("ArrowLeft")) - delta.x += 1; - if (keys.has("ArrowRight")) - delta.x -= 1; - if (keys.has("ArrowUp")) - delta.y += 1; - if (keys.has("ArrowDown")) - delta.y -= 1; - if (delta.equals(new Vec(0, 0))) - return; - if (shiftKey) - delta.mul(10); - const shape = this.editor.getShape(this.editor.getCroppingShapeId()); - if (!shape) - return; - const partial = getTranslateCroppedImageChange(this.editor, shape, delta); - if (partial) { - if (!ephemeral) { - this.editor.mark("translate crop"); - } - this.editor.updateShapes([partial]); - } - } -}; -__publicField(Idle11, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs -var PointingCrop = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onCancel", () => { - this.editor.setCurrentTool("select.crop.idle", {}); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - this.editor.setCurrentTool("select.crop.translating_crop", info2); - } - }); - __publicField(this, "onPointerUp", (info2) => { - this.editor.setCurrentTool("select.crop.idle", info2); - }); - } -}; -__publicField(PointingCrop, "id", "pointing_crop"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs -var PointingCropHandle = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - const selectedShape = this.editor.getSelectedShapes()[0]; - if (!selectedShape) - return; - const cursorType = CursorTypeMap[this.info.handle]; - this.editor.setCursor({ type: cursorType, rotation: this.editor.getSelectionRotation() }); - this.editor.setCroppingShape(selectedShape.id); - }); - __publicField(this, "onExit", () => { - this.editor.setCursor({ type: "default", rotation: 0 }); - this.parent.setCurrentToolIdMask(void 0); - }); - __publicField(this, "onPointerMove", () => { - if (this.editor.inputs.isDragging) { - this.startCropping(); - } - }); - __publicField(this, "onLongPress", () => { - this.startCropping(); - }); - __publicField(this, "onPointerUp", () => { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle"); - } - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - startCropping() { - if (this.editor.getInstanceState().isReadonly) - return; - this.parent.transition("cropping", { - ...this.info, - onInteractionEnd: this.info.onInteractionEnd - }); - } - cancel() { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.editor.setCroppingShape(null); - this.editor.setCurrentTool("select.idle"); - } - } -}; -__publicField(PointingCropHandle, "id", "pointing_crop_handle"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs -var TranslatingCrop = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "markId", "translating crop"); - __publicField(this, "snapshot", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.snapshot = this.createSnapshot(); - this.editor.mark(this.markId); - this.editor.setCursor({ type: "move", rotation: 0 }); - this.updateShapes(); - }); - __publicField(this, "onExit", () => { - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - __publicField(this, "onPointerMove", () => { - this.updateShapes(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onKeyDown", (info2) => { - switch (info2.key) { - case "Alt": - case "Shift": { - this.updateShapes(); - return; - } - } - }); - __publicField(this, "onKeyUp", (info2) => { - switch (info2.key) { - case "Enter": { - this.complete(); - return; - } - case "Alt": - case "Shift": { - this.updateShapes(); - } - } - }); - } - complete() { - this.updateShapes(); - this.editor.setCurrentTool("select.crop.idle", this.info); - } - cancel() { - this.editor.bailToMark(this.markId); - this.editor.setCurrentTool("select.crop.idle", this.info); - } - createSnapshot() { - const shape = this.editor.getOnlySelectedShape(); - return { shape }; - } - updateShapes() { - const shape = this.snapshot.shape; - if (!shape) - return; - const { originPagePoint, currentPagePoint } = this.editor.inputs; - const delta = currentPagePoint.clone().sub(originPagePoint); - const partial = getTranslateCroppedImageChange(this.editor, shape, delta); - if (partial) { - this.editor.updateShapes([partial]); - } - } -}; -__publicField(TranslatingCrop, "id", "translating_crop"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs -var Crop = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "markId", ""); - __publicField(this, "onEnter", () => { - this.didCancel = false; - this.markId = "crop"; - this.editor.mark(this.markId); - }); - __publicField(this, "didCancel", false); - __publicField(this, "onExit", () => { - if (this.didCancel) { - this.editor.bailToMark(this.markId); - } else { - this.editor.squashToMark(this.markId); - } - }); - __publicField(this, "onCancel", () => { - this.didCancel = true; - }); - } -}; -__publicField(Crop, "id", "crop"); -__publicField(Crop, "initial", "idle"); -__publicField(Crop, "children", () => [ - Idle11, - TranslatingCrop, - PointingCrop, - PointingCropHandle, - Cropping -]); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs -var DraggingHandle = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeId", ""); - __publicField(this, "initialHandle", {}); - __publicField(this, "initialAdjacentHandle", null); - __publicField(this, "initialPagePoint", {}); - __publicField(this, "markId", ""); - __publicField(this, "initialPageTransform"); - __publicField(this, "initialPageRotation"); - __publicField(this, "info", {}); - __publicField(this, "isPrecise", false); - __publicField(this, "isPreciseId", null); - __publicField(this, "pointingId", null); - __publicField(this, "onEnter", (info2) => { - const { shape, isCreating, handle } = info2; - this.info = info2; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.shapeId = shape.id; - this.markId = isCreating ? `creating:${shape.id}` : "dragging handle"; - if (!isCreating) - this.editor.mark(this.markId); - this.initialHandle = structuredClone(handle); - if (this.editor.isShapeOfType(shape, "line")) { - if (this.initialHandle.type === "create") { - this.editor.updateShape({ - ...shape, - props: { - points: { - ...shape.props.points, - [handle.index]: { id: handle.index, index: handle.index, x: handle.x, y: handle.y } - } - } - }); - const handlesAfter = this.editor.getShapeHandles(shape); - const handleAfter = handlesAfter.find((h) => h.index === handle.index); - this.initialHandle = structuredClone(handleAfter); - } - } - this.initialPageTransform = this.editor.getShapePageTransform(shape); - this.initialPageRotation = this.initialPageTransform.rotation(); - this.initialPagePoint = this.editor.inputs.originPagePoint.clone(); - this.editor.setCursor({ type: isCreating ? "cross" : "grabbing", rotation: 0 }); - const handles = this.editor.getShapeHandles(shape).sort(sortByIndex); - const index2 = handles.findIndex((h) => h.id === info2.handle.id); - this.initialAdjacentHandle = null; - for (let i = index2 + 1; i < handles.length; i++) { - const handle2 = handles[i]; - if (handle2.type === "vertex" && handle2.id !== "middle" && handle2.id !== info2.handle.id) { - this.initialAdjacentHandle = handle2; - break; - } - } - if (!this.initialAdjacentHandle) { - for (let i = handles.length - 1; i >= 0; i--) { - const handle2 = handles[i]; - if (handle2.type === "vertex" && handle2.id !== "middle" && handle2.id !== info2.handle.id) { - this.initialAdjacentHandle = handle2; - break; - } - } - } - if (this.editor.isShapeOfType(shape, "arrow")) { - const initialBinding = getArrowBindings(this.editor, shape)[info2.handle.id]; - this.isPrecise = false; - if (initialBinding) { - this.editor.setHintingShapes([initialBinding.toId]); - this.isPrecise = initialBinding.props.isPrecise; - if (this.isPrecise) { - this.isPreciseId = initialBinding.toId; - } else { - this.resetExactTimeout(); - } - } else { - this.editor.setHintingShapes([]); - } - } - this.update(); - this.editor.select(this.shapeId); - }); - __publicField(this, "exactTimeout", -1); - __publicField(this, "onPointerMove", () => { - this.update(); - }); - __publicField(this, "onKeyDown", () => { - this.update(); - }); - __publicField(this, "onKeyUp", () => { - this.update(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.update(); - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onExit", () => { - this.parent.setCurrentToolIdMask(void 0); - this.editor.setHintingShapes([]); - this.editor.snaps.clearIndicators(); - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - } - resetExactTimeout() { - if (this.exactTimeout !== -1) { - this.clearExactTimeout(); - } - this.exactTimeout = this.editor.timers.setTimeout(() => { - if (this.getIsActive() && !this.isPrecise) { - this.isPrecise = true; - this.isPreciseId = this.pointingId; - this.update(); - } - this.exactTimeout = -1; - }, 750); - } - clearExactTimeout() { - if (this.exactTimeout !== -1) { - clearTimeout(this.exactTimeout); - this.exactTimeout = -1; - } - } - complete() { - this.editor.snaps.clearIndicators(); - kickoutOccludedShapes(this.editor, [this.shapeId]); - const { onInteractionEnd } = this.info; - if (this.editor.getInstanceState().isToolLocked && onInteractionEnd) { - this.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId }); - return; - } - this.parent.transition("idle"); - } - cancel() { - this.editor.bailToMark(this.markId); - this.editor.snaps.clearIndicators(); - const { onInteractionEnd } = this.info; - if (onInteractionEnd) { - this.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId }); - return; - } - this.parent.transition("idle"); - } - update() { - const { editor, shapeId, initialPagePoint } = this; - const { initialHandle, initialPageRotation, initialAdjacentHandle } = this; - const hintingShapeIds = this.editor.getHintingShapeIds(); - const isSnapMode = this.editor.user.getIsSnapMode(); - const { - snaps, - inputs: { currentPagePoint, shiftKey, ctrlKey, altKey: altKey2, pointerVelocity } - } = editor; - const initial = this.info.shape; - const shape = editor.getShape(shapeId); - if (!shape) - return; - const util = editor.getShapeUtil(shape); - let point = currentPagePoint.clone().sub(initialPagePoint).rot(-initialPageRotation).add(initialHandle); - if (shiftKey && initialAdjacentHandle && initialHandle.id !== "middle") { - const angle = Vec.Angle(initialAdjacentHandle, point); - const snappedAngle = snapAngle(angle, 24); - const angleDifference = snappedAngle - angle; - point = Vec.RotWith(point, initialAdjacentHandle, angleDifference); - } - editor.snaps.clearIndicators(); - let nextHandle = { ...initialHandle, x: point.x, y: point.y }; - if (initialHandle.canSnap && (isSnapMode ? !ctrlKey : ctrlKey)) { - const pageTransform = editor.getShapePageTransform(shape.id); - if (!pageTransform) - throw Error("Expected a page transform"); - const snap = snaps.handles.snapHandle({ currentShapeId: shapeId, handle: nextHandle }); - if (snap) { - snap.nudge.rot(-editor.getShapeParentTransform(shape).rotation()); - point.add(snap.nudge); - nextHandle = { ...initialHandle, x: point.x, y: point.y }; - } - } - const changes = util.onHandleDrag?.(shape, { - handle: nextHandle, - isPrecise: this.isPrecise || altKey2, - initial - }); - const next = { id: shape.id, type: shape.type, ...changes }; - if (initialHandle.type === "vertex" && this.editor.isShapeOfType(shape, "arrow")) { - const bindingAfter = getArrowBindings(editor, shape)[initialHandle.id]; - if (bindingAfter) { - if (hintingShapeIds[0] !== bindingAfter.toId) { - editor.setHintingShapes([bindingAfter.toId]); - this.pointingId = bindingAfter.toId; - this.isPrecise = pointerVelocity.len() < 0.5 || altKey2; - this.isPreciseId = this.isPrecise ? bindingAfter.toId : null; - this.resetExactTimeout(); - } - } else { - if (hintingShapeIds.length > 0) { - editor.setHintingShapes([]); - this.pointingId = null; - this.isPrecise = false; - this.isPreciseId = null; - this.resetExactTimeout(); - } - } - } - if (changes) { - editor.updateShapes([next]); - } - } -}; -__publicField(DraggingHandle, "id", "dragging_handle"); - -// node_modules/tldraw/dist-esm/lib/utils/shapes/shapes.mjs -function getTextLabels(geometry) { - if (geometry.isLabel) { - return [geometry]; - } - if (geometry instanceof Group2d) { - return geometry.children.filter((child) => child.isLabel); - } - return []; -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs -var EditingShape = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "hitShapeForPointerUp", null); - __publicField(this, "onEnter", () => { - const editingShape = this.editor.getEditingShape(); - if (!editingShape) - throw Error("Entered editing state without an editing shape"); - this.hitShapeForPointerUp = null; - updateHoveredShapeId(this.editor); - this.editor.select(editingShape); - }); - __publicField(this, "onExit", () => { - const { editingShapeId } = this.editor.getCurrentPageState(); - if (!editingShapeId) - return; - this.editor.setEditingShape(null); - updateHoveredShapeId.cancel(); - const shape = this.editor.getShape(editingShapeId); - const util = this.editor.getShapeUtil(shape); - util.onEditEnd?.(shape); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.hitShapeForPointerUp && this.editor.inputs.isDragging) { - if (this.editor.getInstanceState().isReadonly) - return; - if (this.hitShapeForPointerUp.isLocked) - return; - this.editor.select(this.hitShapeForPointerUp); - this.parent.transition("translating", info2); - this.hitShapeForPointerUp = null; - return; - } - switch (info2.target) { - case "shape": - case "canvas": { - updateHoveredShapeId(this.editor); - return; - } - } - }); - __publicField(this, "onPointerDown", (info2) => { - this.hitShapeForPointerUp = null; - switch (info2.target) { - case "shape": { - const { shape: selectingShape } = info2; - const editingShape = this.editor.getEditingShape(); - if (!editingShape) { - throw Error("Expected an editing shape!"); - } - const geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape); - const textLabels = getTextLabels(geometry); - const textLabel = textLabels.length === 1 ? textLabels[0] : void 0; - const isEmptyTextShape = this.editor.isShapeOfType(editingShape, "text") && editingShape.props.text.trim() === ""; - if (textLabel && !isEmptyTextShape) { - const pointInShapeSpace = this.editor.getPointInShapeSpace(selectingShape, this.editor.inputs.currentPagePoint); - if (textLabel.bounds.containsPoint(pointInShapeSpace, 0) && textLabel.hitTestPoint(pointInShapeSpace)) { - if (selectingShape.id === editingShape.id) { - return; - } else { - this.hitShapeForPointerUp = selectingShape; - this.editor.mark("editing on pointer up"); - this.editor.select(selectingShape.id); - return; - } - } - } else { - if (selectingShape.id === editingShape.id) { - if (this.editor.isShapeOfType(selectingShape, "frame")) { - this.editor.setEditingShape(null); - this.parent.transition("idle", info2); - } - } else { - this.parent.transition("pointing_shape", info2); - return; - } - return; - } - break; - } - } - this.parent.transition("idle", info2); - this.editor.root.handleEvent(info2); - }); - __publicField(this, "onPointerUp", (info2) => { - const hitShape = this.hitShapeForPointerUp; - if (!hitShape) - return; - this.hitShapeForPointerUp = null; - const util = this.editor.getShapeUtil(hitShape); - if (hitShape.isLocked) - return; - if (this.editor.getInstanceState().isReadonly) { - if (!util.canEditInReadOnly(hitShape)) { - this.parent.transition("pointing_shape", info2); - return; - } - } - this.editor.select(hitShape.id); - this.editor.setEditingShape(hitShape.id); - updateHoveredShapeId(this.editor); - }); - __publicField(this, "onComplete", (info2) => { - this.parent.transition("idle", info2); - }); - __publicField(this, "onCancel", (info2) => { - this.parent.transition("idle", info2); - }); - } -}; -__publicField(EditingShape, "id", "editing_shape"); - -// node_modules/tldraw/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs -function getShouldEnterCropMode(editor) { - const onlySelectedShape = editor.getOnlySelectedShape(); - return !!(onlySelectedShape && !editor.isShapeOrAncestorLocked(onlySelectedShape) && editor.getShapeUtil(onlySelectedShape).canCrop(onlySelectedShape)); -} - -// node_modules/tldraw/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs -function selectOnCanvasPointerUp(editor) { - const selectedShapeIds = editor.getSelectedShapeIds(); - const { shiftKey, altKey: altKey2, currentPagePoint } = editor.inputs; - const hitShape = editor.getShapeAtPoint(currentPagePoint, { - hitInside: false, - margin: editor.options.hitTestMargin / editor.getZoomLevel(), - hitLabels: true, - renderingOnly: true, - filter: (shape) => !shape.isLocked - }); - if (hitShape) { - const outermostSelectableShape = editor.getOutermostSelectableShape(hitShape); - if (shiftKey && !altKey2) { - editor.cancelDoubleClick(); - if (selectedShapeIds.includes(outermostSelectableShape.id)) { - editor.mark("deselecting shape"); - editor.deselect(outermostSelectableShape); - } else { - editor.mark("shift selecting shape"); - editor.setSelectedShapes([...selectedShapeIds, outermostSelectableShape.id]); - } - } else { - let shapeToSelect = void 0; - if (outermostSelectableShape === hitShape) { - shapeToSelect = hitShape; - } else { - if (outermostSelectableShape.id === editor.getFocusedGroupId() || selectedShapeIds.includes(outermostSelectableShape.id)) { - shapeToSelect = hitShape; - } else { - shapeToSelect = outermostSelectableShape; - } - } - if (shapeToSelect && !selectedShapeIds.includes(shapeToSelect.id)) { - editor.mark("selecting shape"); - editor.select(shapeToSelect.id); - } - } - } else { - if (shiftKey) { - return; - } else { - if (selectedShapeIds.length > 0) { - editor.mark("selecting none"); - editor.selectNone(); - } - const focusedGroupId = editor.getFocusedGroupId(); - if (isShapeId(focusedGroupId)) { - const groupShape = editor.getShape(focusedGroupId); - if (!editor.isPointInShape(groupShape, currentPagePoint, { margin: 0, hitInside: true })) { - editor.setFocusedGroup(null); - } - } - } - } -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs -var SKIPPED_KEYS_FOR_AUTO_EDITING = [ - "Delete", - "Backspace", - "[", - "]", - "Enter", - " ", - "Shift", - "Tab" -]; -var Idle12 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - this.parent.setCurrentToolIdMask(void 0); - updateHoveredShapeId(this.editor); - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - __publicField(this, "onExit", () => { - updateHoveredShapeId.cancel(); - }); - __publicField(this, "onPointerMove", () => { - updateHoveredShapeId(this.editor); - }); - __publicField(this, "onPointerDown", (info2) => { - if (this.editor.getIsMenuOpen()) - return; - const shouldEnterCropMode = info2.ctrlKey && getShouldEnterCropMode(this.editor); - if (info2.ctrlKey && !shouldEnterCropMode) { - if (info2.target === "shape" && this.isDarwin && this.editor.inputs.keys.has("ControlLeft")) { - if (!this.editor.isShapeOrAncestorLocked(info2.shape)) { - this.parent.transition("pointing_shape", info2); - return; - } - } - this.parent.transition("brushing", info2); - return; - } - switch (info2.target) { - case "canvas": { - const hitShape = getHitShapeOnCanvasPointerDown(this.editor); - if (hitShape && !hitShape.isLocked) { - this.onPointerDown({ - ...info2, - shape: hitShape, - target: "shape" - }); - return; - } - const selectedShapeIds = this.editor.getSelectedShapeIds(); - const onlySelectedShape = this.editor.getOnlySelectedShape(); - const { - inputs: { currentPagePoint } - } = this.editor; - if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) { - if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) { - this.onPointerDown({ - ...info2, - target: "selection" - }); - return; - } - } - this.parent.transition("pointing_canvas", info2); - break; - } - case "shape": { - const { shape } = info2; - if (this.isOverArrowLabelTest(shape)) { - this.parent.transition("pointing_arrow_label", info2); - break; - } - if (this.editor.isShapeOrAncestorLocked(shape)) { - this.parent.transition("pointing_canvas", info2); - break; - } - this.parent.transition("pointing_shape", info2); - break; - } - case "handle": { - if (this.editor.getInstanceState().isReadonly) - break; - if (this.editor.inputs.altKey) { - this.parent.transition("pointing_shape", info2); - } else { - this.parent.transition("pointing_handle", info2); - } - break; - } - case "selection": { - switch (info2.handle) { - case "mobile_rotate": - case "top_left_rotate": - case "top_right_rotate": - case "bottom_left_rotate": - case "bottom_right_rotate": { - this.parent.transition("pointing_rotate_handle", info2); - break; - } - case "top": - case "right": - case "bottom": - case "left": - case "top_left": - case "top_right": - case "bottom_left": - case "bottom_right": { - if (shouldEnterCropMode) { - this.parent.transition("crop.pointing_crop_handle", info2); - } else { - this.parent.transition("pointing_resize_handle", info2); - } - break; - } - default: { - const hoveredShape = this.editor.getHoveredShape(); - if (hoveredShape && !this.editor.getSelectedShapeIds().includes(hoveredShape.id) && !hoveredShape.isLocked) { - this.onPointerDown({ - ...info2, - shape: hoveredShape, - target: "shape" - }); - return; - } - this.parent.transition("pointing_selection", info2); - } - } - break; - } - } - }); - __publicField(this, "onDoubleClick", (info2) => { - if (this.editor.inputs.shiftKey || info2.phase !== "up") - return; - switch (info2.target) { - case "canvas": { - const hoveredShape = this.editor.getHoveredShape(); - const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ?? this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, { - margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(), - hitInside: false - }); - const focusedGroupId = this.editor.getFocusedGroupId(); - if (hitShape) { - if (this.editor.isShapeOfType(hitShape, "group")) { - selectOnCanvasPointerUp(this.editor); - return; - } else { - const parent = this.editor.getShape(hitShape.parentId); - if (parent && this.editor.isShapeOfType(parent, "group")) { - if (focusedGroupId && parent.id === focusedGroupId) { - } else { - selectOnCanvasPointerUp(this.editor); - return; - } - } - } - this.onDoubleClick({ - ...info2, - shape: hitShape, - target: "shape" - }); - return; - } - if (!this.editor.inputs.shiftKey) { - this.handleDoubleClickOnCanvas(info2); - } - break; - } - case "selection": { - if (this.editor.getInstanceState().isReadonly) - break; - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape) { - const util = this.editor.getShapeUtil(onlySelectedShape); - if (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) { - return; - } - if (info2.handle === "right" || info2.handle === "left" || info2.handle === "top" || info2.handle === "bottom") { - const change = util.onDoubleClickEdge?.(onlySelectedShape); - if (change) { - this.editor.mark("double click edge"); - this.editor.updateShapes([change]); - kickoutOccludedShapes(this.editor, [onlySelectedShape.id]); - return; - } - } - if (util.canCrop(onlySelectedShape) && !this.editor.isShapeOrAncestorLocked(onlySelectedShape)) { - this.parent.transition("crop", info2); - return; - } - if (this.shouldStartEditingShape(onlySelectedShape)) { - this.startEditingShape(onlySelectedShape, info2, true); - } - } - break; - } - case "shape": { - const { shape } = info2; - const util = this.editor.getShapeUtil(shape); - if (shape.type !== "video" && shape.type !== "embed" && this.editor.getInstanceState().isReadonly) - break; - if (util.onDoubleClick) { - const change = util.onDoubleClick?.(shape); - if (change) { - this.editor.updateShapes([change]); - return; - } else if (util.canCrop(shape) && !this.editor.isShapeOrAncestorLocked(shape)) { - this.editor.mark("select and crop"); - this.editor.select(info2.shape?.id); - this.parent.transition("crop", info2); - return; - } - } - if (this.shouldStartEditingShape(shape)) { - this.startEditingShape(shape, info2, true); - } else { - this.handleDoubleClickOnCanvas(info2); - } - break; - } - case "handle": { - if (this.editor.getInstanceState().isReadonly) - break; - const { shape, handle } = info2; - const util = this.editor.getShapeUtil(shape); - const changes = util.onDoubleClickHandle?.(shape, handle); - if (changes) { - this.editor.updateShapes([changes]); - } else { - if (this.shouldStartEditingShape(shape)) { - this.startEditingShape(shape, info2, true); - } - } - } - } - }); - __publicField(this, "onRightClick", (info2) => { - switch (info2.target) { - case "canvas": { - const hoveredShape = this.editor.getHoveredShape(); - const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, { - margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(), - hitInside: false, - hitLabels: true, - hitLocked: true, - hitFrameInside: false, - renderingOnly: true - }); - if (hitShape) { - this.onRightClick({ - ...info2, - shape: hitShape, - target: "shape" - }); - return; - } - const selectedShapeIds = this.editor.getSelectedShapeIds(); - const onlySelectedShape = this.editor.getOnlySelectedShape(); - const { - inputs: { currentPagePoint } - } = this.editor; - if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) { - if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) { - this.onRightClick({ - ...info2, - target: "selection" - }); - return; - } - } - this.editor.selectNone(); - break; - } - case "shape": { - const { selectedShapeIds } = this.editor.getCurrentPageState(); - const { shape } = info2; - const targetShape = this.editor.getOutermostSelectableShape(shape, (parent) => !selectedShapeIds.includes(parent.id)); - if (!selectedShapeIds.includes(targetShape.id) && !this.editor.findShapeAncestor(targetShape, (shape2) => selectedShapeIds.includes(shape2.id))) { - this.editor.mark("selecting shape"); - this.editor.setSelectedShapes([targetShape.id]); - } - break; - } - } - }); - __publicField(this, "onCancel", () => { - if (this.editor.getFocusedGroupId() !== this.editor.getCurrentPageId() && this.editor.getSelectedShapeIds().length > 0) { - this.editor.popFocusedGroupId(); - } else { - this.editor.mark("clearing selection"); - this.editor.selectNone(); - } - }); - __publicField(this, "onKeyDown", (info2) => { - switch (info2.code) { - case "ArrowLeft": - case "ArrowRight": - case "ArrowUp": - case "ArrowDown": { - this.nudgeSelectedShapes(false); - return; - } - } - if (debugFlags["editOnType"].get()) { - if (!SKIPPED_KEYS_FOR_AUTO_EDITING.includes(info2.key) && !info2.altKey && !info2.ctrlKey) { - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape && this.editor.isShapeOfType(onlySelectedShape, "note") && this.shouldStartEditingShape(onlySelectedShape)) { - this.startEditingShape(onlySelectedShape, { - ...info2, - target: "shape", - shape: onlySelectedShape - }, true); - return; - } - } - } - }); - __publicField(this, "onKeyRepeat", (info2) => { - switch (info2.code) { - case "ArrowLeft": - case "ArrowRight": - case "ArrowUp": - case "ArrowDown": { - this.nudgeSelectedShapes(true); - break; - } - } - }); - __publicField(this, "onKeyUp", (info2) => { - switch (info2.code) { - case "Enter": { - const selectedShapes = this.editor.getSelectedShapes(); - if (selectedShapes.every((shape) => this.editor.isShapeOfType(shape, "group"))) { - this.editor.setSelectedShapes(selectedShapes.flatMap((shape) => this.editor.getSortedChildIdsForParent(shape.id))); - return; - } - const onlySelectedShape = this.editor.getOnlySelectedShape(); - if (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) { - this.startEditingShape(onlySelectedShape, { - ...info2, - target: "shape", - shape: onlySelectedShape - }, true); - return; - } - if (getShouldEnterCropMode(this.editor)) { - this.parent.transition("crop", info2); - } - break; - } - } - }); - __publicField(this, "isDarwin", window.navigator.userAgent.toLowerCase().indexOf("mac") > -1); - } - shouldStartEditingShape(shape = this.editor.getOnlySelectedShape()) { - if (!shape) - return false; - if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") - return false; - if (!this.canInteractWithShapeInReadOnly(shape)) - return false; - return this.editor.getShapeUtil(shape).canEdit(shape); - } - startEditingShape(shape, info2, shouldSelectAll) { - if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") - return; - this.editor.mark("editing shape"); - startEditingShapeWithLabel(this.editor, shape, shouldSelectAll); - this.parent.transition("editing_shape", info2); - } - isOverArrowLabelTest(shape) { - if (!shape) - return false; - const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint); - if (this.editor.isShapeOfType(shape, "arrow")) { - const labelGeometry = this.editor.getShapeGeometry(shape).children[1]; - if (labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)) { - return true; - } - } - return false; - } - handleDoubleClickOnCanvas(info2) { - if (this.editor.getInstanceState().isReadonly) - return; - this.editor.mark("creating text shape"); - const id = createShapeId(); - const { x, y } = this.editor.inputs.currentPagePoint; - this.editor.createShapes([ - { - id, - type: "text", - x, - y, - props: { - text: "", - autoSize: true - } - } - ]); - const shape = this.editor.getShape(id); - if (!shape) - return; - const util = this.editor.getShapeUtil(shape); - if (this.editor.getInstanceState().isReadonly) { - if (!util.canEditInReadOnly(shape)) { - return; - } - } - this.editor.setEditingShape(id); - this.editor.select(id); - this.parent.transition("editing_shape", info2); - } - nudgeSelectedShapes(ephemeral = false) { - const { - editor: { - inputs: { keys } - } - } = this; - const shiftKey = keys.has("ShiftLeft"); - const delta = new Vec(0, 0); - if (keys.has("ArrowLeft")) - delta.x -= 1; - if (keys.has("ArrowRight")) - delta.x += 1; - if (keys.has("ArrowUp")) - delta.y -= 1; - if (keys.has("ArrowDown")) - delta.y += 1; - if (delta.equals(new Vec(0, 0))) - return; - if (!ephemeral) - this.editor.mark("nudge shapes"); - const { gridSize } = this.editor.getDocumentSettings(); - const step = this.editor.getInstanceState().isGridMode ? shiftKey ? gridSize * GRID_INCREMENT : gridSize : shiftKey ? MAJOR_NUDGE_FACTOR : MINOR_NUDGE_FACTOR; - const selectedShapeIds = this.editor.getSelectedShapeIds(); - this.editor.nudgeShapes(selectedShapeIds, delta.mul(step)); - kickoutOccludedShapes(this.editor, selectedShapeIds); - } - canInteractWithShapeInReadOnly(shape) { - if (!this.editor.getInstanceState().isReadonly) - return true; - const util = this.editor.getShapeUtil(shape); - if (util.canEditInReadOnly(shape)) - return true; - return false; - } -}; -__publicField(Idle12, "id", "idle"); -var MAJOR_NUDGE_FACTOR = 10; -var MINOR_NUDGE_FACTOR = 1; -var GRID_INCREMENT = 5; -function isPointInRotatedSelectionBounds(editor, point) { - const selectionBounds = editor.getSelectionRotatedPageBounds(); - if (!selectionBounds) - return false; - const selectionRotation = editor.getSelectionRotation(); - if (!selectionRotation) - return selectionBounds.containsPoint(point); - return pointInPolygon(point, selectionBounds.corners.map((c) => Vec.RotWith(c, selectionBounds.point, selectionRotation))); -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs -var PointingArrowLabel = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "shapeId", ""); - __publicField(this, "markId", ""); - __publicField(this, "wasAlreadySelected", false); - __publicField(this, "didDrag", false); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - const { shape } = info2; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.info = info2; - this.shapeId = shape.id; - this.didDrag = false; - this.wasAlreadySelected = this.editor.getOnlySelectedShapeId() === shape.id; - this.updateCursor(); - const geometry = this.editor.getShapeGeometry(shape); - const labelGeometry = geometry.children[1]; - if (!labelGeometry) { - throw Error(`Expected to find an arrow label geometry for shape: ${shape.id}`); - } - const { currentPagePoint } = this.editor.inputs; - const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint); - this._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace); - this.markId = "label-drag start"; - this.editor.mark(this.markId); - this.editor.setSelectedShapes([this.shapeId]); - }); - __publicField(this, "onExit", () => { - this.parent.setCurrentToolIdMask(void 0); - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - __publicField(this, "_labelDragOffset", new Vec(0, 0)); - __publicField(this, "onPointerMove", () => { - const { isDragging } = this.editor.inputs; - if (!isDragging) - return; - const shape = this.editor.getShape(this.shapeId); - if (!shape) - return; - const info2 = getArrowInfo(this.editor, shape); - const groupGeometry = this.editor.getShapeGeometry(shape); - const bodyGeometry = groupGeometry.children[0]; - const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint); - const nearestPoint = bodyGeometry.nearestPoint(Vec.Add(pointInShapeSpace, this._labelDragOffset)); - let nextLabelPosition; - if (info2.isStraight) { - const lineLength = Vec.Dist(info2.start.point, info2.end.point); - const segmentLength = Vec.Dist(info2.end.point, nearestPoint); - nextLabelPosition = 1 - segmentLength / lineLength; - } else { - const { _center, measure, angleEnd, angleStart } = groupGeometry.children[0]; - nextLabelPosition = getPointInArcT(measure, angleStart, angleEnd, _center.angle(nearestPoint)); - } - if (isNaN(nextLabelPosition)) { - nextLabelPosition = 0.5; - } - this.didDrag = true; - this.editor.updateShape({ - id: shape.id, - type: shape.type, - props: { labelPosition: nextLabelPosition } - }); - }); - __publicField(this, "onPointerUp", () => { - const shape = this.editor.getShape(this.shapeId); - if (!shape) - return; - if (this.didDrag || !this.wasAlreadySelected) { - this.complete(); - } else { - this.editor.setEditingShape(shape.id); - this.editor.setCurrentTool("select.editing_shape"); - } - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - updateCursor() { - this.editor.setCursor({ type: "grabbing", rotation: 0 }); - } - complete() { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } - cancel() { - this.editor.bailToMark(this.markId); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } -}; -__publicField(PointingArrowLabel, "id", "pointing_arrow_label"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs -var PointingCanvas = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "onEnter", () => { - const { inputs } = this.editor; - if (!inputs.shiftKey) { - if (this.editor.getSelectedShapeIds().length > 0) { - this.editor.mark("selecting none"); - this.editor.selectNone(); - } - } - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - this.parent.transition("brushing", info2); - } - }); - __publicField(this, "onPointerUp", () => { - selectOnCanvasPointerUp(this.editor); - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onInterrupt", () => { - this.parent.transition("idle"); - }); - } - complete() { - this.parent.transition("idle"); - } -}; -__publicField(PointingCanvas, "id", "pointing_canvas"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs -var PointingHandle = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - const { shape } = info2; - if (this.editor.isShapeOfType(shape, "arrow")) { - const initialBinding = getArrowBindings(this.editor, shape)[info2.handle.id]; - if (initialBinding) { - this.editor.setHintingShapes([initialBinding.toId]); - } - } - this.editor.setCursor({ type: "grabbing", rotation: 0 }); - }); - __publicField(this, "onExit", () => { - this.editor.setHintingShapes([]); - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - __publicField(this, "onPointerUp", () => { - const { shape, handle } = this.info; - if (this.editor.isShapeOfType(shape, "note")) { - const { editor } = this; - const nextNote = getNoteForPit(editor, shape, handle, false); - if (nextNote) { - startEditingShapeWithLabel(editor, nextNote, true); - return; - } - } - this.parent.transition("idle", this.info); - }); - __publicField(this, "onPointerMove", () => { - const { editor } = this; - if (editor.inputs.isDragging) { - this.startDraggingHandle(); - } - }); - __publicField(this, "onLongPress", () => { - this.startDraggingHandle(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - startDraggingHandle() { - const { editor } = this; - if (editor.getInstanceState().isReadonly) - return; - const { shape, handle } = this.info; - if (editor.isShapeOfType(shape, "note")) { - const nextNote = getNoteForPit(editor, shape, handle, true); - if (nextNote) { - const centeredOnPointer = editor.getPointInParentSpace(nextNote, editor.inputs.originPagePoint).sub(Vec.Rot(NOTE_CENTER_OFFSET.clone().mul(shape.props.scale), nextNote.rotation)); - editor.updateShape({ ...nextNote, x: centeredOnPointer.x, y: centeredOnPointer.y }); - editor.setHoveredShape(nextNote.id).select(nextNote.id).setCurrentTool("select.translating", { - ...this.info, - target: "shape", - shape: editor.getShape(nextNote), - onInteractionEnd: "note", - isCreating: true, - onCreate: () => { - startEditingShapeWithLabel(editor, nextNote, true); - } - }); - return; - } - } - this.parent.transition("dragging_handle", this.info); - } - cancel() { - this.parent.transition("idle"); - } -}; -__publicField(PointingHandle, "id", "pointing_handle"); -function getNoteForPit(editor, shape, handle, forceNew) { - const pageTransform = editor.getShapePageTransform(shape.id); - const pagePoint = pageTransform.point(); - const pageRotation = pageTransform.rotation(); - const pits = getNoteAdjacentPositions(editor, pagePoint, pageRotation, shape.props.growY, 0, shape.props.scale); - const pit = pits[handle.index]; - if (pit) { - return getNoteShapeForAdjacentPosition(editor, shape, pit, pageRotation, forceNew); - } -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs -var PointingRotateHandle = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.info = info2; - this.updateCursor(); - }); - __publicField(this, "onExit", () => { - this.parent.setCurrentToolIdMask(void 0); - this.editor.setCursor({ type: "default", rotation: 0 }); - }); - __publicField(this, "onPointerMove", () => { - if (this.editor.inputs.isDragging) { - this.startRotating(); - } - }); - __publicField(this, "onLongPress", () => { - this.startRotating(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - updateCursor() { - this.editor.setCursor({ - type: CursorTypeMap[this.info.handle], - rotation: this.editor.getSelectionRotation() - }); - } - startRotating() { - if (this.editor.getInstanceState().isReadonly) - return; - this.parent.transition("rotating", this.info); - } - complete() { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } - cancel() { - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } -}; -__publicField(PointingRotateHandle, "id", "pointing_rotate_handle"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs -var PointingSelection = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - }); - __publicField(this, "onPointerUp", (info2) => { - selectOnCanvasPointerUp(this.editor); - this.parent.transition("idle", info2); - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - this.startTranslating(info2); - } - }); - __publicField(this, "onLongPress", (info2) => { - this.startTranslating(info2); - }); - __publicField(this, "onDoubleClick", (info2) => { - const hoveredShape = this.editor.getHoveredShape(); - const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, { - hitInside: true, - margin: 0, - renderingOnly: true - }); - if (hitShape) { - this.parent.transition("idle"); - this.parent.onDoubleClick?.({ - ...info2, - target: "shape", - shape: this.editor.getShape(hitShape) - }); - return; - } - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - startTranslating(info2) { - if (this.editor.getInstanceState().isReadonly) - return; - this.parent.transition("translating", info2); - } - cancel() { - this.parent.transition("idle"); - } -}; -__publicField(PointingSelection, "id", "pointing_selection"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs -var PointingShape = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "hitShape", {}); - __publicField(this, "hitShapeForPointerUp", {}); - __publicField(this, "isDoubleClick", false); - __publicField(this, "didSelectOnEnter", false); - __publicField(this, "onEnter", (info2) => { - const selectedShapeIds = this.editor.getSelectedShapeIds(); - const selectionBounds = this.editor.getSelectionRotatedPageBounds(); - const focusedGroupId = this.editor.getFocusedGroupId(); - const { - inputs: { currentPagePoint, shiftKey, altKey: altKey2 } - } = this.editor; - this.hitShape = info2.shape; - this.isDoubleClick = false; - const outermostSelectingShape = this.editor.getOutermostSelectableShape(info2.shape); - const selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) => selectedShapeIds.includes(parent.id)); - if (this.editor.getShapeUtil(info2.shape).onClick || outermostSelectingShape.id === focusedGroupId || selectedShapeIds.includes(outermostSelectingShape.id) || selectedAncestor || selectedShapeIds.length > 1 && selectionBounds?.containsPoint(currentPagePoint)) { - this.didSelectOnEnter = false; - this.hitShapeForPointerUp = outermostSelectingShape; - return; - } - this.didSelectOnEnter = true; - if (shiftKey && !altKey2) { - this.editor.cancelDoubleClick(); - if (!selectedShapeIds.includes(outermostSelectingShape.id)) { - this.editor.mark("shift selecting shape"); - this.editor.setSelectedShapes([...selectedShapeIds, outermostSelectingShape.id]); - } - } else { - this.editor.mark("selecting shape"); - this.editor.setSelectedShapes([outermostSelectingShape.id]); - } - }); - __publicField(this, "onPointerUp", (info2) => { - const selectedShapeIds = this.editor.getSelectedShapeIds(); - const focusedGroupId = this.editor.getFocusedGroupId(); - const zoomLevel = this.editor.getZoomLevel(); - const { - inputs: { currentPagePoint, shiftKey } - } = this.editor; - const hitShape = this.editor.getShapeAtPoint(currentPagePoint, { - margin: this.editor.options.hitTestMargin / zoomLevel, - hitInside: true, - renderingOnly: true - }) ?? this.hitShape; - const selectingShape = hitShape ? this.editor.getOutermostSelectableShape(hitShape) : this.hitShapeForPointerUp; - if (selectingShape) { - const util = this.editor.getShapeUtil(selectingShape); - if (util.onClick) { - const change = util.onClick?.(selectingShape); - if (change) { - this.editor.mark("shape on click"); - this.editor.updateShapes([change]); - this.parent.transition("idle", info2); - return; - } - } - if (selectingShape.id === focusedGroupId) { - if (selectedShapeIds.length > 0) { - this.editor.mark("clearing shape ids"); - this.editor.setSelectedShapes([]); - } else { - this.editor.popFocusedGroupId(); - } - this.parent.transition("idle", info2); - return; - } - } - if (!this.didSelectOnEnter) { - const outermostSelectableShape = this.editor.getOutermostSelectableShape(hitShape, (parent) => !selectedShapeIds.includes(parent.id)); - if (selectedShapeIds.includes(outermostSelectableShape.id)) { - if (shiftKey) { - this.editor.mark("deselecting on pointer up"); - this.editor.deselect(selectingShape); - } else { - if (selectedShapeIds.includes(selectingShape.id)) { - if (selectedShapeIds.length === 1) { - const geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape); - const textLabels = getTextLabels(geometry); - const textLabel = textLabels.length === 1 ? textLabels[0] : void 0; - if (textLabel) { - const pointInShapeSpace = this.editor.getPointInShapeSpace(selectingShape, currentPagePoint); - if (textLabel.bounds.containsPoint(pointInShapeSpace, 0) && textLabel.hitTestPoint(pointInShapeSpace)) { - this.editor.run(() => { - this.editor.mark("editing on pointer up"); - this.editor.select(selectingShape.id); - const util = this.editor.getShapeUtil(selectingShape); - if (this.editor.getInstanceState().isReadonly) { - if (!util.canEditInReadOnly(selectingShape)) { - return; - } - } - this.editor.setEditingShape(selectingShape.id); - this.editor.setCurrentTool("select.editing_shape"); - if (this.isDoubleClick) { - this.editor.emit("select-all-text", { shapeId: selectingShape.id }); - } - }); - return; - } - } - } - this.editor.mark("selecting on pointer up"); - this.editor.select(selectingShape.id); - } else { - this.editor.mark("selecting on pointer up"); - this.editor.select(selectingShape); - } - } - } else if (shiftKey) { - const ancestors = this.editor.getShapeAncestors(outermostSelectableShape); - this.editor.mark("shift deselecting on pointer up"); - this.editor.setSelectedShapes([ - ...this.editor.getSelectedShapeIds().filter((id) => !ancestors.find((a) => a.id === id)), - outermostSelectableShape.id - ]); - } else { - this.editor.mark("selecting on pointer up"); - this.editor.setSelectedShapes([outermostSelectableShape.id]); - } - } - this.parent.transition("idle", info2); - }); - __publicField(this, "onDoubleClick", () => { - this.isDoubleClick = true; - }); - __publicField(this, "onPointerMove", (info2) => { - if (this.editor.inputs.isDragging) { - this.startTranslating(info2); - } - }); - __publicField(this, "onLongPress", (info2) => { - this.startTranslating(info2); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.cancel(); - }); - __publicField(this, "onInterrupt", () => { - this.cancel(); - }); - } - startTranslating(info2) { - if (this.editor.getInstanceState().isReadonly) - return; - this.editor.focus(); - this.parent.transition("translating", info2); - } - cancel() { - this.parent.transition("idle"); - } -}; -__publicField(PointingShape, "id", "pointing_shape"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs -var Resizing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "markId", ""); - __publicField(this, "didHoldCommand", false); - __publicField(this, "creationCursorOffset", { x: 0, y: 0 }); - __publicField(this, "snapshot", {}); - __publicField(this, "onEnter", (info2) => { - const { isCreating = false, creationCursorOffset = { x: 0, y: 0 } } = info2; - this.info = info2; - this.didHoldCommand = false; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.creationCursorOffset = creationCursorOffset; - this.snapshot = this._createSnapshot(); - if (isCreating) { - this.markId = `creating:${this.editor.getOnlySelectedShape().id}`; - this.editor.setCursor({ type: "cross", rotation: 0 }); - } else { - this.markId = "starting resizing"; - this.editor.mark(this.markId); - } - this.handleResizeStart(); - this.updateShapes(); - }); - __publicField(this, "onTick", ({ elapsed }) => { - const { editor } = this; - editor.edgeScrollManager.updateEdgeScrolling(elapsed); - }); - __publicField(this, "onPointerMove", () => { - this.updateShapes(); - }); - __publicField(this, "onKeyDown", () => { - this.updateShapes(); - }); - __publicField(this, "onKeyUp", () => { - this.updateShapes(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onExit", () => { - this.parent.setCurrentToolIdMask(void 0); - this.editor.setCursor({ type: "default", rotation: 0 }); - this.editor.snaps.clearIndicators(); - }); - __publicField(this, "_createSnapshot", () => { - const selectedShapeIds = this.editor.getSelectedShapeIds(); - const selectionRotation = this.editor.getSelectionRotation(); - const { - inputs: { originPagePoint } - } = this.editor; - const selectionBounds = this.editor.getSelectionRotatedPageBounds(); - const dragHandlePoint = Vec.RotWith(selectionBounds.getHandlePoint(this.info.handle), selectionBounds.point, selectionRotation); - const cursorHandleOffset = Vec.Sub(originPagePoint, dragHandlePoint); - const shapeSnapshots = /* @__PURE__ */ new Map(); - const frames = []; - selectedShapeIds.forEach((id) => { - const shape = this.editor.getShape(id); - if (shape) { - if (shape.type === "frame") { - frames.push({ - id, - children: compact(this.editor.getSortedChildIdsForParent(shape).map((id2) => this.editor.getShape(id2))) - }); - } - shapeSnapshots.set(shape.id, this._createShapeSnapshot(shape)); - if (this.editor.isShapeOfType(shape, "frame") && selectedShapeIds.length === 1) - return; - this.editor.visitDescendants(shape.id, (descendantId) => { - const descendent = this.editor.getShape(descendantId); - if (descendent) { - shapeSnapshots.set(descendent.id, this._createShapeSnapshot(descendent)); - if (this.editor.isShapeOfType(descendent, "frame")) { - return false; - } - } - }); - } - }); - const canShapesDeform = ![...shapeSnapshots.values()].some((shape) => !areAnglesCompatible(shape.pageRotation, selectionRotation) || shape.isAspectRatioLocked); - return { - shapeSnapshots, - selectionBounds, - cursorHandleOffset, - selectionRotation, - selectedShapeIds, - canShapesDeform, - initialSelectionPageBounds: this.editor.getSelectionPageBounds(), - frames - }; - }); - __publicField(this, "_createShapeSnapshot", (shape) => { - const pageTransform = this.editor.getShapePageTransform(shape); - const util = this.editor.getShapeUtil(shape); - return { - shape, - bounds: this.editor.getShapeGeometry(shape).bounds, - pageTransform, - pageRotation: Mat.Decompose(pageTransform).rotation, - isAspectRatioLocked: util.isAspectRatioLocked(shape) - }; - }); - } - cancel() { - this.editor.bailToMark(this.markId); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - } else { - this.parent.transition("idle"); - } - } - complete() { - kickoutOccludedShapes(this.editor, this.snapshot.selectedShapeIds); - this.handleResizeEnd(); - if (this.info.isCreating && this.info.onCreate) { - this.info.onCreate?.(this.editor.getOnlySelectedShape()); - return; - } - if (this.editor.getInstanceState().isToolLocked && this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, {}); - return; - } - this.parent.transition("idle"); - } - handleResizeStart() { - const { shapeSnapshots } = this.snapshot; - const changes = []; - shapeSnapshots.forEach(({ shape }) => { - const util = this.editor.getShapeUtil(shape); - const change = util.onResizeStart?.(shape); - if (change) { - changes.push(change); - } - }); - if (changes.length > 0) { - this.editor.updateShapes(changes); - } - } - handleResizeEnd() { - const { shapeSnapshots } = this.snapshot; - const changes = []; - shapeSnapshots.forEach(({ shape }) => { - const current = this.editor.getShape(shape.id); - const util = this.editor.getShapeUtil(shape); - const change = util.onResizeEnd?.(shape, current); - if (change) { - changes.push(change); - } - }); - if (changes.length > 0) { - this.editor.updateShapes(changes); - } - } - updateShapes() { - const { altKey: altKey2, shiftKey } = this.editor.inputs; - const { - frames, - shapeSnapshots, - selectionBounds, - cursorHandleOffset, - selectedShapeIds, - selectionRotation, - canShapesDeform - } = this.snapshot; - let isAspectRatioLocked = shiftKey || !canShapesDeform; - if (shapeSnapshots.size === 1) { - const onlySnapshot = [...shapeSnapshots.values()][0]; - if (this.editor.isShapeOfType(onlySnapshot.shape, "text")) { - isAspectRatioLocked = !(this.info.handle === "left" || this.info.handle === "right"); - } - } - const { ctrlKey } = this.editor.inputs; - const currentPagePoint = this.editor.inputs.currentPagePoint.clone().sub(cursorHandleOffset).sub(this.creationCursorOffset); - const originPagePoint = this.editor.inputs.originPagePoint.clone().sub(cursorHandleOffset); - if (this.editor.getInstanceState().isGridMode && !ctrlKey) { - const { gridSize } = this.editor.getDocumentSettings(); - currentPagePoint.snapToGrid(gridSize); - } - const dragHandle = this.info.handle; - const scaleOriginHandle = rotateSelectionHandle2(dragHandle, Math.PI); - this.editor.snaps.clearIndicators(); - const shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey; - if (shouldSnap && selectionRotation % HALF_PI === 0) { - const { nudge } = this.editor.snaps.shapeBounds.snapResizeShapes({ - dragDelta: Vec.Sub(currentPagePoint, originPagePoint), - initialSelectionPageBounds: this.snapshot.initialSelectionPageBounds, - handle: rotateSelectionHandle2(dragHandle, selectionRotation), - isAspectRatioLocked, - isResizingFromCenter: altKey2 - }); - currentPagePoint.add(nudge); - } - const scaleOriginPage = Vec.RotWith(altKey2 ? selectionBounds.center : selectionBounds.getHandlePoint(scaleOriginHandle), selectionBounds.point, selectionRotation); - const distanceFromScaleOriginNow = Vec.Sub(currentPagePoint, scaleOriginPage).rot(-selectionRotation); - const distanceFromScaleOriginAtStart = Vec.Sub(originPagePoint, scaleOriginPage).rot(-selectionRotation); - const scale = Vec.DivV(distanceFromScaleOriginNow, distanceFromScaleOriginAtStart); - if (!Number.isFinite(scale.x)) - scale.x = 1; - if (!Number.isFinite(scale.y)) - scale.y = 1; - const isXLocked = dragHandle === "top" || dragHandle === "bottom"; - const isYLocked = dragHandle === "left" || dragHandle === "right"; - if (isAspectRatioLocked) { - if (isYLocked) { - scale.y = Math.abs(scale.x); - } else if (isXLocked) { - scale.x = Math.abs(scale.y); - } else if (Math.abs(scale.x) > Math.abs(scale.y)) { - scale.y = Math.abs(scale.x) * (scale.y < 0 ? -1 : 1); - } else { - scale.x = Math.abs(scale.y) * (scale.x < 0 ? -1 : 1); - } - } else { - if (isXLocked) { - scale.x = 1; - } - if (isYLocked) { - scale.y = 1; - } - } - if (!this.info.isCreating) { - this.updateCursor({ - dragHandle, - isFlippedX: scale.x < 0, - isFlippedY: scale.y < 0, - rotation: selectionRotation - }); - } - for (const id of shapeSnapshots.keys()) { - const snapshot = shapeSnapshots.get(id); - this.editor.resizeShape(id, scale, { - initialShape: snapshot.shape, - initialBounds: snapshot.bounds, - initialPageTransform: snapshot.pageTransform, - dragHandle, - mode: selectedShapeIds.length === 1 && id === selectedShapeIds[0] ? "resize_bounds" : "scale_shape", - scaleOrigin: scaleOriginPage, - isAspectRatioLocked, - scaleAxisRotation: selectionRotation, - skipStartAndEndCallbacks: true - }); - } - if (this.editor.inputs.ctrlKey) { - this.didHoldCommand = true; - for (const { id, children } of frames) { - if (!children.length) - continue; - const initial = shapeSnapshots.get(id).shape; - const current = this.editor.getShape(id); - if (!(initial && current)) - continue; - const dx = current.x - initial.x; - const dy = current.y - initial.y; - const delta = new Vec(dx, dy).rot(-initial.rotation); - if (delta.x !== 0 || delta.y !== 0) { - for (const child of children) { - this.editor.updateShape({ - id: child.id, - type: child.type, - x: child.x - delta.x, - y: child.y - delta.y - }); - } - } - } - } else if (this.didHoldCommand) { - this.didHoldCommand = false; - for (const { children } of frames) { - if (!children.length) - continue; - for (const child of children) { - this.editor.updateShape({ - id: child.id, - type: child.type, - x: child.x, - y: child.y - }); - } - } - } - } - updateCursor({ - dragHandle, - isFlippedX, - isFlippedY, - rotation - }) { - const nextCursor = { ...this.editor.getInstanceState().cursor }; - switch (dragHandle) { - case "top_left": - case "bottom_right": { - nextCursor.type = "nwse-resize"; - if (isFlippedX !== isFlippedY) { - nextCursor.type = "nesw-resize"; - } - break; - } - case "top_right": - case "bottom_left": { - nextCursor.type = "nesw-resize"; - if (isFlippedX !== isFlippedY) { - nextCursor.type = "nwse-resize"; - } - break; - } - } - nextCursor.rotation = rotation; - this.editor.setCursor(nextCursor); - } -}; -__publicField(Resizing, "id", "resizing"); -var ORDERED_SELECTION_HANDLES = [ - "top", - "top_right", - "right", - "bottom_right", - "bottom", - "bottom_left", - "left", - "top_left" -]; -function rotateSelectionHandle2(handle, rotation) { - rotation = rotation % PI2; - const numSteps = Math.round(rotation / (PI / 4)); - const currentIndex = ORDERED_SELECTION_HANDLES.indexOf(handle); - return ORDERED_SELECTION_HANDLES[(currentIndex + numSteps) % ORDERED_SELECTION_HANDLES.length]; -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs -var ONE_DEGREE = Math.PI / 180; -var Rotating = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "snapshot", {}); - __publicField(this, "info", {}); - __publicField(this, "markId", ""); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.markId = "rotate start"; - this.editor.mark(this.markId); - const snapshot = getRotationSnapshot({ editor: this.editor }); - if (!snapshot) - return this.parent.transition("idle", this.info); - this.snapshot = snapshot; - const newSelectionRotation = this._getRotationFromPointerPosition({ - snapToNearestDegree: false - }); - applyRotationToSnapshotShapes({ - editor: this.editor, - delta: this._getRotationFromPointerPosition({ snapToNearestDegree: false }), - snapshot: this.snapshot, - stage: "start" - }); - this.editor.setCursor({ - type: CursorTypeMap[this.info.handle], - rotation: newSelectionRotation + this.snapshot.initialSelectionRotation - }); - }); - __publicField(this, "onExit", () => { - this.editor.setCursor({ type: "default", rotation: 0 }); - this.parent.setCurrentToolIdMask(void 0); - this.snapshot = {}; - }); - __publicField(this, "onPointerMove", () => { - this.update(); - }); - __publicField(this, "onKeyDown", () => { - this.update(); - }); - __publicField(this, "onKeyUp", () => { - this.update(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "update", () => { - const newSelectionRotation = this._getRotationFromPointerPosition({ - snapToNearestDegree: false - }); - applyRotationToSnapshotShapes({ - editor: this.editor, - delta: newSelectionRotation, - snapshot: this.snapshot, - stage: "update" - }); - this.editor.setCursor({ - type: CursorTypeMap[this.info.handle], - rotation: newSelectionRotation + this.snapshot.initialSelectionRotation - }); - }); - __publicField(this, "cancel", () => { - this.editor.bailToMark(this.markId); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.parent.transition("idle", this.info); - } - }); - __publicField(this, "complete", () => { - applyRotationToSnapshotShapes({ - editor: this.editor, - delta: this._getRotationFromPointerPosition({ snapToNearestDegree: true }), - snapshot: this.snapshot, - stage: "end" - }); - kickoutOccludedShapes(this.editor, this.snapshot.shapeSnapshots.map((s) => s.shape.id)); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.parent.transition("idle", this.info); - } - }); - } - _getRotationFromPointerPosition({ snapToNearestDegree }) { - const selectionRotation = this.editor.getSelectionRotation(); - const selectionBounds = this.editor.getSelectionRotatedPageBounds(); - const { - inputs: { shiftKey, currentPagePoint } - } = this.editor; - const { initialCursorAngle, initialSelectionRotation } = this.snapshot; - if (!selectionBounds) - return initialSelectionRotation; - const selectionPageCenter = selectionBounds.center.clone().rotWith(selectionBounds.point, selectionRotation); - const preSnapRotationDelta = selectionPageCenter.angle(currentPagePoint) - initialCursorAngle; - let newSelectionRotation = initialSelectionRotation + preSnapRotationDelta; - if (shiftKey) { - newSelectionRotation = snapAngle(newSelectionRotation, 24); - } else if (snapToNearestDegree) { - newSelectionRotation = Math.round(newSelectionRotation / ONE_DEGREE) * ONE_DEGREE; - if (this.editor.getInstanceState().isCoarsePointer) { - const snappedToRightAngle = snapAngle(newSelectionRotation, 4); - const angleToRightAngle = shortAngleDist(newSelectionRotation, snappedToRightAngle); - if (Math.abs(angleToRightAngle) < degreesToRadians(5)) { - newSelectionRotation = snappedToRightAngle; - } - } - } - return newSelectionRotation - initialSelectionRotation; - } -}; -__publicField(Rotating, "id", "rotating"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs -var ScribbleBrushing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "hits", /* @__PURE__ */ new Set()); - __publicField(this, "size", 0); - __publicField(this, "scribbleId", "id"); - __publicField(this, "initialSelectedShapeIds", /* @__PURE__ */ new Set()); - __publicField(this, "newlySelectedShapeIds", /* @__PURE__ */ new Set()); - __publicField(this, "onEnter", () => { - this.initialSelectedShapeIds = new Set(this.editor.inputs.shiftKey ? this.editor.getSelectedShapeIds() : []); - this.newlySelectedShapeIds = /* @__PURE__ */ new Set(); - this.size = 0; - this.hits.clear(); - const scribbleItem = this.editor.scribbles.addScribble({ - color: "selection-stroke", - opacity: 0.32, - size: 12 - }); - this.scribbleId = scribbleItem.id; - this.updateScribbleSelection(true); - this.editor.updateInstanceState({ brush: null }); - }); - __publicField(this, "onExit", () => { - this.editor.scribbles.stop(this.scribbleId); - }); - __publicField(this, "onPointerMove", () => { - this.updateScribbleSelection(true); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onKeyDown", () => { - this.updateScribbleSelection(false); - }); - __publicField(this, "onKeyUp", () => { - if (!this.editor.inputs.altKey) { - this.parent.transition("brushing"); - } else { - this.updateScribbleSelection(false); - } - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "pushPointToScribble", () => { - const { x, y } = this.editor.inputs.currentPagePoint; - this.editor.scribbles.addPoint(this.scribbleId, x, y); - }); - } - updateScribbleSelection(addPoint) { - const { editor } = this; - const currentPageShapes = this.editor.getCurrentPageShapes(); - const { - inputs: { shiftKey, originPagePoint, previousPagePoint, currentPagePoint } - } = this.editor; - const { newlySelectedShapeIds, initialSelectedShapeIds } = this; - if (addPoint) { - this.pushPointToScribble(); - } - const shapes = currentPageShapes; - let shape, geometry, A, B; - const minDist = 0; - for (let i = 0, n = shapes.length; i < n; i++) { - shape = shapes[i]; - if (editor.isShapeOfType(shape, "group") || newlySelectedShapeIds.has(shape.id) || editor.isShapeOrAncestorLocked(shape)) { - continue; - } - geometry = editor.getShapeGeometry(shape); - if (editor.isShapeOfType(shape, "frame") && geometry.bounds.containsPoint(editor.getPointInShapeSpace(shape, originPagePoint))) { - continue; - } - const pageTransform = editor.getShapePageTransform(shape); - if (!geometry || !pageTransform) - continue; - const pt = pageTransform.clone().invert(); - A = pt.applyToPoint(previousPagePoint); - B = pt.applyToPoint(currentPagePoint); - const { bounds } = geometry; - if (bounds.minX - minDist > Math.max(A.x, B.x) || bounds.minY - minDist > Math.max(A.y, B.y) || bounds.maxX + minDist < Math.min(A.x, B.x) || bounds.maxY + minDist < Math.min(A.y, B.y)) { - continue; - } - if (geometry.hitTestLineSegment(A, B, minDist)) { - const outermostShape = this.editor.getOutermostSelectableShape(shape); - const pageMask = this.editor.getShapeMask(outermostShape.id); - if (pageMask) { - const intersection = intersectLineSegmentPolygon(previousPagePoint, currentPagePoint, pageMask); - if (intersection !== null) { - const isInMask = pointInPolygon(currentPagePoint, pageMask); - if (!isInMask) - continue; - } - } - newlySelectedShapeIds.add(outermostShape.id); - } - } - const current = editor.getSelectedShapeIds(); - const next = new Set(shiftKey ? [...newlySelectedShapeIds, ...initialSelectedShapeIds] : [...newlySelectedShapeIds]); - if (current.length !== next.size || current.some((id) => !next.has(id))) { - this.editor.setSelectedShapes(Array.from(next)); - } - } - complete() { - this.updateScribbleSelection(true); - this.parent.transition("idle"); - } - cancel() { - this.editor.setSelectedShapes([...this.initialSelectedShapeIds]); - this.parent.transition("idle"); - } -}; -__publicField(ScribbleBrushing, "id", "scribble_brushing"); - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs -var INITIAL_POINTER_LAG_DURATION = 20; -var FAST_POINTER_LAG_DURATION = 100; -var DragAndDropManager = class { - constructor(editor) { - __publicField(this, "prevDroppingShapeId", null); - __publicField(this, "droppingNodeTimer", null); - __publicField(this, "first", true); - __publicField(this, "dispose", () => { - this.clear(); - }); - this.editor = editor; - editor.disposables.add(this.dispose); - } - updateDroppingNode(movingShapes, cb) { - if (this.first) { - this.editor.setHintingShapes(movingShapes.map((s) => this.editor.findShapeAncestor(s, (v) => v.type !== "group")).filter((s) => s)); - this.prevDroppingShapeId = this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint, movingShapes)?.id ?? null; - this.first = false; - } - if (this.droppingNodeTimer === null) { - this.setDragTimer(movingShapes, INITIAL_POINTER_LAG_DURATION, cb); - } else if (this.editor.inputs.pointerVelocity.len() > 0.5) { - clearTimeout(this.droppingNodeTimer); - this.setDragTimer(movingShapes, FAST_POINTER_LAG_DURATION, cb); - } - } - setDragTimer(movingShapes, duration, cb) { - this.droppingNodeTimer = this.editor.timers.setTimeout(() => { - this.editor.run(() => { - this.handleDrag(this.editor.inputs.currentPagePoint, movingShapes, cb); - }); - this.droppingNodeTimer = null; - }, duration); - } - handleDrag(point, movingShapes, cb) { - movingShapes = compact(movingShapes.map((shape) => this.editor.getShape(shape.id))); - const nextDroppingShapeId = this.editor.getDroppingOverShape(point, movingShapes)?.id ?? null; - if (nextDroppingShapeId === this.prevDroppingShapeId) { - this.hintParents(movingShapes); - return; - } - const { prevDroppingShapeId } = this; - const prevDroppingShape = prevDroppingShapeId && this.editor.getShape(prevDroppingShapeId); - const nextDroppingShape = nextDroppingShapeId && this.editor.getShape(nextDroppingShapeId); - if (prevDroppingShape) { - this.editor.getShapeUtil(prevDroppingShape).onDragShapesOut?.(prevDroppingShape, movingShapes); - } - if (nextDroppingShape) { - this.editor.getShapeUtil(nextDroppingShape).onDragShapesOver?.(nextDroppingShape, movingShapes); - } - this.hintParents(movingShapes); - cb?.(); - this.prevDroppingShapeId = nextDroppingShapeId; - } - hintParents(movingShapes) { - const shapesGroupedByAncestor = /* @__PURE__ */ new Map(); - for (const shape of movingShapes) { - const ancestor = this.editor.findShapeAncestor(shape, (v) => v.type !== "group"); - if (!ancestor) - continue; - if (!shapesGroupedByAncestor.has(ancestor.id)) { - shapesGroupedByAncestor.set(ancestor.id, []); - } - shapesGroupedByAncestor.get(ancestor.id).push(shape.id); - } - const hintingShapes = []; - for (const [ancestorId, shapeIds] of shapesGroupedByAncestor) { - const ancestor = this.editor.getShape(ancestorId); - if (!ancestor) - continue; - if (getOccludedChildren(this.editor, ancestor).length < shapeIds.length) { - hintingShapes.push(ancestor.id); - } - } - this.editor.setHintingShapes(hintingShapes); - } - dropShapes(shapes) { - const { prevDroppingShapeId } = this; - this.handleDrag(this.editor.inputs.currentPagePoint, shapes); - if (prevDroppingShapeId) { - const shape = this.editor.getShape(prevDroppingShapeId); - if (!shape) - return; - this.editor.getShapeUtil(shape).onDropShapesOver?.(shape, shapes); - } - } - clear() { - this.prevDroppingShapeId = null; - if (this.droppingNodeTimer !== null) { - clearTimeout(this.droppingNodeTimer); - } - this.droppingNodeTimer = null; - this.editor.setHintingShapes([]); - this.first = true; - } -}; - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs -var Translating = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "selectionSnapshot", {}); - __publicField(this, "snapshot", {}); - __publicField(this, "markId", ""); - __publicField(this, "isCloning", false); - __publicField(this, "isCreating", false); - __publicField(this, "onCreate", () => void 0); - __publicField(this, "dragAndDropManager", new DragAndDropManager(this.editor)); - __publicField(this, "onEnter", (info2) => { - const { isCreating = false, onCreate = () => void 0 } = info2; - if (!this.editor.getSelectedShapeIds()?.length) { - this.parent.transition("idle"); - return; - } - this.info = info2; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.isCreating = isCreating; - this.onCreate = onCreate; - if (isCreating) { - this.markId = `creating:${this.editor.getOnlySelectedShape().id}`; - } else { - this.markId = "translating"; - this.editor.mark(this.markId); - } - this.isCloning = false; - this.info = info2; - this.editor.setCursor({ type: "move", rotation: 0 }); - this.selectionSnapshot = getTranslatingSnapshot(this.editor); - if (!this.isCreating) { - if (this.editor.inputs.altKey) { - this.startCloning(); - return; - } - } - this.snapshot = this.selectionSnapshot; - this.handleStart(); - this.updateShapes(); - }); - __publicField(this, "onExit", () => { - this.parent.setCurrentToolIdMask(void 0); - this.selectionSnapshot = {}; - this.snapshot = {}; - this.editor.snaps.clearIndicators(); - this.editor.setCursor({ type: "default", rotation: 0 }); - this.dragAndDropManager.clear(); - }); - __publicField(this, "onTick", ({ elapsed }) => { - const { editor } = this; - this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes, this.updateParentTransforms); - editor.edgeScrollManager.updateEdgeScrolling(elapsed); - }); - __publicField(this, "onPointerMove", () => { - this.updateShapes(); - }); - __publicField(this, "onKeyDown", () => { - if (this.editor.inputs.altKey && !this.isCloning) { - this.startCloning(); - return; - } - this.updateShapes(); - }); - __publicField(this, "onKeyUp", () => { - if (!this.editor.inputs.altKey && this.isCloning) { - this.stopCloning(); - return; - } - this.updateShapes(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onComplete", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - __publicField(this, "updateParentTransforms", () => { - const { - editor, - snapshot: { shapeSnapshots } - } = this; - const movingShapes = []; - shapeSnapshots.forEach((shapeSnapshot) => { - const shape = editor.getShape(shapeSnapshot.shape.id); - if (!shape) - return null; - movingShapes.push(shape); - const parentTransform = isPageId(shape.parentId) ? null : Mat.Inverse(editor.getShapePageTransform(shape.parentId)); - shapeSnapshot.parentTransform = parentTransform; - }); - }); - } - startCloning() { - if (this.isCreating) - return; - this.isCloning = true; - this.reset(); - this.markId = "translating"; - this.editor.mark(this.markId); - this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())); - this.snapshot = getTranslatingSnapshot(this.editor); - this.handleStart(); - this.updateShapes(); - } - stopCloning() { - this.isCloning = false; - this.snapshot = this.selectionSnapshot; - this.reset(); - this.markId = "translating"; - this.editor.mark(this.markId); - this.updateShapes(); - } - reset() { - this.editor.bailToMark(this.markId); - } - complete() { - this.updateShapes(); - this.dragAndDropManager.dropShapes(this.snapshot.movingShapes); - kickoutOccludedShapes(this.editor, this.snapshot.movingShapes.map((s) => s.id)); - this.handleEnd(); - if (this.editor.getInstanceState().isToolLocked && this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd); - } else { - if (this.isCreating) { - this.onCreate?.(this.editor.getOnlySelectedShape()); - } else { - this.parent.transition("idle"); - } - } - } - cancel() { - this.reset(); - if (this.info.onInteractionEnd) { - this.editor.setCurrentTool(this.info.onInteractionEnd); - } else { - this.parent.transition("idle", this.info); - } - } - handleStart() { - const { movingShapes } = this.snapshot; - const changes = []; - movingShapes.forEach((shape) => { - const util = this.editor.getShapeUtil(shape); - const change = util.onTranslateStart?.(shape); - if (change) { - changes.push(change); - } - }); - if (changes.length > 0) { - this.editor.updateShapes(changes); - } - this.editor.setHoveredShape(null); - } - handleEnd() { - const { movingShapes } = this.snapshot; - if (this.isCloning && movingShapes.length > 0) { - const currentAveragePagePoint = Vec.Average(movingShapes.map((s) => this.editor.getShapePageTransform(s.id).point())); - const offset4 = Vec.Sub(currentAveragePagePoint, this.selectionSnapshot.averagePagePoint); - if (!Vec.IsNaN(offset4)) { - this.editor.updateInstanceState({ - duplicateProps: { - shapeIds: movingShapes.map((s) => s.id), - offset: { x: offset4.x, y: offset4.y } - } - }); - } - } - const changes = []; - movingShapes.forEach((shape) => { - const current = this.editor.getShape(shape.id); - const util = this.editor.getShapeUtil(shape); - const change = util.onTranslateEnd?.(shape, current); - if (change) { - changes.push(change); - } - }); - if (changes.length > 0) { - this.editor.updateShapes(changes); - } - } - updateShapes() { - const { snapshot } = this; - this.dragAndDropManager.updateDroppingNode(snapshot.movingShapes, this.updateParentTransforms); - moveShapesToPoint({ - editor: this.editor, - snapshot - }); - const { movingShapes } = snapshot; - const changes = []; - movingShapes.forEach((shape) => { - const current = this.editor.getShape(shape.id); - const util = this.editor.getShapeUtil(shape); - const change = util.onTranslate?.(shape, current); - if (change) { - changes.push(change); - } - }); - if (changes.length > 0) { - this.editor.updateShapes(changes); - } - } -}; -__publicField(Translating, "id", "translating"); -function getTranslatingSnapshot(editor) { - const movingShapes = []; - const pagePoints = []; - const selectedShapeIds = editor.getSelectedShapeIds(); - const shapeSnapshots = compact(selectedShapeIds.map((id) => { - const shape = editor.getShape(id); - if (!shape) - return null; - movingShapes.push(shape); - const pageTransform = editor.getShapePageTransform(id); - const pagePoint = pageTransform.point(); - const pageRotation = pageTransform.rotation(); - pagePoints.push(pagePoint); - const parentTransform = PageRecordType.isId(shape.parentId) ? null : Mat.Inverse(editor.getShapePageTransform(shape.parentId)); - return { - shape, - pagePoint, - pageRotation, - parentTransform - }; - })); - const onlySelectedShape = editor.getOnlySelectedShape(); - let initialSnapPoints = []; - if (onlySelectedShape) { - initialSnapPoints = editor.snaps.shapeBounds.getSnapPoints(onlySelectedShape.id); - } else { - const selectionPageBounds = editor.getSelectionPageBounds(); - if (selectionPageBounds) { - initialSnapPoints = selectionPageBounds.cornersAndCenter.map((p, i) => ({ - id: "selection:" + i, - x: p.x, - y: p.y - })); - } - } - let noteAdjacentPositions; - let noteSnapshot; - const { originPagePoint } = editor.inputs; - const allHoveredNotes = shapeSnapshots.filter((s) => editor.isShapeOfType(s.shape, "note") && editor.isPointInShape(s.shape, originPagePoint)); - if (allHoveredNotes.length === 0) { - } else if (allHoveredNotes.length === 1) { - noteSnapshot = allHoveredNotes[0]; - } else { - const allShapesSorted = editor.getCurrentPageShapesSorted(); - noteSnapshot = allHoveredNotes.map((s) => ({ - snapshot: s, - index: allShapesSorted.findIndex((shape) => shape.id === s.shape.id) - })).sort((a, b) => b.index - a.index)[0]?.snapshot; - } - if (noteSnapshot) { - noteAdjacentPositions = getAvailableNoteAdjacentPositions(editor, noteSnapshot.pageRotation, noteSnapshot.shape.props.scale, noteSnapshot.shape.props.growY ?? 0); - } - return { - averagePagePoint: Vec.Average(pagePoints), - movingShapes, - shapeSnapshots, - initialPageBounds: editor.getSelectionPageBounds(), - initialSnapPoints, - noteAdjacentPositions, - noteSnapshot - }; -} -function moveShapesToPoint({ - editor, - snapshot -}) { - const { inputs } = editor; - const { - noteSnapshot, - noteAdjacentPositions, - initialPageBounds, - initialSnapPoints, - shapeSnapshots, - averagePagePoint - } = snapshot; - const isGridMode = editor.getInstanceState().isGridMode; - const gridSize = editor.getDocumentSettings().gridSize; - const delta = Vec.Sub(inputs.currentPagePoint, inputs.originPagePoint); - const flatten = editor.inputs.shiftKey ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null; - if (flatten === "x") { - delta.x = 0; - } else if (flatten === "y") { - delta.y = 0; - } - editor.snaps.clearIndicators(); - const isSnapping = editor.user.getIsSnapMode() ? !inputs.ctrlKey : inputs.ctrlKey; - if (isSnapping && editor.inputs.pointerVelocity.len() < 0.5) { - const { nudge } = editor.snaps.shapeBounds.snapTranslateShapes({ - dragDelta: delta, - initialSelectionPageBounds: initialPageBounds, - lockedAxis: flatten, - initialSelectionSnapPoints: initialSnapPoints - }); - delta.add(nudge); - } else { - if (noteSnapshot && noteAdjacentPositions) { - const { scale } = noteSnapshot.shape.props; - const pageCenter = noteSnapshot.pagePoint.clone().add(delta).add(NOTE_CENTER_OFFSET.clone().mul(scale).rot(noteSnapshot.pageRotation)); - let min3 = NOTE_ADJACENT_POSITION_SNAP_RADIUS / editor.getZoomLevel(); - let offset4 = new Vec(0, 0); - for (const pit of noteAdjacentPositions) { - const deltaToPit = Vec.Sub(pageCenter, pit); - const dist = deltaToPit.len(); - if (dist < min3) { - min3 = dist; - offset4 = deltaToPit; - } - } - delta.sub(offset4); - } - } - const averageSnappedPoint = Vec.Add(averagePagePoint, delta); - if (isGridMode && !inputs.ctrlKey) { - averageSnappedPoint.snapToGrid(gridSize); - } - const averageSnap = Vec.Sub(averageSnappedPoint, averagePagePoint); - editor.updateShapes(compact(shapeSnapshots.map(({ shape, pagePoint, parentTransform }) => { - const newPagePoint = Vec.Add(pagePoint, averageSnap); - const newLocalPoint = parentTransform ? Mat.applyToPoint(parentTransform, newPagePoint) : newPagePoint; - return { - id: shape.id, - type: shape.type, - x: newLocalPoint.x, - y: newLocalPoint.y - }; - }))); -} - -// node_modules/tldraw/dist-esm/lib/tools/SelectTool/SelectTool.mjs -var SelectTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "reactor"); - __publicField(this, "cleanUpDuplicateProps", () => { - const selectedShapeIds = this.editor.getSelectedShapeIds(); - const instance = this.editor.getInstanceState(); - if (!instance.duplicateProps) - return; - const duplicatedShapes = new Set(instance.duplicateProps.shapeIds); - if (selectedShapeIds.length === duplicatedShapes.size && selectedShapeIds.every((shapeId) => duplicatedShapes.has(shapeId))) { - return; - } - this.editor.updateInstanceState({ - duplicateProps: null - }); - }); - __publicField(this, "onEnter", () => { - this.reactor = react("clean duplicate props", () => { - try { - this.cleanUpDuplicateProps(); - } catch (e) { - if (typeof process !== "undefined" && false) { - } else { - console.error(e); - } - } - }); - }); - __publicField(this, "onExit", () => { - this.reactor?.(); - if (this.editor.getCurrentPageState().editingShapeId) { - this.editor.setEditingShape(null); - } - }); - } -}; -__publicField(SelectTool, "id", "select"); -__publicField(SelectTool, "initial", "idle"); -__publicField(SelectTool, "isLockable", false); -__publicField(SelectTool, "children", () => [ - Crop, - Cropping, - Idle12, - PointingCanvas, - PointingShape, - Translating, - Brushing, - ScribbleBrushing, - PointingCropHandle, - PointingSelection, - PointingResizeHandle, - EditingShape, - Resizing, - Rotating, - PointingRotateHandle, - PointingArrowLabel, - PointingHandle, - DraggingHandle -]); - -// node_modules/tldraw/dist-esm/lib/tools/ZoomTool/childStates/Idle.mjs -var Idle13 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - }); - __publicField(this, "onPointerDown", () => { - this.parent.transition("pointing", this.info); - }); - } -}; -__publicField(Idle13, "id", "idle"); - -// node_modules/tldraw/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs -var Pointing9 = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onPointerMove", () => { - if (this.editor.inputs.isDragging) { - this.parent.transition("zoom_brushing", this.info); - } - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - } - complete() { - const { currentScreenPoint } = this.editor.inputs; - if (this.editor.inputs.altKey) { - this.editor.zoomOut(currentScreenPoint, { animation: { duration: 220 } }); - } else { - this.editor.zoomIn(currentScreenPoint, { animation: { duration: 220 } }); - } - this.parent.transition("idle", this.info); - } - cancel() { - this.parent.transition("idle", this.info); - } -}; -__publicField(Pointing9, "id", "pointing"); - -// node_modules/tldraw/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs -var ZoomBrushing = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "zoomBrush", new Box()); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.update(); - }); - __publicField(this, "onExit", () => { - this.editor.updateInstanceState({ zoomBrush: null }); - }); - __publicField(this, "onPointerMove", () => { - this.update(); - }); - __publicField(this, "onPointerUp", () => { - this.complete(); - }); - __publicField(this, "onCancel", () => { - this.cancel(); - }); - } - update() { - const { - inputs: { originPagePoint, currentPagePoint } - } = this.editor; - this.zoomBrush.setTo(Box.FromPoints([originPagePoint, currentPagePoint])); - this.editor.updateInstanceState({ zoomBrush: this.zoomBrush.toJson() }); - } - cancel() { - this.parent.transition("idle", this.info); - } - complete() { - const { zoomBrush } = this; - const threshold = 8 / this.editor.getZoomLevel(); - if (zoomBrush.width < threshold && zoomBrush.height < threshold) { - const point = this.editor.inputs.currentScreenPoint; - if (this.editor.inputs.altKey) { - this.editor.zoomOut(point, { animation: { duration: 220 } }); - } else { - this.editor.zoomIn(point, { animation: { duration: 220 } }); - } - } else { - const targetZoom = this.editor.inputs.altKey ? this.editor.getZoomLevel() / 2 : void 0; - this.editor.zoomToBounds(zoomBrush, { targetZoom, animation: { duration: 220 } }); - } - this.parent.transition("idle", this.info); - } -}; -__publicField(ZoomBrushing, "id", "zoom_brushing"); - -// node_modules/tldraw/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs -var ZoomTool = class extends StateNode { - constructor() { - super(...arguments); - __publicField(this, "info", {}); - __publicField(this, "onEnter", (info2) => { - this.info = info2; - this.parent.setCurrentToolIdMask(info2.onInteractionEnd); - this.updateCursor(); - }); - __publicField(this, "onExit", () => { - this.parent.setCurrentToolIdMask(void 0); - this.editor.updateInstanceState({ zoomBrush: null, cursor: { type: "default", rotation: 0 } }); - this.parent.setCurrentToolIdMask(void 0); - }); - __publicField(this, "onKeyDown", () => { - this.updateCursor(); - }); - __publicField(this, "onKeyUp", (info2) => { - this.updateCursor(); - if (info2.code === "KeyZ") { - this.complete(); - } - }); - __publicField(this, "onInterrupt", () => { - this.complete(); - }); - } - complete() { - if (this.info.onInteractionEnd && this.info.onInteractionEnd !== "select") { - this.editor.setCurrentTool(this.info.onInteractionEnd, this.info); - } else { - this.parent.transition("select"); - } - } - updateCursor() { - if (this.editor.inputs.altKey) { - this.editor.setCursor({ type: "zoom-out", rotation: 0 }); - } else { - this.editor.setCursor({ type: "zoom-in", rotation: 0 }); - } - } -}; -__publicField(ZoomTool, "id", "zoom"); -__publicField(ZoomTool, "initial", "idle"); -__publicField(ZoomTool, "children", () => [Idle13, ZoomBrushing, Pointing9]); -__publicField(ZoomTool, "isLockable", false); - -// node_modules/tldraw/dist-esm/lib/defaultTools.mjs -var defaultTools = [EraserTool, HandTool, LaserTool, ZoomTool, SelectTool]; - -// node_modules/tldraw/dist-esm/lib/ui/TldrawUi.mjs -var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1); -var import_classnames29 = __toESM(require_classnames(), 1); -var import_react114 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/Dialogs.mjs -var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@radix-ui/react-dialog/dist/index.mjs -var React39 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/primitive/dist/index.mjs -function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) { - return function handleEvent(event) { - originalEventHandler?.(event); - if (checkForDefaultPrevented === false || !event.defaultPrevented) { - return ourEventHandler?.(event); - } - }; -} - -// node_modules/@radix-ui/react-compose-refs/dist/index.mjs -var React17 = __toESM(require_react(), 1); -function setRef(ref, value) { - if (typeof ref === "function") { - ref(value); - } else if (ref !== null && ref !== void 0) { - ref.current = value; - } -} -function composeRefs(...refs) { - return (node) => refs.forEach((ref) => setRef(ref, node)); -} -function useComposedRefs(...refs) { - return React17.useCallback(composeRefs(...refs), refs); -} - -// node_modules/@radix-ui/react-context/dist/index.mjs -var React18 = __toESM(require_react(), 1); -var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); -function createContext22(rootComponentName, defaultContext) { - const Context2 = React18.createContext(defaultContext); - function Provider2(props) { - const { children, ...context } = props; - const value = React18.useMemo(() => context, Object.values(context)); - return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Context2.Provider, { value, children }); - } - function useContext22(consumerName) { - const context = React18.useContext(Context2); - if (context) - return context; - if (defaultContext !== void 0) - return defaultContext; - throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``); - } - Provider2.displayName = rootComponentName + "Provider"; - return [Provider2, useContext22]; -} -function createContextScope(scopeName, createContextScopeDeps = []) { - let defaultContexts = []; - function createContext32(rootComponentName, defaultContext) { - const BaseContext = React18.createContext(defaultContext); - const index2 = defaultContexts.length; - defaultContexts = [...defaultContexts, defaultContext]; - function Provider2(props) { - const { scope, children, ...context } = props; - const Context2 = scope?.[scopeName][index2] || BaseContext; - const value = React18.useMemo(() => context, Object.values(context)); - return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Context2.Provider, { value, children }); - } - function useContext22(consumerName, scope) { - const Context2 = scope?.[scopeName][index2] || BaseContext; - const context = React18.useContext(Context2); - if (context) - return context; - if (defaultContext !== void 0) - return defaultContext; - throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``); - } - Provider2.displayName = rootComponentName + "Provider"; - return [Provider2, useContext22]; - } - const createScope = () => { - const scopeContexts = defaultContexts.map((defaultContext) => { - return React18.createContext(defaultContext); - }); - return function useScope(scope) { - const contexts = scope?.[scopeName] || scopeContexts; - return React18.useMemo(() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }), [scope, contexts]); - }; - }; - createScope.scopeName = scopeName; - return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)]; -} -function composeContextScopes(...scopes) { - const baseScope = scopes[0]; - if (scopes.length === 1) - return baseScope; - const createScope = () => { - const scopeHooks = scopes.map((createScope2) => ({ - useScope: createScope2(), - scopeName: createScope2.scopeName - })); - return function useComposedScopes(overrideScopes) { - const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => { - const scopeProps = useScope(overrideScopes); - const currentScope = scopeProps[`__scope${scopeName}`]; - return { ...nextScopes2, ...currentScope }; - }, {}); - return React18.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]); - }; - }; - createScope.scopeName = baseScope.scopeName; - return createScope; -} - -// node_modules/@radix-ui/react-id/dist/index.mjs -var React20 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs -var React19 = __toESM(require_react(), 1); -var useLayoutEffect22 = Boolean(globalThis?.document) ? React19.useLayoutEffect : () => { -}; - -// node_modules/@radix-ui/react-id/dist/index.mjs -var useReactId = React20["useId".toString()] || (() => void 0); -var count = 0; -function useId2(deterministicId) { - const [id, setId] = React20.useState(useReactId()); - useLayoutEffect22(() => { - if (!deterministicId) - setId((reactId) => reactId ?? String(count++)); - }, [deterministicId]); - return deterministicId || (id ? `radix-${id}` : ""); -} - -// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs -var React22 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs -var React21 = __toESM(require_react(), 1); -function useCallbackRef(callback) { - const callbackRef = React21.useRef(callback); - React21.useEffect(() => { - callbackRef.current = callback; - }); - return React21.useMemo(() => (...args) => callbackRef.current?.(...args), []); -} - -// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs -function useControllableState({ - prop, - defaultProp, - onChange = () => { - } -}) { - const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange }); - const isControlled = prop !== void 0; - const value = isControlled ? prop : uncontrolledProp; - const handleChange = useCallbackRef(onChange); - const setValue = React22.useCallback((nextValue) => { - if (isControlled) { - const setter = nextValue; - const value2 = typeof nextValue === "function" ? setter(prop) : nextValue; - if (value2 !== prop) - handleChange(value2); - } else { - setUncontrolledProp(nextValue); - } - }, [isControlled, prop, setUncontrolledProp, handleChange]); - return [value, setValue]; -} -function useUncontrolledState({ - defaultProp, - onChange -}) { - const uncontrolledState = React22.useState(defaultProp); - const [value] = uncontrolledState; - const prevValueRef = React22.useRef(value); - const handleChange = useCallbackRef(onChange); - React22.useEffect(() => { - if (prevValueRef.current !== value) { - handleChange(value); - prevValueRef.current = value; - } - }, [value, prevValueRef, handleChange]); - return uncontrolledState; -} - -// node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs -var React26 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-primitive/dist/index.mjs -var React24 = __toESM(require_react(), 1); -var ReactDOM = __toESM(require_react_dom(), 1); - -// node_modules/@radix-ui/react-slot/dist/index.mjs -var React23 = __toESM(require_react(), 1); -var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); -var Slot = React23.forwardRef((props, forwardedRef) => { - const { children, ...slotProps } = props; - const childrenArray = React23.Children.toArray(children); - const slottable = childrenArray.find(isSlottable); - if (slottable) { - const newElement = slottable.props.children; - const newChildren = childrenArray.map((child) => { - if (child === slottable) { - if (React23.Children.count(newElement) > 1) - return React23.Children.only(null); - return React23.isValidElement(newElement) ? newElement.props.children : null; - } else { - return child; - } - }); - return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children: React23.isValidElement(newElement) ? React23.cloneElement(newElement, void 0, newChildren) : null }); - } - return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children }); -}); -Slot.displayName = "Slot"; -var SlotClone = React23.forwardRef((props, forwardedRef) => { - const { children, ...slotProps } = props; - if (React23.isValidElement(children)) { - const childrenRef = getElementRef(children); - return React23.cloneElement(children, { - ...mergeProps(slotProps, children.props), - ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef - }); - } - return React23.Children.count(children) > 1 ? React23.Children.only(null) : null; -}); -SlotClone.displayName = "SlotClone"; -var Slottable = ({ children }) => { - return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children }); -}; -function isSlottable(child) { - return React23.isValidElement(child) && child.type === Slottable; -} -function mergeProps(slotProps, childProps) { - const overrideProps = { ...childProps }; - for (const propName in childProps) { - const slotPropValue = slotProps[propName]; - const childPropValue = childProps[propName]; - const isHandler = /^on[A-Z]/.test(propName); - if (isHandler) { - if (slotPropValue && childPropValue) { - overrideProps[propName] = (...args) => { - childPropValue(...args); - slotPropValue(...args); - }; - } else if (slotPropValue) { - overrideProps[propName] = slotPropValue; - } - } else if (propName === "style") { - overrideProps[propName] = { ...slotPropValue, ...childPropValue }; - } else if (propName === "className") { - overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" "); - } - } - return { ...slotProps, ...overrideProps }; -} -function getElementRef(element) { - let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get; - let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning; - if (mayWarn) { - return element.ref; - } - getter = Object.getOwnPropertyDescriptor(element, "ref")?.get; - mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning; - if (mayWarn) { - return element.props.ref; - } - return element.props.ref || element.ref; -} - -// node_modules/@radix-ui/react-primitive/dist/index.mjs -var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); -var NODES = [ - "a", - "button", - "div", - "form", - "h2", - "h3", - "img", - "input", - "label", - "li", - "nav", - "ol", - "p", - "span", - "svg", - "ul" -]; -var Primitive = NODES.reduce((primitive, node) => { - const Node2 = React24.forwardRef((props, forwardedRef) => { - const { asChild, ...primitiveProps } = props; - const Comp = asChild ? Slot : node; - if (typeof window !== "undefined") { - window[Symbol.for("radix-ui")] = true; - } - return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Comp, { ...primitiveProps, ref: forwardedRef }); - }); - Node2.displayName = `Primitive.${node}`; - return { ...primitive, [node]: Node2 }; -}, {}); -function dispatchDiscreteCustomEvent(target, event) { - if (target) - ReactDOM.flushSync(() => target.dispatchEvent(event)); -} - -// node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs -var React25 = __toESM(require_react(), 1); -function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) { - const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp); - React25.useEffect(() => { - const handleKeyDown = (event) => { - if (event.key === "Escape") { - onEscapeKeyDown(event); - } - }; - ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true }); - return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true }); - }, [onEscapeKeyDown, ownerDocument]); -} - -// node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs -var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); -"use client"; -var DISMISSABLE_LAYER_NAME = "DismissableLayer"; -var CONTEXT_UPDATE = "dismissableLayer.update"; -var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside"; -var FOCUS_OUTSIDE = "dismissableLayer.focusOutside"; -var originalBodyPointerEvents; -var DismissableLayerContext = React26.createContext({ - layers: /* @__PURE__ */ new Set(), - layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(), - branches: /* @__PURE__ */ new Set() -}); -var DismissableLayer = React26.forwardRef((props, forwardedRef) => { - const { - disableOutsidePointerEvents = false, - onEscapeKeyDown, - onPointerDownOutside, - onFocusOutside, - onInteractOutside, - onDismiss, - ...layerProps - } = props; - const context = React26.useContext(DismissableLayerContext); - const [node, setNode] = React26.useState(null); - const ownerDocument = node?.ownerDocument ?? globalThis?.document; - const [, force] = React26.useState({}); - const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2)); - const layers = Array.from(context.layers); - const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1); - const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); - const index2 = node ? layers.indexOf(node) : -1; - const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0; - const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex; - const pointerDownOutside = usePointerDownOutside((event) => { - const target = event.target; - const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target)); - if (!isPointerEventsEnabled || isPointerDownOnBranch) - return; - onPointerDownOutside?.(event); - onInteractOutside?.(event); - if (!event.defaultPrevented) - onDismiss?.(); - }, ownerDocument); - const focusOutside = useFocusOutside((event) => { - const target = event.target; - const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target)); - if (isFocusInBranch) - return; - onFocusOutside?.(event); - onInteractOutside?.(event); - if (!event.defaultPrevented) - onDismiss?.(); - }, ownerDocument); - useEscapeKeydown((event) => { - const isHighestLayer = index2 === context.layers.size - 1; - if (!isHighestLayer) - return; - onEscapeKeyDown?.(event); - if (!event.defaultPrevented && onDismiss) { - event.preventDefault(); - onDismiss(); - } - }, ownerDocument); - React26.useEffect(() => { - if (!node) - return; - if (disableOutsidePointerEvents) { - if (context.layersWithOutsidePointerEventsDisabled.size === 0) { - originalBodyPointerEvents = ownerDocument.body.style.pointerEvents; - ownerDocument.body.style.pointerEvents = "none"; - } - context.layersWithOutsidePointerEventsDisabled.add(node); - } - context.layers.add(node); - dispatchUpdate(); - return () => { - if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) { - ownerDocument.body.style.pointerEvents = originalBodyPointerEvents; - } - }; - }, [node, ownerDocument, disableOutsidePointerEvents, context]); - React26.useEffect(() => { - return () => { - if (!node) - return; - context.layers.delete(node); - context.layersWithOutsidePointerEventsDisabled.delete(node); - dispatchUpdate(); - }; - }, [node, context]); - React26.useEffect(() => { - const handleUpdate = () => force({}); - document.addEventListener(CONTEXT_UPDATE, handleUpdate); - return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Primitive.div, { - ...layerProps, - ref: composedRefs, - style: { - pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0, - ...props.style - }, - onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture), - onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture), - onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture) - }); -}); -DismissableLayer.displayName = DISMISSABLE_LAYER_NAME; -var BRANCH_NAME = "DismissableLayerBranch"; -var DismissableLayerBranch = React26.forwardRef((props, forwardedRef) => { - const context = React26.useContext(DismissableLayerContext); - const ref = React26.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - React26.useEffect(() => { - const node = ref.current; - if (node) { - context.branches.add(node); - return () => { - context.branches.delete(node); - }; - } - }, [context.branches]); - return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Primitive.div, { ...props, ref: composedRefs }); -}); -DismissableLayerBranch.displayName = BRANCH_NAME; -function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) { - const handlePointerDownOutside = useCallbackRef(onPointerDownOutside); - const isPointerInsideReactTreeRef = React26.useRef(false); - const handleClickRef = React26.useRef(() => { - }); - React26.useEffect(() => { - const handlePointerDown = (event) => { - if (event.target && !isPointerInsideReactTreeRef.current) { - let handleAndDispatchPointerDownOutsideEvent2 = function() { - handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, { discrete: true }); - }; - var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2; - const eventDetail = { originalEvent: event }; - if (event.pointerType === "touch") { - ownerDocument.removeEventListener("click", handleClickRef.current); - handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2; - ownerDocument.addEventListener("click", handleClickRef.current, { once: true }); - } else { - handleAndDispatchPointerDownOutsideEvent2(); - } - } else { - ownerDocument.removeEventListener("click", handleClickRef.current); - } - isPointerInsideReactTreeRef.current = false; - }; - const timerId = window.setTimeout(() => { - ownerDocument.addEventListener("pointerdown", handlePointerDown); - }, 0); - return () => { - window.clearTimeout(timerId); - ownerDocument.removeEventListener("pointerdown", handlePointerDown); - ownerDocument.removeEventListener("click", handleClickRef.current); - }; - }, [ownerDocument, handlePointerDownOutside]); - return { - onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true - }; -} -function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) { - const handleFocusOutside = useCallbackRef(onFocusOutside); - const isFocusInsideReactTreeRef = React26.useRef(false); - React26.useEffect(() => { - const handleFocus = (event) => { - if (event.target && !isFocusInsideReactTreeRef.current) { - const eventDetail = { originalEvent: event }; - handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, { - discrete: false - }); - } - }; - ownerDocument.addEventListener("focusin", handleFocus); - return () => ownerDocument.removeEventListener("focusin", handleFocus); - }, [ownerDocument, handleFocusOutside]); - return { - onFocusCapture: () => isFocusInsideReactTreeRef.current = true, - onBlurCapture: () => isFocusInsideReactTreeRef.current = false - }; -} -function dispatchUpdate() { - const event = new CustomEvent(CONTEXT_UPDATE); - document.dispatchEvent(event); -} -function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) { - const target = detail.originalEvent.target; - const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail }); - if (handler) - target.addEventListener(name, handler, { once: true }); - if (discrete) { - dispatchDiscreteCustomEvent(target, event); - } else { - target.dispatchEvent(event); - } -} -var Root = DismissableLayer; -var Branch = DismissableLayerBranch; - -// node_modules/@radix-ui/react-focus-scope/dist/index.mjs -var React27 = __toESM(require_react(), 1); -var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1); -"use client"; -var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount"; -var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount"; -var EVENT_OPTIONS = { bubbles: false, cancelable: true }; -var FOCUS_SCOPE_NAME = "FocusScope"; -var FocusScope = React27.forwardRef((props, forwardedRef) => { - const { - loop = false, - trapped = false, - onMountAutoFocus: onMountAutoFocusProp, - onUnmountAutoFocus: onUnmountAutoFocusProp, - ...scopeProps - } = props; - const [container, setContainer] = React27.useState(null); - const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp); - const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp); - const lastFocusedElementRef = React27.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node)); - const focusScope = React27.useRef({ - paused: false, - pause() { - this.paused = true; - }, - resume() { - this.paused = false; - } - }).current; - React27.useEffect(() => { - if (trapped) { - let handleFocusIn2 = function(event) { - if (focusScope.paused || !container) - return; - const target = event.target; - if (container.contains(target)) { - lastFocusedElementRef.current = target; - } else { - focus(lastFocusedElementRef.current, { select: true }); - } - }, handleFocusOut2 = function(event) { - if (focusScope.paused || !container) - return; - const relatedTarget = event.relatedTarget; - if (relatedTarget === null) - return; - if (!container.contains(relatedTarget)) { - focus(lastFocusedElementRef.current, { select: true }); - } - }, handleMutations2 = function(mutations) { - const focusedElement = document.activeElement; - if (focusedElement !== document.body) - return; - for (const mutation of mutations) { - if (mutation.removedNodes.length > 0) - focus(container); - } - }; - var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2, handleMutations = handleMutations2; - document.addEventListener("focusin", handleFocusIn2); - document.addEventListener("focusout", handleFocusOut2); - const mutationObserver = new MutationObserver(handleMutations2); - if (container) - mutationObserver.observe(container, { childList: true, subtree: true }); - return () => { - document.removeEventListener("focusin", handleFocusIn2); - document.removeEventListener("focusout", handleFocusOut2); - mutationObserver.disconnect(); - }; - } - }, [trapped, container, focusScope.paused]); - React27.useEffect(() => { - if (container) { - focusScopesStack.add(focusScope); - const previouslyFocusedElement = document.activeElement; - const hasFocusedCandidate = container.contains(previouslyFocusedElement); - if (!hasFocusedCandidate) { - const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS); - container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus); - container.dispatchEvent(mountEvent); - if (!mountEvent.defaultPrevented) { - focusFirst(removeLinks(getTabbableCandidates(container)), { select: true }); - if (document.activeElement === previouslyFocusedElement) { - focus(container); - } - } - } - return () => { - container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus); - setTimeout(() => { - const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS); - container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus); - container.dispatchEvent(unmountEvent); - if (!unmountEvent.defaultPrevented) { - focus(previouslyFocusedElement ?? document.body, { select: true }); - } - container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus); - focusScopesStack.remove(focusScope); - }, 0); - }; - } - }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]); - const handleKeyDown = React27.useCallback((event) => { - if (!loop && !trapped) - return; - if (focusScope.paused) - return; - const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey; - const focusedElement = document.activeElement; - if (isTabKey && focusedElement) { - const container2 = event.currentTarget; - const [first, last3] = getTabbableEdges(container2); - const hasTabbableElementsInside = first && last3; - if (!hasTabbableElementsInside) { - if (focusedElement === container2) - event.preventDefault(); - } else { - if (!event.shiftKey && focusedElement === last3) { - event.preventDefault(); - if (loop) - focus(first, { select: true }); - } else if (event.shiftKey && focusedElement === first) { - event.preventDefault(); - if (loop) - focus(last3, { select: true }); - } - } - } - }, [loop, trapped, focusScope.paused]); - return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown }); -}); -FocusScope.displayName = FOCUS_SCOPE_NAME; -function focusFirst(candidates, { select = false } = {}) { - const previouslyFocusedElement = document.activeElement; - for (const candidate of candidates) { - focus(candidate, { select }); - if (document.activeElement !== previouslyFocusedElement) - return; - } -} -function getTabbableEdges(container) { - const candidates = getTabbableCandidates(container); - const first = findVisible(candidates, container); - const last3 = findVisible(candidates.reverse(), container); - return [first, last3]; -} -function getTabbableCandidates(container) { - const nodes = []; - const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, { - acceptNode: (node) => { - const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden"; - if (node.disabled || node.hidden || isHiddenInput) - return NodeFilter.FILTER_SKIP; - return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; - } - }); - while (walker.nextNode()) - nodes.push(walker.currentNode); - return nodes; -} -function findVisible(elements, container) { - for (const element of elements) { - if (!isHidden(element, { upTo: container })) - return element; - } -} -function isHidden(node, { upTo }) { - if (getComputedStyle(node).visibility === "hidden") - return true; - while (node) { - if (upTo !== void 0 && node === upTo) - return false; - if (getComputedStyle(node).display === "none") - return true; - node = node.parentElement; - } - return false; -} -function isSelectableInput(element) { - return element instanceof HTMLInputElement && "select" in element; -} -function focus(element, { select = false } = {}) { - if (element && element.focus) { - const previouslyFocusedElement = document.activeElement; - element.focus({ preventScroll: true }); - if (element !== previouslyFocusedElement && isSelectableInput(element) && select) - element.select(); - } -} -var focusScopesStack = createFocusScopesStack(); -function createFocusScopesStack() { - let stack2 = []; - return { - add(focusScope) { - const activeFocusScope = stack2[0]; - if (focusScope !== activeFocusScope) { - activeFocusScope?.pause(); - } - stack2 = arrayRemove(stack2, focusScope); - stack2.unshift(focusScope); - }, - remove(focusScope) { - stack2 = arrayRemove(stack2, focusScope); - stack2[0]?.resume(); - } - }; -} -function arrayRemove(array2, item) { - const updatedArray = [...array2]; - const index2 = updatedArray.indexOf(item); - if (index2 !== -1) { - updatedArray.splice(index2, 1); - } - return updatedArray; -} -function removeLinks(items) { - return items.filter((item) => item.tagName !== "A"); -} - -// node_modules/@radix-ui/react-portal/dist/index.mjs -var React28 = __toESM(require_react(), 1); -var import_react_dom2 = __toESM(require_react_dom(), 1); -var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1); -"use client"; -var PORTAL_NAME = "Portal"; -var Portal = React28.forwardRef((props, forwardedRef) => { - const { container: containerProp, ...portalProps } = props; - const [mounted, setMounted] = React28.useState(false); - useLayoutEffect22(() => setMounted(true), []); - const container = containerProp || mounted && globalThis?.document?.body; - return container ? import_react_dom2.default.createPortal(/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null; -}); -Portal.displayName = PORTAL_NAME; - -// node_modules/@radix-ui/react-presence/dist/index.mjs -var React29 = __toESM(require_react(), 1); -var ReactDOM3 = __toESM(require_react_dom(), 1); -var React30 = __toESM(require_react(), 1); -"use client"; -function useStateMachine(initialState2, machine) { - return React30.useReducer((state, event) => { - const nextState = machine[state][event]; - return nextState ?? state; - }, initialState2); -} -var Presence = (props) => { - const { present, children } = props; - const presence = usePresence2(present); - const child = typeof children === "function" ? children({ present: presence.isPresent }) : React29.Children.only(children); - const ref = useComposedRefs(presence.ref, getElementRef2(child)); - const forceMount = typeof children === "function"; - return forceMount || presence.isPresent ? React29.cloneElement(child, { ref }) : null; -}; -Presence.displayName = "Presence"; -function usePresence2(present) { - const [node, setNode] = React29.useState(); - const stylesRef = React29.useRef({}); - const prevPresentRef = React29.useRef(present); - const prevAnimationNameRef = React29.useRef("none"); - const initialState2 = present ? "mounted" : "unmounted"; - const [state, send] = useStateMachine(initialState2, { - mounted: { - UNMOUNT: "unmounted", - ANIMATION_OUT: "unmountSuspended" - }, - unmountSuspended: { - MOUNT: "mounted", - ANIMATION_END: "unmounted" - }, - unmounted: { - MOUNT: "mounted" - } - }); - React29.useEffect(() => { - const currentAnimationName = getAnimationName(stylesRef.current); - prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none"; - }, [state]); - useLayoutEffect22(() => { - const styles3 = stylesRef.current; - const wasPresent = prevPresentRef.current; - const hasPresentChanged = wasPresent !== present; - if (hasPresentChanged) { - const prevAnimationName = prevAnimationNameRef.current; - const currentAnimationName = getAnimationName(styles3); - if (present) { - send("MOUNT"); - } else if (currentAnimationName === "none" || styles3?.display === "none") { - send("UNMOUNT"); - } else { - const isAnimating = prevAnimationName !== currentAnimationName; - if (wasPresent && isAnimating) { - send("ANIMATION_OUT"); - } else { - send("UNMOUNT"); - } - } - prevPresentRef.current = present; - } - }, [present, send]); - useLayoutEffect22(() => { - if (node) { - const handleAnimationEnd = (event) => { - const currentAnimationName = getAnimationName(stylesRef.current); - const isCurrentAnimation = currentAnimationName.includes(event.animationName); - if (event.target === node && isCurrentAnimation) { - ReactDOM3.flushSync(() => send("ANIMATION_END")); - } - }; - const handleAnimationStart = (event) => { - if (event.target === node) { - prevAnimationNameRef.current = getAnimationName(stylesRef.current); - } - }; - node.addEventListener("animationstart", handleAnimationStart); - node.addEventListener("animationcancel", handleAnimationEnd); - node.addEventListener("animationend", handleAnimationEnd); - return () => { - node.removeEventListener("animationstart", handleAnimationStart); - node.removeEventListener("animationcancel", handleAnimationEnd); - node.removeEventListener("animationend", handleAnimationEnd); - }; - } else { - send("ANIMATION_END"); - } - }, [node, send]); - return { - isPresent: ["mounted", "unmountSuspended"].includes(state), - ref: React29.useCallback((node2) => { - if (node2) - stylesRef.current = getComputedStyle(node2); - setNode(node2); - }, []) - }; -} -function getAnimationName(styles3) { - return styles3?.animationName || "none"; -} -function getElementRef2(element) { - let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get; - let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning; - if (mayWarn) { - return element.ref; - } - getter = Object.getOwnPropertyDescriptor(element, "ref")?.get; - mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning; - if (mayWarn) { - return element.props.ref; - } - return element.props.ref || element.ref; -} - -// node_modules/@radix-ui/react-focus-guards/dist/index.mjs -var React31 = __toESM(require_react(), 1); -"use client"; -var count2 = 0; -function useFocusGuards() { - React31.useEffect(() => { - const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]"); - document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()); - document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()); - count2++; - return () => { - if (count2 === 1) { - document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove()); - } - count2--; - }; - }, []); -} -function createFocusGuard() { - const element = document.createElement("span"); - element.setAttribute("data-radix-focus-guard", ""); - element.tabIndex = 0; - element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none"; - return element; -} - -// node_modules/tslib/modules/index.js -var import_tslib = __toESM(require_tslib(), 1); -var { - __extends, - __assign, - __rest, - __decorate, - __param, - __metadata, - __awaiter, - __generator, - __exportStar, - __createBinding, - __values, - __read, - __spread, - __spreadArrays, - __spreadArray, - __await, - __asyncGenerator, - __asyncDelegator, - __asyncValues, - __makeTemplateObject, - __importStar, - __importDefault, - __classPrivateFieldGet, - __classPrivateFieldSet, - __classPrivateFieldIn -} = import_tslib.default; - -// node_modules/react-remove-scroll/dist/es2015/Combination.js -var React38 = __toESM(require_react()); - -// node_modules/react-remove-scroll/dist/es2015/UI.js -var React34 = __toESM(require_react()); - -// node_modules/react-remove-scroll-bar/dist/es2015/constants.js -var zeroRightClassName = "right-scroll-bar-position"; -var fullWidthClassName = "width-before-scroll-bar"; -var noScrollbarsClassName = "with-scroll-bars-hidden"; -var removedBarSizeVariable = "--removed-body-scroll-bar-size"; - -// node_modules/use-callback-ref/dist/es2015/assignRef.js -function assignRef(ref, value) { - if (typeof ref === "function") { - ref(value); - } else if (ref) { - ref.current = value; - } - return ref; -} - -// node_modules/use-callback-ref/dist/es2015/useRef.js -var import_react63 = __toESM(require_react()); -function useCallbackRef2(initialValue, callback) { - var ref = (0, import_react63.useState)(function() { - return { - value: initialValue, - callback, - facade: { - get current() { - return ref.value; - }, - set current(value) { - var last3 = ref.value; - if (last3 !== value) { - ref.value = value; - ref.callback(value, last3); - } - } - } - }; - })[0]; - ref.callback = callback; - return ref.facade; -} - -// node_modules/use-callback-ref/dist/es2015/useMergeRef.js -var React32 = __toESM(require_react()); -var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React32.useLayoutEffect : React32.useEffect; -var currentValues = /* @__PURE__ */ new WeakMap(); -function useMergeRefs(refs, defaultValue) { - var callbackRef = useCallbackRef2(defaultValue || null, function(newValue) { - return refs.forEach(function(ref) { - return assignRef(ref, newValue); - }); - }); - useIsomorphicLayoutEffect(function() { - var oldValue = currentValues.get(callbackRef); - if (oldValue) { - var prevRefs_1 = new Set(oldValue); - var nextRefs_1 = new Set(refs); - var current_1 = callbackRef.current; - prevRefs_1.forEach(function(ref) { - if (!nextRefs_1.has(ref)) { - assignRef(ref, null); - } - }); - nextRefs_1.forEach(function(ref) { - if (!prevRefs_1.has(ref)) { - assignRef(ref, current_1); - } - }); - } - currentValues.set(callbackRef, refs); - }, [refs]); - return callbackRef; -} - -// node_modules/use-sidecar/dist/es2015/medium.js -function ItoI(a) { - return a; -} -function innerCreateMedium(defaults2, middleware) { - if (middleware === void 0) { - middleware = ItoI; - } - var buffer = []; - var assigned = false; - var medium = { - read: function() { - if (assigned) { - throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`."); - } - if (buffer.length) { - return buffer[buffer.length - 1]; - } - return defaults2; - }, - useMedium: function(data) { - var item = middleware(data, assigned); - buffer.push(item); - return function() { - buffer = buffer.filter(function(x) { - return x !== item; - }); - }; - }, - assignSyncMedium: function(cb) { - assigned = true; - while (buffer.length) { - var cbs = buffer; - buffer = []; - cbs.forEach(cb); - } - buffer = { - push: function(x) { - return cb(x); - }, - filter: function() { - return buffer; - } - }; - }, - assignMedium: function(cb) { - assigned = true; - var pendingQueue = []; - if (buffer.length) { - var cbs = buffer; - buffer = []; - cbs.forEach(cb); - pendingQueue = buffer; - } - var executeQueue = function() { - var cbs2 = pendingQueue; - pendingQueue = []; - cbs2.forEach(cb); - }; - var cycle = function() { - return Promise.resolve().then(executeQueue); - }; - cycle(); - buffer = { - push: function(x) { - pendingQueue.push(x); - cycle(); - }, - filter: function(filter2) { - pendingQueue = pendingQueue.filter(filter2); - return buffer; - } - }; - } - }; - return medium; -} -function createSidecarMedium(options) { - if (options === void 0) { - options = {}; - } - var medium = innerCreateMedium(null); - medium.options = __assign({ async: true, ssr: false }, options); - return medium; -} - -// node_modules/use-sidecar/dist/es2015/exports.js -var React33 = __toESM(require_react()); -var SideCar = function(_a) { - var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]); - if (!sideCar) { - throw new Error("Sidecar: please provide `sideCar` property to import the right car"); - } - var Target = sideCar.read(); - if (!Target) { - throw new Error("Sidecar medium not found"); - } - return React33.createElement(Target, __assign({}, rest)); -}; -SideCar.isSideCarExport = true; -function exportSidecar(medium, exported) { - medium.useMedium(exported); - return SideCar; -} - -// node_modules/react-remove-scroll/dist/es2015/medium.js -var effectCar = createSidecarMedium(); - -// node_modules/react-remove-scroll/dist/es2015/UI.js -var nothing = function() { - return; -}; -var RemoveScroll = React34.forwardRef(function(props, parentRef) { - var ref = React34.useRef(null); - var _a = React34.useState({ - onScrollCapture: nothing, - onWheelCapture: nothing, - onTouchMoveCapture: nothing - }), callbacks = _a[0], setCallbacks = _a[1]; - var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]); - var SideCar2 = sideCar; - var containerRef = useMergeRefs([ref, parentRef]); - var containerProps = __assign(__assign({}, rest), callbacks); - return React34.createElement(React34.Fragment, null, enabled && React34.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }), forwardProps ? React34.cloneElement(React34.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React34.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)); -}); -RemoveScroll.defaultProps = { - enabled: true, - removeScrollBar: true, - inert: false -}; -RemoveScroll.classNames = { - fullWidth: fullWidthClassName, - zeroRight: zeroRightClassName -}; - -// node_modules/react-remove-scroll/dist/es2015/SideEffect.js -var React37 = __toESM(require_react()); - -// node_modules/react-remove-scroll-bar/dist/es2015/component.js -var React36 = __toESM(require_react()); - -// node_modules/react-style-singleton/dist/es2015/hook.js -var React35 = __toESM(require_react()); - -// node_modules/get-nonce/dist/es2015/index.js -var currentNonce; -var getNonce = function() { - if (currentNonce) { - return currentNonce; - } - if (typeof __webpack_nonce__ !== "undefined") { - return __webpack_nonce__; - } - return void 0; -}; - -// node_modules/react-style-singleton/dist/es2015/singleton.js -function makeStyleTag() { - if (!document) - return null; - var tag = document.createElement("style"); - tag.type = "text/css"; - var nonce = getNonce(); - if (nonce) { - tag.setAttribute("nonce", nonce); - } - return tag; -} -function injectStyles(tag, css) { - if (tag.styleSheet) { - tag.styleSheet.cssText = css; - } else { - tag.appendChild(document.createTextNode(css)); - } -} -function insertStyleTag(tag) { - var head = document.head || document.getElementsByTagName("head")[0]; - head.appendChild(tag); -} -var stylesheetSingleton = function() { - var counter = 0; - var stylesheet = null; - return { - add: function(style) { - if (counter == 0) { - if (stylesheet = makeStyleTag()) { - injectStyles(stylesheet, style); - insertStyleTag(stylesheet); - } - } - counter++; - }, - remove: function() { - counter--; - if (!counter && stylesheet) { - stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet); - stylesheet = null; - } - } - }; -}; - -// node_modules/react-style-singleton/dist/es2015/hook.js -var styleHookSingleton = function() { - var sheet = stylesheetSingleton(); - return function(styles3, isDynamic) { - React35.useEffect(function() { - sheet.add(styles3); - return function() { - sheet.remove(); - }; - }, [styles3 && isDynamic]); - }; -}; - -// node_modules/react-style-singleton/dist/es2015/component.js -var styleSingleton = function() { - var useStyle = styleHookSingleton(); - var Sheet = function(_a) { - var styles3 = _a.styles, dynamic = _a.dynamic; - useStyle(styles3, dynamic); - return null; - }; - return Sheet; -}; - -// node_modules/react-remove-scroll-bar/dist/es2015/utils.js -var zeroGap = { - left: 0, - top: 0, - right: 0, - gap: 0 -}; -var parse = function(x) { - return parseInt(x || "", 10) || 0; -}; -var getOffset = function(gapMode) { - var cs = window.getComputedStyle(document.body); - var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"]; - var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"]; - var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"]; - return [parse(left), parse(top), parse(right)]; -}; -var getGapWidth = function(gapMode) { - if (gapMode === void 0) { - gapMode = "margin"; - } - if (typeof window === "undefined") { - return zeroGap; - } - var offsets = getOffset(gapMode); - var documentWidth = document.documentElement.clientWidth; - var windowWidth = window.innerWidth; - return { - left: offsets[0], - top: offsets[1], - right: offsets[2], - gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]) - }; -}; - -// node_modules/react-remove-scroll-bar/dist/es2015/component.js -var Style = styleSingleton(); -var lockAttribute = "data-scroll-locked"; -var getStyles = function(_a, allowRelative, gapMode, important) { - var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap; - if (gapMode === void 0) { - gapMode = "margin"; - } - return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([ - allowRelative && "position: relative ".concat(important, ";"), - gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "), - gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";") - ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n"); -}; -var getCurrentUseCounter = function() { - var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10); - return isFinite(counter) ? counter : 0; -}; -var useLockAttribute = function() { - React36.useEffect(function() { - document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString()); - return function() { - var newCounter = getCurrentUseCounter() - 1; - if (newCounter <= 0) { - document.body.removeAttribute(lockAttribute); - } else { - document.body.setAttribute(lockAttribute, newCounter.toString()); - } - }; - }, []); -}; -var RemoveScrollBar = function(_a) { - var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b; - useLockAttribute(); - var gap = React36.useMemo(function() { - return getGapWidth(gapMode); - }, [gapMode]); - return React36.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") }); -}; - -// node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js -var passiveSupported = false; -if (typeof window !== "undefined") { - try { - options = Object.defineProperty({}, "passive", { - get: function() { - passiveSupported = true; - return true; - } - }); - window.addEventListener("test", options, options); - window.removeEventListener("test", options, options); - } catch (err) { - passiveSupported = false; - } -} -var options; -var nonPassive = passiveSupported ? { passive: false } : false; - -// node_modules/react-remove-scroll/dist/es2015/handleScroll.js -var alwaysContainsScroll = function(node) { - return node.tagName === "TEXTAREA"; -}; -var elementCanBeScrolled = function(node, overflow) { - var styles3 = window.getComputedStyle(node); - return styles3[overflow] !== "hidden" && !(styles3.overflowY === styles3.overflowX && !alwaysContainsScroll(node) && styles3[overflow] === "visible"); -}; -var elementCouldBeVScrolled = function(node) { - return elementCanBeScrolled(node, "overflowY"); -}; -var elementCouldBeHScrolled = function(node) { - return elementCanBeScrolled(node, "overflowX"); -}; -var locationCouldBeScrolled = function(axis, node) { - var ownerDocument = node.ownerDocument; - var current = node; - do { - if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) { - current = current.host; - } - var isScrollable = elementCouldBeScrolled(axis, current); - if (isScrollable) { - var _a = getScrollVariables(axis, current), s = _a[1], d = _a[2]; - if (s > d) { - return true; - } - } - current = current.parentNode; - } while (current && current !== ownerDocument.body); - return false; -}; -var getVScrollVariables = function(_a) { - var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight; - return [ - scrollTop, - scrollHeight, - clientHeight - ]; -}; -var getHScrollVariables = function(_a) { - var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth; - return [ - scrollLeft, - scrollWidth, - clientWidth - ]; -}; -var elementCouldBeScrolled = function(axis, node) { - return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node); -}; -var getScrollVariables = function(axis, node) { - return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node); -}; -var getDirectionFactor = function(axis, direction) { - return axis === "h" && direction === "rtl" ? -1 : 1; -}; -var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) { - var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction); - var delta = directionFactor * sourceDelta; - var target = event.target; - var targetInLock = endTarget.contains(target); - var shouldCancelScroll = false; - var isDeltaPositive = delta > 0; - var availableScroll = 0; - var availableScrollTop = 0; - do { - var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2]; - var elementScroll = scroll_1 - capacity - directionFactor * position; - if (position || elementScroll) { - if (elementCouldBeScrolled(axis, target)) { - availableScroll += elementScroll; - availableScrollTop += position; - } - } - if (target instanceof ShadowRoot) { - target = target.host; - } else { - target = target.parentNode; - } - } while (!targetInLock && target !== document.body || targetInLock && (endTarget.contains(target) || endTarget === target)); - if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) { - shouldCancelScroll = true; - } else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) { - shouldCancelScroll = true; - } - return shouldCancelScroll; -}; - -// node_modules/react-remove-scroll/dist/es2015/SideEffect.js -var getTouchXY = function(event) { - return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0]; -}; -var getDeltaXY = function(event) { - return [event.deltaX, event.deltaY]; -}; -var extractRef = function(ref) { - return ref && "current" in ref ? ref.current : ref; -}; -var deltaCompare = function(x, y) { - return x[0] === y[0] && x[1] === y[1]; -}; -var generateStyle = function(id) { - return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); -}; -var idCounter = 0; -var lockStack = []; -function RemoveScrollSideCar(props) { - var shouldPreventQueue = React37.useRef([]); - var touchStartRef = React37.useRef([0, 0]); - var activeAxis = React37.useRef(); - var id = React37.useState(idCounter++)[0]; - var Style2 = React37.useState(styleSingleton)[0]; - var lastProps = React37.useRef(props); - React37.useEffect(function() { - lastProps.current = props; - }, [props]); - React37.useEffect(function() { - if (props.inert) { - document.body.classList.add("block-interactivity-".concat(id)); - var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean); - allow_1.forEach(function(el) { - return el.classList.add("allow-interactivity-".concat(id)); - }); - return function() { - document.body.classList.remove("block-interactivity-".concat(id)); - allow_1.forEach(function(el) { - return el.classList.remove("allow-interactivity-".concat(id)); - }); - }; - } - return; - }, [props.inert, props.lockRef.current, props.shards]); - var shouldCancelEvent = React37.useCallback(function(event, parent) { - if ("touches" in event && event.touches.length === 2) { - return !lastProps.current.allowPinchZoom; - } - var touch = getTouchXY(event); - var touchStart = touchStartRef.current; - var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0]; - var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1]; - var currentAxis; - var target = event.target; - var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v"; - if ("touches" in event && moveDirection === "h" && target.type === "range") { - return false; - } - var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target); - if (!canBeScrolledInMainDirection) { - return true; - } - if (canBeScrolledInMainDirection) { - currentAxis = moveDirection; - } else { - currentAxis = moveDirection === "v" ? "h" : "v"; - canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target); - } - if (!canBeScrolledInMainDirection) { - return false; - } - if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) { - activeAxis.current = currentAxis; - } - if (!currentAxis) { - return true; - } - var cancelingAxis = activeAxis.current || currentAxis; - return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true); - }, []); - var shouldPrevent = React37.useCallback(function(_event) { - var event = _event; - if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) { - return; - } - var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event); - var sourceEvent = shouldPreventQueue.current.filter(function(e) { - return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta); - })[0]; - if (sourceEvent && sourceEvent.should) { - if (event.cancelable) { - event.preventDefault(); - } - return; - } - if (!sourceEvent) { - var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) { - return node.contains(event.target); - }); - var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation; - if (shouldStop) { - if (event.cancelable) { - event.preventDefault(); - } - } - } - }, []); - var shouldCancel = React37.useCallback(function(name, delta, target, should) { - var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) }; - shouldPreventQueue.current.push(event); - setTimeout(function() { - shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) { - return e !== event; - }); - }, 1); - }, []); - var scrollTouchStart = React37.useCallback(function(event) { - touchStartRef.current = getTouchXY(event); - activeAxis.current = void 0; - }, []); - var scrollWheel = React37.useCallback(function(event) { - shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current)); - }, []); - var scrollTouchMove = React37.useCallback(function(event) { - shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current)); - }, []); - React37.useEffect(function() { - lockStack.push(Style2); - props.setCallbacks({ - onScrollCapture: scrollWheel, - onWheelCapture: scrollWheel, - onTouchMoveCapture: scrollTouchMove - }); - document.addEventListener("wheel", shouldPrevent, nonPassive); - document.addEventListener("touchmove", shouldPrevent, nonPassive); - document.addEventListener("touchstart", scrollTouchStart, nonPassive); - return function() { - lockStack = lockStack.filter(function(inst3) { - return inst3 !== Style2; - }); - document.removeEventListener("wheel", shouldPrevent, nonPassive); - document.removeEventListener("touchmove", shouldPrevent, nonPassive); - document.removeEventListener("touchstart", scrollTouchStart, nonPassive); - }; - }, []); - var removeScrollBar = props.removeScrollBar, inert = props.inert; - return React37.createElement(React37.Fragment, null, inert ? React37.createElement(Style2, { styles: generateStyle(id) }) : null, removeScrollBar ? React37.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null); -} -function getOutermostShadowParent(node) { - var shadowParent = null; - while (node !== null) { - if (node instanceof ShadowRoot) { - shadowParent = node.host; - node = node.host; - } - node = node.parentNode; - } - return shadowParent; -} - -// node_modules/react-remove-scroll/dist/es2015/sidecar.js -var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar); - -// node_modules/react-remove-scroll/dist/es2015/Combination.js -var ReactRemoveScroll = React38.forwardRef(function(props, ref) { - return React38.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: sidecar_default })); -}); -ReactRemoveScroll.classNames = RemoveScroll.classNames; -var Combination_default = ReactRemoveScroll; - -// node_modules/aria-hidden/dist/es2015/index.js -var getDefaultParent = function(originalTarget) { - if (typeof document === "undefined") { - return null; - } - var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget; - return sampleTarget.ownerDocument.body; -}; -var counterMap = /* @__PURE__ */ new WeakMap(); -var uncontrolledNodes = /* @__PURE__ */ new WeakMap(); -var markerMap = {}; -var lockCount = 0; -var unwrapHost = function(node) { - return node && (node.host || unwrapHost(node.parentNode)); -}; -var correctTargets = function(parent, targets) { - return targets.map(function(target) { - if (parent.contains(target)) { - return target; - } - var correctedTarget = unwrapHost(target); - if (correctedTarget && parent.contains(correctedTarget)) { - return correctedTarget; - } - console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing"); - return null; - }).filter(function(x) { - return Boolean(x); - }); -}; -var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) { - var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]); - if (!markerMap[markerName]) { - markerMap[markerName] = /* @__PURE__ */ new WeakMap(); - } - var markerCounter = markerMap[markerName]; - var hiddenNodes = []; - var elementsToKeep = /* @__PURE__ */ new Set(); - var elementsToStop = new Set(targets); - var keep = function(el) { - if (!el || elementsToKeep.has(el)) { - return; - } - elementsToKeep.add(el); - keep(el.parentNode); - }; - targets.forEach(keep); - var deep = function(parent) { - if (!parent || elementsToStop.has(parent)) { - return; - } - Array.prototype.forEach.call(parent.children, function(node) { - if (elementsToKeep.has(node)) { - deep(node); - } else { - try { - var attr = node.getAttribute(controlAttribute); - var alreadyHidden = attr !== null && attr !== "false"; - var counterValue = (counterMap.get(node) || 0) + 1; - var markerValue = (markerCounter.get(node) || 0) + 1; - counterMap.set(node, counterValue); - markerCounter.set(node, markerValue); - hiddenNodes.push(node); - if (counterValue === 1 && alreadyHidden) { - uncontrolledNodes.set(node, true); - } - if (markerValue === 1) { - node.setAttribute(markerName, "true"); - } - if (!alreadyHidden) { - node.setAttribute(controlAttribute, "true"); - } - } catch (e) { - console.error("aria-hidden: cannot operate on ", node, e); - } - } - }); - }; - deep(parentNode); - elementsToKeep.clear(); - lockCount++; - return function() { - hiddenNodes.forEach(function(node) { - var counterValue = counterMap.get(node) - 1; - var markerValue = markerCounter.get(node) - 1; - counterMap.set(node, counterValue); - markerCounter.set(node, markerValue); - if (!counterValue) { - if (!uncontrolledNodes.has(node)) { - node.removeAttribute(controlAttribute); - } - uncontrolledNodes.delete(node); - } - if (!markerValue) { - node.removeAttribute(markerName); - } - }); - lockCount--; - if (!lockCount) { - counterMap = /* @__PURE__ */ new WeakMap(); - counterMap = /* @__PURE__ */ new WeakMap(); - uncontrolledNodes = /* @__PURE__ */ new WeakMap(); - markerMap = {}; - } - }; -}; -var hideOthers = function(originalTarget, parentNode, markerName) { - if (markerName === void 0) { - markerName = "data-aria-hidden"; - } - var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]); - var activeParentNode = parentNode || getDefaultParent(originalTarget); - if (!activeParentNode) { - return function() { - return null; - }; - } - targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live]"))); - return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden"); -}; - -// node_modules/@radix-ui/react-dialog/dist/index.mjs -var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1); -"use client"; -var DIALOG_NAME = "Dialog"; -var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME); -var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME); -var Dialog = (props) => { - const { - __scopeDialog, - children, - open: openProp, - defaultOpen, - onOpenChange, - modal = true - } = props; - const triggerRef = React39.useRef(null); - const contentRef = React39.useRef(null); - const [open = false, setOpen] = useControllableState({ - prop: openProp, - defaultProp: defaultOpen, - onChange: onOpenChange - }); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DialogProvider, { - scope: __scopeDialog, - triggerRef, - contentRef, - contentId: useId2(), - titleId: useId2(), - descriptionId: useId2(), - open, - onOpenChange: setOpen, - onOpenToggle: React39.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]), - modal, - children - }); -}; -Dialog.displayName = DIALOG_NAME; -var TRIGGER_NAME = "DialogTrigger"; -var DialogTrigger = React39.forwardRef((props, forwardedRef) => { - const { __scopeDialog, ...triggerProps } = props; - const context = useDialogContext(TRIGGER_NAME, __scopeDialog); - const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Primitive.button, { - type: "button", - "aria-haspopup": "dialog", - "aria-expanded": context.open, - "aria-controls": context.contentId, - "data-state": getState(context.open), - ...triggerProps, - ref: composedTriggerRef, - onClick: composeEventHandlers(props.onClick, context.onOpenToggle) - }); -}); -DialogTrigger.displayName = TRIGGER_NAME; -var PORTAL_NAME2 = "DialogPortal"; -var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME2, { - forceMount: void 0 -}); -var DialogPortal = (props) => { - const { __scopeDialog, forceMount, children, container } = props; - const context = useDialogContext(PORTAL_NAME2, __scopeDialog); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PortalProvider, { scope: __scopeDialog, forceMount, children: React39.Children.map(children, (child) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Portal, { asChild: true, container, children: child }) })) }); -}; -DialogPortal.displayName = PORTAL_NAME2; -var OVERLAY_NAME = "DialogOverlay"; -var DialogOverlay = React39.forwardRef((props, forwardedRef) => { - const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog); - const { forceMount = portalContext.forceMount, ...overlayProps } = props; - const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog); - return context.modal ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null; -}); -DialogOverlay.displayName = OVERLAY_NAME; -var DialogOverlayImpl = React39.forwardRef((props, forwardedRef) => { - const { __scopeDialog, ...overlayProps } = props; - const context = useDialogContext(OVERLAY_NAME, __scopeDialog); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Combination_default, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Primitive.div, { - "data-state": getState(context.open), - ...overlayProps, - ref: forwardedRef, - style: { pointerEvents: "auto", ...overlayProps.style } - }) }); -}); -var CONTENT_NAME = "DialogContent"; -var DialogContent = React39.forwardRef((props, forwardedRef) => { - const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog); - const { forceMount = portalContext.forceMount, ...contentProps } = props; - const context = useDialogContext(CONTENT_NAME, props.__scopeDialog); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) }); -}); -DialogContent.displayName = CONTENT_NAME; -var DialogContentModal = React39.forwardRef((props, forwardedRef) => { - const context = useDialogContext(CONTENT_NAME, props.__scopeDialog); - const contentRef = React39.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef); - React39.useEffect(() => { - const content = contentRef.current; - if (content) - return hideOthers(content); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DialogContentImpl, { - ...props, - ref: composedRefs, - trapFocus: context.open, - disableOutsidePointerEvents: true, - onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => { - event.preventDefault(); - context.triggerRef.current?.focus(); - }), - onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => { - const originalEvent = event.detail.originalEvent; - const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true; - const isRightClick = originalEvent.button === 2 || ctrlLeftClick; - if (isRightClick) - event.preventDefault(); - }), - onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => event.preventDefault()) - }); -}); -var DialogContentNonModal = React39.forwardRef((props, forwardedRef) => { - const context = useDialogContext(CONTENT_NAME, props.__scopeDialog); - const hasInteractedOutsideRef = React39.useRef(false); - const hasPointerDownOutsideRef = React39.useRef(false); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DialogContentImpl, { - ...props, - ref: forwardedRef, - trapFocus: false, - disableOutsidePointerEvents: false, - onCloseAutoFocus: (event) => { - props.onCloseAutoFocus?.(event); - if (!event.defaultPrevented) { - if (!hasInteractedOutsideRef.current) - context.triggerRef.current?.focus(); - event.preventDefault(); - } - hasInteractedOutsideRef.current = false; - hasPointerDownOutsideRef.current = false; - }, - onInteractOutside: (event) => { - props.onInteractOutside?.(event); - if (!event.defaultPrevented) { - hasInteractedOutsideRef.current = true; - if (event.detail.originalEvent.type === "pointerdown") { - hasPointerDownOutsideRef.current = true; - } - } - const target = event.target; - const targetIsTrigger = context.triggerRef.current?.contains(target); - if (targetIsTrigger) - event.preventDefault(); - if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) { - event.preventDefault(); - } - } - }); -}); -var DialogContentImpl = React39.forwardRef((props, forwardedRef) => { - const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props; - const context = useDialogContext(CONTENT_NAME, __scopeDialog); - const contentRef = React39.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, contentRef); - useFocusGuards(); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(FocusScope, { - asChild: true, - loop: true, - trapped: trapFocus, - onMountAutoFocus: onOpenAutoFocus, - onUnmountAutoFocus: onCloseAutoFocus, - children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DismissableLayer, { - role: "dialog", - id: context.contentId, - "aria-describedby": context.descriptionId, - "aria-labelledby": context.titleId, - "data-state": getState(context.open), - ...contentProps, - ref: composedRefs, - onDismiss: () => context.onOpenChange(false) - }) - }), - /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(TitleWarning, { titleId: context.titleId }), - /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DescriptionWarning, { contentRef, descriptionId: context.descriptionId }) - ] }) - ] }); -}); -var TITLE_NAME = "DialogTitle"; -var DialogTitle = React39.forwardRef((props, forwardedRef) => { - const { __scopeDialog, ...titleProps } = props; - const context = useDialogContext(TITLE_NAME, __scopeDialog); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef }); -}); -DialogTitle.displayName = TITLE_NAME; -var DESCRIPTION_NAME = "DialogDescription"; -var DialogDescription = React39.forwardRef((props, forwardedRef) => { - const { __scopeDialog, ...descriptionProps } = props; - const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef }); -}); -DialogDescription.displayName = DESCRIPTION_NAME; -var CLOSE_NAME = "DialogClose"; -var DialogClose = React39.forwardRef((props, forwardedRef) => { - const { __scopeDialog, ...closeProps } = props; - const context = useDialogContext(CLOSE_NAME, __scopeDialog); - return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Primitive.button, { - type: "button", - ...closeProps, - ref: forwardedRef, - onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false)) - }); -}); -DialogClose.displayName = CLOSE_NAME; -function getState(open) { - return open ? "open" : "closed"; -} -var TITLE_WARNING_NAME = "DialogTitleWarning"; -var [WarningProvider, useWarningContext] = createContext22(TITLE_WARNING_NAME, { - contentName: CONTENT_NAME, - titleName: TITLE_NAME, - docsSlug: "dialog" -}); -var TitleWarning = ({ titleId }) => { - const titleWarningContext = useWarningContext(TITLE_WARNING_NAME); - const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users. - -If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component. - -For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`; - React39.useEffect(() => { - if (titleId) { - const hasTitle = document.getElementById(titleId); - if (!hasTitle) - console.error(MESSAGE); - } - }, [MESSAGE, titleId]); - return null; -}; -var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning"; -var DescriptionWarning = ({ contentRef, descriptionId }) => { - const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME); - const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`; - React39.useEffect(() => { - const describedById = contentRef.current?.getAttribute("aria-describedby"); - if (descriptionId && describedById) { - const hasDescription = document.getElementById(descriptionId); - if (!hasDescription) - console.warn(MESSAGE); - } - }, [MESSAGE, contentRef, descriptionId]); - return null; -}; -var Root2 = Dialog; -var Portal2 = DialogPortal; -var Overlay = DialogOverlay; -var Content = DialogContent; - -// node_modules/tldraw/dist-esm/lib/ui/components/Dialogs.mjs -var import_react65 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/context/dialogs.mjs -var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1); -var import_react64 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/context/events.mjs -var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1); -var React40 = __toESM(require_react(), 1); -var defaultEventHandler = () => void 0; -var EventsContext = React40.createContext(null); -function UiEventsProvider({ onEvent, children }) { - return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventsContext.Provider, { value: onEvent ?? defaultEventHandler, children }); -} -function useUiEvents() { - const eventHandler2 = React40.useContext(EventsContext); - return eventHandler2 ?? defaultEventHandler; -} - -// node_modules/tldraw/dist-esm/lib/ui/context/dialogs.mjs -var DialogsContext = (0, import_react64.createContext)(null); -function DialogsProvider({ children }) { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const [dialogs, setDialogs] = (0, import_react64.useState)([]); - const addDialog = (0, import_react64.useCallback)((dialog) => { - const id = dialog.id ?? uniqueId(); - setDialogs((d) => { - return [...d.filter((m) => m.id !== dialog.id), { ...dialog, id }]; - }); - trackEvent("open-menu", { source: "dialog", id }); - editor.addOpenMenu(id); - return id; - }, [editor, trackEvent]); - const updateDialog = (0, import_react64.useCallback)((id, newDialogData) => { - setDialogs((d) => d.map((m) => { - if (m.id === id) { - return { - ...m, - ...newDialogData - }; - } - return m; - })); - trackEvent("open-menu", { source: "dialog", id }); - editor.addOpenMenu(id); - return id; - }, [editor, trackEvent]); - const removeDialog = (0, import_react64.useCallback)((id) => { - setDialogs((d) => d.filter((m) => { - if (m.id === id) { - m.onClose?.(); - return false; - } - return true; - })); - trackEvent("close-menu", { source: "dialog", id }); - editor.deleteOpenMenu(id); - return id; - }, [editor, trackEvent]); - const clearDialogs = (0, import_react64.useCallback)(() => { - setDialogs((d) => { - d.forEach((m) => { - m.onClose?.(); - trackEvent("close-menu", { source: "dialog", id: m.id }); - editor.deleteOpenMenu(m.id); - }); - return []; - }); - }, [editor, trackEvent]); - return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DialogsContext.Provider, { - value: { dialogs, addDialog, removeDialog, clearDialogs, updateDialog }, - children - }); -} -function useDialogs() { - const ctx = (0, import_react64.useContext)(DialogsContext); - if (!ctx) { - throw new Error("useDialogs must be used within a DialogsProvider"); - } - return ctx; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Dialogs.mjs -var Dialog2 = ({ id, component: ModalContent, onClose }) => { - const { removeDialog } = useDialogs(); - const container = useContainer(); - const handleOpenChange = (0, import_react65.useCallback)((isOpen) => { - if (!isOpen) { - if (onClose) { - try { - onClose(); - } catch (err) { - console.warn(err); - } - } - removeDialog(id); - } - }, [id, onClose, removeDialog]); - return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Root2, { onOpenChange: handleOpenChange, defaultOpen: true, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Portal2, { container, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Overlay, { - dir: "ltr", - className: "tlui-dialog__overlay", - onClick: (e) => { - if (e.target === e.currentTarget) - handleOpenChange(false); - }, - children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Content, { dir: "ltr", className: "tlui-dialog__content", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ModalContent, { onClose: () => handleOpenChange(false) }) }) - }) }) }); -}; -function _Dialogs() { - const { dialogs } = useDialogs(); - return dialogs.map((dialog) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Dialog2, { ...dialog }, dialog.id)); -} -var Dialogs = import_react65.default.memo(_Dialogs); - -// node_modules/tldraw/dist-esm/lib/ui/components/FollowingIndicator.mjs -var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1); -function FollowingIndicator() { - const editor = useEditor(); - const followingUserId = useValue("follow", () => editor.getInstanceState().followingUserId, [ - editor - ]); - if (!followingUserId) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(FollowingIndicatorInner, { userId: followingUserId }); -} -function FollowingIndicatorInner({ userId }) { - const presence = usePresence(userId); - if (!presence) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "tlui-following-indicator", style: { borderColor: presence.color } }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toasts.mjs -var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@radix-ui/react-toast/dist/index.mjs -var React44 = __toESM(require_react(), 1); -var ReactDOM4 = __toESM(require_react_dom(), 1); - -// node_modules/@radix-ui/react-collection/dist/index.mjs -var import_react66 = __toESM(require_react(), 1); -var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1); -"use client"; -function createCollection(name) { - const PROVIDER_NAME2 = name + "CollectionProvider"; - const [createCollectionContext, createCollectionScope5] = createContextScope(PROVIDER_NAME2); - const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME2, { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }); - const CollectionProvider = (props) => { - const { scope, children } = props; - const ref = import_react66.default.useRef(null); - const itemMap = import_react66.default.useRef(/* @__PURE__ */ new Map()).current; - return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children }); - }; - CollectionProvider.displayName = PROVIDER_NAME2; - const COLLECTION_SLOT_NAME = name + "CollectionSlot"; - const CollectionSlot = import_react66.default.forwardRef((props, forwardedRef) => { - const { scope, children } = props; - const context = useCollectionContext(COLLECTION_SLOT_NAME, scope); - const composedRefs = useComposedRefs(forwardedRef, context.collectionRef); - return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Slot, { ref: composedRefs, children }); - }); - CollectionSlot.displayName = COLLECTION_SLOT_NAME; - const ITEM_SLOT_NAME = name + "CollectionItemSlot"; - const ITEM_DATA_ATTR = "data-radix-collection-item"; - const CollectionItemSlot = import_react66.default.forwardRef((props, forwardedRef) => { - const { scope, children, ...itemData } = props; - const ref = import_react66.default.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - const context = useCollectionContext(ITEM_SLOT_NAME, scope); - import_react66.default.useEffect(() => { - context.itemMap.set(ref, { ref, ...itemData }); - return () => void context.itemMap.delete(ref); - }); - return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children }); - }); - CollectionItemSlot.displayName = ITEM_SLOT_NAME; - function useCollection5(scope) { - const context = useCollectionContext(name + "CollectionConsumer", scope); - const getItems = import_react66.default.useCallback(() => { - const collectionNode = context.collectionRef.current; - if (!collectionNode) - return []; - const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)); - const items = Array.from(context.itemMap.values()); - const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)); - return orderedItems; - }, [context.collectionRef, context.itemMap]); - return getItems; - } - return [ - { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot }, - useCollection5, - createCollectionScope5 - ]; -} - -// node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs -var React43 = __toESM(require_react(), 1); -var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1); -var NAME = "VisuallyHidden"; -var VisuallyHidden = React43.forwardRef((props, forwardedRef) => { - return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Primitive.span, { - ...props, - ref: forwardedRef, - style: { - position: "absolute", - border: 0, - width: 1, - height: 1, - padding: 0, - margin: -1, - overflow: "hidden", - clip: "rect(0, 0, 0, 0)", - whiteSpace: "nowrap", - wordWrap: "normal", - ...props.style - } - }); -}); -VisuallyHidden.displayName = NAME; - -// node_modules/@radix-ui/react-toast/dist/index.mjs -var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1); -"use client"; -var PROVIDER_NAME = "ToastProvider"; -var [Collection, useCollection, createCollectionScope] = createCollection("Toast"); -var [createToastContext, createToastScope] = createContextScope("Toast", [createCollectionScope]); -var [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME); -var ToastProvider = (props) => { - const { - __scopeToast, - label = "Notification", - duration = 5e3, - swipeDirection = "right", - swipeThreshold = 50, - children - } = props; - const [viewport, setViewport] = React44.useState(null); - const [toastCount, setToastCount] = React44.useState(0); - const isFocusedToastEscapeKeyDownRef = React44.useRef(false); - const isClosePausedRef = React44.useRef(false); - if (!label.trim()) { - console.error(`Invalid prop \`label\` supplied to \`${PROVIDER_NAME}\`. Expected non-empty \`string\`.`); - } - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Collection.Provider, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastProviderProvider, { - scope: __scopeToast, - label, - duration, - swipeDirection, - swipeThreshold, - toastCount, - viewport, - onViewportChange: setViewport, - onToastAdd: React44.useCallback(() => setToastCount((prevCount) => prevCount + 1), []), - onToastRemove: React44.useCallback(() => setToastCount((prevCount) => prevCount - 1), []), - isFocusedToastEscapeKeyDownRef, - isClosePausedRef, - children - }) }); -}; -ToastProvider.displayName = PROVIDER_NAME; -var VIEWPORT_NAME = "ToastViewport"; -var VIEWPORT_DEFAULT_HOTKEY = ["F8"]; -var VIEWPORT_PAUSE = "toast.viewportPause"; -var VIEWPORT_RESUME = "toast.viewportResume"; -var ToastViewport = React44.forwardRef((props, forwardedRef) => { - const { - __scopeToast, - hotkey = VIEWPORT_DEFAULT_HOTKEY, - label = "Notifications ({hotkey})", - ...viewportProps - } = props; - const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast); - const getItems = useCollection(__scopeToast); - const wrapperRef = React44.useRef(null); - const headFocusProxyRef = React44.useRef(null); - const tailFocusProxyRef = React44.useRef(null); - const ref = React44.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange); - const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""); - const hasToasts = context.toastCount > 0; - React44.useEffect(() => { - const handleKeyDown = (event) => { - const isHotkeyPressed = hotkey.every((key) => event[key] || event.code === key); - if (isHotkeyPressed) - ref.current?.focus(); - }; - document.addEventListener("keydown", handleKeyDown); - return () => document.removeEventListener("keydown", handleKeyDown); - }, [hotkey]); - React44.useEffect(() => { - const wrapper = wrapperRef.current; - const viewport = ref.current; - if (hasToasts && wrapper && viewport) { - const handlePause = () => { - if (!context.isClosePausedRef.current) { - const pauseEvent = new CustomEvent(VIEWPORT_PAUSE); - viewport.dispatchEvent(pauseEvent); - context.isClosePausedRef.current = true; - } - }; - const handleResume = () => { - if (context.isClosePausedRef.current) { - const resumeEvent = new CustomEvent(VIEWPORT_RESUME); - viewport.dispatchEvent(resumeEvent); - context.isClosePausedRef.current = false; - } - }; - const handleFocusOutResume = (event) => { - const isFocusMovingOutside = !wrapper.contains(event.relatedTarget); - if (isFocusMovingOutside) - handleResume(); - }; - const handlePointerLeaveResume = () => { - const isFocusInside = wrapper.contains(document.activeElement); - if (!isFocusInside) - handleResume(); - }; - wrapper.addEventListener("focusin", handlePause); - wrapper.addEventListener("focusout", handleFocusOutResume); - wrapper.addEventListener("pointermove", handlePause); - wrapper.addEventListener("pointerleave", handlePointerLeaveResume); - window.addEventListener("blur", handlePause); - window.addEventListener("focus", handleResume); - return () => { - wrapper.removeEventListener("focusin", handlePause); - wrapper.removeEventListener("focusout", handleFocusOutResume); - wrapper.removeEventListener("pointermove", handlePause); - wrapper.removeEventListener("pointerleave", handlePointerLeaveResume); - window.removeEventListener("blur", handlePause); - window.removeEventListener("focus", handleResume); - }; - } - }, [hasToasts, context.isClosePausedRef]); - const getSortedTabbableCandidates = React44.useCallback(({ tabbingDirection }) => { - const toastItems = getItems(); - const tabbableCandidates = toastItems.map((toastItem) => { - const toastNode = toastItem.ref.current; - const toastTabbableCandidates = [toastNode, ...getTabbableCandidates2(toastNode)]; - return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse(); - }); - return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat(); - }, [getItems]); - React44.useEffect(() => { - const viewport = ref.current; - if (viewport) { - const handleKeyDown = (event) => { - const isMetaKey = event.altKey || event.ctrlKey || event.metaKey; - const isTabKey = event.key === "Tab" && !isMetaKey; - if (isTabKey) { - const focusedElement = document.activeElement; - const isTabbingBackwards = event.shiftKey; - const targetIsViewport = event.target === viewport; - if (targetIsViewport && isTabbingBackwards) { - headFocusProxyRef.current?.focus(); - return; - } - const tabbingDirection = isTabbingBackwards ? "backwards" : "forwards"; - const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection }); - const index2 = sortedCandidates.findIndex((candidate) => candidate === focusedElement); - if (focusFirst2(sortedCandidates.slice(index2 + 1))) { - event.preventDefault(); - } else { - isTabbingBackwards ? headFocusProxyRef.current?.focus() : tailFocusProxyRef.current?.focus(); - } - } - }; - viewport.addEventListener("keydown", handleKeyDown); - return () => viewport.removeEventListener("keydown", handleKeyDown); - } - }, [getItems, getSortedTabbableCandidates]); - return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(Branch, { - ref: wrapperRef, - role: "region", - "aria-label": label.replace("{hotkey}", hotkeyLabel), - tabIndex: -1, - style: { pointerEvents: hasToasts ? void 0 : "none" }, - children: [ - hasToasts && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(FocusProxy, { - ref: headFocusProxyRef, - onFocusFromOutsideViewport: () => { - const tabbableCandidates = getSortedTabbableCandidates({ - tabbingDirection: "forwards" - }); - focusFirst2(tabbableCandidates); - } - }), - /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Collection.Slot, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Primitive.ol, { tabIndex: -1, ...viewportProps, ref: composedRefs }) }), - hasToasts && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(FocusProxy, { - ref: tailFocusProxyRef, - onFocusFromOutsideViewport: () => { - const tabbableCandidates = getSortedTabbableCandidates({ - tabbingDirection: "backwards" - }); - focusFirst2(tabbableCandidates); - } - }) - ] - }); -}); -ToastViewport.displayName = VIEWPORT_NAME; -var FOCUS_PROXY_NAME = "ToastFocusProxy"; -var FocusProxy = React44.forwardRef((props, forwardedRef) => { - const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props; - const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast); - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { - "aria-hidden": true, - tabIndex: 0, - ...proxyProps, - ref: forwardedRef, - style: { position: "fixed" }, - onFocus: (event) => { - const prevFocusedElement = event.relatedTarget; - const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement); - if (isFocusFromOutsideViewport) - onFocusFromOutsideViewport(); - } - }); -}); -FocusProxy.displayName = FOCUS_PROXY_NAME; -var TOAST_NAME = "Toast"; -var TOAST_SWIPE_START = "toast.swipeStart"; -var TOAST_SWIPE_MOVE = "toast.swipeMove"; -var TOAST_SWIPE_CANCEL = "toast.swipeCancel"; -var TOAST_SWIPE_END = "toast.swipeEnd"; -var Toast = React44.forwardRef((props, forwardedRef) => { - const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props; - const [open = true, setOpen] = useControllableState({ - prop: openProp, - defaultProp: defaultOpen, - onChange: onOpenChange - }); - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Presence, { present: forceMount || open, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastImpl, { - open, - ...toastProps, - ref: forwardedRef, - onClose: () => setOpen(false), - onPause: useCallbackRef(props.onPause), - onResume: useCallbackRef(props.onResume), - onSwipeStart: composeEventHandlers(props.onSwipeStart, (event) => { - event.currentTarget.setAttribute("data-swipe", "start"); - }), - onSwipeMove: composeEventHandlers(props.onSwipeMove, (event) => { - const { x, y } = event.detail.delta; - event.currentTarget.setAttribute("data-swipe", "move"); - event.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${x}px`); - event.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${y}px`); - }), - onSwipeCancel: composeEventHandlers(props.onSwipeCancel, (event) => { - event.currentTarget.setAttribute("data-swipe", "cancel"); - event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"); - event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"); - event.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"); - event.currentTarget.style.removeProperty("--radix-toast-swipe-end-y"); - }), - onSwipeEnd: composeEventHandlers(props.onSwipeEnd, (event) => { - const { x, y } = event.detail.delta; - event.currentTarget.setAttribute("data-swipe", "end"); - event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"); - event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"); - event.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${x}px`); - event.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${y}px`); - setOpen(false); - }) - }) }); -}); -Toast.displayName = TOAST_NAME; -var [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, { - onClose() { - } -}); -var ToastImpl = React44.forwardRef((props, forwardedRef) => { - const { - __scopeToast, - type = "foreground", - duration: durationProp, - open, - onClose, - onEscapeKeyDown, - onPause, - onResume, - onSwipeStart, - onSwipeMove, - onSwipeCancel, - onSwipeEnd, - ...toastProps - } = props; - const context = useToastProviderContext(TOAST_NAME, __scopeToast); - const [node, setNode] = React44.useState(null); - const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2)); - const pointerStartRef = React44.useRef(null); - const swipeDeltaRef = React44.useRef(null); - const duration = durationProp || context.duration; - const closeTimerStartTimeRef = React44.useRef(0); - const closeTimerRemainingTimeRef = React44.useRef(duration); - const closeTimerRef = React44.useRef(0); - const { onToastAdd, onToastRemove } = context; - const handleClose = useCallbackRef(() => { - const isFocusInToast = node?.contains(document.activeElement); - if (isFocusInToast) - context.viewport?.focus(); - onClose(); - }); - const startTimer = React44.useCallback((duration2) => { - if (!duration2 || duration2 === Infinity) - return; - window.clearTimeout(closeTimerRef.current); - closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime(); - closeTimerRef.current = window.setTimeout(handleClose, duration2); - }, [handleClose]); - React44.useEffect(() => { - const viewport = context.viewport; - if (viewport) { - const handleResume = () => { - startTimer(closeTimerRemainingTimeRef.current); - onResume?.(); - }; - const handlePause = () => { - const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current; - closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime; - window.clearTimeout(closeTimerRef.current); - onPause?.(); - }; - viewport.addEventListener(VIEWPORT_PAUSE, handlePause); - viewport.addEventListener(VIEWPORT_RESUME, handleResume); - return () => { - viewport.removeEventListener(VIEWPORT_PAUSE, handlePause); - viewport.removeEventListener(VIEWPORT_RESUME, handleResume); - }; - } - }, [context.viewport, duration, onPause, onResume, startTimer]); - React44.useEffect(() => { - if (open && !context.isClosePausedRef.current) - startTimer(duration); - }, [open, duration, context.isClosePausedRef, startTimer]); - React44.useEffect(() => { - onToastAdd(); - return () => onToastRemove(); - }, [onToastAdd, onToastRemove]); - const announceTextContent = React44.useMemo(() => { - return node ? getAnnounceTextContent(node) : null; - }, [node]); - if (!context.viewport) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [ - announceTextContent && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastAnnounce, { - __scopeToast, - role: "status", - "aria-live": type === "foreground" ? "assertive" : "polite", - "aria-atomic": true, - children: announceTextContent - }), - /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastInteractiveProvider, { scope: __scopeToast, onClose: handleClose, children: ReactDOM4.createPortal(/* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Collection.ItemSlot, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Root, { - asChild: true, - onEscapeKeyDown: composeEventHandlers(onEscapeKeyDown, () => { - if (!context.isFocusedToastEscapeKeyDownRef.current) - handleClose(); - context.isFocusedToastEscapeKeyDownRef.current = false; - }), - children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Primitive.li, { - role: "status", - "aria-live": "off", - "aria-atomic": true, - tabIndex: 0, - "data-state": open ? "open" : "closed", - "data-swipe-direction": context.swipeDirection, - ...toastProps, - ref: composedRefs, - style: { userSelect: "none", touchAction: "none", ...props.style }, - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - if (event.key !== "Escape") - return; - onEscapeKeyDown?.(event.nativeEvent); - if (!event.nativeEvent.defaultPrevented) { - context.isFocusedToastEscapeKeyDownRef.current = true; - handleClose(); - } - }), - onPointerDown: composeEventHandlers(props.onPointerDown, (event) => { - if (event.button !== 0) - return; - pointerStartRef.current = { x: event.clientX, y: event.clientY }; - }), - onPointerMove: composeEventHandlers(props.onPointerMove, (event) => { - if (!pointerStartRef.current) - return; - const x = event.clientX - pointerStartRef.current.x; - const y = event.clientY - pointerStartRef.current.y; - const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current); - const isHorizontalSwipe = ["left", "right"].includes(context.swipeDirection); - const clamp4 = ["left", "up"].includes(context.swipeDirection) ? Math.min : Math.max; - const clampedX = isHorizontalSwipe ? clamp4(0, x) : 0; - const clampedY = !isHorizontalSwipe ? clamp4(0, y) : 0; - const moveStartBuffer = event.pointerType === "touch" ? 10 : 2; - const delta = { x: clampedX, y: clampedY }; - const eventDetail = { originalEvent: event, delta }; - if (hasSwipeMoveStarted) { - swipeDeltaRef.current = delta; - handleAndDispatchCustomEvent2(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, { - discrete: false - }); - } else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) { - swipeDeltaRef.current = delta; - handleAndDispatchCustomEvent2(TOAST_SWIPE_START, onSwipeStart, eventDetail, { - discrete: false - }); - event.target.setPointerCapture(event.pointerId); - } else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) { - pointerStartRef.current = null; - } - }), - onPointerUp: composeEventHandlers(props.onPointerUp, (event) => { - const delta = swipeDeltaRef.current; - const target = event.target; - if (target.hasPointerCapture(event.pointerId)) { - target.releasePointerCapture(event.pointerId); - } - swipeDeltaRef.current = null; - pointerStartRef.current = null; - if (delta) { - const toast = event.currentTarget; - const eventDetail = { originalEvent: event, delta }; - if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) { - handleAndDispatchCustomEvent2(TOAST_SWIPE_END, onSwipeEnd, eventDetail, { - discrete: true - }); - } else { - handleAndDispatchCustomEvent2(TOAST_SWIPE_CANCEL, onSwipeCancel, eventDetail, { - discrete: true - }); - } - toast.addEventListener("click", (event2) => event2.preventDefault(), { - once: true - }); - } - }) - }) - }) }), context.viewport) }) - ] }); -}); -var ToastAnnounce = (props) => { - const { __scopeToast, children, ...announceProps } = props; - const context = useToastProviderContext(TOAST_NAME, __scopeToast); - const [renderAnnounceText, setRenderAnnounceText] = React44.useState(false); - const [isAnnounced, setIsAnnounced] = React44.useState(false); - useNextFrame(() => setRenderAnnounceText(true)); - React44.useEffect(() => { - const timer = window.setTimeout(() => setIsAnnounced(true), 1e3); - return () => window.clearTimeout(timer); - }, []); - return isAnnounced ? null : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Portal, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { ...announceProps, children: renderAnnounceText && /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [ - context.label, - " ", - children - ] }) }) }); -}; -var TITLE_NAME2 = "ToastTitle"; -var ToastTitle = React44.forwardRef((props, forwardedRef) => { - const { __scopeToast, ...titleProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Primitive.div, { ...titleProps, ref: forwardedRef }); -}); -ToastTitle.displayName = TITLE_NAME2; -var DESCRIPTION_NAME2 = "ToastDescription"; -var ToastDescription = React44.forwardRef((props, forwardedRef) => { - const { __scopeToast, ...descriptionProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Primitive.div, { ...descriptionProps, ref: forwardedRef }); -}); -ToastDescription.displayName = DESCRIPTION_NAME2; -var ACTION_NAME = "ToastAction"; -var ToastAction = React44.forwardRef((props, forwardedRef) => { - const { altText, ...actionProps } = props; - if (!altText.trim()) { - console.error(`Invalid prop \`altText\` supplied to \`${ACTION_NAME}\`. Expected non-empty \`string\`.`); - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastAnnounceExclude, { altText, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastClose, { ...actionProps, ref: forwardedRef }) }); -}); -ToastAction.displayName = ACTION_NAME; -var CLOSE_NAME2 = "ToastClose"; -var ToastClose = React44.forwardRef((props, forwardedRef) => { - const { __scopeToast, ...closeProps } = props; - const interactiveContext = useToastInteractiveContext(CLOSE_NAME2, __scopeToast); - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ToastAnnounceExclude, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Primitive.button, { - type: "button", - ...closeProps, - ref: forwardedRef, - onClick: composeEventHandlers(props.onClick, interactiveContext.onClose) - }) }); -}); -ToastClose.displayName = CLOSE_NAME2; -var ToastAnnounceExclude = React44.forwardRef((props, forwardedRef) => { - const { __scopeToast, altText, ...announceExcludeProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Primitive.div, { - "data-radix-toast-announce-exclude": "", - "data-radix-toast-announce-alt": altText || void 0, - ...announceExcludeProps, - ref: forwardedRef - }); -}); -function getAnnounceTextContent(container) { - const textContent = []; - const childNodes = Array.from(container.childNodes); - childNodes.forEach((node) => { - if (node.nodeType === node.TEXT_NODE && node.textContent) - textContent.push(node.textContent); - if (isHTMLElement(node)) { - const isHidden2 = node.ariaHidden || node.hidden || node.style.display === "none"; - const isExcluded = node.dataset.radixToastAnnounceExclude === ""; - if (!isHidden2) { - if (isExcluded) { - const altText = node.dataset.radixToastAnnounceAlt; - if (altText) - textContent.push(altText); - } else { - textContent.push(...getAnnounceTextContent(node)); - } - } - } - }); - return textContent; -} -function handleAndDispatchCustomEvent2(name, handler, detail, { discrete }) { - const currentTarget = detail.originalEvent.currentTarget; - const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail }); - if (handler) - currentTarget.addEventListener(name, handler, { once: true }); - if (discrete) { - dispatchDiscreteCustomEvent(currentTarget, event); - } else { - currentTarget.dispatchEvent(event); - } -} -var isDeltaInDirection = (delta, direction, threshold = 0) => { - const deltaX = Math.abs(delta.x); - const deltaY = Math.abs(delta.y); - const isDeltaX = deltaX > deltaY; - if (direction === "left" || direction === "right") { - return isDeltaX && deltaX > threshold; - } else { - return !isDeltaX && deltaY > threshold; - } -}; -function useNextFrame(callback = () => { -}) { - const fn = useCallbackRef(callback); - useLayoutEffect22(() => { - let raf1 = 0; - let raf2 = 0; - raf1 = window.requestAnimationFrame(() => raf2 = window.requestAnimationFrame(fn)); - return () => { - window.cancelAnimationFrame(raf1); - window.cancelAnimationFrame(raf2); - }; - }, [fn]); -} -function isHTMLElement(node) { - return node.nodeType === node.ELEMENT_NODE; -} -function getTabbableCandidates2(container) { - const nodes = []; - const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, { - acceptNode: (node) => { - const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden"; - if (node.disabled || node.hidden || isHiddenInput) - return NodeFilter.FILTER_SKIP; - return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; - } - }); - while (walker.nextNode()) - nodes.push(walker.currentNode); - return nodes; -} -function focusFirst2(candidates) { - const previouslyFocusedElement = document.activeElement; - return candidates.some((candidate) => { - if (candidate === previouslyFocusedElement) - return true; - candidate.focus(); - return document.activeElement !== previouslyFocusedElement; - }); -} -var Root22 = Toast; -var Title = ToastTitle; -var Description = ToastDescription; -var Action = ToastAction; -var Close = ToastClose; - -// node_modules/tldraw/dist-esm/lib/ui/components/Toasts.mjs -var React46 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/context/toasts.mjs -var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1); -var import_react67 = __toESM(require_react(), 1); -var ToastsContext = (0, import_react67.createContext)(null); -function ToastsProvider({ children }) { - const [toasts, setToasts] = (0, import_react67.useState)([]); - const addToast = (0, import_react67.useCallback)((toast) => { - const id = toast.id ?? uniqueId(); - setToasts((d) => [...d.filter((m) => m.id !== toast.id), { ...toast, id }]); - return id; - }, []); - const removeToast = (0, import_react67.useCallback)((id) => { - setToasts((d) => d.filter((m) => m.id !== id)); - return id; - }, []); - const clearToasts = (0, import_react67.useCallback)(() => { - setToasts(() => []); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ToastProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ToastsContext.Provider, { value: { toasts, addToast, removeToast, clearToasts }, children }) }); -} -function useToasts() { - const ctx = (0, import_react67.useContext)(ToastsContext); - if (!ctx) { - throw new Error("useToasts must be used within a ToastsProvider"); - } - return ctx; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/Button/TldrawUiButton.mjs -var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1); -var import_classnames19 = __toESM(require_classnames(), 1); -var React45 = __toESM(require_react(), 1); -var TldrawUiButton = React45.forwardRef(function TldrawUiButton2({ children, disabled, type, ...props }, ref) { - return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("button", { - ref, - type: "button", - draggable: false, - disabled, - ...props, - className: (0, import_classnames19.default)("tlui-button", `tlui-button__${type}`, props.className), - children - }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonLabel.mjs -var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1); -function TldrawUiButtonLabel({ children }) { - return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "tlui-button__label", children }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs -var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1); -var import_classnames20 = __toESM(require_classnames(), 1); -var import_react68 = __toESM(require_react(), 1); -var TldrawUiIcon = (0, import_react68.memo)(function TldrawUiIcon2({ - small, - invertIcon, - icon, - color, - className, - ...props -}) { - const assetUrls = useAssetUrls(); - const asset = assetUrls.icons[icon] ?? assetUrls.icons["question-mark-circle"]; - const ref = (0, import_react68.useRef)(null); - (0, import_react68.useLayoutEffect)(() => { - if (!asset) { - console.error(`Icon not found: ${icon}. Add it to the assetUrls.icons object.`); - } - if (ref?.current) { - ref.current.style.webkitMask = `url(${asset}) center 100% / 100% no-repeat`; - } - }, [ref, asset, icon]); - if (icon === "none") { - return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { - className: (0, import_classnames20.default)("tlui-icon tlui-icon__placeholder", { "tlui-icon__small": small }, className) - }); - } - return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { - ...props, - ref, - className: (0, import_classnames20.default)("tlui-icon", { "tlui-icon__small": small }, className), - style: { - color, - mask: `url(${asset}) center 100% / 100% no-repeat`, - transform: invertIcon ? "scale(-1, 1)" : void 0 - } - }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/Toasts.mjs -var SEVERITY_TO_ICON = { - success: "check-circle", - warning: "warning-triangle", - error: "cross-circle", - info: "info-circle" -}; -function Toast2({ toast }) { - const { removeToast } = useToasts(); - const msg2 = useTranslation(); - const onOpenChange = (isOpen) => { - if (!isOpen) { - removeToast(toast.id); - } - }; - const hasActions = toast.actions && toast.actions.length > 0; - const icon = toast.icon || toast.severity && SEVERITY_TO_ICON[toast.severity]; - return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Root22, { - onOpenChange, - className: "tlui-toast__container", - duration: toast.keepOpen ? Infinity : 5e3, - "data-severity": toast.severity, - children: [ - icon && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: "tlui-toast__icon", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiIcon, { icon }) }), - /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "tlui-toast__main", children: [ - /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "tlui-toast__content", children: [ - toast.title && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Title, { className: "tlui-toast__title", children: toast.title }), - toast.description && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Description, { className: "tlui-toast__description", children: toast.description }) - ] }), - toast.actions && /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "tlui-toast__actions", children: [ - toast.actions.map((action, i) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Action, { altText: action.label, asChild: true, onClick: action.onClick, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiButton, { type: action.type, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiButtonLabel, { children: action.label }) }) }, i)), - /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiButton, { - type: "normal", - className: "tlui-toast__close", - style: { marginLeft: "auto" }, - children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiButtonLabel, { children: toast.closeLabel ?? msg2("toast.close") }) - }) }) - ] }) - ] }), - !hasActions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiButton, { type: "normal", className: "tlui-toast__close", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TldrawUiButtonLabel, { children: toast.closeLabel ?? msg2("toast.close") }) }) }) - ] - }); -} -function _Toasts() { - const { toasts } = useToasts(); - return toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Toast2, { toast }, toast.id)); -} -var Toasts = React46.memo(_Toasts); -function ToastViewport2() { - const editor = useEditor(); - const { toasts } = useToasts(); - const [hasToasts, setHasToasts] = React46.useState(false); - React46.useEffect(() => { - let timeoutId = -1; - if (toasts.length) { - setHasToasts(true); - } else { - timeoutId = editor.timers.setTimeout(() => { - setHasToasts(false); - }, 1e3); - } - return () => { - clearTimeout(timeoutId); - }; - }, [toasts.length, setHasToasts, editor]); - if (!hasToasts) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ToastViewport, { className: "tlui-toast__viewport" }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs -var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1); -function TldrawUiButtonIcon({ icon, small, invertIcon }) { - return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(TldrawUiIcon, { className: "tlui-button__icon", icon, small, invertIcon }); -} - -// node_modules/tldraw/dist-esm/lib/ui/constants.mjs -var PORTRAIT_BREAKPOINTS = [0, 390, 428, 468, 580, 640, 840, 1023]; -var PORTRAIT_BREAKPOINT = /* @__PURE__ */ ((PORTRAIT_BREAKPOINT2) => { - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["ZERO"] = 0] = "ZERO"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["MOBILE_XXS"] = 1] = "MOBILE_XXS"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["MOBILE_XS"] = 2] = "MOBILE_XS"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["MOBILE_SM"] = 3] = "MOBILE_SM"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["MOBILE"] = 4] = "MOBILE"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["TABLET_SM"] = 5] = "TABLET_SM"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["TABLET"] = 6] = "TABLET"; - PORTRAIT_BREAKPOINT2[PORTRAIT_BREAKPOINT2["DESKTOP"] = 7] = "DESKTOP"; - return PORTRAIT_BREAKPOINT2; -})(PORTRAIT_BREAKPOINT || {}); - -// node_modules/tldraw/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs -var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/utils/static-assets/assetUrls.mjs -var import_react69 = __toESM(require_react(), 1); -var defaultEditorAssetUrls = { - fonts: { - draw: `${getDefaultCdnBaseUrl()}/fonts/Shantell_Sans-Tldrawish.woff2`, - serif: `${getDefaultCdnBaseUrl()}/fonts/IBMPlexSerif-Medium.woff2`, - sansSerif: `${getDefaultCdnBaseUrl()}/fonts/IBMPlexSans-Medium.woff2`, - monospace: `${getDefaultCdnBaseUrl()}/fonts/IBMPlexMono-Medium.woff2` - } -}; -function useDefaultEditorAssetsWithOverrides(overrides) { - return (0, import_react69.useMemo)(() => { - if (!overrides) - return defaultEditorAssetUrls; - return { - fonts: { ...defaultEditorAssetUrls.fonts, ...overrides?.fonts } - }; - }, [overrides]); -} - -// node_modules/tldraw/dist-esm/lib/ui/icon-types.mjs -var iconTypes = [ - "align-bottom", - "align-center-horizontal", - "align-center-vertical", - "align-left", - "align-right", - "align-top", - "arrow-left", - "arrowhead-arrow", - "arrowhead-bar", - "arrowhead-diamond", - "arrowhead-dot", - "arrowhead-none", - "arrowhead-square", - "arrowhead-triangle-inverted", - "arrowhead-triangle", - "blob", - "bring-forward", - "bring-to-front", - "broken", - "check-circle", - "check", - "chevron-down", - "chevron-left", - "chevron-right", - "chevron-up", - "chevrons-ne", - "chevrons-sw", - "clipboard-copied", - "clipboard-copy", - "color", - "cross-2", - "cross-circle", - "dash-dashed", - "dash-dotted", - "dash-draw", - "dash-solid", - "disconnected", - "discord", - "distribute-horizontal", - "distribute-vertical", - "dot", - "dots-horizontal", - "dots-vertical", - "drag-handle-dots", - "duplicate", - "edit", - "external-link", - "fill-fill", - "fill-none", - "fill-pattern", - "fill-semi", - "fill-solid", - "follow", - "following", - "font-draw", - "font-mono", - "font-sans", - "font-serif", - "geo-arrow-down", - "geo-arrow-left", - "geo-arrow-right", - "geo-arrow-up", - "geo-check-box", - "geo-cloud", - "geo-diamond", - "geo-ellipse", - "geo-heart", - "geo-hexagon", - "geo-octagon", - "geo-oval", - "geo-pentagon", - "geo-rectangle", - "geo-rhombus-2", - "geo-rhombus", - "geo-star", - "geo-trapezoid", - "geo-triangle", - "geo-x-box", - "github", - "group", - "horizontal-align-end", - "horizontal-align-middle", - "horizontal-align-start", - "info-circle", - "leading", - "link", - "lock", - "menu", - "minus", - "mixed", - "pack", - "plus", - "question-mark-circle", - "question-mark", - "redo", - "reset-zoom", - "rotate-ccw", - "rotate-cw", - "send-backward", - "send-to-back", - "share-1", - "size-extra-large", - "size-large", - "size-medium", - "size-small", - "spline-cubic", - "spline-line", - "stack-horizontal", - "stack-vertical", - "status-offline", - "stretch-horizontal", - "stretch-vertical", - "text-align-center", - "text-align-left", - "text-align-right", - "toggle-off", - "toggle-on", - "tool-arrow", - "tool-eraser", - "tool-frame", - "tool-hand", - "tool-highlight", - "tool-laser", - "tool-line", - "tool-media", - "tool-note", - "tool-pencil", - "tool-pointer", - "tool-screenshot", - "tool-text", - "trash", - "twitter", - "undo", - "ungroup", - "unlock", - "vertical-align-end", - "vertical-align-middle", - "vertical-align-start", - "warning-triangle", - "zoom-in", - "zoom-out" -]; - -// node_modules/tldraw/dist-esm/lib/ui/assetUrls.mjs -var defaultUiAssetUrls = { - ...defaultEditorAssetUrls, - icons: Object.fromEntries(iconTypes.map((name) => [name, `${getDefaultCdnBaseUrl()}/icons/icon/${name}.svg`])), - translations: Object.fromEntries(LANGUAGES.map((lang) => [ - lang.locale, - `${getDefaultCdnBaseUrl()}/translations/${lang.locale}.json` - ])), - embedIcons: Object.fromEntries(EMBED_DEFINITIONS.map((def) => [ - def.type, - `${getDefaultCdnBaseUrl()}/embed-icons/${def.type}.png` - ])) -}; -function useDefaultUiAssetUrlsWithOverrides(overrides) { - if (!overrides) - return defaultUiAssetUrls; - return { - fonts: Object.assign({ ...defaultUiAssetUrls.fonts }, { ...overrides?.fonts }), - icons: Object.assign({ ...defaultUiAssetUrls.icons }, { ...overrides?.icons }), - embedIcons: Object.assign({ ...defaultUiAssetUrls.embedIcons }, { ...overrides?.embedIcons }), - translations: Object.assign({ ...defaultUiAssetUrls.translations }, { ...overrides?.translations }) - }; -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useTools.mjs -var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1); -var React48 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/EmbedDialog.mjs -var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1); -var import_react70 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs -var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1); -var import_classnames21 = __toESM(require_classnames(), 1); -function TldrawUiDialogHeader({ className, children }) { - return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: (0, import_classnames21.default)("tlui-dialog__header", className), children }); -} -function TldrawUiDialogTitle({ className, children }) { - return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(DialogTitle, { dir: "ltr", className: (0, import_classnames21.default)("tlui-dialog__header__title", className), children }); -} -function TldrawUiDialogCloseButton() { - return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "tlui-dialog__header__close", children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(DialogClose, { "data-testid": "dialog.close", dir: "ltr", asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(TldrawUiButton, { - type: "icon", - "aria-label": "Close", - onTouchEnd: (e) => e.target.click(), - children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(TldrawUiButtonIcon, { small: true, icon: "cross-2" }) - }) }) }); -} -function TldrawUiDialogBody({ className, children, style }) { - return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: (0, import_classnames21.default)("tlui-dialog__body", className), style, children }); -} -function TldrawUiDialogFooter({ className, children }) { - return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: (0, import_classnames21.default)("tlui-dialog__footer", className), children }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs -var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1); -var import_classnames22 = __toESM(require_classnames(), 1); -var React47 = __toESM(require_react(), 1); -var TldrawUiInput = React47.forwardRef(function TldrawUiInput2({ - className, - label, - icon, - iconLeft, - autoSelect = false, - autoFocus = false, - defaultValue, - placeholder, - onComplete, - onValueChange, - onCancel, - onFocus, - onBlur, - shouldManuallyMaintainScrollPositionWhenFocused = false, - children, - value -}, ref) { - const editor = useEditor(); - const rInputRef = React47.useRef(null); - React47.useImperativeHandle(ref, () => rInputRef.current); - const msg2 = useTranslation(); - const rInitialValue = React47.useRef(defaultValue ?? ""); - const rCurrentValue = React47.useRef(defaultValue ?? ""); - const [isFocused, setIsFocused] = React47.useState(false); - const handleFocus = React47.useCallback((e) => { - setIsFocused(true); - const elm = e.currentTarget; - rCurrentValue.current = elm.value; - editor.timers.requestAnimationFrame(() => { - if (autoSelect) { - elm.select(); - } - }); - onFocus?.(); - }, [autoSelect, onFocus, editor.timers]); - const handleChange = React47.useCallback((e) => { - const value2 = e.currentTarget.value; - rCurrentValue.current = value2; - onValueChange?.(value2); - }, [onValueChange]); - const handleKeyUp = React47.useCallback((e) => { - switch (e.key) { - case "Enter": { - e.currentTarget.blur(); - stopEventPropagation(e); - onComplete?.(e.currentTarget.value); - break; - } - case "Escape": { - e.currentTarget.value = rInitialValue.current; - e.currentTarget.blur(); - stopEventPropagation(e); - onCancel?.(e.currentTarget.value); - break; - } - } - }, [onComplete, onCancel]); - const handleBlur = React47.useCallback((e) => { - setIsFocused(false); - const value2 = e.currentTarget.value; - onBlur?.(value2); - }, [onBlur]); - React47.useEffect(() => { - if (!editor.environment.isIos) - return; - const visualViewport = window.visualViewport; - if (isFocused && shouldManuallyMaintainScrollPositionWhenFocused && visualViewport) { - const onViewportChange = () => { - rInputRef.current?.scrollIntoView({ block: "center" }); - }; - visualViewport.addEventListener("resize", onViewportChange); - visualViewport.addEventListener("scroll", onViewportChange); - editor.timers.requestAnimationFrame(() => { - rInputRef.current?.scrollIntoView({ block: "center" }); - }); - return () => { - visualViewport.removeEventListener("resize", onViewportChange); - visualViewport.removeEventListener("scroll", onViewportChange); - }; - } - }, [editor, isFocused, shouldManuallyMaintainScrollPositionWhenFocused]); - return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { draggable: false, className: "tlui-input__wrapper", children: [ - children, - label && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("label", { children: msg2(label) }), - iconLeft && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(TldrawUiIcon, { icon: iconLeft, className: "tlui-icon-left", small: true }), - /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("input", { - ref: rInputRef, - className: (0, import_classnames22.default)("tlui-input", className), - type: "text", - defaultValue, - onKeyUp: handleKeyUp, - onChange: handleChange, - onFocus: handleFocus, - onBlur: handleBlur, - autoFocus, - placeholder, - value - }), - icon && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(TldrawUiIcon, { icon, small: !!label }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/EmbedDialog.mjs -var EmbedDialog = track(function EmbedDialog2({ onClose }) { - const editor = useEditor(); - const msg2 = useTranslation(); - const assetUrls = useAssetUrls(); - const [embedDefinition, setEmbedDefinition] = (0, import_react70.useState)(null); - const [url, setUrl] = (0, import_react70.useState)(""); - const [embedInfoForUrl, setEmbedInfoForUrl] = (0, import_react70.useState)(null); - const [showError, setShowError] = (0, import_react70.useState)(false); - const rShowErrorTimeout = (0, import_react70.useRef)(-1); - return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(TldrawUiDialogHeader, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiDialogTitle, { children: embedDefinition ? `${msg2("embed-dialog.title")} \u2014 ${embedDefinition.title}` : msg2("embed-dialog.title") }), - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiDialogCloseButton, {}) - ] }), - embedDefinition ? /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(TldrawUiDialogBody, { className: "tlui-embed-dialog__enter", children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiInput, { - className: "tlui-embed-dialog__input", - label: "embed-dialog.url", - placeholder: "http://example.com", - autoFocus: true, - onValueChange: (value) => { - setUrl(value); - const embedInfo = getEmbedInfo(value); - setEmbedInfoForUrl(embedInfo && embedInfo.definition.type === embedDefinition.type ? embedInfo : null); - setShowError(false); - clearTimeout(rShowErrorTimeout.current); - rShowErrorTimeout.current = editor.timers.setTimeout(() => setShowError(!embedInfo), 320); - } - }), - url === "" ? /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: "tlui-embed-dialog__instruction", children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { children: msg2("embed-dialog.instruction") }), - " ", - embedDefinition.instructionLink && /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("a", { - target: "_blank", - rel: "noopener noreferrer", - href: embedDefinition.instructionLink, - className: "tlui-embed-dialog__instruction__link", - children: [ - "Learn more.", - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiIcon, { icon: "external-link", small: true }) - ] - }) - ] }) : /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "tlui-embed-dialog__warning", children: showError ? msg2("embed-dialog.invalid-url") : "\xA0" }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(TldrawUiDialogFooter, { className: "tlui-dialog__footer__actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButton, { - type: "normal", - onClick: () => { - setEmbedDefinition(null); - setEmbedInfoForUrl(null); - setUrl(""); - }, - children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButtonLabel, { children: msg2("embed-dialog.back") }) - }), - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "tlui-embed__spacer" }), - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButton, { type: "normal", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButtonLabel, { children: msg2("embed-dialog.cancel") }) }), - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButton, { - type: "primary", - disabled: !embedInfoForUrl, - onClick: () => { - if (!embedInfoForUrl) - return; - editor.putExternalContent({ - type: "embed", - url, - point: editor.getViewportPageBounds().center, - embed: embedInfoForUrl.definition - }); - onClose(); - }, - children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButtonLabel, { children: msg2("embed-dialog.create") }) - }) - ] }) - ] }) : /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_jsx_runtime88.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiDialogBody, { className: "tlui-embed-dialog__list", children: EMBED_DEFINITIONS.map((def) => { - return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(TldrawUiButton, { type: "menu", onClick: () => setEmbedDefinition(def), children: [ - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TldrawUiButtonLabel, { children: untranslated(def.title) }), - /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { - className: "tlui-embed-dialog__item__image", - style: { backgroundImage: `url(${assetUrls.embedIcons[def.type]})` } - }) - ] }, def.type); - }) }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useInsertMedia.mjs -var import_react71 = __toESM(require_react(), 1); -function useInsertMedia() { - const editor = useEditor(); - const inputRef = (0, import_react71.useRef)(); - (0, import_react71.useEffect)(() => { - const input = window.document.createElement("input"); - input.type = "file"; - input.accept = DEFAULT_SUPPORTED_MEDIA_TYPE_LIST; - input.multiple = true; - inputRef.current = input; - async function onchange(e) { - const fileList = e.target.files; - if (!fileList || fileList.length === 0) - return; - editor.mark("insert media"); - await editor.putExternalContent({ - type: "files", - files: Array.from(fileList), - point: editor.getViewportPageBounds().center, - ignoreParent: false - }); - input.value = ""; - } - input.addEventListener("change", onchange); - return () => { - inputRef.current = void 0; - input.removeEventListener("change", onchange); - }; - }, [editor]); - return (0, import_react71.useCallback)(() => { - inputRef.current?.click(); - }, [inputRef]); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useTools.mjs -var ToolsContext = React48.createContext(null); -function ToolsProvider({ overrides, children }) { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const { addDialog } = useDialogs(); - const insertMedia = useInsertMedia(); - const tools = React48.useMemo(() => { - const toolsArray = [ - { - id: "select", - label: "tool.select", - icon: "tool-pointer", - kbd: "v", - readonlyOk: true, - onSelect(source) { - editor.setCurrentTool("select"); - trackEvent("select-tool", { source, id: "select" }); - } - }, - { - id: "hand", - label: "tool.hand", - icon: "tool-hand", - kbd: "h", - readonlyOk: true, - onSelect(source) { - editor.setCurrentTool("hand"); - trackEvent("select-tool", { source, id: "hand" }); - } - }, - { - id: "eraser", - label: "tool.eraser", - icon: "tool-eraser", - kbd: "e", - onSelect(source) { - editor.setCurrentTool("eraser"); - trackEvent("select-tool", { source, id: "eraser" }); - } - }, - { - id: "draw", - label: "tool.draw", - icon: "tool-pencil", - kbd: "d,b,x", - onSelect(source) { - editor.setCurrentTool("draw"); - trackEvent("select-tool", { source, id: "draw" }); - } - }, - ...[...GeoShapeGeoStyle.values].map((id) => ({ - id, - label: `tool.${id}`, - meta: { - geo: id - }, - kbd: id === "rectangle" ? "r" : id === "ellipse" ? "o" : void 0, - icon: "geo-" + id, - onSelect(source) { - editor.run(() => { - editor.setStyleForNextShapes(GeoShapeGeoStyle, id); - editor.setCurrentTool("geo"); - trackEvent("select-tool", { source, id: `geo-${id}` }); - }); - } - })), - { - id: "arrow", - label: "tool.arrow", - icon: "tool-arrow", - kbd: "a", - onSelect(source) { - editor.setCurrentTool("arrow"); - trackEvent("select-tool", { source, id: "arrow" }); - } - }, - { - id: "line", - label: "tool.line", - icon: "tool-line", - kbd: "l", - onSelect(source) { - editor.setCurrentTool("line"); - trackEvent("select-tool", { source, id: "line" }); - } - }, - { - id: "frame", - label: "tool.frame", - icon: "tool-frame", - kbd: "f", - onSelect(source) { - editor.setCurrentTool("frame"); - trackEvent("select-tool", { source, id: "frame" }); - } - }, - { - id: "text", - label: "tool.text", - icon: "tool-text", - kbd: "t", - onSelect(source) { - editor.setCurrentTool("text"); - trackEvent("select-tool", { source, id: "text" }); - } - }, - { - id: "asset", - label: "tool.asset", - icon: "tool-media", - kbd: "$u", - onSelect(source) { - insertMedia(); - trackEvent("select-tool", { source, id: "media" }); - } - }, - { - id: "note", - label: "tool.note", - icon: "tool-note", - kbd: "n", - onSelect(source) { - editor.setCurrentTool("note"); - trackEvent("select-tool", { source, id: "note" }); - } - }, - { - id: "laser", - label: "tool.laser", - readonlyOk: true, - icon: "tool-laser", - kbd: "k", - onSelect(source) { - editor.setCurrentTool("laser"); - trackEvent("select-tool", { source, id: "laser" }); - } - }, - { - id: "embed", - label: "tool.embed", - icon: "dot", - onSelect(source) { - addDialog({ component: EmbedDialog }); - trackEvent("select-tool", { source, id: "embed" }); - } - }, - { - id: "highlight", - label: "tool.highlight", - icon: "tool-highlight", - kbd: "!d", - onSelect(source) { - editor.setCurrentTool("highlight"); - trackEvent("select-tool", { source, id: "highlight" }); - } - } - ]; - toolsArray.push(); - const tools2 = Object.fromEntries(toolsArray.map((t2) => [t2.id, t2])); - if (overrides) { - return overrides(editor, tools2, { insertMedia }); - } - return tools2; - }, [overrides, editor, trackEvent, insertMedia, addDialog]); - return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ToolsContext.Provider, { value: tools, children }); -} -function useTools() { - const ctx = React48.useContext(ToolsContext); - if (!ctx) { - throw new Error("useTools must be used within a ToolProvider"); - } - return ctx; -} - -// node_modules/tldraw/dist-esm/lib/ui/overrides.mjs -var import_react73 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/context/breakpoints.mjs -var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1); -var import_react72 = __toESM(require_react(), 1); -var BreakpointContext = import_react72.default.createContext(null); -function BreakPointProvider({ forceMobile = false, children }) { - const editor = useEditor(); - const breakpoint = useValue("breakpoint", () => { - const { width } = editor.getViewportScreenBounds(); - const maxBreakpoint = forceMobile ? PORTRAIT_BREAKPOINT.MOBILE_SM : PORTRAIT_BREAKPOINTS.length - 1; - for (let i = 0; i < maxBreakpoint; i++) { - if (width > PORTRAIT_BREAKPOINTS[i] && width <= PORTRAIT_BREAKPOINTS[i + 1]) { - return i; - } - } - return maxBreakpoint; - }, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BreakpointContext.Provider, { value: breakpoint, children }); -} -function useBreakpoint() { - const breakpoint = (0, import_react72.useContext)(BreakpointContext); - if (breakpoint === null) { - throw new Error("useBreakpoint must be used inside of the <BreakpointProvider /> component"); - } - return breakpoint; -} - -// node_modules/tldraw/dist-esm/lib/ui/overrides.mjs -function useDefaultHelpers() { - const { addToast, removeToast, clearToasts } = useToasts(); - const { addDialog, clearDialogs, removeDialog, updateDialog } = useDialogs(); - const breakpoint = useBreakpoint(); - const isMobile = breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM; - const msg2 = useTranslation(); - return (0, import_react73.useMemo)(() => ({ - addToast, - removeToast, - clearToasts, - addDialog, - clearDialogs, - removeDialog, - updateDialog, - msg: msg2, - isMobile - }), [ - addDialog, - addToast, - clearDialogs, - clearToasts, - msg2, - removeDialog, - removeToast, - updateDialog, - isMobile - ]); -} -function mergeOverrides(overrides, defaultHelpers) { - const mergedTranslations = {}; - for (const override of overrides) { - if (override.translations) { - for (const [key, value] of objectMapEntries(override.translations)) { - let strings = mergedTranslations[key]; - if (!strings) { - strings = mergedTranslations[key] = {}; - } - Object.assign(strings, value); - } - } - } - return { - actions: (editor, schema) => { - for (const override of overrides) { - if (override.actions) { - schema = override.actions(editor, schema, defaultHelpers); - } - } - return schema; - }, - tools: (editor, schema, helpers) => { - for (const override of overrides) { - if (override.tools) { - schema = override.tools(editor, schema, { ...defaultHelpers, ...helpers }); - } - } - return schema; - }, - translations: mergedTranslations - }; -} -function useShallowArrayEquality(array2) { - return (0, import_react73.useMemo)(() => array2, array2); -} -function useMergedTranslationOverrides(overrides) { - const overridesArray = useShallowArrayEquality(overrides == null ? [] : Array.isArray(overrides) ? overrides : [overrides]); - return (0, import_react73.useMemo)(() => { - const mergedTranslations = {}; - for (const override of overridesArray) { - if (override.translations) { - for (const [key, value] of objectMapEntries(override.translations)) { - let strings = mergedTranslations[key]; - if (!strings) { - strings = mergedTranslations[key] = {}; - } - Object.assign(strings, value); - } - } - } - return mergedTranslations; - }, [overridesArray]); -} -function useMergedOverrides(overrides) { - const defaultHelpers = useDefaultHelpers(); - const overridesArray = useShallowArrayEquality(overrides == null ? [] : Array.isArray(overrides) ? overrides : [overrides]); - return (0, import_react73.useMemo)(() => mergeOverrides(overridesArray, defaultHelpers), [overridesArray, defaultHelpers]); -} - -// node_modules/tldraw/dist-esm/lib/ui/context/actions.mjs -var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1); -var React50 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/utils/frames/frames.mjs -function removeFrame(editor, ids) { - const frames = compact(ids.map((id) => editor.getShape(id)).filter((f) => f && editor.isShapeOfType(f, "frame"))); - if (!frames.length) - return; - const allChildren = []; - editor.run(() => { - frames.map((frame2) => { - const children = editor.getSortedChildIdsForParent(frame2.id); - if (children.length) { - editor.reparentShapes(children, frame2.parentId, frame2.index); - allChildren.push(...children); - } - }); - editor.setSelectedShapes(allChildren); - editor.deleteShapes(ids); - }); -} -var DEFAULT_FRAME_PADDING = 50; -function fitFrameToContent(editor, id, opts = {}) { - const frame2 = editor.getShape(id); - if (!frame2) - return; - const childIds = editor.getSortedChildIdsForParent(frame2.id); - const children = compact(childIds.map((id2) => editor.getShape(id2))); - if (!children.length) - return; - const bounds = Box.FromPoints(children.flatMap((shape) => { - const geometry = editor.getShapeGeometry(shape.id); - return editor.getShapeLocalTransform(shape).applyToPoints(geometry.vertices); - })); - const { padding = DEFAULT_FRAME_PADDING } = opts; - const w = bounds.w + 2 * padding; - const h = bounds.h + 2 * padding; - const dx = padding - bounds.minX; - const dy = padding - bounds.minY; - if (dx === 0 && dy === 0 && frame2.props.w === w && frame2.props.h === h) - return; - const diff = new Vec(dx, dy).rot(frame2.rotation); - editor.run(() => { - const changes = childIds.map((child) => { - const shape = editor.getShape(child); - return { - id: shape.id, - type: shape.type, - x: shape.x + dx, - y: shape.y + dy - }; - }); - changes.push({ - id: frame2.id, - type: frame2.type, - x: frame2.x - diff.x, - y: frame2.y - diff.y, - props: { - w, - h - } - }); - editor.updateShapes(changes); - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/EditLinkDialog.mjs -var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1); -var import_react74 = __toESM(require_react(), 1); -function validateUrl(url) { - if (validation_exports.linkUrl.isValid(url)) { - return { isValid: true, hasProtocol: true }; - } - if (validation_exports.linkUrl.isValid("https://" + url)) { - return { isValid: true, hasProtocol: false }; - } - return { isValid: false, hasProtocol: false }; -} -var EditLinkDialog = track(function EditLinkDialog2({ onClose }) { - const editor = useEditor(); - const selectedShape = editor.getOnlySelectedShape(); - if (!(selectedShape && "url" in selectedShape.props && typeof selectedShape.props.url === "string")) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(EditLinkDialogInner, { onClose, selectedShape }); -}); -var EditLinkDialogInner = track(function EditLinkDialogInner2({ - onClose, - selectedShape -}) { - const editor = useEditor(); - const msg2 = useTranslation(); - const rInput = (0, import_react74.useRef)(null); - (0, import_react74.useEffect)(() => { - editor.timers.requestAnimationFrame(() => rInput.current?.focus()); - }, [editor]); - const rInitialValue = (0, import_react74.useRef)(selectedShape.props.url); - const [urlInputState, setUrlInputState] = (0, import_react74.useState)(() => { - const urlValidResult = validateUrl(selectedShape.props.url); - const initialValue = urlValidResult.isValid === true ? urlValidResult.hasProtocol ? selectedShape.props.url : "https://" + selectedShape.props.url : "https://"; - return { - actual: initialValue, - safe: initialValue, - valid: true - }; - }); - const handleChange = (0, import_react74.useCallback)((rawValue) => { - const fixedRawValue = rawValue.replace(/https?:\/\/(https?:\/\/)/, (_match, arg1) => { - return arg1; - }); - const urlValidResult = validateUrl(fixedRawValue); - const safeValue = urlValidResult.isValid === true ? urlValidResult.hasProtocol ? fixedRawValue : "https://" + fixedRawValue : "https://"; - setUrlInputState({ - actual: fixedRawValue, - safe: safeValue, - valid: urlValidResult.isValid - }); - }, []); - const handleClear = (0, import_react74.useCallback)(() => { - const onlySelectedShape = editor.getOnlySelectedShape(); - if (!onlySelectedShape) - return; - editor.updateShapes([ - { id: onlySelectedShape.id, type: onlySelectedShape.type, props: { url: "" } } - ]); - onClose(); - }, [editor, onClose]); - const handleComplete = (0, import_react74.useCallback)(() => { - const onlySelectedShape = editor.getOnlySelectedShape(); - if (!onlySelectedShape) - return; - if (onlySelectedShape && "url" in onlySelectedShape.props) { - if (onlySelectedShape.props.url !== urlInputState.safe) { - editor.updateShapes([ - { - id: onlySelectedShape.id, - type: onlySelectedShape.type, - props: { url: urlInputState.safe } - } - ]); - } - } - onClose(); - }, [editor, onClose, urlInputState]); - const handleCancel = (0, import_react74.useCallback)(() => { - onClose(); - }, [onClose]); - if (!selectedShape) { - onClose(); - return null; - } - const isRemoving = rInitialValue.current && !urlInputState.valid; - return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(TldrawUiDialogHeader, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiDialogTitle, { children: msg2("edit-link-dialog.title") }), - /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiDialogCloseButton, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiDialogBody, { children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "tlui-edit-link-dialog", children: [ - /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiInput, { - ref: rInput, - className: "tlui-edit-link-dialog__input", - label: "edit-link-dialog.url", - autoFocus: true, - value: urlInputState.actual, - onValueChange: handleChange, - onComplete: handleComplete, - onCancel: handleCancel - }), - /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { children: urlInputState.valid ? msg2("edit-link-dialog.detail") : msg2("edit-link-dialog.invalid-url") }) - ] }) }), - /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(TldrawUiDialogFooter, { className: "tlui-dialog__footer__actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiButton, { type: "normal", onClick: handleCancel, onTouchEnd: handleCancel, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiButtonLabel, { children: msg2("edit-link-dialog.cancel") }) }), - isRemoving ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiButton, { type: "danger", onTouchEnd: handleClear, onClick: handleClear, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiButtonLabel, { children: msg2("edit-link-dialog.clear") }) }) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiButton, { - type: "primary", - disabled: !urlInputState.valid, - onTouchEnd: handleComplete, - onClick: handleComplete, - children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(TldrawUiButtonLabel, { children: msg2("edit-link-dialog.save") }) - }) - ] }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useClipboardEvents.mjs -var import_lz_string = __toESM(require_lz_string(), 1); -var import_react75 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/clipboard/pasteExcalidrawContent.mjs -async function pasteExcalidrawContent(editor, clipboard, point) { - const { elements, files } = clipboard; - const tldrawContent = { - shapes: [], - bindings: [], - rootShapeIds: [], - assets: [], - schema: editor.store.schema.serialize() - }; - const groupShapeIdToChildren = /* @__PURE__ */ new Map(); - const rotatedElements = /* @__PURE__ */ new Map(); - const currentPageId = editor.getCurrentPageId(); - const excElementIdsToTldrawShapeIds = /* @__PURE__ */ new Map(); - const rootShapeIds = []; - const skipIds = /* @__PURE__ */ new Set(); - elements.forEach((element) => { - excElementIdsToTldrawShapeIds.set(element.id, createShapeId()); - if (element.boundElements !== null) { - for (const boundElement of element.boundElements) { - if (boundElement.type === "text") { - skipIds.add(boundElement.id); - } - } - } - }); - let index2 = ZERO_INDEX_KEY; - for (const element of elements) { - if (skipIds.has(element.id)) { - continue; - } - const id = excElementIdsToTldrawShapeIds.get(element.id); - const base = { - id, - typeName: "shape", - parentId: currentPageId, - index: index2, - x: element.x, - y: element.y, - rotation: 0, - isLocked: element.locked, - opacity: getOpacity(element.opacity), - meta: {} - }; - if (element.angle !== 0) { - rotatedElements.set(id, element.angle); - } - if (element.groupIds && element.groupIds.length > 0) { - if (groupShapeIdToChildren.has(element.groupIds[0])) { - groupShapeIdToChildren.get(element.groupIds[0])?.push(id); - } else { - groupShapeIdToChildren.set(element.groupIds[0], [id]); - } - } else { - rootShapeIds.push(id); - } - switch (element.type) { - case "rectangle": - case "ellipse": - case "diamond": { - let text = ""; - let align = "middle"; - if (element.boundElements !== null) { - for (const boundElement of element.boundElements) { - if (boundElement.type === "text") { - const labelElement = elements.find((elm) => elm.id === boundElement.id); - if (labelElement) { - text = labelElement.text; - align = textAlignToAlignTypes[labelElement.textAlign]; - } - } - } - } - const colorToUse = element.backgroundColor === "transparent" ? element.strokeColor : element.backgroundColor; - tldrawContent.shapes.push({ - ...base, - type: "geo", - props: { - geo: element.type, - url: element.link ?? "", - w: element.width, - h: element.height, - size: strokeWidthsToSizes[element.strokeWidth] ?? "draw", - color: colorsToColors[colorToUse] ?? "black", - text, - align, - dash: getDash(element), - fill: getFill(element) - } - }); - break; - } - case "freedraw": { - tldrawContent.shapes.push({ - ...base, - type: "draw", - props: { - dash: getDash(element), - size: strokeWidthsToSizes[element.strokeWidth], - color: colorsToColors[element.strokeColor] ?? "black", - segments: [ - { - type: "free", - points: element.points.map(([x, y, z = 0.5]) => ({ - x, - y, - z - })) - } - ] - } - }); - break; - } - case "line": { - const points = element.points.slice(); - if (points.length < 2) { - break; - } - const indices = getIndices(element.points.length); - tldrawContent.shapes.push({ - ...base, - type: "line", - props: { - dash: getDash(element), - size: strokeWidthsToSizes[element.strokeWidth], - color: colorsToColors[element.strokeColor] ?? "black", - spline: element.roundness ? "cubic" : "line", - points: { - ...Object.fromEntries(element.points.map(([x, y], i) => { - const index22 = indices[i]; - return [index22, { id: index22, index: index22, x, y }]; - })) - } - } - }); - break; - } - case "arrow": { - let text = ""; - if (element.boundElements !== null) { - for (const boundElement of element.boundElements) { - if (boundElement.type === "text") { - const labelElement = elements.find((elm) => elm.id === boundElement.id); - if (labelElement) { - text = labelElement.text; - } - } - } - } - const start = element.points[0]; - const end = element.points[element.points.length - 1]; - const startTargetId = excElementIdsToTldrawShapeIds.get(element.startBinding?.elementId); - const endTargetId = excElementIdsToTldrawShapeIds.get(element.endBinding?.elementId); - tldrawContent.shapes.push({ - ...base, - type: "arrow", - props: { - text, - bend: getBend(element, start, end), - dash: getDash(element), - size: strokeWidthsToSizes[element.strokeWidth] ?? "m", - color: colorsToColors[element.strokeColor] ?? "black", - start: { x: start[0], y: start[1] }, - end: { x: end[0], y: end[1] }, - arrowheadEnd: arrowheadsToArrowheadTypes[element.endArrowhead] ?? "none", - arrowheadStart: arrowheadsToArrowheadTypes[element.startArrowhead] ?? "none" - } - }); - if (startTargetId) { - tldrawContent.bindings.push({ - id: createBindingId(), - typeName: "binding", - type: "arrow", - fromId: id, - toId: startTargetId, - props: { - terminal: "start", - normalizedAnchor: { x: 0.5, y: 0.5 }, - isPrecise: false, - isExact: false - }, - meta: {} - }); - } - if (endTargetId) { - tldrawContent.bindings.push({ - id: createBindingId(), - typeName: "binding", - type: "arrow", - fromId: id, - toId: endTargetId, - props: { - terminal: "end", - normalizedAnchor: { x: 0.5, y: 0.5 }, - isPrecise: false, - isExact: false - }, - meta: {} - }); - } - break; - } - case "text": { - const { size: size4, scale } = getFontSizeAndScale(element.fontSize); - tldrawContent.shapes.push({ - ...base, - type: "text", - props: { - size: size4, - scale, - font: fontFamilyToFontType[element.fontFamily] ?? "draw", - color: colorsToColors[element.strokeColor] ?? "black", - text: element.text, - textAlign: textAlignToTextAlignTypes[element.textAlign] - } - }); - break; - } - case "image": { - const file = files[element.fileId]; - if (!file) - break; - const assetId = AssetRecordType.createId(); - tldrawContent.assets.push({ - id: assetId, - typeName: "asset", - type: "image", - props: { - w: element.width, - h: element.height, - fileSize: file.size, - name: element.id ?? "Untitled", - isAnimated: false, - mimeType: file.mimeType, - src: file.dataURL - }, - meta: {} - }); - tldrawContent.shapes.push({ - ...base, - type: "image", - props: { - w: element.width, - h: element.height, - assetId - } - }); - } - } - index2 = getIndexAbove(index2); - } - const p = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : void 0); - editor.mark("paste"); - editor.putContentOntoCurrentPage(tldrawContent, { - point: p, - select: false, - preserveIds: true - }); - for (const groupedShapeIds of groupShapeIdToChildren.values()) { - if (groupedShapeIds.length > 1) { - editor.groupShapes(groupedShapeIds); - const groupShape = editor.getShape(groupedShapeIds[0]); - if (groupShape?.parentId && isShapeId(groupShape.parentId)) { - rootShapeIds.push(groupShape.parentId); - } - } - } - for (const [id, angle] of rotatedElements) { - editor.select(id); - editor.rotateShapesBy([id], angle); - } - const rootShapes = compact(rootShapeIds.map((id) => editor.getShape(id))); - const bounds = Box.Common(rootShapes.map((s) => editor.getShapePageBounds(s))); - const viewPortCenter = editor.getViewportPageBounds().center; - editor.updateShapes(rootShapes.map((s) => { - const delta = { - x: (s.x ?? 0) - (bounds.x + bounds.w / 2), - y: (s.y ?? 0) - (bounds.y + bounds.h / 2) - }; - return { - id: s.id, - type: s.type, - x: viewPortCenter.x + delta.x, - y: viewPortCenter.y + delta.y - }; - })); - editor.setSelectedShapes(rootShapeIds); -} -var getOpacity = (opacity) => { - const t2 = opacity / 100; - if (t2 < 0.2) { - return 0.1; - } else if (t2 < 0.4) { - return 0.25; - } else if (t2 < 0.6) { - return 0.5; - } else if (t2 < 0.8) { - return 0.75; - } - return 1; -}; -var strokeWidthsToSizes = { - 1: "s", - 2: "m", - 3: "l", - 4: "xl" -}; -var fontSizesToSizes = { - 16: "s", - 20: "m", - 28: "l", - 36: "xl" -}; -function getFontSizeAndScale(fontSize) { - const size4 = fontSizesToSizes[fontSize]; - if (size4) { - return { size: size4, scale: 1 }; - } - if (fontSize < 16) { - return { size: "s", scale: fontSize / 16 }; - } - if (fontSize > 36) { - return { size: "xl", scale: fontSize / 36 }; - } - return { size: "m", scale: 1 }; -} -var fontFamilyToFontType = { - 1: "draw", - 2: "sans", - 3: "mono" -}; -var colorsToColors = { - "#ffffff": "grey", - "#000000": "black", - "#343a40": "black", - "#495057": "grey", - "#c92a2a": "red", - "#a61e4d": "light-red", - "#862e9c": "violet", - "#5f3dc4": "light-violet", - "#364fc7": "blue", - "#1864ab": "light-blue", - "#0b7285": "light-green", - "#087f5b": "light-green", - "#2b8a3e": "green", - "#5c940d": "light-green", - "#e67700": "yellow", - "#d9480f": "orange", - "#ced4da": "grey", - "#868e96": "grey", - "#fa5252": "light-red", - "#e64980": "red", - "#be4bdb": "light-violet", - "#7950f2": "violet", - "#4c6ef5": "blue", - "#228be6": "light-blue", - "#15aabf": "light-green", - "#12b886": "green", - "#40c057": "green", - "#82c91e": "light-green", - "#fab005": "yellow", - "#fd7e14": "orange", - "#212529": "grey" -}; -var strokeStylesToStrokeTypes = { - solid: "draw", - dashed: "dashed", - dotted: "dotted" -}; -var fillStylesToFillType = { - "cross-hatch": "pattern", - hachure: "pattern", - solid: "solid" -}; -var textAlignToAlignTypes = { - left: "start", - center: "middle", - right: "end" -}; -var textAlignToTextAlignTypes = { - left: "start", - center: "middle", - right: "end" -}; -var arrowheadsToArrowheadTypes = { - arrow: "arrow", - dot: "dot", - triangle: "triangle", - bar: "pipe" -}; -function getBend(element, startPoint, endPoint) { - let bend = 0; - if (element.points.length > 2) { - const start = new Vec(startPoint[0], startPoint[1]); - const end = new Vec(endPoint[0], endPoint[1]); - const handle = new Vec(element.points[1][0], element.points[1][1]); - const delta = Vec.Sub(end, start); - const v = Vec.Per(delta); - const med = Vec.Med(end, start); - const A = Vec.Sub(med, v); - const B = Vec.Add(med, v); - const point = Vec.NearestPointOnLineSegment(A, B, handle, false); - bend = Vec.Dist(point, med); - if (Vec.Clockwise(point, end, med)) - bend *= -1; - } - return bend; -} -var getDash = (element) => { - let dash = strokeStylesToStrokeTypes[element.strokeStyle] ?? "draw"; - if (dash === "draw" && element.roughness === 0) { - dash = "solid"; - } - return dash; -}; -var getFill = (element) => { - if (element.backgroundColor === "transparent") { - return "none"; - } - return fillStylesToFillType[element.fillStyle] ?? "solid"; -}; - -// node_modules/tldraw/dist-esm/lib/ui/hooks/clipboard/pasteFiles.mjs -async function pasteFiles(editor, urls, point, sources) { - const blobs = await Promise.all(urls.map(async (url) => await (await fetch2(url)).blob())); - const files = blobs.map((blob) => new File([blob], "tldrawFile", { type: blob.type })); - editor.mark("paste"); - await editor.putExternalContent({ - type: "files", - files, - point, - ignoreParent: false, - sources - }); - urls.forEach((url) => URL.revokeObjectURL(url)); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/clipboard/pasteTldrawContent.mjs -function pasteTldrawContent(editor, clipboard, point) { - const selectionBoundsBefore = editor.getSelectionPageBounds(); - editor.mark("paste"); - editor.putContentOntoCurrentPage(clipboard, { - point, - select: true - }); - const selectedBoundsAfter = editor.getSelectionPageBounds(); - if (selectionBoundsBefore && selectedBoundsAfter && selectionBoundsBefore?.collides(selectedBoundsAfter)) { - editor.updateInstanceState({ isChangingStyle: true }); - editor.timers.setTimeout(() => { - editor.updateInstanceState({ isChangingStyle: false }); - }, 150); - } -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/clipboard/pasteUrl.mjs -async function pasteUrl(editor, url, point, sources) { - editor.mark("paste"); - return await editor.putExternalContent({ - type: "url", - point, - url, - sources - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useClipboardEvents.mjs -function stripHtml(html) { - const doc = document.implementation.createHTMLDocument(""); - doc.documentElement.innerHTML = html.trim(); - return doc.body.textContent || doc.body.innerText || ""; -} -var isValidHttpURL = (url) => { - try { - const u = new URL(url); - return u.protocol === "http:" || u.protocol === "https:"; - } catch (e) { - return false; - } -}; -var getValidHttpURLList = (url) => { - const urls = url.split(/[\n\s]/); - for (const url2 of urls) { - try { - const u = new URL(url2); - if (!(u.protocol === "http:" || u.protocol === "https:")) { - return; - } - } catch (e) { - return; - } - } - return uniq(urls); -}; -var isSvgText = (text) => { - return /^<svg/.test(text); -}; -var INPUTS2 = ["input", "select", "textarea"]; -function disallowClipboardEvents(editor) { - const { activeElement } = document; - return editor.getIsMenuOpen() || activeElement && (activeElement.getAttribute("contenteditable") || INPUTS2.indexOf(activeElement.tagName.toLowerCase()) > -1); -} -var isFile = (item) => { - return item.types.find((i) => i.match(/^image\//)); -}; -var handleText = (editor, data, point, sources) => { - const validUrlList = getValidHttpURLList(data); - if (validUrlList) { - for (const url of validUrlList) { - pasteUrl(editor, url, point); - } - } else if (isValidHttpURL(data)) { - pasteUrl(editor, data, point); - } else if (isSvgText(data)) { - editor.mark("paste"); - editor.putExternalContent({ - type: "svg-text", - text: data, - point, - sources - }); - } else { - editor.mark("paste"); - editor.putExternalContent({ - type: "text", - text: data, - point, - sources - }); - } -}; -var handlePasteFromEventClipboardData = async (editor, clipboardData, point) => { - if (editor.getEditingShapeId() !== null) - return; - if (!clipboardData) { - throw Error("No clipboard data"); - } - const things = []; - for (const item of Object.values(clipboardData.items)) { - switch (item.kind) { - case "file": { - things.push({ - type: "file", - source: new Promise((r) => r(item.getAsFile())) - }); - break; - } - case "string": { - if (item.type === "text/html") { - things.push({ - type: "html", - source: new Promise((r) => item.getAsString(r)) - }); - } else if (item.type === "text/plain") { - things.push({ - type: "text", - source: new Promise((r) => item.getAsString(r)) - }); - } else { - things.push({ type: item.type, source: new Promise((r) => item.getAsString(r)) }); - } - break; - } - } - } - handleClipboardThings(editor, things, point); -}; -var handlePasteFromClipboardApi = async (editor, clipboardItems, point) => { - const things = []; - for (const item of clipboardItems) { - if (isFile(item)) { - for (const type of item.types) { - if (type.match(/^image\//)) { - things.push({ type: "blob", source: item.getType(type) }); - } - } - } - if (item.types.includes("text/html")) { - things.push({ - type: "html", - source: (async () => { - const blob = await item.getType("text/html"); - return await FileHelpers.blobToText(blob); - })() - }); - } - if (item.types.includes("text/uri-list")) { - things.push({ - type: "url", - source: (async () => { - const blob = await item.getType("text/uri-list"); - return await FileHelpers.blobToText(blob); - })() - }); - } - if (item.types.includes("text/plain")) { - things.push({ - type: "text", - source: (async () => { - const blob = await item.getType("text/plain"); - return await FileHelpers.blobToText(blob); - })() - }); - } - } - return await handleClipboardThings(editor, things, point); -}; -async function handleClipboardThings(editor, things, point) { - const files = things.filter((t2) => (t2.type === "file" || t2.type === "blob") && t2.source !== null); - if (files.length) { - const fileBlobs = await Promise.all(files.map((t2) => t2.source)); - const urls = fileBlobs.filter(Boolean).map((blob) => URL.createObjectURL(blob)); - return await pasteFiles(editor, urls, point); - } - const results = await Promise.all(things.filter((t2) => t2.type !== "file").map((t2) => new Promise((r) => { - const thing = t2; - if (thing.type === "file") { - r({ type: "error", data: null, reason: "unexpected file" }); - return; - } - thing.source.then((text) => { - const tldrawHtmlComment = text.match(/<div data-tldraw[^>]*>(.*)<\/div>/)?.[1]; - if (tldrawHtmlComment) { - try { - const jsonComment = import_lz_string.default.decompressFromBase64(tldrawHtmlComment); - if (jsonComment === null) { - r({ - type: "error", - data: jsonComment, - reason: `found tldraw data comment but could not parse base64` - }); - return; - } else { - const json = JSON.parse(jsonComment); - if (json.type !== "application/tldraw") { - r({ - type: "error", - data: json, - reason: `found tldraw data comment but JSON was of a different type: ${json.type}` - }); - } - if (typeof json.data === "string") { - r({ - type: "error", - data: json, - reason: "found tldraw json but data was a string instead of a TLClipboardModel object" - }); - return; - } - r({ type: "tldraw", data: json.data }); - return; - } - } catch (e) { - r({ - type: "error", - data: tldrawHtmlComment, - reason: "found tldraw json but data was a string instead of a TLClipboardModel object" - }); - return; - } - } else { - if (thing.type === "html") { - r({ type: "text", data: text, subtype: "html" }); - return; - } - if (thing.type === "url") { - r({ type: "text", data: text, subtype: "url" }); - return; - } - try { - const json = JSON.parse(text); - if (json.type === "excalidraw/clipboard") { - r({ type: "excalidraw", data: json }); - return; - } else { - r({ type: "text", data: text, subtype: "json" }); - return; - } - } catch (e) { - r({ type: "text", data: text, subtype: "text" }); - return; - } - } - r({ type: "error", data: text, reason: "unhandled case" }); - }); - }))); - for (const result of results) { - if (result.type === "tldraw") { - pasteTldrawContent(editor, result.data, point); - return; - } - } - for (const result of results) { - if (result.type === "excalidraw") { - pasteExcalidrawContent(editor, result.data, point); - return; - } - } - for (const result of results) { - if (result.type === "text" && result.subtype === "html") { - const rootNode = new DOMParser().parseFromString(result.data, "text/html"); - const bodyNode = rootNode.querySelector("body"); - const isHtmlSingleLink = bodyNode && Array.from(bodyNode.children).filter((el) => el.nodeType === 1).length === 1 && bodyNode.firstElementChild && bodyNode.firstElementChild.tagName === "A" && bodyNode.firstElementChild.hasAttribute("href") && bodyNode.firstElementChild.getAttribute("href") !== ""; - if (isHtmlSingleLink) { - const href = bodyNode.firstElementChild.getAttribute("href"); - handleText(editor, href, point, results); - return; - } - if (!results.some((r) => r.type === "text" && r.subtype !== "html") && result.data.trim()) { - handleText(editor, stripHtml(result.data), point, results); - return; - } - } - } - for (const result of results) { - if (result.type === "text" && result.subtype === "url") { - pasteUrl(editor, result.data, point, results); - return; - } - } - for (const result of results) { - if (result.type === "text" && result.subtype === "text" && result.data.trim()) { - handleText(editor, result.data, point, results); - return; - } - } -} -var handleNativeOrMenuCopy = async (editor) => { - const content = await editor.resolveAssetsInContent(editor.getContentFromCurrentPage(editor.getSelectedShapeIds())); - if (!content) { - if (navigator && navigator.clipboard) { - navigator.clipboard.writeText(""); - } - return; - } - const stringifiedClipboard = import_lz_string.default.compressToBase64(JSON.stringify({ - type: "application/tldraw", - kind: "content", - data: content - })); - if (typeof navigator === "undefined") { - return; - } else { - const textItems = content.shapes.map((shape) => { - if (editor.isShapeOfType(shape, "text") || editor.isShapeOfType(shape, "geo") || editor.isShapeOfType(shape, "arrow")) { - return shape.props.text; - } - if (editor.isShapeOfType(shape, "bookmark") || editor.isShapeOfType(shape, "embed")) { - return shape.props.url; - } - return null; - }).filter(isNonNull); - if (navigator.clipboard?.write) { - const htmlBlob = new Blob([`<div data-tldraw>${stringifiedClipboard}</div>`], { - type: "text/html" - }); - let textContent = textItems.join(" "); - if (textContent === "") { - textContent = " "; - } - navigator.clipboard.write([ - new ClipboardItem({ - "text/html": htmlBlob, - "text/plain": new Blob([textContent], { type: "text/plain" }) - }) - ]); - } else if (navigator.clipboard.writeText) { - navigator.clipboard.writeText(`<div data-tldraw>${stringifiedClipboard}</div>`); - } - } -}; -function useMenuClipboardEvents() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const copy = (0, import_react75.useCallback)(async function onCopy(source) { - if (editor.getSelectedShapeIds().length === 0) - return; - await handleNativeOrMenuCopy(editor); - trackEvent("copy", { source }); - }, [editor, trackEvent]); - const cut = (0, import_react75.useCallback)(async function onCut(source) { - if (editor.getSelectedShapeIds().length === 0) - return; - await handleNativeOrMenuCopy(editor); - editor.deleteShapes(editor.getSelectedShapeIds()); - trackEvent("cut", { source }); - }, [editor, trackEvent]); - const paste = (0, import_react75.useCallback)(async function onPaste(data, source, point) { - if (editor.getEditingShapeId() !== null) - return; - if (Array.isArray(data) && data[0] instanceof ClipboardItem) { - handlePasteFromClipboardApi(editor, data, point); - trackEvent("paste", { source: "menu" }); - } else { - navigator.clipboard.read().then((clipboardItems) => { - paste(clipboardItems, source, point); - }); - } - }, [editor, trackEvent]); - return { - copy, - cut, - paste - }; -} -function useNativeClipboardEvents() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const appIsFocused = useValue("editor.isFocused", () => editor.getInstanceState().isFocused, [ - editor - ]); - (0, import_react75.useEffect)(() => { - if (!appIsFocused) - return; - const copy = async (e) => { - if (editor.getSelectedShapeIds().length === 0 || editor.getEditingShapeId() !== null || disallowClipboardEvents(editor)) { - return; - } - preventDefault(e); - await handleNativeOrMenuCopy(editor); - trackEvent("copy", { source: "kbd" }); - }; - async function cut(e) { - if (editor.getSelectedShapeIds().length === 0 || editor.getEditingShapeId() !== null || disallowClipboardEvents(editor)) { - return; - } - preventDefault(e); - await handleNativeOrMenuCopy(editor); - editor.deleteShapes(editor.getSelectedShapeIds()); - trackEvent("cut", { source: "kbd" }); - } - let disablingMiddleClickPaste = false; - const pointerUpHandler = (e) => { - if (e.button === 1) { - disablingMiddleClickPaste = true; - editor.timers.requestAnimationFrame(() => { - disablingMiddleClickPaste = false; - }); - } - }; - const paste = (e) => { - if (disablingMiddleClickPaste) { - stopEventPropagation(e); - return; - } - if (editor.getEditingShapeId() !== null || disallowClipboardEvents(editor)) - return; - let point = void 0; - let pasteAtCursor = false; - if (editor.inputs.shiftKey) - pasteAtCursor = true; - if (editor.user.getIsPasteAtCursorMode()) - pasteAtCursor = !pasteAtCursor; - if (pasteAtCursor) - point = editor.inputs.currentPagePoint; - if (e.clipboardData && !editor.inputs.shiftKey) { - handlePasteFromEventClipboardData(editor, e.clipboardData, point); - } else { - navigator.clipboard.read().then((clipboardItems) => { - if (Array.isArray(clipboardItems) && clipboardItems[0] instanceof ClipboardItem) { - handlePasteFromClipboardApi(editor, clipboardItems, point); - } - }); - } - preventDefault(e); - trackEvent("paste", { source: "kbd" }); - }; - document.addEventListener("copy", copy); - document.addEventListener("cut", cut); - document.addEventListener("paste", paste); - document.addEventListener("pointerup", pointerUpHandler); - return () => { - document.removeEventListener("copy", copy); - document.removeEventListener("cut", cut); - document.removeEventListener("paste", paste); - document.removeEventListener("pointerup", pointerUpHandler); - }; - }, [editor, trackEvent, appIsFocused]); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useCopyAs.mjs -var import_react76 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/utils/export/export.mjs -async function getSvgAsImage(editor, svgString, options) { - const { type, quality, scale, width, height } = options; - let [clampedWidth, clampedHeight] = await clampToBrowserMaxCanvasSize(width * scale, height * scale); - clampedWidth = Math.floor(clampedWidth); - clampedHeight = Math.floor(clampedHeight); - const effectiveScale = clampedWidth / width; - const svgUrl = URL.createObjectURL(new Blob([svgString], { type: "image/svg+xml" })); - const canvas = await new Promise((resolve) => { - const image = Image(); - image.crossOrigin = "anonymous"; - image.onload = async () => { - if (editor.environment.isSafari) { - await new Promise((resolve2) => editor.timers.setTimeout(resolve2, 250)); - } - const canvas2 = document.createElement("canvas"); - const ctx = canvas2.getContext("2d"); - canvas2.width = clampedWidth; - canvas2.height = clampedHeight; - ctx.imageSmoothingEnabled = true; - ctx.imageSmoothingQuality = "high"; - ctx.drawImage(image, 0, 0, clampedWidth, clampedHeight); - URL.revokeObjectURL(svgUrl); - resolve(canvas2); - }; - image.onerror = () => { - resolve(null); - }; - image.src = svgUrl; - }); - if (!canvas) - return null; - const blob = await new Promise((resolve) => canvas.toBlob((blob2) => { - if (!blob2 || debugFlags.throwToBlob.get()) { - resolve(null); - } - resolve(blob2); - }, "image/" + type, quality)); - if (!blob) - return null; - if (type === "png") { - const view = new DataView(await blob.arrayBuffer()); - return PngHelpers.setPhysChunk(view, effectiveScale, { - type: "image/" + type - }); - } else { - return blob; - } -} -async function getSvgString(editor, ids, opts) { - const svg = await editor.getSvgString(ids?.length ? ids : [...editor.getCurrentPageShapeIds()], { - scale: 1, - background: editor.getInstanceState().exportBackground, - ...opts - }); - if (!svg) { - throw new Error("Could not construct SVG."); - } - return svg; -} -async function exportToString(editor, ids, format, opts = {}) { - switch (format) { - case "svg": { - return (await getSvgString(editor, ids, opts))?.svg; - } - case "json": { - const data = await editor.resolveAssetsInContent(editor.getContentFromCurrentPage(ids)); - return JSON.stringify(data); - } - default: { - exhaustiveSwitchError(format); - } - } -} -async function exportToBlob({ - editor, - ids, - format, - opts = {} -}) { - switch (format) { - case "svg": - return new Blob([await exportToString(editor, ids, "svg", opts)], { type: "text/plain" }); - case "json": - return new Blob([await exportToString(editor, ids, "json", opts)], { type: "text/plain" }); - case "jpeg": - case "png": - case "webp": { - const svgResult = await getSvgString(editor, ids, opts); - if (!svgResult) - throw new Error("Could not construct image."); - const image = await getSvgAsImage(editor, svgResult.svg, { - type: format, - quality: 1, - scale: 2, - width: svgResult.width, - height: svgResult.height - }); - if (!image) { - throw new Error("Could not construct image."); - } - return image; - } - default: { - exhaustiveSwitchError(format); - } - } -} -var mimeTypeByFormat = { - jpeg: "image/jpeg", - png: "image/png", - webp: "image/webp", - json: "text/plain", - svg: "text/plain" -}; -function exportToBlobPromise(editor, ids, format, opts = {}) { - return { - blobPromise: exportToBlob({ editor, ids, format, opts }), - mimeType: mimeTypeByFormat[format] - }; -} - -// node_modules/tldraw/dist-esm/lib/utils/export/copyAs.mjs -function copyAs(editor, ids, format = "svg", opts = {}) { - if (!window.navigator.clipboard) - return Promise.reject(new Error("Copy not supported")); - if (window.navigator.clipboard.write) { - const { blobPromise, mimeType } = exportToBlobPromise(editor, ids, format, opts); - return window.navigator.clipboard.write([new ClipboardItem({ [mimeType]: blobPromise })]).catch((err) => { - console.error(err); - return blobPromise.then((blob) => { - return window.navigator.clipboard.write([new ClipboardItem({ [mimeType]: blob })]); - }); - }); - } - switch (format) { - case "json": - case "svg": - return fallbackWriteTextAsync(async () => exportToString(editor, ids, format, opts)); - case "jpeg": - case "png": - throw new Error("Copy not supported"); - default: - exhaustiveSwitchError(format); - } -} -async function fallbackWriteTextAsync(getText) { - await navigator.clipboard?.writeText?.(await getText()); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useCopyAs.mjs -function useCopyAs() { - const editor = useEditor(); - const { addToast } = useToasts(); - const msg2 = useTranslation(); - return (0, import_react76.useCallback)((ids, format = "svg") => { - copyAs(editor, ids, format).catch(() => { - addToast({ - id: "copy-fail", - severity: "warning", - title: msg2("toast.error.copy-fail.title"), - description: msg2("toast.error.copy-fail.desc") - }); - }); - }, [editor, addToast, msg2]); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useExportAs.mjs -var import_react77 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/utils/export/exportAs.mjs -async function exportAs(editor, ids, format = "png", name, opts = {}) { - if (!name) { - name = `shapes at ${getTimestamp()}`; - if (ids.length === 1) { - const first = editor.getShape(ids[0]); - if (editor.isShapeOfType(first, "frame")) { - name = first.props.name ?? "frame"; - } else { - name = `${first.id.replace(/:/, "_")} at ${getTimestamp()}`; - } - } - } - name += `.${format}`; - const blob = await exportToBlob({ editor, ids, format, opts }); - const file = new File([blob], name, { type: blob.type }); - downloadFile(file); -} -function getTimestamp() { - const now = /* @__PURE__ */ new Date(); - const year = String(now.getFullYear()).slice(2); - const month = String(now.getMonth() + 1).padStart(2, "0"); - const day = String(now.getDate()).padStart(2, "0"); - const hours = String(now.getHours()).padStart(2, "0"); - const minutes = String(now.getMinutes()).padStart(2, "0"); - const seconds = String(now.getSeconds()).padStart(2, "0"); - return `${year}-${month}-${day} ${hours}.${minutes}.${seconds}`; -} -function downloadFile(file) { - const link = document.createElement("a"); - const url = URL.createObjectURL(file); - link.href = url; - link.download = file.name; - link.click(); - URL.revokeObjectURL(url); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useExportAs.mjs -function useExportAs() { - const editor = useEditor(); - const { addToast } = useToasts(); - const msg2 = useTranslation(); - return (0, import_react77.useCallback)((ids, format = "png", name) => { - exportAs(editor, ids, format, name, { - scale: 1, - background: editor.getInstanceState().exportBackground - }).catch((e) => { - console.error(e.message); - addToast({ - id: "export-fail", - title: msg2("toast.error.export-fail.title"), - description: msg2("toast.error.export-fail.desc"), - severity: "error" - }); - }); - }, [editor, addToast, msg2]); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useFlatten.mjs -var import_react78 = __toESM(require_react(), 1); -async function flattenShapesToImages(editor, shapeIds, flattenImageBoundsExpand) { - const shapes = compact(shapeIds.map((id) => { - const shape = editor.getShape(id); - if (!shape) - return; - const util = editor.getShapeUtil(shape.type); - if (util.toSvg === void 0) - return; - return shape; - })); - if (shapes.length === 0) - return; - if (shapes.length === 1) { - const shape = shapes[0]; - if (!shape) - return; - if (editor.isShapeOfType(shape, "image")) - return; - } - const groups = []; - if (flattenImageBoundsExpand !== void 0) { - const expandedBounds = shapes.map((shape) => { - return { - shape, - bounds: editor.getShapeMaskedPageBounds(shape).clone().expandBy(flattenImageBoundsExpand) - }; - }); - for (let i = 0; i < expandedBounds.length; i++) { - const item = expandedBounds[i]; - if (i === 0) { - groups[0] = { - shapes: [item.shape], - bounds: item.bounds - }; - continue; - } - let didLand = false; - for (const group of groups) { - if (group.bounds.includes(item.bounds)) { - group.shapes.push(item.shape); - group.bounds.expand(item.bounds); - didLand = true; - break; - } - } - if (!didLand) { - groups.push({ - shapes: [item.shape], - bounds: item.bounds - }); - } - } - } else { - const bounds = Box.Common(shapes.map((shape) => editor.getShapeMaskedPageBounds(shape))); - groups.push({ - shapes, - bounds - }); - } - const padding = editor.options.flattenImageBoundsPadding; - for (const group of groups) { - if (flattenImageBoundsExpand !== void 0) { - group.bounds.expandBy(-flattenImageBoundsExpand); - } - const svgResult = await editor.getSvgString(group.shapes, { - padding - }); - if (!svgResult?.svg) - continue; - const blob = new Blob([svgResult.svg], { type: "image/svg+xml" }); - const asset = await editor.getAssetForExternalContent({ - type: "file", - file: new File([blob], "asset.svg", { type: "image/svg+xml" }) - }); - if (!asset) - continue; - group.asset = asset; - } - const createdShapeIds = []; - transact(() => { - for (const group of groups) { - const { asset, bounds, shapes: shapes2 } = group; - if (!asset) - continue; - const commonAncestorId = editor.findCommonAncestor(shapes2) ?? editor.getCurrentPageId(); - if (!commonAncestorId) - continue; - let index2 = "a1"; - for (const shape of shapes2) { - if (shape.parentId === commonAncestorId) { - if (shape.index > index2) { - index2 = shape.index; - } - break; - } - } - let x; - let y; - let rotation; - if (isShapeId(commonAncestorId)) { - const commonAncestor = editor.getShape(commonAncestorId); - if (!commonAncestor) - continue; - const point = editor.getPointInShapeSpace(commonAncestor, { - x: bounds.x, - y: bounds.y - }); - rotation = editor.getShapePageTransform(commonAncestorId).rotation(); - point.sub(new Vec(padding, padding).rot(-rotation)); - x = point.x; - y = point.y; - } else { - x = bounds.x - padding; - y = bounds.y - padding; - rotation = 0; - } - editor.deleteShapes(shapes2); - editor.createAssets([{ ...asset, id: asset.id }]); - const shapeId = createShapeId(); - editor.createShape({ - id: shapeId, - type: "image", - index: index2, - parentId: commonAncestorId, - x, - y, - rotation: -rotation, - props: { - assetId: asset.id, - w: bounds.w + padding * 2, - h: bounds.h + padding * 2 - } - }); - createdShapeIds.push(shapeId); - } - }); - return createdShapeIds; -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useIsMultiplayer.mjs -function useIsMultiplayer() { - const editor = useEditor(); - return !!editor.store.props.multiplayerStatus; -} -function useMultiplayerStatus() { - const editor = useEditor(); - return useValue("multiplayerStatus", () => { - if (!editor.store.props.multiplayerStatus) { - return null; - } - return editor.store.props.multiplayerStatus.get(); - }, [editor]); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/usePrint.mjs -var import_react79 = __toESM(require_react(), 1); -function usePrint() { - const editor = useEditor(); - const prevPrintEl = (0, import_react79.useRef)(null); - const prevStyleEl = (0, import_react79.useRef)(null); - return (0, import_react79.useCallback)(async function printSelectionOrPages() { - const el = document.createElement("div"); - const style = document.createElement("style"); - const clearElements = (printEl, styleEl) => { - if (printEl) - printEl.innerHTML = ""; - if (styleEl && document.head.contains(styleEl)) - document.head.removeChild(styleEl); - if (printEl && document.body.contains(printEl)) { - document.body.removeChild(printEl); - } - }; - clearElements(prevPrintEl.current, prevStyleEl.current); - prevPrintEl.current = el; - prevStyleEl.current = style; - const className = `tl-print-surface-${uniqueId()}`; - el.className = className; - const enableMargins = false; - const allowAllPages = false; - style.innerHTML = ` - .${className} { - display: none; - } - - .${className} svg { - max-width: 100%; - height: 100%; - display: block; - } - - @media print { - html, body { - min-height: 100%; - height: 100%; - margin: 0; - } - - body { - position: relative; - } - - body > * { - display: none; - } - - .tldraw__editor { - display: none; - } - - .${className} { - display: block !important; - background: white; - min-height: 100%; - height: 100%; - max-width: 100%; - } - - .${className}__item { - padding: 10mm; - display: flex; - min-height: 100%; - flex-direction: column; - page-break-after: always; - position: relative; - overflow: hidden; - height: 100%; - } - - .${className}__item__main { - flex: 1; - display: flex; - align-items: center; - justify-content: center; - max-height: 100%; - } - - .${className}__item__header { - display: none; - } - - .${className}__item__footer { - display: none; - text-align: right; - } - - .${className}__item__footer__hide { - display: none; - } - - ${!enableMargins ? "" : ` - /** - * Note: Safari doesn't support removing the page margins to remove them all! - */ - @page { - margin:0; - } - - .${className} .${className}__item__header { - display: block; - } - - .${className} .${className}__item__footer { - display: block; - } - `} - } - - `; - const beforePrintHandler = () => { - document.head.appendChild(style); - document.body.appendChild(el); - }; - const afterPrintHandler = () => { - editor.once("tick", () => { - clearElements(el, style); - }); - }; - window.addEventListener("beforeprint", beforePrintHandler); - window.addEventListener("afterprint", afterPrintHandler); - function addPageToPrint(title, footer, svg) { - try { - el.innerHTML += `<div class="${className}__item"> - <div class="${className}__item__header"> - ${title.replace(/</g, "<").replace(/>/g, ">")} - </div> - <div class="${className}__item__main"> - ${svg} - </div> - <div class="${className}__item__footer ${className}__item__footer__${footer ? "" : "hide"}"> - ${footer ?? ""} - </div> - </div>`; - } catch (e) { - console.error(e); - } - } - function triggerPrint() { - if (editor.environment.isChromeForIos) { - beforePrintHandler(); - window.print(); - } else if (editor.environment.isSafari) { - beforePrintHandler(); - document.execCommand("print", false); - } else { - window.print(); - } - } - const selectedShapeIds = editor.getSelectedShapeIds(); - const currentPageId = editor.getCurrentPageId(); - const pages = editor.getPages(); - const preserveAspectRatio = "xMidYMid meet"; - const svgOpts = { - scale: 1, - background: false, - darkMode: false, - preserveAspectRatio - }; - if (editor.getSelectedShapeIds().length > 0) { - const svgExport = await editor.getSvgString(selectedShapeIds, svgOpts); - if (svgExport) { - const page = pages.find((p) => p.id === currentPageId); - addPageToPrint(`tldraw \u2014 ${page?.name}`, null, svgExport.svg); - triggerPrint(); - } - } else { - if (allowAllPages) { - for (let i = 0; i < pages.length; i++) { - const page = pages[i]; - const svgExport = await editor.getSvgString(editor.getSortedChildIdsForParent(page.id), svgOpts); - if (svgExport) { - addPageToPrint(`tldraw \u2014 ${page.name}`, `${i}/${pages.length}`, svgExport.svg); - } - } - triggerPrint(); - } else { - const page = editor.getCurrentPage(); - const svgExport = await editor.getSvgString(editor.getSortedChildIdsForParent(page.id), svgOpts); - if (svgExport) { - addPageToPrint(`tldraw \u2014 ${page.name}`, null, svgExport.svg); - triggerPrint(); - } - } - } - window.removeEventListener("beforeprint", beforePrintHandler); - window.removeEventListener("afterprint", afterPrintHandler); - }, [editor]); -} - -// node_modules/tldraw/dist-esm/lib/ui/context/actions.mjs -var ActionsContext = React50.createContext(null); -function makeActions(actions) { - return Object.fromEntries(actions.map((action) => [action.id, action])); -} -function getExportName(editor, defaultName) { - const selectedShapes = editor.getSelectedShapes(); - if (selectedShapes.length === 0) { - return editor.getDocumentSettings().name || defaultName; - } - return void 0; -} -function ActionsProvider({ overrides, children }) { - const editor = useEditor(); - const isMultiplayer = useIsMultiplayer(); - const { addDialog, clearDialogs } = useDialogs(); - const { clearToasts, addToast } = useToasts(); - const msg2 = useTranslation(); - const insertMedia = useInsertMedia(); - const printSelectionOrPages = usePrint(); - const { cut, copy, paste } = useMenuClipboardEvents(); - const copyAs2 = useCopyAs(); - const exportAs2 = useExportAs(); - const defaultDocumentName = msg2("document.default-name"); - const trackEvent = useUiEvents(); - const actions = React50.useMemo(() => { - function mustGoBackToSelectToolFirst() { - if (!editor.isIn("select")) { - editor.complete(); - editor.setCurrentTool("select"); - return false; - } - return false; - } - function canApplySelectionAction() { - return editor.isIn("select") && editor.getSelectedShapeIds().length > 0; - } - const actionItems = [ - { - id: "edit-link", - label: "action.edit-link", - icon: "link", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("edit-link", { source }); - editor.mark("edit-link"); - addDialog({ component: EditLinkDialog }); - } - }, - { - id: "insert-embed", - label: "action.insert-embed", - kbd: "$i", - onSelect(source) { - trackEvent("insert-embed", { source }); - addDialog({ component: EmbedDialog }); - } - }, - { - id: "insert-media", - label: "action.insert-media", - kbd: "$u", - onSelect(source) { - trackEvent("insert-media", { source }); - insertMedia(); - } - }, - { - id: "undo", - label: "action.undo", - icon: "undo", - kbd: "$z", - onSelect(source) { - trackEvent("undo", { source }); - editor.undo(); - } - }, - { - id: "redo", - label: "action.redo", - icon: "redo", - kbd: "$!z", - onSelect(source) { - trackEvent("redo", { source }); - editor.redo(); - } - }, - { - id: "export-as-svg", - label: { - default: "action.export-as-svg", - menu: "action.export-as-svg.short", - ["context-menu"]: "action.export-as-svg.short" - }, - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("export-as", { format: "svg", source }); - exportAs2(ids, "svg", getExportName(editor, defaultDocumentName)); - } - }, - { - id: "export-as-png", - label: { - default: "action.export-as-png", - menu: "action.export-as-png.short", - ["context-menu"]: "action.export-as-png.short" - }, - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("export-as", { format: "png", source }); - exportAs2(ids, "png", getExportName(editor, defaultDocumentName)); - } - }, - { - id: "export-as-json", - label: { - default: "action.export-as-json", - menu: "action.export-as-json.short", - ["context-menu"]: "action.export-as-json.short" - }, - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("export-as", { format: "json", source }); - exportAs2(ids, "json", getExportName(editor, defaultDocumentName)); - } - }, - { - id: "export-all-as-svg", - label: { - default: "action.export-all-as-svg", - menu: "action.export-all-as-svg.short", - ["context-menu"]: "action.export-all-as-svg.short" - }, - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("export-all-as", { format: "svg", source }); - exportAs2(Array.from(editor.getCurrentPageShapeIds()), "svg", getExportName(editor, defaultDocumentName)); - } - }, - { - id: "export-all-as-png", - label: { - default: "action.export-all-as-png", - menu: "action.export-all-as-png.short", - ["context-menu"]: "action.export-all-as-png.short" - }, - readonlyOk: true, - onSelect(source) { - const ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("export-all-as", { format: "png", source }); - exportAs2(ids, "png", getExportName(editor, defaultDocumentName)); - } - }, - { - id: "export-all-as-json", - label: { - default: "action.export-all-as-json", - menu: "action.export-all-as-json.short", - ["context-menu"]: "action.export-all-as-json.short" - }, - readonlyOk: true, - onSelect(source) { - const ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("export-all-as", { format: "json", source }); - exportAs2(ids, "json", getExportName(editor, defaultDocumentName)); - } - }, - { - id: "copy-as-svg", - label: { - default: "action.copy-as-svg", - menu: "action.copy-as-svg.short", - ["context-menu"]: "action.copy-as-svg.short" - }, - kbd: "$!c", - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("copy-as", { format: "svg", source }); - copyAs2(ids, "svg"); - } - }, - { - id: "copy-as-png", - label: { - default: "action.copy-as-png", - menu: "action.copy-as-png.short", - ["context-menu"]: "action.copy-as-png.short" - }, - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("copy-as", { format: "png", source }); - copyAs2(ids, "png"); - } - }, - { - id: "copy-as-json", - label: { - default: "action.copy-as-json", - menu: "action.copy-as-json.short", - ["context-menu"]: "action.copy-as-json.short" - }, - readonlyOk: true, - onSelect(source) { - let ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - ids = Array.from(editor.getCurrentPageShapeIds().values()); - if (ids.length === 0) - return; - trackEvent("copy-as", { format: "json", source }); - copyAs2(ids, "json"); - } - }, - { - id: "toggle-auto-size", - label: "action.toggle-auto-size", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("toggle-auto-size", { source }); - editor.mark("toggling auto size"); - const shapes = editor.getSelectedShapes().filter((shape) => editor.isShapeOfType(shape, "text") && shape.props.autoSize === false); - editor.updateShapes(shapes.map((shape) => { - return { - id: shape.id, - type: shape.type, - props: { - ...shape.props, - w: 8, - autoSize: true - } - }; - })); - kickoutOccludedShapes(editor, shapes.map((shape) => shape.id)); - } - }, - { - id: "open-embed-link", - label: "action.open-embed-link", - readonlyOk: true, - onSelect(source) { - trackEvent("open-embed-link", { source }); - const ids = editor.getSelectedShapeIds(); - const warnMsg = "No embed shapes selected"; - if (ids.length !== 1) { - console.error(warnMsg); - return; - } - const shape = editor.getShape(ids[0]); - if (!shape || !editor.isShapeOfType(shape, "embed")) { - console.error(warnMsg); - return; - } - openWindow(shape.props.url, "_blank"); - } - }, - { - id: "select-zoom-tool", - readonlyOk: true, - kbd: "z", - onSelect(source) { - if (editor.root.getCurrent()?.id === "zoom") - return; - trackEvent("zoom-tool", { source }); - if (!(editor.inputs.shiftKey || editor.inputs.ctrlKey)) { - const currentTool = editor.root.getCurrent(); - if (currentTool && currentTool.getCurrent()?.id === "idle") { - editor.setCurrentTool("zoom", { onInteractionEnd: currentTool.id, maskAs: "zoom" }); - } - } - } - }, - { - id: "convert-to-bookmark", - label: "action.convert-to-bookmark", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - editor.run(() => { - trackEvent("convert-to-bookmark", { source }); - const shapes = editor.getSelectedShapes(); - const createList = []; - const deleteList = []; - for (const shape of shapes) { - if (!shape || !editor.isShapeOfType(shape, "embed") || !shape.props.url) - continue; - const newPos = new Vec(shape.x, shape.y); - newPos.rot(-shape.rotation); - newPos.add(new Vec(shape.props.w / 2 - 300 / 2, shape.props.h / 2 - 320 / 2)); - newPos.rot(shape.rotation); - const partial = { - id: createShapeId(), - type: "bookmark", - rotation: shape.rotation, - x: newPos.x, - y: newPos.y, - opacity: 1, - props: { - url: shape.props.url - } - }; - createList.push(partial); - deleteList.push(shape.id); - } - editor.mark("convert shapes to bookmark"); - editor.deleteShapes(deleteList); - editor.createShapes(createList); - }); - } - }, - { - id: "convert-to-embed", - label: "action.convert-to-embed", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("convert-to-embed", { source }); - editor.run(() => { - const ids = editor.getSelectedShapeIds(); - const shapes = compact(ids.map((id) => editor.getShape(id))); - const createList = []; - const deleteList = []; - for (const shape of shapes) { - if (!editor.isShapeOfType(shape, "bookmark")) - continue; - const { url } = shape.props; - const embedInfo = getEmbedInfo(shape.props.url); - if (!embedInfo) - continue; - if (!embedInfo.definition) - continue; - const { width, height } = embedInfo.definition; - const newPos = new Vec(shape.x, shape.y); - newPos.rot(-shape.rotation); - newPos.add(new Vec(shape.props.w / 2 - width / 2, shape.props.h / 2 - height / 2)); - newPos.rot(shape.rotation); - const shapeToCreate = { - id: createShapeId(), - type: "embed", - x: newPos.x, - y: newPos.y, - rotation: shape.rotation, - props: { - url, - w: width, - h: height - } - }; - createList.push(shapeToCreate); - deleteList.push(shape.id); - } - editor.mark("convert shapes to embed"); - editor.deleteShapes(deleteList); - editor.createShapes(createList); - }); - } - }, - { - id: "duplicate", - kbd: "$d", - label: "action.duplicate", - icon: "duplicate", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("duplicate-shapes", { source }); - const instanceState = editor.getInstanceState(); - let ids; - let offset4; - if (instanceState.duplicateProps) { - ids = instanceState.duplicateProps.shapeIds; - offset4 = instanceState.duplicateProps.offset; - } else { - ids = editor.getSelectedShapeIds(); - const commonBounds = Box.Common(compact(ids.map((id) => editor.getShapePageBounds(id)))); - offset4 = editor.getCameraOptions().isLocked ? { - x: editor.options.adjacentShapeMargin, - y: editor.options.adjacentShapeMargin - } : { - x: commonBounds.width + editor.options.adjacentShapeMargin, - y: 0 - }; - } - editor.mark("duplicate shapes"); - editor.duplicateShapes(ids, offset4); - if (instanceState.duplicateProps) { - editor.updateInstanceState({ - duplicateProps: { - ...instanceState.duplicateProps, - shapeIds: editor.getSelectedShapeIds() - } - }); - } - } - }, - { - id: "ungroup", - label: "action.ungroup", - kbd: "$!g", - icon: "ungroup", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("ungroup-shapes", { source }); - editor.mark("ungroup"); - editor.ungroupShapes(editor.getSelectedShapeIds()); - } - }, - { - id: "group", - label: "action.group", - kbd: "$g", - icon: "group", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("group-shapes", { source }); - const onlySelectedShape = editor.getOnlySelectedShape(); - if (onlySelectedShape && editor.isShapeOfType(onlySelectedShape, "group")) { - editor.mark("ungroup"); - editor.ungroupShapes(editor.getSelectedShapeIds()); - } else { - editor.mark("group"); - editor.groupShapes(editor.getSelectedShapeIds()); - } - } - }, - { - id: "remove-frame", - label: "action.remove-frame", - kbd: "$!f", - onSelect(source) { - if (!canApplySelectionAction()) - return; - trackEvent("remove-frame", { source }); - const selectedShapes = editor.getSelectedShapes(); - if (selectedShapes.length > 0 && selectedShapes.every((shape) => editor.isShapeOfType(shape, "frame"))) { - editor.mark("remove-frame"); - removeFrame(editor, selectedShapes.map((shape) => shape.id)); - } - } - }, - { - id: "fit-frame-to-content", - label: "action.fit-frame-to-content", - onSelect(source) { - if (!canApplySelectionAction()) - return; - trackEvent("fit-frame-to-content", { source }); - const onlySelectedShape = editor.getOnlySelectedShape(); - if (onlySelectedShape && editor.isShapeOfType(onlySelectedShape, "frame")) { - editor.mark("fit-frame-to-content"); - fitFrameToContent(editor, onlySelectedShape.id); - } - } - }, - { - id: "align-left", - label: "action.align-left", - kbd: "?A", - icon: "align-left", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("align-shapes", { operation: "left", source }); - editor.mark("align left"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.alignShapes(selectedShapeIds, "left"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "align-center-horizontal", - label: { - default: "action.align-center-horizontal", - ["context-menu"]: "action.align-center-horizontal.short" - }, - kbd: "?H", - icon: "align-center-horizontal", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("align-shapes", { operation: "center-horizontal", source }); - editor.mark("align center horizontal"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.alignShapes(selectedShapeIds, "center-horizontal"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "align-right", - label: "action.align-right", - kbd: "?D", - icon: "align-right", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("align-shapes", { operation: "right", source }); - editor.mark("align right"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.alignShapes(selectedShapeIds, "right"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "align-center-vertical", - label: { - default: "action.align-center-vertical", - ["context-menu"]: "action.align-center-vertical.short" - }, - kbd: "?V", - icon: "align-center-vertical", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("align-shapes", { operation: "center-vertical", source }); - editor.mark("align center vertical"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.alignShapes(selectedShapeIds, "center-vertical"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "align-top", - label: "action.align-top", - icon: "align-top", - kbd: "?W", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("align-shapes", { operation: "top", source }); - editor.mark("align top"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.alignShapes(selectedShapeIds, "top"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "align-bottom", - label: "action.align-bottom", - icon: "align-bottom", - kbd: "?S", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("align-shapes", { operation: "bottom", source }); - editor.mark("align bottom"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.alignShapes(selectedShapeIds, "bottom"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "distribute-horizontal", - label: { - default: "action.distribute-horizontal", - ["context-menu"]: "action.distribute-horizontal.short" - }, - icon: "distribute-horizontal", - kbd: "?!h", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("distribute-shapes", { operation: "horizontal", source }); - editor.mark("distribute horizontal"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.distributeShapes(selectedShapeIds, "horizontal"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "distribute-vertical", - label: { - default: "action.distribute-vertical", - ["context-menu"]: "action.distribute-vertical.short" - }, - icon: "distribute-vertical", - kbd: "?!V", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("distribute-shapes", { operation: "vertical", source }); - editor.mark("distribute vertical"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.distributeShapes(selectedShapeIds, "vertical"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "stretch-horizontal", - label: { - default: "action.stretch-horizontal", - ["context-menu"]: "action.stretch-horizontal.short" - }, - icon: "stretch-horizontal", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("stretch-shapes", { operation: "horizontal", source }); - editor.mark("stretch horizontal"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.stretchShapes(selectedShapeIds, "horizontal"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "stretch-vertical", - label: { - default: "action.stretch-vertical", - ["context-menu"]: "action.stretch-vertical.short" - }, - icon: "stretch-vertical", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("stretch-shapes", { operation: "vertical", source }); - editor.mark("stretch vertical"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.stretchShapes(selectedShapeIds, "vertical"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "flip-horizontal", - label: { - default: "action.flip-horizontal", - ["context-menu"]: "action.flip-horizontal.short" - }, - kbd: "!h", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("flip-shapes", { operation: "horizontal", source }); - editor.mark("flip horizontal"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.flipShapes(selectedShapeIds, "horizontal"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "flip-vertical", - label: { default: "action.flip-vertical", ["context-menu"]: "action.flip-vertical.short" }, - kbd: "!v", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("flip-shapes", { operation: "vertical", source }); - editor.mark("flip vertical"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.flipShapes(selectedShapeIds, "vertical"); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "pack", - label: "action.pack", - icon: "pack", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("pack-shapes", { source }); - editor.mark("pack"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.packShapes(selectedShapeIds, editor.options.adjacentShapeMargin); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "stack-vertical", - label: { - default: "action.stack-vertical", - ["context-menu"]: "action.stack-vertical.short" - }, - icon: "stack-vertical", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("stack-shapes", { operation: "vertical", source }); - editor.mark("stack-vertical"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.stackShapes(selectedShapeIds, "vertical", 16); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "stack-horizontal", - label: { - default: "action.stack-horizontal", - ["context-menu"]: "action.stack-horizontal.short" - }, - icon: "stack-horizontal", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("stack-shapes", { operation: "horizontal", source }); - editor.mark("stack-horizontal"); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.stackShapes(selectedShapeIds, "horizontal", 16); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "bring-to-front", - label: "action.bring-to-front", - kbd: "]", - icon: "bring-to-front", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("reorder-shapes", { operation: "toFront", source }); - editor.mark("bring to front"); - editor.bringToFront(editor.getSelectedShapeIds()); - } - }, - { - id: "bring-forward", - label: "action.bring-forward", - icon: "bring-forward", - kbd: "?]", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("reorder-shapes", { operation: "forward", source }); - editor.mark("bring forward"); - editor.bringForward(editor.getSelectedShapeIds()); - } - }, - { - id: "send-backward", - label: "action.send-backward", - icon: "send-backward", - kbd: "?[", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("reorder-shapes", { operation: "backward", source }); - editor.mark("send backward"); - editor.sendBackward(editor.getSelectedShapeIds()); - } - }, - { - id: "send-to-back", - label: "action.send-to-back", - icon: "send-to-back", - kbd: "[", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("reorder-shapes", { operation: "toBack", source }); - editor.mark("send to back"); - editor.sendToBack(editor.getSelectedShapeIds()); - } - }, - { - id: "cut", - label: "action.cut", - kbd: "$x", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - editor.mark("cut"); - cut(source); - } - }, - { - id: "copy", - label: "action.copy", - kbd: "$c", - readonlyOk: true, - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - copy(source); - } - }, - { - id: "paste", - label: "action.paste", - kbd: "$v", - onSelect(source) { - navigator.clipboard?.read().then((clipboardItems) => { - paste(clipboardItems, source, source === "context-menu" ? editor.inputs.currentPagePoint : void 0); - }).catch(() => { - addToast({ - title: msg2("action.paste-error-title"), - description: msg2("action.paste-error-description"), - severity: "error" - }); - }); - } - }, - { - id: "select-all", - label: "action.select-all", - kbd: "$a", - readonlyOk: true, - onSelect(source) { - editor.run(() => { - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("select-all-shapes", { source }); - editor.mark("select all kbd"); - editor.selectAll(); - }); - } - }, - { - id: "select-none", - label: "action.select-none", - readonlyOk: true, - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("select-none-shapes", { source }); - editor.mark("select none"); - editor.selectNone(); - } - }, - { - id: "delete", - label: "action.delete", - kbd: "\u232B,del,backspace", - icon: "trash", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("delete-shapes", { source }); - editor.mark("delete"); - editor.deleteShapes(editor.getSelectedShapeIds()); - } - }, - { - id: "rotate-cw", - label: "action.rotate-cw", - icon: "rotate-cw", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("rotate-cw", { source }); - editor.mark("rotate-cw"); - const offset4 = editor.getSelectionRotation() % (HALF_PI / 2); - const dontUseOffset = approximately(offset4, 0) || approximately(offset4, HALF_PI / 2); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.rotateShapesBy(selectedShapeIds, HALF_PI / 2 - (dontUseOffset ? 0 : offset4)); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "rotate-ccw", - label: "action.rotate-ccw", - icon: "rotate-ccw", - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("rotate-ccw", { source }); - editor.mark("rotate-ccw"); - const offset4 = editor.getSelectionRotation() % (HALF_PI / 2); - const offsetCloseToZero = approximately(offset4, 0); - const selectedShapeIds = editor.getSelectedShapeIds(); - editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -(HALF_PI / 2) : -offset4); - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - { - id: "zoom-in", - label: "action.zoom-in", - kbd: "$=,=", - readonlyOk: true, - onSelect(source) { - trackEvent("zoom-in", { source }); - editor.zoomIn(void 0, { - animation: { duration: editor.options.animationMediumMs } - }); - } - }, - { - id: "zoom-out", - label: "action.zoom-out", - kbd: "$-,-", - readonlyOk: true, - onSelect(source) { - trackEvent("zoom-out", { source }); - editor.zoomOut(void 0, { - animation: { duration: editor.options.animationMediumMs } - }); - } - }, - { - id: "zoom-to-100", - label: "action.zoom-to-100", - icon: "reset-zoom", - kbd: "!0", - readonlyOk: true, - onSelect(source) { - trackEvent("reset-zoom", { source }); - editor.resetZoom(void 0, { - animation: { duration: editor.options.animationMediumMs } - }); - } - }, - { - id: "zoom-to-fit", - label: "action.zoom-to-fit", - kbd: "!1", - readonlyOk: true, - onSelect(source) { - trackEvent("zoom-to-fit", { source }); - editor.zoomToFit({ animation: { duration: editor.options.animationMediumMs } }); - } - }, - { - id: "zoom-to-selection", - label: "action.zoom-to-selection", - kbd: "!2", - readonlyOk: true, - onSelect(source) { - if (!canApplySelectionAction()) - return; - if (mustGoBackToSelectToolFirst()) - return; - trackEvent("zoom-to-selection", { source }); - editor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } }); - } - }, - { - id: "toggle-snap-mode", - label: { - default: "action.toggle-snap-mode", - menu: "action.toggle-snap-mode.menu" - }, - onSelect(source) { - trackEvent("toggle-snap-mode", { source }); - editor.user.updateUserPreferences({ isSnapMode: !editor.user.getIsSnapMode() }); - }, - checkbox: true - }, - { - id: "toggle-dark-mode", - label: { - default: "action.toggle-dark-mode", - menu: "action.toggle-dark-mode.menu" - }, - kbd: "$/", - readonlyOk: true, - onSelect(source) { - const value = editor.user.getIsDarkMode() ? "light" : "dark"; - trackEvent("color-scheme", { source, value }); - editor.user.updateUserPreferences({ - colorScheme: value - }); - }, - checkbox: true - }, - { - id: "toggle-wrap-mode", - label: { - default: "action.toggle-wrap-mode", - menu: "action.toggle-wrap-mode.menu" - }, - readonlyOk: true, - onSelect(source) { - trackEvent("toggle-wrap-mode", { source }); - editor.user.updateUserPreferences({ - isWrapMode: !editor.user.getIsWrapMode() - }); - }, - checkbox: true - }, - { - id: "toggle-dynamic-size-mode", - label: { - default: "action.toggle-dynamic-size-mode", - menu: "action.toggle-dynamic-size-mode.menu" - }, - readonlyOk: false, - onSelect(source) { - trackEvent("toggle-dynamic-size-mode", { source }); - editor.user.updateUserPreferences({ - isDynamicSizeMode: !editor.user.getIsDynamicResizeMode() - }); - }, - checkbox: true - }, - { - id: "toggle-paste-at-cursor", - label: { - default: "action.toggle-paste-at-cursor", - menu: "action.toggle-paste-at-cursor.menu" - }, - readonlyOk: false, - onSelect(source) { - trackEvent("toggle-paste-at-cursor", { source }); - editor.user.updateUserPreferences({ - isPasteAtCursorMode: !editor.user.getIsPasteAtCursorMode() - }); - }, - checkbox: true - }, - { - id: "toggle-reduce-motion", - label: { - default: "action.toggle-reduce-motion", - menu: "action.toggle-reduce-motion.menu" - }, - readonlyOk: true, - onSelect(source) { - trackEvent("toggle-reduce-motion", { source }); - editor.user.updateUserPreferences({ - animationSpeed: editor.user.getAnimationSpeed() === 0 ? 1 : 0 - }); - }, - checkbox: true - }, - { - id: "toggle-edge-scrolling", - label: { - default: "action.toggle-edge-scrolling", - menu: "action.toggle-edge-scrolling.menu" - }, - readonlyOk: true, - onSelect(source) { - trackEvent("toggle-edge-scrolling", { source }); - editor.user.updateUserPreferences({ - edgeScrollSpeed: editor.user.getEdgeScrollSpeed() === 0 ? 1 : 0 - }); - }, - checkbox: true - }, - { - id: "toggle-transparent", - label: { - default: "action.toggle-transparent", - menu: "action.toggle-transparent.menu", - ["context-menu"]: "action.toggle-transparent.context-menu" - }, - readonlyOk: true, - onSelect(source) { - trackEvent("toggle-transparent", { source }); - editor.updateInstanceState({ - exportBackground: !editor.getInstanceState().exportBackground - }); - }, - checkbox: true - }, - { - id: "toggle-tool-lock", - label: { - default: "action.toggle-tool-lock", - menu: "action.toggle-tool-lock.menu" - }, - kbd: "q", - onSelect(source) { - trackEvent("toggle-tool-lock", { source }); - editor.updateInstanceState({ isToolLocked: !editor.getInstanceState().isToolLocked }); - }, - checkbox: true - }, - { - id: "unlock-all", - label: "action.unlock-all", - onSelect(source) { - trackEvent("unlock-all", { source }); - const updates = []; - for (const shape of editor.getCurrentPageShapes()) { - if (shape.isLocked) { - updates.push({ id: shape.id, type: shape.type, isLocked: false }); - } - } - if (updates.length > 0) { - editor.updateShapes(updates); - } - } - }, - { - id: "toggle-focus-mode", - label: { - default: "action.toggle-focus-mode", - menu: "action.toggle-focus-mode.menu" - }, - readonlyOk: true, - kbd: "$.", - checkbox: true, - onSelect(source) { - editor.timers.requestAnimationFrame(() => { - editor.run(() => { - trackEvent("toggle-focus-mode", { source }); - clearDialogs(); - clearToasts(); - editor.updateInstanceState({ isFocusMode: !editor.getInstanceState().isFocusMode }); - }); - }); - } - }, - { - id: "toggle-grid", - label: { - default: "action.toggle-grid", - menu: "action.toggle-grid.menu" - }, - readonlyOk: true, - kbd: "$'", - onSelect(source) { - trackEvent("toggle-grid-mode", { source }); - editor.updateInstanceState({ isGridMode: !editor.getInstanceState().isGridMode }); - }, - checkbox: true - }, - { - id: "toggle-debug-mode", - label: { - default: "action.toggle-debug-mode", - menu: "action.toggle-debug-mode.menu" - }, - readonlyOk: true, - onSelect(source) { - trackEvent("toggle-debug-mode", { source }); - editor.updateInstanceState({ - isDebugMode: !editor.getInstanceState().isDebugMode - }); - }, - checkbox: true - }, - { - id: "print", - label: "action.print", - kbd: "$p", - readonlyOk: true, - onSelect(source) { - trackEvent("print", { source }); - printSelectionOrPages(); - } - }, - { - id: "exit-pen-mode", - label: "action.exit-pen-mode", - icon: "cross-2", - readonlyOk: true, - onSelect(source) { - trackEvent("exit-pen-mode", { source }); - editor.updateInstanceState({ isPenMode: false }); - } - }, - { - id: "stop-following", - label: "action.stop-following", - icon: "cross-2", - readonlyOk: true, - onSelect(source) { - trackEvent("stop-following", { source }); - editor.stopFollowingUser(); - } - }, - { - id: "back-to-content", - label: "action.back-to-content", - icon: "arrow-left", - readonlyOk: true, - onSelect(source) { - trackEvent("zoom-to-content", { source }); - const bounds = editor.getSelectionPageBounds() ?? editor.getCurrentPageBounds(); - if (!bounds) - return; - editor.zoomToBounds(bounds, { - targetZoom: Math.min(1, editor.getZoomLevel()), - animation: { duration: 220 } - }); - } - }, - { - id: "toggle-lock", - label: "action.toggle-lock", - kbd: "!l", - onSelect(source) { - editor.mark("locking"); - trackEvent("toggle-lock", { source }); - editor.toggleLock(editor.getSelectedShapeIds()); - } - }, - { - id: "move-to-new-page", - label: "context.pages.new-page", - onSelect(source) { - const newPageId = PageRecordType.createId(); - const ids = editor.getSelectedShapeIds(); - editor.run(() => { - editor.mark("move_shapes_to_page"); - editor.createPage({ name: msg2("page-menu.new-page-initial-name"), id: newPageId }); - editor.moveShapesToPage(ids, newPageId); - }); - trackEvent("move-to-new-page", { source }); - } - }, - { - id: "select-white-color", - label: "color-style.white", - kbd: "?t", - onSelect(source) { - const style = DefaultColorStyle; - editor.run(() => { - editor.mark("change-color"); - if (editor.isIn("select")) { - editor.setStyleForSelectedShapes(style, "white"); - } - editor.setStyleForNextShapes(style, "white"); - }); - trackEvent("set-style", { source, id: style.id, value: "white" }); - } - }, - { - id: "select-fill-fill", - label: "fill-style.fill", - kbd: "?f", - onSelect(source) { - const style = DefaultFillStyle; - editor.run(() => { - editor.mark("change-fill"); - if (editor.isIn("select")) { - editor.setStyleForSelectedShapes(style, "fill"); - } - editor.setStyleForNextShapes(style, "fill"); - }); - trackEvent("set-style", { source, id: style.id, value: "fill" }); - } - }, - { - id: "flatten-to-image", - label: "action.flatten-to-image", - kbd: "!f", - onSelect: async (source) => { - const ids = editor.getSelectedShapeIds(); - if (ids.length === 0) - return; - editor.mark("flattening to image"); - trackEvent("flatten-to-image", { source }); - const newShapeIds = await flattenShapesToImages(editor, ids, editor.options.flattenImageBoundsExpand); - if (newShapeIds?.length) { - editor.setSelectedShapes(newShapeIds); - } - } - } - ]; - if (isMultiplayer) { - actionItems.push({ - id: "open-cursor-chat", - label: "action.open-cursor-chat", - readonlyOk: true, - kbd: "/", - onSelect(source) { - trackEvent("open-cursor-chat", { source }); - if (editor.getInstanceState().isCoarsePointer) { - return; - } - editor.timers.requestAnimationFrame(() => { - editor.updateInstanceState({ isChatting: true }); - }); - } - }); - } - const actions2 = makeActions(actionItems); - if (overrides) { - return overrides(editor, actions2, void 0); - } - return actions2; - }, [ - editor, - trackEvent, - overrides, - addDialog, - addToast, - insertMedia, - exportAs2, - copyAs2, - cut, - copy, - paste, - clearDialogs, - clearToasts, - printSelectionOrPages, - msg2, - defaultDocumentName, - isMultiplayer - ]); - return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ActionsContext.Provider, { value: asActions(actions), children }); -} -function useActions() { - const ctx = React50.useContext(ActionsContext); - if (!ctx) { - throw new Error("useTools must be used within a ToolProvider"); - } - return ctx; -} -function asActions(actions) { - return actions; -} -function unwrapLabel(label, menuType) { - return label ? typeof label === "string" ? label : menuType ? label[menuType] ?? label["default"] : void 0 : void 0; -} - -// node_modules/tldraw/dist-esm/lib/ui/context/components.mjs -var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1); -var import_react112 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs -var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1); -var import_react84 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs -var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@radix-ui/react-popover/dist/index.mjs -var React55 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-popper/dist/index.mjs -var React54 = __toESM(require_react(), 1); - -// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs -var sides = ["top", "right", "bottom", "left"]; -var min2 = Math.min; -var max = Math.max; -var round2 = Math.round; -var floor = Math.floor; -var createCoords = (v) => ({ - x: v, - y: v -}); -var oppositeSideMap = { - left: "right", - right: "left", - bottom: "top", - top: "bottom" -}; -var oppositeAlignmentMap = { - start: "end", - end: "start" -}; -function clamp2(start, value, end) { - return max(start, min2(value, end)); -} -function evaluate(value, param) { - return typeof value === "function" ? value(param) : value; -} -function getSide(placement) { - return placement.split("-")[0]; -} -function getAlignment(placement) { - return placement.split("-")[1]; -} -function getOppositeAxis(axis) { - return axis === "x" ? "y" : "x"; -} -function getAxisLength(axis) { - return axis === "y" ? "height" : "width"; -} -function getSideAxis(placement) { - return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x"; -} -function getAlignmentAxis(placement) { - return getOppositeAxis(getSideAxis(placement)); -} -function getAlignmentSides(placement, rects, rtl) { - if (rtl === void 0) { - rtl = false; - } - const alignment = getAlignment(placement); - const alignmentAxis = getAlignmentAxis(placement); - const length = getAxisLength(alignmentAxis); - let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; - if (rects.reference[length] > rects.floating[length]) { - mainAlignmentSide = getOppositePlacement(mainAlignmentSide); - } - return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; -} -function getExpandedPlacements(placement) { - const oppositePlacement = getOppositePlacement(placement); - return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; -} -function getOppositeAlignmentPlacement(placement) { - return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]); -} -function getSideList(side, isStart, rtl) { - const lr = ["left", "right"]; - const rl = ["right", "left"]; - const tb = ["top", "bottom"]; - const bt = ["bottom", "top"]; - switch (side) { - case "top": - case "bottom": - if (rtl) - return isStart ? rl : lr; - return isStart ? lr : rl; - case "left": - case "right": - return isStart ? tb : bt; - default: - return []; - } -} -function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { - const alignment = getAlignment(placement); - let list = getSideList(getSide(placement), direction === "start", rtl); - if (alignment) { - list = list.map((side) => side + "-" + alignment); - if (flipAlignment) { - list = list.concat(list.map(getOppositeAlignmentPlacement)); - } - } - return list; -} -function getOppositePlacement(placement) { - return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]); -} -function expandPaddingObject(padding) { - return { - top: 0, - right: 0, - bottom: 0, - left: 0, - ...padding - }; -} -function getPaddingObject(padding) { - return typeof padding !== "number" ? expandPaddingObject(padding) : { - top: padding, - right: padding, - bottom: padding, - left: padding - }; -} -function rectToClientRect(rect) { - const { - x, - y, - width, - height - } = rect; - return { - width, - height, - top: y, - left: x, - right: x + width, - bottom: y + height, - x, - y - }; -} - -// node_modules/@floating-ui/core/dist/floating-ui.core.mjs -function computeCoordsFromPlacement(_ref, placement, rtl) { - let { - reference, - floating - } = _ref; - const sideAxis = getSideAxis(placement); - const alignmentAxis = getAlignmentAxis(placement); - const alignLength = getAxisLength(alignmentAxis); - const side = getSide(placement); - const isVertical = sideAxis === "y"; - const commonX = reference.x + reference.width / 2 - floating.width / 2; - const commonY = reference.y + reference.height / 2 - floating.height / 2; - const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; - let coords; - switch (side) { - case "top": - coords = { - x: commonX, - y: reference.y - floating.height - }; - break; - case "bottom": - coords = { - x: commonX, - y: reference.y + reference.height - }; - break; - case "right": - coords = { - x: reference.x + reference.width, - y: commonY - }; - break; - case "left": - coords = { - x: reference.x - floating.width, - y: commonY - }; - break; - default: - coords = { - x: reference.x, - y: reference.y - }; - } - switch (getAlignment(placement)) { - case "start": - coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); - break; - case "end": - coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); - break; - } - return coords; -} -var computePosition = async (reference, floating, config) => { - const { - placement = "bottom", - strategy = "absolute", - middleware = [], - platform: platform2 - } = config; - const validMiddleware = middleware.filter(Boolean); - const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating)); - let rects = await platform2.getElementRects({ - reference, - floating, - strategy - }); - let { - x, - y - } = computeCoordsFromPlacement(rects, placement, rtl); - let statefulPlacement = placement; - let middlewareData = {}; - let resetCount = 0; - for (let i = 0; i < validMiddleware.length; i++) { - const { - name, - fn - } = validMiddleware[i]; - const { - x: nextX, - y: nextY, - data, - reset - } = await fn({ - x, - y, - initialPlacement: placement, - placement: statefulPlacement, - strategy, - middlewareData, - rects, - platform: platform2, - elements: { - reference, - floating - } - }); - x = nextX != null ? nextX : x; - y = nextY != null ? nextY : y; - middlewareData = { - ...middlewareData, - [name]: { - ...middlewareData[name], - ...data - } - }; - if (reset && resetCount <= 50) { - resetCount++; - if (typeof reset === "object") { - if (reset.placement) { - statefulPlacement = reset.placement; - } - if (reset.rects) { - rects = reset.rects === true ? await platform2.getElementRects({ - reference, - floating, - strategy - }) : reset.rects; - } - ({ - x, - y - } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); - } - i = -1; - } - } - return { - x, - y, - placement: statefulPlacement, - strategy, - middlewareData - }; -}; -async function detectOverflow(state, options) { - var _await$platform$isEle; - if (options === void 0) { - options = {}; - } - const { - x, - y, - platform: platform2, - rects, - elements, - strategy - } = state; - const { - boundary = "clippingAncestors", - rootBoundary = "viewport", - elementContext = "floating", - altBoundary = false, - padding = 0 - } = evaluate(options, state); - const paddingObject = getPaddingObject(padding); - const altContext = elementContext === "floating" ? "reference" : "floating"; - const element = elements[altBoundary ? altContext : elementContext]; - const clippingClientRect = rectToClientRect(await platform2.getClippingRect({ - element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)), - boundary, - rootBoundary, - strategy - })); - const rect = elementContext === "floating" ? { - x, - y, - width: rects.floating.width, - height: rects.floating.height - } : rects.reference; - const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating)); - const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || { - x: 1, - y: 1 - } : { - x: 1, - y: 1 - }; - const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({ - elements, - rect, - offsetParent, - strategy - }) : rect); - return { - top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, - bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, - left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, - right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x - }; -} -var arrow = (options) => ({ - name: "arrow", - options, - async fn(state) { - const { - x, - y, - placement, - rects, - platform: platform2, - elements, - middlewareData - } = state; - const { - element, - padding = 0 - } = evaluate(options, state) || {}; - if (element == null) { - return {}; - } - const paddingObject = getPaddingObject(padding); - const coords = { - x, - y - }; - const axis = getAlignmentAxis(placement); - const length = getAxisLength(axis); - const arrowDimensions = await platform2.getDimensions(element); - const isYAxis = axis === "y"; - const minProp = isYAxis ? "top" : "left"; - const maxProp = isYAxis ? "bottom" : "right"; - const clientProp = isYAxis ? "clientHeight" : "clientWidth"; - const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; - const startDiff = coords[axis] - rects.reference[axis]; - const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element)); - let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; - if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) { - clientSize = elements.floating[clientProp] || rects.floating[length]; - } - const centerToReference = endDiff / 2 - startDiff / 2; - const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; - const minPadding = min2(paddingObject[minProp], largestPossiblePadding); - const maxPadding = min2(paddingObject[maxProp], largestPossiblePadding); - const min$1 = minPadding; - const max2 = clientSize - arrowDimensions[length] - maxPadding; - const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; - const offset4 = clamp2(min$1, center, max2); - const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; - const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0; - return { - [axis]: coords[axis] + alignmentOffset, - data: { - [axis]: offset4, - centerOffset: center - offset4 - alignmentOffset, - ...shouldAddOffset && { - alignmentOffset - } - }, - reset: shouldAddOffset - }; - } -}); -var flip = function(options) { - if (options === void 0) { - options = {}; - } - return { - name: "flip", - options, - async fn(state) { - var _middlewareData$arrow, _middlewareData$flip; - const { - placement, - middlewareData, - rects, - initialPlacement, - platform: platform2, - elements - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true, - fallbackPlacements: specifiedFallbackPlacements, - fallbackStrategy = "bestFit", - fallbackAxisSideDirection = "none", - flipAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - const side = getSide(placement); - const initialSideAxis = getSideAxis(initialPlacement); - const isBasePlacement = getSide(initialPlacement) === initialPlacement; - const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)); - const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); - const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; - if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { - fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); - } - const placements2 = [initialPlacement, ...fallbackPlacements]; - const overflow = await detectOverflow(state, detectOverflowOptions); - const overflows = []; - let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; - if (checkMainAxis) { - overflows.push(overflow[side]); - } - if (checkCrossAxis) { - const sides2 = getAlignmentSides(placement, rects, rtl); - overflows.push(overflow[sides2[0]], overflow[sides2[1]]); - } - overflowsData = [...overflowsData, { - placement, - overflows - }]; - if (!overflows.every((side2) => side2 <= 0)) { - var _middlewareData$flip2, _overflowsData$filter; - const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; - const nextPlacement = placements2[nextIndex]; - if (nextPlacement) { - return { - data: { - index: nextIndex, - overflows: overflowsData - }, - reset: { - placement: nextPlacement - } - }; - } - let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; - if (!resetPlacement) { - switch (fallbackStrategy) { - case "bestFit": { - var _overflowsData$filter2; - const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => { - if (hasFallbackAxisSideDirection) { - const currentSideAxis = getSideAxis(d.placement); - return currentSideAxis === initialSideAxis || currentSideAxis === "y"; - } - return true; - }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; - if (placement2) { - resetPlacement = placement2; - } - break; - } - case "initialPlacement": - resetPlacement = initialPlacement; - break; - } - } - if (placement !== resetPlacement) { - return { - reset: { - placement: resetPlacement - } - }; - } - } - return {}; - } - }; -}; -function getSideOffsets(overflow, rect) { - return { - top: overflow.top - rect.height, - right: overflow.right - rect.width, - bottom: overflow.bottom - rect.height, - left: overflow.left - rect.width - }; -} -function isAnySideFullyClipped(overflow) { - return sides.some((side) => overflow[side] >= 0); -} -var hide = function(options) { - if (options === void 0) { - options = {}; - } - return { - name: "hide", - options, - async fn(state) { - const { - rects - } = state; - const { - strategy = "referenceHidden", - ...detectOverflowOptions - } = evaluate(options, state); - switch (strategy) { - case "referenceHidden": { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - elementContext: "reference" - }); - const offsets = getSideOffsets(overflow, rects.reference); - return { - data: { - referenceHiddenOffsets: offsets, - referenceHidden: isAnySideFullyClipped(offsets) - } - }; - } - case "escaped": { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - altBoundary: true - }); - const offsets = getSideOffsets(overflow, rects.floating); - return { - data: { - escapedOffsets: offsets, - escaped: isAnySideFullyClipped(offsets) - } - }; - } - default: { - return {}; - } - } - } - }; -}; -async function convertValueToCoords(state, options) { - const { - placement, - platform: platform2, - elements - } = state; - const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isVertical = getSideAxis(placement) === "y"; - const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1; - const crossAxisMulti = rtl && isVertical ? -1 : 1; - const rawValue = evaluate(options, state); - let { - mainAxis, - crossAxis, - alignmentAxis - } = typeof rawValue === "number" ? { - mainAxis: rawValue, - crossAxis: 0, - alignmentAxis: null - } : { - mainAxis: 0, - crossAxis: 0, - alignmentAxis: null, - ...rawValue - }; - if (alignment && typeof alignmentAxis === "number") { - crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; - } - return isVertical ? { - x: crossAxis * crossAxisMulti, - y: mainAxis * mainAxisMulti - } : { - x: mainAxis * mainAxisMulti, - y: crossAxis * crossAxisMulti - }; -} -var offset = function(options) { - if (options === void 0) { - options = 0; - } - return { - name: "offset", - options, - async fn(state) { - var _middlewareData$offse, _middlewareData$arrow; - const { - x, - y, - placement, - middlewareData - } = state; - const diffCoords = await convertValueToCoords(state, options); - if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - return { - x: x + diffCoords.x, - y: y + diffCoords.y, - data: { - ...diffCoords, - placement - } - }; - } - }; -}; -var shift = function(options) { - if (options === void 0) { - options = {}; - } - return { - name: "shift", - options, - async fn(state) { - const { - x, - y, - placement - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = false, - limiter = { - fn: (_ref) => { - let { - x: x2, - y: y2 - } = _ref; - return { - x: x2, - y: y2 - }; - } - }, - ...detectOverflowOptions - } = evaluate(options, state); - const coords = { - x, - y - }; - const overflow = await detectOverflow(state, detectOverflowOptions); - const crossAxis = getSideAxis(getSide(placement)); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - if (checkMainAxis) { - const minSide = mainAxis === "y" ? "top" : "left"; - const maxSide = mainAxis === "y" ? "bottom" : "right"; - const min3 = mainAxisCoord + overflow[minSide]; - const max2 = mainAxisCoord - overflow[maxSide]; - mainAxisCoord = clamp2(min3, mainAxisCoord, max2); - } - if (checkCrossAxis) { - const minSide = crossAxis === "y" ? "top" : "left"; - const maxSide = crossAxis === "y" ? "bottom" : "right"; - const min3 = crossAxisCoord + overflow[minSide]; - const max2 = crossAxisCoord - overflow[maxSide]; - crossAxisCoord = clamp2(min3, crossAxisCoord, max2); - } - const limitedCoords = limiter.fn({ - ...state, - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }); - return { - ...limitedCoords, - data: { - x: limitedCoords.x - x, - y: limitedCoords.y - y - } - }; - } - }; -}; -var limitShift = function(options) { - if (options === void 0) { - options = {}; - } - return { - options, - fn(state) { - const { - x, - y, - placement, - rects, - middlewareData - } = state; - const { - offset: offset4 = 0, - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true - } = evaluate(options, state); - const coords = { - x, - y - }; - const crossAxis = getSideAxis(placement); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - const rawOffset = evaluate(offset4, state); - const computedOffset = typeof rawOffset === "number" ? { - mainAxis: rawOffset, - crossAxis: 0 - } : { - mainAxis: 0, - crossAxis: 0, - ...rawOffset - }; - if (checkMainAxis) { - const len = mainAxis === "y" ? "height" : "width"; - const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; - const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; - if (mainAxisCoord < limitMin) { - mainAxisCoord = limitMin; - } else if (mainAxisCoord > limitMax) { - mainAxisCoord = limitMax; - } - } - if (checkCrossAxis) { - var _middlewareData$offse, _middlewareData$offse2; - const len = mainAxis === "y" ? "width" : "height"; - const isOriginSide = ["top", "left"].includes(getSide(placement)); - const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); - const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); - if (crossAxisCoord < limitMin) { - crossAxisCoord = limitMin; - } else if (crossAxisCoord > limitMax) { - crossAxisCoord = limitMax; - } - } - return { - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }; - } - }; -}; -var size = function(options) { - if (options === void 0) { - options = {}; - } - return { - name: "size", - options, - async fn(state) { - const { - placement, - rects, - platform: platform2, - elements - } = state; - const { - apply = () => { - }, - ...detectOverflowOptions - } = evaluate(options, state); - const overflow = await detectOverflow(state, detectOverflowOptions); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isYAxis = getSideAxis(placement) === "y"; - const { - width, - height - } = rects.floating; - let heightSide; - let widthSide; - if (side === "top" || side === "bottom") { - heightSide = side; - widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; - } else { - widthSide = side; - heightSide = alignment === "end" ? "top" : "bottom"; - } - const maximumClippingHeight = height - overflow.top - overflow.bottom; - const maximumClippingWidth = width - overflow.left - overflow.right; - const overflowAvailableHeight = min2(height - overflow[heightSide], maximumClippingHeight); - const overflowAvailableWidth = min2(width - overflow[widthSide], maximumClippingWidth); - const noShift = !state.middlewareData.shift; - let availableHeight = overflowAvailableHeight; - let availableWidth = overflowAvailableWidth; - if (isYAxis) { - availableWidth = alignment || noShift ? min2(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; - } else { - availableHeight = alignment || noShift ? min2(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; - } - if (noShift && !alignment) { - const xMin = max(overflow.left, 0); - const xMax = max(overflow.right, 0); - const yMin = max(overflow.top, 0); - const yMax = max(overflow.bottom, 0); - if (isYAxis) { - availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); - } else { - availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); - } - } - await apply({ - ...state, - availableWidth, - availableHeight - }); - const nextDimensions = await platform2.getDimensions(elements.floating); - if (width !== nextDimensions.width || height !== nextDimensions.height) { - return { - reset: { - rects: true - } - }; - } - return {}; - } - }; -}; - -// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs -function getNodeName(node) { - if (isNode(node)) { - return (node.nodeName || "").toLowerCase(); - } - return "#document"; -} -function getWindow(node) { - var _node$ownerDocument; - return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; -} -function getDocumentElement(node) { - var _ref; - return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; -} -function isNode(value) { - return value instanceof Node || value instanceof getWindow(value).Node; -} -function isElement(value) { - return value instanceof Element || value instanceof getWindow(value).Element; -} -function isHTMLElement2(value) { - return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; -} -function isShadowRoot(value) { - if (typeof ShadowRoot === "undefined") { - return false; - } - return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; -} -function isOverflowElement(element) { - const { - overflow, - overflowX, - overflowY, - display - } = getComputedStyle2(element); - return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display); -} -function isTableElement(element) { - return ["table", "td", "th"].includes(getNodeName(element)); -} -function isTopLayer(element) { - return [":popover-open", ":modal"].some((selector) => { - try { - return element.matches(selector); - } catch (e) { - return false; - } - }); -} -function isContainingBlock(elementOrCss) { - const webkit = isWebKit(); - const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; - return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value)); -} -function getContainingBlock(element) { - let currentNode = getParentNode(element); - while (isHTMLElement2(currentNode) && !isLastTraversableNode(currentNode)) { - if (isContainingBlock(currentNode)) { - return currentNode; - } else if (isTopLayer(currentNode)) { - return null; - } - currentNode = getParentNode(currentNode); - } - return null; -} -function isWebKit() { - if (typeof CSS === "undefined" || !CSS.supports) - return false; - return CSS.supports("-webkit-backdrop-filter", "none"); -} -function isLastTraversableNode(node) { - return ["html", "body", "#document"].includes(getNodeName(node)); -} -function getComputedStyle2(element) { - return getWindow(element).getComputedStyle(element); -} -function getNodeScroll(element) { - if (isElement(element)) { - return { - scrollLeft: element.scrollLeft, - scrollTop: element.scrollTop - }; - } - return { - scrollLeft: element.scrollX, - scrollTop: element.scrollY - }; -} -function getParentNode(node) { - if (getNodeName(node) === "html") { - return node; - } - const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node); - return isShadowRoot(result) ? result.host : result; -} -function getNearestOverflowAncestor(node) { - const parentNode = getParentNode(node); - if (isLastTraversableNode(parentNode)) { - return node.ownerDocument ? node.ownerDocument.body : node.body; - } - if (isHTMLElement2(parentNode) && isOverflowElement(parentNode)) { - return parentNode; - } - return getNearestOverflowAncestor(parentNode); -} -function getOverflowAncestors(node, list, traverseIframes) { - var _node$ownerDocument2; - if (list === void 0) { - list = []; - } - if (traverseIframes === void 0) { - traverseIframes = true; - } - const scrollableAncestor = getNearestOverflowAncestor(node); - const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); - const win = getWindow(scrollableAncestor); - if (isBody) { - return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []); - } - return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); -} - -// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs -function getCssDimensions(element) { - const css = getComputedStyle2(element); - let width = parseFloat(css.width) || 0; - let height = parseFloat(css.height) || 0; - const hasOffset = isHTMLElement2(element); - const offsetWidth = hasOffset ? element.offsetWidth : width; - const offsetHeight = hasOffset ? element.offsetHeight : height; - const shouldFallback = round2(width) !== offsetWidth || round2(height) !== offsetHeight; - if (shouldFallback) { - width = offsetWidth; - height = offsetHeight; - } - return { - width, - height, - $: shouldFallback - }; -} -function unwrapElement(element) { - return !isElement(element) ? element.contextElement : element; -} -function getScale(element) { - const domElement = unwrapElement(element); - if (!isHTMLElement2(domElement)) { - return createCoords(1); - } - const rect = domElement.getBoundingClientRect(); - const { - width, - height, - $ - } = getCssDimensions(domElement); - let x = ($ ? round2(rect.width) : rect.width) / width; - let y = ($ ? round2(rect.height) : rect.height) / height; - if (!x || !Number.isFinite(x)) { - x = 1; - } - if (!y || !Number.isFinite(y)) { - y = 1; - } - return { - x, - y - }; -} -var noOffsets = /* @__PURE__ */ createCoords(0); -function getVisualOffsets(element) { - const win = getWindow(element); - if (!isWebKit() || !win.visualViewport) { - return noOffsets; - } - return { - x: win.visualViewport.offsetLeft, - y: win.visualViewport.offsetTop - }; -} -function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { - if (isFixed === void 0) { - isFixed = false; - } - if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { - return false; - } - return isFixed; -} -function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { - if (includeScale === void 0) { - includeScale = false; - } - if (isFixedStrategy === void 0) { - isFixedStrategy = false; - } - const clientRect = element.getBoundingClientRect(); - const domElement = unwrapElement(element); - let scale = createCoords(1); - if (includeScale) { - if (offsetParent) { - if (isElement(offsetParent)) { - scale = getScale(offsetParent); - } - } else { - scale = getScale(element); - } - } - const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); - let x = (clientRect.left + visualOffsets.x) / scale.x; - let y = (clientRect.top + visualOffsets.y) / scale.y; - let width = clientRect.width / scale.x; - let height = clientRect.height / scale.y; - if (domElement) { - const win = getWindow(domElement); - const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; - let currentWin = win; - let currentIFrame = currentWin.frameElement; - while (currentIFrame && offsetParent && offsetWin !== currentWin) { - const iframeScale = getScale(currentIFrame); - const iframeRect = currentIFrame.getBoundingClientRect(); - const css = getComputedStyle2(currentIFrame); - const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; - const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; - x *= iframeScale.x; - y *= iframeScale.y; - width *= iframeScale.x; - height *= iframeScale.y; - x += left; - y += top; - currentWin = getWindow(currentIFrame); - currentIFrame = currentWin.frameElement; - } - } - return rectToClientRect({ - width, - height, - x, - y - }); -} -function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { - let { - elements, - rect, - offsetParent, - strategy - } = _ref; - const isFixed = strategy === "fixed"; - const documentElement = getDocumentElement(offsetParent); - const topLayer = elements ? isTopLayer(elements.floating) : false; - if (offsetParent === documentElement || topLayer && isFixed) { - return rect; - } - let scroll = { - scrollLeft: 0, - scrollTop: 0 - }; - let scale = createCoords(1); - const offsets = createCoords(0); - const isOffsetParentAnElement = isHTMLElement2(offsetParent); - if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { - if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { - scroll = getNodeScroll(offsetParent); - } - if (isHTMLElement2(offsetParent)) { - const offsetRect = getBoundingClientRect(offsetParent); - scale = getScale(offsetParent); - offsets.x = offsetRect.x + offsetParent.clientLeft; - offsets.y = offsetRect.y + offsetParent.clientTop; - } - } - return { - width: rect.width * scale.x, - height: rect.height * scale.y, - x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x, - y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y - }; -} -function getClientRects(element) { - return Array.from(element.getClientRects()); -} -function getWindowScrollBarX(element) { - return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; -} -function getDocumentRect(element) { - const html = getDocumentElement(element); - const scroll = getNodeScroll(element); - const body = element.ownerDocument.body; - const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); - const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); - let x = -scroll.scrollLeft + getWindowScrollBarX(element); - const y = -scroll.scrollTop; - if (getComputedStyle2(body).direction === "rtl") { - x += max(html.clientWidth, body.clientWidth) - width; - } - return { - width, - height, - x, - y - }; -} -function getViewportRect(element, strategy) { - const win = getWindow(element); - const html = getDocumentElement(element); - const visualViewport = win.visualViewport; - let width = html.clientWidth; - let height = html.clientHeight; - let x = 0; - let y = 0; - if (visualViewport) { - width = visualViewport.width; - height = visualViewport.height; - const visualViewportBased = isWebKit(); - if (!visualViewportBased || visualViewportBased && strategy === "fixed") { - x = visualViewport.offsetLeft; - y = visualViewport.offsetTop; - } - } - return { - width, - height, - x, - y - }; -} -function getInnerBoundingClientRect(element, strategy) { - const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); - const top = clientRect.top + element.clientTop; - const left = clientRect.left + element.clientLeft; - const scale = isHTMLElement2(element) ? getScale(element) : createCoords(1); - const width = element.clientWidth * scale.x; - const height = element.clientHeight * scale.y; - const x = left * scale.x; - const y = top * scale.y; - return { - width, - height, - x, - y - }; -} -function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { - let rect; - if (clippingAncestor === "viewport") { - rect = getViewportRect(element, strategy); - } else if (clippingAncestor === "document") { - rect = getDocumentRect(getDocumentElement(element)); - } else if (isElement(clippingAncestor)) { - rect = getInnerBoundingClientRect(clippingAncestor, strategy); - } else { - const visualOffsets = getVisualOffsets(element); - rect = { - ...clippingAncestor, - x: clippingAncestor.x - visualOffsets.x, - y: clippingAncestor.y - visualOffsets.y - }; - } - return rectToClientRect(rect); -} -function hasFixedPositionAncestor(element, stopNode) { - const parentNode = getParentNode(element); - if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { - return false; - } - return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); -} -function getClippingElementAncestors(element, cache) { - const cachedResult = cache.get(element); - if (cachedResult) { - return cachedResult; - } - let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); - let currentContainingBlockComputedStyle = null; - const elementIsFixed = getComputedStyle2(element).position === "fixed"; - let currentNode = elementIsFixed ? getParentNode(element) : element; - while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { - const computedStyle = getComputedStyle2(currentNode); - const currentNodeIsContaining = isContainingBlock(currentNode); - if (!currentNodeIsContaining && computedStyle.position === "fixed") { - currentContainingBlockComputedStyle = null; - } - const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); - if (shouldDropCurrentNode) { - result = result.filter((ancestor) => ancestor !== currentNode); - } else { - currentContainingBlockComputedStyle = computedStyle; - } - currentNode = getParentNode(currentNode); - } - cache.set(element, result); - return result; -} -function getClippingRect(_ref) { - let { - element, - boundary, - rootBoundary, - strategy - } = _ref; - const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); - const clippingAncestors = [...elementClippingAncestors, rootBoundary]; - const firstClippingAncestor = clippingAncestors[0]; - const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => { - const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy); - accRect.top = max(rect.top, accRect.top); - accRect.right = min2(rect.right, accRect.right); - accRect.bottom = min2(rect.bottom, accRect.bottom); - accRect.left = max(rect.left, accRect.left); - return accRect; - }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); - return { - width: clippingRect.right - clippingRect.left, - height: clippingRect.bottom - clippingRect.top, - x: clippingRect.left, - y: clippingRect.top - }; -} -function getDimensions(element) { - const { - width, - height - } = getCssDimensions(element); - return { - width, - height - }; -} -function getRectRelativeToOffsetParent(element, offsetParent, strategy) { - const isOffsetParentAnElement = isHTMLElement2(offsetParent); - const documentElement = getDocumentElement(offsetParent); - const isFixed = strategy === "fixed"; - const rect = getBoundingClientRect(element, true, isFixed, offsetParent); - let scroll = { - scrollLeft: 0, - scrollTop: 0 - }; - const offsets = createCoords(0); - if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { - if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { - scroll = getNodeScroll(offsetParent); - } - if (isOffsetParentAnElement) { - const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); - offsets.x = offsetRect.x + offsetParent.clientLeft; - offsets.y = offsetRect.y + offsetParent.clientTop; - } else if (documentElement) { - offsets.x = getWindowScrollBarX(documentElement); - } - } - const x = rect.left + scroll.scrollLeft - offsets.x; - const y = rect.top + scroll.scrollTop - offsets.y; - return { - x, - y, - width: rect.width, - height: rect.height - }; -} -function isStaticPositioned(element) { - return getComputedStyle2(element).position === "static"; -} -function getTrueOffsetParent(element, polyfill) { - if (!isHTMLElement2(element) || getComputedStyle2(element).position === "fixed") { - return null; - } - if (polyfill) { - return polyfill(element); - } - return element.offsetParent; -} -function getOffsetParent(element, polyfill) { - const win = getWindow(element); - if (isTopLayer(element)) { - return win; - } - if (!isHTMLElement2(element)) { - let svgOffsetParent = getParentNode(element); - while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { - if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { - return svgOffsetParent; - } - svgOffsetParent = getParentNode(svgOffsetParent); - } - return win; - } - let offsetParent = getTrueOffsetParent(element, polyfill); - while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { - offsetParent = getTrueOffsetParent(offsetParent, polyfill); - } - if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { - return win; - } - return offsetParent || getContainingBlock(element) || win; -} -var getElementRects = async function(data) { - const getOffsetParentFn = this.getOffsetParent || getOffsetParent; - const getDimensionsFn = this.getDimensions; - const floatingDimensions = await getDimensionsFn(data.floating); - return { - reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), - floating: { - x: 0, - y: 0, - width: floatingDimensions.width, - height: floatingDimensions.height - } - }; -}; -function isRTL(element) { - return getComputedStyle2(element).direction === "rtl"; -} -var platform = { - convertOffsetParentRelativeRectToViewportRelativeRect, - getDocumentElement, - getClippingRect, - getOffsetParent, - getElementRects, - getClientRects, - getDimensions, - getScale, - isElement, - isRTL -}; -function observeMove(element, onMove) { - let io = null; - let timeoutId; - const root = getDocumentElement(element); - function cleanup() { - var _io; - clearTimeout(timeoutId); - (_io = io) == null || _io.disconnect(); - io = null; - } - function refresh(skip, threshold) { - if (skip === void 0) { - skip = false; - } - if (threshold === void 0) { - threshold = 1; - } - cleanup(); - const { - left, - top, - width, - height - } = element.getBoundingClientRect(); - if (!skip) { - onMove(); - } - if (!width || !height) { - return; - } - const insetTop = floor(top); - const insetRight = floor(root.clientWidth - (left + width)); - const insetBottom = floor(root.clientHeight - (top + height)); - const insetLeft = floor(left); - const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; - const options = { - rootMargin, - threshold: max(0, min2(1, threshold)) || 1 - }; - let isFirstUpdate = true; - function handleObserve(entries) { - const ratio = entries[0].intersectionRatio; - if (ratio !== threshold) { - if (!isFirstUpdate) { - return refresh(); - } - if (!ratio) { - timeoutId = setTimeout(() => { - refresh(false, 1e-7); - }, 1e3); - } else { - refresh(false, ratio); - } - } - isFirstUpdate = false; - } - try { - io = new IntersectionObserver(handleObserve, { - ...options, - root: root.ownerDocument - }); - } catch (e) { - io = new IntersectionObserver(handleObserve, options); - } - io.observe(element); - } - refresh(true); - return cleanup; -} -function autoUpdate(reference, floating, update, options) { - if (options === void 0) { - options = {}; - } - const { - ancestorScroll = true, - ancestorResize = true, - elementResize = typeof ResizeObserver === "function", - layoutShift = typeof IntersectionObserver === "function", - animationFrame = false - } = options; - const referenceEl = unwrapElement(reference); - const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : []; - ancestors.forEach((ancestor) => { - ancestorScroll && ancestor.addEventListener("scroll", update, { - passive: true - }); - ancestorResize && ancestor.addEventListener("resize", update); - }); - const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null; - let reobserveFrame = -1; - let resizeObserver = null; - if (elementResize) { - resizeObserver = new ResizeObserver((_ref) => { - let [firstEntry] = _ref; - if (firstEntry && firstEntry.target === referenceEl && resizeObserver) { - resizeObserver.unobserve(floating); - cancelAnimationFrame(reobserveFrame); - reobserveFrame = requestAnimationFrame(() => { - var _resizeObserver; - (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); - }); - } - update(); - }); - if (referenceEl && !animationFrame) { - resizeObserver.observe(referenceEl); - } - resizeObserver.observe(floating); - } - let frameId; - let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; - if (animationFrame) { - frameLoop(); - } - function frameLoop() { - const nextRefRect = getBoundingClientRect(reference); - if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) { - update(); - } - prevRefRect = nextRefRect; - frameId = requestAnimationFrame(frameLoop); - } - update(); - return () => { - var _resizeObserver2; - ancestors.forEach((ancestor) => { - ancestorScroll && ancestor.removeEventListener("scroll", update); - ancestorResize && ancestor.removeEventListener("resize", update); - }); - cleanupIo == null || cleanupIo(); - (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); - resizeObserver = null; - if (animationFrame) { - cancelAnimationFrame(frameId); - } - }; -} -var offset2 = offset; -var shift2 = shift; -var flip2 = flip; -var size2 = size; -var hide2 = hide; -var arrow2 = arrow; -var limitShift2 = limitShift; -var computePosition2 = (reference, floating, options) => { - const cache = /* @__PURE__ */ new Map(); - const mergedOptions = { - platform, - ...options - }; - const platformWithCache = { - ...mergedOptions.platform, - _c: cache - }; - return computePosition(reference, floating, { - ...mergedOptions, - platform: platformWithCache - }); -}; - -// node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs -var React51 = __toESM(require_react(), 1); -var import_react80 = __toESM(require_react(), 1); -var ReactDOM5 = __toESM(require_react_dom(), 1); -var index = typeof document !== "undefined" ? import_react80.useLayoutEffect : import_react80.useEffect; -function deepEqual(a, b) { - if (a === b) { - return true; - } - if (typeof a !== typeof b) { - return false; - } - if (typeof a === "function" && a.toString() === b.toString()) { - return true; - } - let length; - let i; - let keys; - if (a && b && typeof a === "object") { - if (Array.isArray(a)) { - length = a.length; - if (length !== b.length) - return false; - for (i = length; i-- !== 0; ) { - if (!deepEqual(a[i], b[i])) { - return false; - } - } - return true; - } - keys = Object.keys(a); - length = keys.length; - if (length !== Object.keys(b).length) { - return false; - } - for (i = length; i-- !== 0; ) { - if (!{}.hasOwnProperty.call(b, keys[i])) { - return false; - } - } - for (i = length; i-- !== 0; ) { - const key = keys[i]; - if (key === "_owner" && a.$$typeof) { - continue; - } - if (!deepEqual(a[key], b[key])) { - return false; - } - } - return true; - } - return a !== a && b !== b; -} -function getDPR(element) { - if (typeof window === "undefined") { - return 1; - } - const win = element.ownerDocument.defaultView || window; - return win.devicePixelRatio || 1; -} -function roundByDPR(element, value) { - const dpr = getDPR(element); - return Math.round(value * dpr) / dpr; -} -function useLatestRef(value) { - const ref = React51.useRef(value); - index(() => { - ref.current = value; - }); - return ref; -} -function useFloating(options) { - if (options === void 0) { - options = {}; - } - const { - placement = "bottom", - strategy = "absolute", - middleware = [], - platform: platform2, - elements: { - reference: externalReference, - floating: externalFloating - } = {}, - transform = true, - whileElementsMounted, - open - } = options; - const [data, setData] = React51.useState({ - x: 0, - y: 0, - strategy, - placement, - middlewareData: {}, - isPositioned: false - }); - const [latestMiddleware, setLatestMiddleware] = React51.useState(middleware); - if (!deepEqual(latestMiddleware, middleware)) { - setLatestMiddleware(middleware); - } - const [_reference, _setReference] = React51.useState(null); - const [_floating, _setFloating] = React51.useState(null); - const setReference = React51.useCallback((node) => { - if (node !== referenceRef.current) { - referenceRef.current = node; - _setReference(node); - } - }, []); - const setFloating = React51.useCallback((node) => { - if (node !== floatingRef.current) { - floatingRef.current = node; - _setFloating(node); - } - }, []); - const referenceEl = externalReference || _reference; - const floatingEl = externalFloating || _floating; - const referenceRef = React51.useRef(null); - const floatingRef = React51.useRef(null); - const dataRef = React51.useRef(data); - const hasWhileElementsMounted = whileElementsMounted != null; - const whileElementsMountedRef = useLatestRef(whileElementsMounted); - const platformRef = useLatestRef(platform2); - const update = React51.useCallback(() => { - if (!referenceRef.current || !floatingRef.current) { - return; - } - const config = { - placement, - strategy, - middleware: latestMiddleware - }; - if (platformRef.current) { - config.platform = platformRef.current; - } - computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { - const fullData = { - ...data2, - isPositioned: true - }; - if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { - dataRef.current = fullData; - ReactDOM5.flushSync(() => { - setData(fullData); - }); - } - }); - }, [latestMiddleware, placement, strategy, platformRef]); - index(() => { - if (open === false && dataRef.current.isPositioned) { - dataRef.current.isPositioned = false; - setData((data2) => ({ - ...data2, - isPositioned: false - })); - } - }, [open]); - const isMountedRef = React51.useRef(false); - index(() => { - isMountedRef.current = true; - return () => { - isMountedRef.current = false; - }; - }, []); - index(() => { - if (referenceEl) - referenceRef.current = referenceEl; - if (floatingEl) - floatingRef.current = floatingEl; - if (referenceEl && floatingEl) { - if (whileElementsMountedRef.current) { - return whileElementsMountedRef.current(referenceEl, floatingEl, update); - } - update(); - } - }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]); - const refs = React51.useMemo(() => ({ - reference: referenceRef, - floating: floatingRef, - setReference, - setFloating - }), [setReference, setFloating]); - const elements = React51.useMemo(() => ({ - reference: referenceEl, - floating: floatingEl - }), [referenceEl, floatingEl]); - const floatingStyles = React51.useMemo(() => { - const initialStyles = { - position: strategy, - left: 0, - top: 0 - }; - if (!elements.floating) { - return initialStyles; - } - const x = roundByDPR(elements.floating, data.x); - const y = roundByDPR(elements.floating, data.y); - if (transform) { - return { - ...initialStyles, - transform: "translate(" + x + "px, " + y + "px)", - ...getDPR(elements.floating) >= 1.5 && { - willChange: "transform" - } - }; - } - return { - position: strategy, - left: x, - top: y - }; - }, [strategy, transform, elements.floating, data.x, data.y]); - return React51.useMemo(() => ({ - ...data, - update, - refs, - elements, - floatingStyles - }), [data, update, refs, elements, floatingStyles]); -} -var arrow$1 = (options) => { - function isRef(value) { - return {}.hasOwnProperty.call(value, "current"); - } - return { - name: "arrow", - options, - fn(state) { - const { - element, - padding - } = typeof options === "function" ? options(state) : options; - if (element && isRef(element)) { - if (element.current != null) { - return arrow2({ - element: element.current, - padding - }).fn(state); - } - return {}; - } - if (element) { - return arrow2({ - element, - padding - }).fn(state); - } - return {}; - } - }; -}; -var offset3 = (options, deps) => ({ - ...offset2(options), - options: [options, deps] -}); -var shift3 = (options, deps) => ({ - ...shift2(options), - options: [options, deps] -}); -var limitShift3 = (options, deps) => ({ - ...limitShift2(options), - options: [options, deps] -}); -var flip3 = (options, deps) => ({ - ...flip2(options), - options: [options, deps] -}); -var size3 = (options, deps) => ({ - ...size2(options), - options: [options, deps] -}); -var hide3 = (options, deps) => ({ - ...hide2(options), - options: [options, deps] -}); -var arrow3 = (options, deps) => ({ - ...arrow$1(options), - options: [options, deps] -}); - -// node_modules/@radix-ui/react-arrow/dist/index.mjs -var React52 = __toESM(require_react(), 1); -var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1); -var NAME2 = "Arrow"; -var Arrow = React52.forwardRef((props, forwardedRef) => { - const { children, width = 10, height = 5, ...arrowProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Primitive.svg, { - ...arrowProps, - ref: forwardedRef, - width, - height, - viewBox: "0 0 30 10", - preserveAspectRatio: "none", - children: props.asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("polygon", { points: "0,0 30,0 15,10" }) - }); -}); -Arrow.displayName = NAME2; -var Root3 = Arrow; - -// node_modules/@radix-ui/react-use-size/dist/index.mjs -var React53 = __toESM(require_react(), 1); -function useSize(element) { - const [size4, setSize] = React53.useState(void 0); - useLayoutEffect22(() => { - if (element) { - setSize({ width: element.offsetWidth, height: element.offsetHeight }); - const resizeObserver = new ResizeObserver((entries) => { - if (!Array.isArray(entries)) { - return; - } - if (!entries.length) { - return; - } - const entry = entries[0]; - let width; - let height; - if ("borderBoxSize" in entry) { - const borderSizeEntry = entry["borderBoxSize"]; - const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry; - width = borderSize["inlineSize"]; - height = borderSize["blockSize"]; - } else { - width = element.offsetWidth; - height = element.offsetHeight; - } - setSize({ width, height }); - }); - resizeObserver.observe(element, { box: "border-box" }); - return () => resizeObserver.unobserve(element); - } else { - setSize(void 0); - } - }, [element]); - return size4; -} - -// node_modules/@radix-ui/react-popper/dist/index.mjs -var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1); -"use client"; -var POPPER_NAME = "Popper"; -var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME); -var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME); -var Popper = (props) => { - const { __scopePopper, children } = props; - const [anchor, setAnchor] = React54.useState(null); - return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children }); -}; -Popper.displayName = POPPER_NAME; -var ANCHOR_NAME = "PopperAnchor"; -var PopperAnchor = React54.forwardRef((props, forwardedRef) => { - const { __scopePopper, virtualRef, ...anchorProps } = props; - const context = usePopperContext(ANCHOR_NAME, __scopePopper); - const ref = React54.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - React54.useEffect(() => { - context.onAnchorChange(virtualRef?.current || ref.current); - }); - return virtualRef ? null : /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Primitive.div, { ...anchorProps, ref: composedRefs }); -}); -PopperAnchor.displayName = ANCHOR_NAME; -var CONTENT_NAME2 = "PopperContent"; -var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME2); -var PopperContent = React54.forwardRef((props, forwardedRef) => { - const { - __scopePopper, - side = "bottom", - sideOffset = 0, - align = "center", - alignOffset = 0, - arrowPadding = 0, - avoidCollisions = true, - collisionBoundary = [], - collisionPadding: collisionPaddingProp = 0, - sticky = "partial", - hideWhenDetached = false, - updatePositionStrategy = "optimized", - onPlaced, - ...contentProps - } = props; - const context = usePopperContext(CONTENT_NAME2, __scopePopper); - const [content, setContent] = React54.useState(null); - const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node)); - const [arrow4, setArrow] = React54.useState(null); - const arrowSize = useSize(arrow4); - const arrowWidth = arrowSize?.width ?? 0; - const arrowHeight = arrowSize?.height ?? 0; - const desiredPlacement = side + (align !== "center" ? "-" + align : ""); - const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp }; - const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary]; - const hasExplicitBoundaries = boundary.length > 0; - const detectOverflowOptions = { - padding: collisionPadding, - boundary: boundary.filter(isNotNull), - altBoundary: hasExplicitBoundaries - }; - const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({ - strategy: "fixed", - placement: desiredPlacement, - whileElementsMounted: (...args) => { - const cleanup = autoUpdate(...args, { - animationFrame: updatePositionStrategy === "always" - }); - return cleanup; - }, - elements: { - reference: context.anchor - }, - middleware: [ - offset3({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }), - avoidCollisions && shift3({ - mainAxis: true, - crossAxis: false, - limiter: sticky === "partial" ? limitShift3() : void 0, - ...detectOverflowOptions - }), - avoidCollisions && flip3({ ...detectOverflowOptions }), - size3({ - ...detectOverflowOptions, - apply: ({ elements, rects, availableWidth, availableHeight }) => { - const { width: anchorWidth, height: anchorHeight } = rects.reference; - const contentStyle = elements.floating.style; - contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`); - contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`); - contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`); - contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`); - } - }), - arrow4 && arrow3({ element: arrow4, padding: arrowPadding }), - transformOrigin({ arrowWidth, arrowHeight }), - hideWhenDetached && hide3({ strategy: "referenceHidden", ...detectOverflowOptions }) - ] - }); - const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement); - const handlePlaced = useCallbackRef(onPlaced); - useLayoutEffect22(() => { - if (isPositioned) { - handlePlaced?.(); - } - }, [isPositioned, handlePlaced]); - const arrowX = middlewareData.arrow?.x; - const arrowY = middlewareData.arrow?.y; - const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0; - const [contentZIndex, setContentZIndex] = React54.useState(); - useLayoutEffect22(() => { - if (content) - setContentZIndex(window.getComputedStyle(content).zIndex); - }, [content]); - return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { - ref: refs.setFloating, - "data-radix-popper-content-wrapper": "", - style: { - ...floatingStyles, - transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)", - minWidth: "max-content", - zIndex: contentZIndex, - ["--radix-popper-transform-origin"]: [ - middlewareData.transformOrigin?.x, - middlewareData.transformOrigin?.y - ].join(" "), - ...middlewareData.hide?.referenceHidden && { - visibility: "hidden", - pointerEvents: "none" - } - }, - dir: props.dir, - children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(PopperContentProvider, { - scope: __scopePopper, - placedSide, - onArrowChange: setArrow, - arrowX, - arrowY, - shouldHideArrow: cannotCenterArrow, - children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Primitive.div, { - "data-side": placedSide, - "data-align": placedAlign, - ...contentProps, - ref: composedRefs, - style: { - ...contentProps.style, - animation: !isPositioned ? "none" : void 0 - } - }) - }) - }); -}); -PopperContent.displayName = CONTENT_NAME2; -var ARROW_NAME = "PopperArrow"; -var OPPOSITE_SIDE = { - top: "bottom", - right: "left", - bottom: "top", - left: "right" -}; -var PopperArrow = React54.forwardRef(function PopperArrow2(props, forwardedRef) { - const { __scopePopper, ...arrowProps } = props; - const contentContext = useContentContext(ARROW_NAME, __scopePopper); - const baseSide = OPPOSITE_SIDE[contentContext.placedSide]; - return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { - ref: contentContext.onArrowChange, - style: { - position: "absolute", - left: contentContext.arrowX, - top: contentContext.arrowY, - [baseSide]: 0, - transformOrigin: { - top: "", - right: "0 0", - bottom: "center 0", - left: "100% 0" - }[contentContext.placedSide], - transform: { - top: "translateY(100%)", - right: "translateY(50%) rotate(90deg) translateX(-50%)", - bottom: `rotate(180deg)`, - left: "translateY(50%) rotate(-90deg) translateX(50%)" - }[contentContext.placedSide], - visibility: contentContext.shouldHideArrow ? "hidden" : void 0 - }, - children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Root3, { - ...arrowProps, - ref: forwardedRef, - style: { - ...arrowProps.style, - display: "block" - } - }) - }); -}); -PopperArrow.displayName = ARROW_NAME; -function isNotNull(value) { - return value !== null; -} -var transformOrigin = (options) => ({ - name: "transformOrigin", - options, - fn(data) { - const { placement, rects, middlewareData } = data; - const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0; - const isArrowHidden = cannotCenterArrow; - const arrowWidth = isArrowHidden ? 0 : options.arrowWidth; - const arrowHeight = isArrowHidden ? 0 : options.arrowHeight; - const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement); - const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign]; - const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2; - const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2; - let x = ""; - let y = ""; - if (placedSide === "bottom") { - x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`; - y = `${-arrowHeight}px`; - } else if (placedSide === "top") { - x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`; - y = `${rects.floating.height + arrowHeight}px`; - } else if (placedSide === "right") { - x = `${-arrowHeight}px`; - y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`; - } else if (placedSide === "left") { - x = `${rects.floating.width + arrowHeight}px`; - y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`; - } - return { data: { x, y } }; - } -}); -function getSideAndAlignFromPlacement(placement) { - const [side, align = "center"] = placement.split("-"); - return [side, align]; -} -var Root23 = Popper; -var Anchor = PopperAnchor; -var Content2 = PopperContent; -var Arrow2 = PopperArrow; - -// node_modules/@radix-ui/react-popover/dist/index.mjs -var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1); -"use client"; -var POPOVER_NAME = "Popover"; -var [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [ - createPopperScope -]); -var usePopperScope = createPopperScope(); -var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME); -var Popover = (props) => { - const { - __scopePopover, - children, - open: openProp, - defaultOpen, - onOpenChange, - modal = false - } = props; - const popperScope = usePopperScope(__scopePopover); - const triggerRef = React55.useRef(null); - const [hasCustomAnchor, setHasCustomAnchor] = React55.useState(false); - const [open = false, setOpen] = useControllableState({ - prop: openProp, - defaultProp: defaultOpen, - onChange: onOpenChange - }); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Root23, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(PopoverProvider, { - scope: __scopePopover, - contentId: useId2(), - triggerRef, - open, - onOpenChange: setOpen, - onOpenToggle: React55.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]), - hasCustomAnchor, - onCustomAnchorAdd: React55.useCallback(() => setHasCustomAnchor(true), []), - onCustomAnchorRemove: React55.useCallback(() => setHasCustomAnchor(false), []), - modal, - children - }) }); -}; -Popover.displayName = POPOVER_NAME; -var ANCHOR_NAME2 = "PopoverAnchor"; -var PopoverAnchor = React55.forwardRef((props, forwardedRef) => { - const { __scopePopover, ...anchorProps } = props; - const context = usePopoverContext(ANCHOR_NAME2, __scopePopover); - const popperScope = usePopperScope(__scopePopover); - const { onCustomAnchorAdd, onCustomAnchorRemove } = context; - React55.useEffect(() => { - onCustomAnchorAdd(); - return () => onCustomAnchorRemove(); - }, [onCustomAnchorAdd, onCustomAnchorRemove]); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef }); -}); -PopoverAnchor.displayName = ANCHOR_NAME2; -var TRIGGER_NAME2 = "PopoverTrigger"; -var PopoverTrigger = React55.forwardRef((props, forwardedRef) => { - const { __scopePopover, ...triggerProps } = props; - const context = usePopoverContext(TRIGGER_NAME2, __scopePopover); - const popperScope = usePopperScope(__scopePopover); - const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef); - const trigger2 = /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Primitive.button, { - type: "button", - "aria-haspopup": "dialog", - "aria-expanded": context.open, - "aria-controls": context.contentId, - "data-state": getState2(context.open), - ...triggerProps, - ref: composedTriggerRef, - onClick: composeEventHandlers(props.onClick, context.onOpenToggle) - }); - return context.hasCustomAnchor ? trigger2 : /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Anchor, { asChild: true, ...popperScope, children: trigger2 }); -}); -PopoverTrigger.displayName = TRIGGER_NAME2; -var PORTAL_NAME3 = "PopoverPortal"; -var [PortalProvider2, usePortalContext2] = createPopoverContext(PORTAL_NAME3, { - forceMount: void 0 -}); -var PopoverPortal = (props) => { - const { __scopePopover, forceMount, children, container } = props; - const context = usePopoverContext(PORTAL_NAME3, __scopePopover); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(PortalProvider2, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Portal, { asChild: true, container, children }) }) }); -}; -PopoverPortal.displayName = PORTAL_NAME3; -var CONTENT_NAME3 = "PopoverContent"; -var PopoverContent = React55.forwardRef((props, forwardedRef) => { - const portalContext = usePortalContext2(CONTENT_NAME3, props.__scopePopover); - const { forceMount = portalContext.forceMount, ...contentProps } = props; - const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) }); -}); -PopoverContent.displayName = CONTENT_NAME3; -var PopoverContentModal = React55.forwardRef((props, forwardedRef) => { - const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover); - const contentRef = React55.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, contentRef); - const isRightClickOutsideRef = React55.useRef(false); - React55.useEffect(() => { - const content = contentRef.current; - if (content) - return hideOthers(content); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Combination_default, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(PopoverContentImpl, { - ...props, - ref: composedRefs, - trapFocus: context.open, - disableOutsidePointerEvents: true, - onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => { - event.preventDefault(); - if (!isRightClickOutsideRef.current) - context.triggerRef.current?.focus(); - }), - onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => { - const originalEvent = event.detail.originalEvent; - const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true; - const isRightClick = originalEvent.button === 2 || ctrlLeftClick; - isRightClickOutsideRef.current = isRightClick; - }, { checkForDefaultPrevented: false }), - onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => event.preventDefault(), { checkForDefaultPrevented: false }) - }) }); -}); -var PopoverContentNonModal = React55.forwardRef((props, forwardedRef) => { - const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover); - const hasInteractedOutsideRef = React55.useRef(false); - const hasPointerDownOutsideRef = React55.useRef(false); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(PopoverContentImpl, { - ...props, - ref: forwardedRef, - trapFocus: false, - disableOutsidePointerEvents: false, - onCloseAutoFocus: (event) => { - props.onCloseAutoFocus?.(event); - if (!event.defaultPrevented) { - if (!hasInteractedOutsideRef.current) - context.triggerRef.current?.focus(); - event.preventDefault(); - } - hasInteractedOutsideRef.current = false; - hasPointerDownOutsideRef.current = false; - }, - onInteractOutside: (event) => { - props.onInteractOutside?.(event); - if (!event.defaultPrevented) { - hasInteractedOutsideRef.current = true; - if (event.detail.originalEvent.type === "pointerdown") { - hasPointerDownOutsideRef.current = true; - } - } - const target = event.target; - const targetIsTrigger = context.triggerRef.current?.contains(target); - if (targetIsTrigger) - event.preventDefault(); - if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) { - event.preventDefault(); - } - } - }); -}); -var PopoverContentImpl = React55.forwardRef((props, forwardedRef) => { - const { - __scopePopover, - trapFocus, - onOpenAutoFocus, - onCloseAutoFocus, - disableOutsidePointerEvents, - onEscapeKeyDown, - onPointerDownOutside, - onFocusOutside, - onInteractOutside, - ...contentProps - } = props; - const context = usePopoverContext(CONTENT_NAME3, __scopePopover); - const popperScope = usePopperScope(__scopePopover); - useFocusGuards(); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(FocusScope, { - asChild: true, - loop: true, - trapped: trapFocus, - onMountAutoFocus: onOpenAutoFocus, - onUnmountAutoFocus: onCloseAutoFocus, - children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(DismissableLayer, { - asChild: true, - disableOutsidePointerEvents, - onInteractOutside, - onEscapeKeyDown, - onPointerDownOutside, - onFocusOutside, - onDismiss: () => context.onOpenChange(false), - children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Content2, { - "data-state": getState2(context.open), - role: "dialog", - id: context.contentId, - ...popperScope, - ...contentProps, - ref: forwardedRef, - style: { - ...contentProps.style, - ...{ - "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)", - "--radix-popover-content-available-width": "var(--radix-popper-available-width)", - "--radix-popover-content-available-height": "var(--radix-popper-available-height)", - "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)", - "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)" - } - } - }) - }) - }); -}); -var CLOSE_NAME3 = "PopoverClose"; -var PopoverClose = React55.forwardRef((props, forwardedRef) => { - const { __scopePopover, ...closeProps } = props; - const context = usePopoverContext(CLOSE_NAME3, __scopePopover); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Primitive.button, { - type: "button", - ...closeProps, - ref: forwardedRef, - onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false)) - }); -}); -PopoverClose.displayName = CLOSE_NAME3; -var ARROW_NAME2 = "PopoverArrow"; -var PopoverArrow = React55.forwardRef((props, forwardedRef) => { - const { __scopePopover, ...arrowProps } = props; - const popperScope = usePopperScope(__scopePopover); - return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Arrow2, { ...popperScope, ...arrowProps, ref: forwardedRef }); -}); -PopoverArrow.displayName = ARROW_NAME2; -function getState2(open) { - return open ? "open" : "closed"; -} -var Root24 = Popover; -var Trigger = PopoverTrigger; -var Portal3 = PopoverPortal; -var Content22 = PopoverContent; - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useMenuIsOpen.mjs -var import_react81 = __toESM(require_react(), 1); -function useMenuIsOpen(id, cb) { - const editor = useEditor(); - const rIsOpen = (0, import_react81.useRef)(false); - const trackEvent = useUiEvents(); - const onOpenChange = (0, import_react81.useCallback)((isOpen2) => { - rIsOpen.current = isOpen2; - editor.run(() => { - if (isOpen2) { - editor.complete(); - editor.addOpenMenu(id); - } else { - editor.updateInstanceState({ - openMenus: editor.getOpenMenus().filter((m) => !m.startsWith(id)) - }); - } - cb?.(isOpen2); - }); - }, [editor, id, cb]); - const isOpen = useValue("is menu open", () => editor.getOpenMenus().includes(id), [editor, id]); - (0, import_react81.useEffect)(() => { - if (rIsOpen.current) { - trackEvent("open-menu", { source: "unknown", id }); - editor.addOpenMenu(id); - } - return () => { - if (rIsOpen.current) { - editor.deleteOpenMenu(id); - editor.getOpenMenus().forEach((menuId) => { - if (menuId.startsWith(id)) { - trackEvent("close-menu", { source: "unknown", id }); - editor.deleteOpenMenu(menuId); - } - }); - rIsOpen.current = false; - } - }; - }, [editor, id, trackEvent]); - return [isOpen, onOpenChange]; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs -function TldrawUiPopover({ id, children, onOpenChange, open }) { - const [isOpen, handleOpenChange] = useMenuIsOpen(id, onOpenChange); - return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Root24, { - onOpenChange: handleOpenChange, - open: open || isOpen, - children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "tlui-popover", children }) - }); -} -function TldrawUiPopoverTrigger({ children }) { - return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Trigger, { asChild: true, dir: "ltr", children }); -} -function TldrawUiPopoverContent({ - side, - children, - align = "center", - sideOffset = 8, - alignOffset = 0 -}) { - const container = useContainer(); - return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Portal3, { container, children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Content22, { - className: "tlui-popover__content", - side, - sideOffset, - align, - alignOffset, - dir: "ltr", - children - }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs -var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1); -var import_react82 = __toESM(require_react(), 1); -var menuContext = (0, import_react82.createContext)(null); -function useTldrawUiMenuContext() { - const context = (0, import_react82.useContext)(menuContext); - if (!context) { - throw new Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider"); - } - return context; -} -function TldrawUiMenuContextProvider({ - type, - sourceId, - children -}) { - return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(menuContext.Provider, { value: { type, sourceId }, children }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs -var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/menu-hooks.mjs -function shapesWithUnboundArrows(editor) { - const selectedShapeIds = editor.getSelectedShapeIds(); - const selectedShapes = selectedShapeIds.map((id) => { - return editor.getShape(id); - }); - return selectedShapes.filter((shape) => { - if (!shape) - return false; - if (editor.isShapeOfType(shape, "arrow")) { - const bindings = getArrowBindings(editor, shape); - if (bindings.start || bindings.end) - return false; - } - return true; - }); -} -var useThreeStackableItems = () => { - const editor = useEditor(); - return useValue("threeStackableItems", () => shapesWithUnboundArrows(editor).length > 2, [editor]); -}; -var useIsInSelectState = () => { - const editor = useEditor(); - return useValue("isInSelectState", () => editor.isIn("select"), [editor]); -}; -var useAllowGroup = () => { - const editor = useEditor(); - return useValue("allow group", () => { - const selectedShapes = editor.getSelectedShapes(); - if (selectedShapes.length < 2) - return false; - for (const shape of selectedShapes) { - if (editor.isShapeOfType(shape, "arrow")) { - const bindings = getArrowBindings(editor, shape); - if (bindings.start) { - if (!selectedShapes.some((s) => s.id === bindings.start.toId)) { - return false; - } - } - if (bindings.end) { - if (!selectedShapes.some((s) => s.id === bindings.end.toId)) { - return false; - } - } - } - } - return true; - }, [editor]); -}; -var useAllowUngroup = () => { - const editor = useEditor(); - return useValue("allowUngroup", () => editor.getSelectedShapeIds().some((id) => editor.getShape(id)?.type === "group"), [editor]); -}; -var showMenuPaste = typeof window !== "undefined" && "navigator" in window && Boolean(navigator.clipboard) && Boolean(navigator.clipboard.read); -function useAnySelectedShapesCount(min3, max2) { - const editor = useEditor(); - return useValue("selectedShapes", () => { - const len = editor.getSelectedShapes().length; - if (min3 === void 0) { - if (max2 === void 0) { - return len; - } else { - return len <= max2; - } - } else { - if (max2 === void 0) { - return len >= min3; - } else { - return len >= min3 && len <= max2; - } - } - }, [editor, min3, max2]); -} -function useUnlockedSelectedShapesCount(min3, max2) { - const editor = useEditor(); - return useValue("selectedShapes", () => { - const len = editor.getSelectedShapes().filter((s) => !editor.isShapeOrAncestorLocked(s)).length; - if (min3 === void 0) { - if (max2 === void 0) { - return len; - } else { - return len <= max2; - } - } else { - if (max2 === void 0) { - return len >= min3; - } else { - return len >= min3 && len <= max2; - } - } - }, [editor]); -} -function useShowAutoSizeToggle() { - const editor = useEditor(); - return useValue("showAutoSizeToggle", () => { - const selectedShapes = editor.getSelectedShapes(); - return selectedShapes.length === 1 && editor.isShapeOfType(selectedShapes[0], "text") && selectedShapes[0].props.autoSize === false; - }, [editor]); -} -function useHasLinkShapeSelected() { - const editor = useEditor(); - return useValue("hasLinkShapeSelected", () => { - const onlySelectedShape = editor.getOnlySelectedShape(); - return !!(onlySelectedShape && onlySelectedShape.type !== "embed" && "url" in onlySelectedShape.props && !onlySelectedShape.isLocked); - }, [editor]); -} -function useOnlyFlippableShape() { - const editor = useEditor(); - return useValue("onlyFlippableShape", () => { - const shape = editor.getOnlySelectedShape(); - return shape && (editor.isShapeOfType(shape, "group") || editor.isShapeOfType(shape, "image") || editor.isShapeOfType(shape, "arrow") || editor.isShapeOfType(shape, "line") || editor.isShapeOfType(shape, "draw")); - }, [editor]); -} -function useCanRedo() { - const editor = useEditor(); - return useValue("useCanRedo", () => editor.getCanRedo(), [editor]); -} -function useCanUndo() { - const editor = useEditor(); - return useValue("useCanUndo", () => editor.getCanUndo(), [editor]); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs -var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@radix-ui/react-context-menu/dist/index.mjs -var React59 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-menu/dist/index.mjs -var React58 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-direction/dist/index.mjs -var React56 = __toESM(require_react(), 1); -var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1); -var DirectionContext = React56.createContext(void 0); -function useDirection(localDir) { - const globalDir = React56.useContext(DirectionContext); - return localDir || globalDir || "ltr"; -} - -// node_modules/@radix-ui/react-roving-focus/dist/index.mjs -var React57 = __toESM(require_react(), 1); -var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1); -"use client"; -var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus"; -var EVENT_OPTIONS2 = { bubbles: false, cancelable: true }; -var GROUP_NAME = "RovingFocusGroup"; -var [Collection2, useCollection2, createCollectionScope2] = createCollection(GROUP_NAME); -var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(GROUP_NAME, [createCollectionScope2]); -var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME); -var RovingFocusGroup = React57.forwardRef((props, forwardedRef) => { - return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Collection2.Provider, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Collection2.Slot, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) }); -}); -RovingFocusGroup.displayName = GROUP_NAME; -var RovingFocusGroupImpl = React57.forwardRef((props, forwardedRef) => { - const { - __scopeRovingFocusGroup, - orientation, - loop = false, - dir, - currentTabStopId: currentTabStopIdProp, - defaultCurrentTabStopId, - onCurrentTabStopIdChange, - onEntryFocus, - preventScrollOnEntryFocus = false, - ...groupProps - } = props; - const ref = React57.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - const direction = useDirection(dir); - const [currentTabStopId = null, setCurrentTabStopId] = useControllableState({ - prop: currentTabStopIdProp, - defaultProp: defaultCurrentTabStopId, - onChange: onCurrentTabStopIdChange - }); - const [isTabbingBackOut, setIsTabbingBackOut] = React57.useState(false); - const handleEntryFocus = useCallbackRef(onEntryFocus); - const getItems = useCollection2(__scopeRovingFocusGroup); - const isClickFocusRef = React57.useRef(false); - const [focusableItemsCount, setFocusableItemsCount] = React57.useState(0); - React57.useEffect(() => { - const node = ref.current; - if (node) { - node.addEventListener(ENTRY_FOCUS, handleEntryFocus); - return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus); - } - }, [handleEntryFocus]); - return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(RovingFocusProvider, { - scope: __scopeRovingFocusGroup, - orientation, - dir: direction, - loop, - currentTabStopId, - onItemFocus: React57.useCallback((tabStopId) => setCurrentTabStopId(tabStopId), [setCurrentTabStopId]), - onItemShiftTab: React57.useCallback(() => setIsTabbingBackOut(true), []), - onFocusableItemAdd: React57.useCallback(() => setFocusableItemsCount((prevCount) => prevCount + 1), []), - onFocusableItemRemove: React57.useCallback(() => setFocusableItemsCount((prevCount) => prevCount - 1), []), - children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Primitive.div, { - tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0, - "data-orientation": orientation, - ...groupProps, - ref: composedRefs, - style: { outline: "none", ...props.style }, - onMouseDown: composeEventHandlers(props.onMouseDown, () => { - isClickFocusRef.current = true; - }), - onFocus: composeEventHandlers(props.onFocus, (event) => { - const isKeyboardFocus = !isClickFocusRef.current; - if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) { - const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS2); - event.currentTarget.dispatchEvent(entryFocusEvent); - if (!entryFocusEvent.defaultPrevented) { - const items = getItems().filter((item) => item.focusable); - const activeItem = items.find((item) => item.active); - const currentItem = items.find((item) => item.id === currentTabStopId); - const candidateItems = [activeItem, currentItem, ...items].filter(Boolean); - const candidateNodes = candidateItems.map((item) => item.ref.current); - focusFirst3(candidateNodes, preventScrollOnEntryFocus); - } - } - isClickFocusRef.current = false; - }), - onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false)) - }) - }); -}); -var ITEM_NAME = "RovingFocusGroupItem"; -var RovingFocusGroupItem = React57.forwardRef((props, forwardedRef) => { - const { - __scopeRovingFocusGroup, - focusable = true, - active = false, - tabStopId, - ...itemProps - } = props; - const autoId = useId2(); - const id = tabStopId || autoId; - const context = useRovingFocusContext(ITEM_NAME, __scopeRovingFocusGroup); - const isCurrentTabStop = context.currentTabStopId === id; - const getItems = useCollection2(__scopeRovingFocusGroup); - const { onFocusableItemAdd, onFocusableItemRemove } = context; - React57.useEffect(() => { - if (focusable) { - onFocusableItemAdd(); - return () => onFocusableItemRemove(); - } - }, [focusable, onFocusableItemAdd, onFocusableItemRemove]); - return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Collection2.ItemSlot, { - scope: __scopeRovingFocusGroup, - id, - focusable, - active, - children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Primitive.span, { - tabIndex: isCurrentTabStop ? 0 : -1, - "data-orientation": context.orientation, - ...itemProps, - ref: forwardedRef, - onMouseDown: composeEventHandlers(props.onMouseDown, (event) => { - if (!focusable) - event.preventDefault(); - else - context.onItemFocus(id); - }), - onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)), - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - if (event.key === "Tab" && event.shiftKey) { - context.onItemShiftTab(); - return; - } - if (event.target !== event.currentTarget) - return; - const focusIntent = getFocusIntent(event, context.orientation, context.dir); - if (focusIntent !== void 0) { - if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) - return; - event.preventDefault(); - const items = getItems().filter((item) => item.focusable); - let candidateNodes = items.map((item) => item.ref.current); - if (focusIntent === "last") - candidateNodes.reverse(); - else if (focusIntent === "prev" || focusIntent === "next") { - if (focusIntent === "prev") - candidateNodes.reverse(); - const currentIndex = candidateNodes.indexOf(event.currentTarget); - candidateNodes = context.loop ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1); - } - setTimeout(() => focusFirst3(candidateNodes)); - } - }) - }) - }); -}); -RovingFocusGroupItem.displayName = ITEM_NAME; -var MAP_KEY_TO_FOCUS_INTENT = { - ArrowLeft: "prev", - ArrowUp: "prev", - ArrowRight: "next", - ArrowDown: "next", - PageUp: "first", - Home: "first", - PageDown: "last", - End: "last" -}; -function getDirectionAwareKey(key, dir) { - if (dir !== "rtl") - return key; - return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key; -} -function getFocusIntent(event, orientation, dir) { - const key = getDirectionAwareKey(event.key, dir); - if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) - return void 0; - if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) - return void 0; - return MAP_KEY_TO_FOCUS_INTENT[key]; -} -function focusFirst3(candidates, preventScroll = false) { - const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement; - for (const candidate of candidates) { - if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) - return; - candidate.focus({ preventScroll }); - if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) - return; - } -} -function wrapArray(array2, startIndex) { - return array2.map((_, index2) => array2[(startIndex + index2) % array2.length]); -} -var Root4 = RovingFocusGroup; -var Item = RovingFocusGroupItem; - -// node_modules/@radix-ui/react-menu/dist/index.mjs -var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1); -"use client"; -var SELECTION_KEYS = ["Enter", " "]; -var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"]; -var LAST_KEYS = ["ArrowUp", "PageDown", "End"]; -var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS]; -var SUB_OPEN_KEYS = { - ltr: [...SELECTION_KEYS, "ArrowRight"], - rtl: [...SELECTION_KEYS, "ArrowLeft"] -}; -var SUB_CLOSE_KEYS = { - ltr: ["ArrowLeft"], - rtl: ["ArrowRight"] -}; -var MENU_NAME = "Menu"; -var [Collection3, useCollection3, createCollectionScope3] = createCollection(MENU_NAME); -var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [ - createCollectionScope3, - createPopperScope, - createRovingFocusGroupScope -]); -var usePopperScope2 = createPopperScope(); -var useRovingFocusGroupScope = createRovingFocusGroupScope(); -var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME); -var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME); -var Menu = (props) => { - const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props; - const popperScope = usePopperScope2(__scopeMenu); - const [content, setContent] = React58.useState(null); - const isUsingKeyboardRef = React58.useRef(false); - const handleOpenChange = useCallbackRef(onOpenChange); - const direction = useDirection(dir); - React58.useEffect(() => { - const handleKeyDown = () => { - isUsingKeyboardRef.current = true; - document.addEventListener("pointerdown", handlePointer, { capture: true, once: true }); - document.addEventListener("pointermove", handlePointer, { capture: true, once: true }); - }; - const handlePointer = () => isUsingKeyboardRef.current = false; - document.addEventListener("keydown", handleKeyDown, { capture: true }); - return () => { - document.removeEventListener("keydown", handleKeyDown, { capture: true }); - document.removeEventListener("pointerdown", handlePointer, { capture: true }); - document.removeEventListener("pointermove", handlePointer, { capture: true }); - }; - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Root23, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuProvider, { - scope: __scopeMenu, - open, - onOpenChange: handleOpenChange, - content, - onContentChange: setContent, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuRootProvider, { - scope: __scopeMenu, - onClose: React58.useCallback(() => handleOpenChange(false), [handleOpenChange]), - isUsingKeyboardRef, - dir: direction, - modal, - children - }) - }) }); -}; -Menu.displayName = MENU_NAME; -var ANCHOR_NAME3 = "MenuAnchor"; -var MenuAnchor = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, ...anchorProps } = props; - const popperScope = usePopperScope2(__scopeMenu); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef }); -}); -MenuAnchor.displayName = ANCHOR_NAME3; -var PORTAL_NAME4 = "MenuPortal"; -var [PortalProvider3, usePortalContext3] = createMenuContext(PORTAL_NAME4, { - forceMount: void 0 -}); -var MenuPortal = (props) => { - const { __scopeMenu, forceMount, children, container } = props; - const context = useMenuContext(PORTAL_NAME4, __scopeMenu); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(PortalProvider3, { scope: __scopeMenu, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Portal, { asChild: true, container, children }) }) }); -}; -MenuPortal.displayName = PORTAL_NAME4; -var CONTENT_NAME4 = "MenuContent"; -var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME4); -var MenuContent = React58.forwardRef((props, forwardedRef) => { - const portalContext = usePortalContext3(CONTENT_NAME4, props.__scopeMenu); - const { forceMount = portalContext.forceMount, ...contentProps } = props; - const context = useMenuContext(CONTENT_NAME4, props.__scopeMenu); - const rootContext = useMenuRootContext(CONTENT_NAME4, props.__scopeMenu); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Collection3.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Collection3.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) }); -}); -var MenuRootContentModal = React58.forwardRef((props, forwardedRef) => { - const context = useMenuContext(CONTENT_NAME4, props.__scopeMenu); - const ref = React58.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - React58.useEffect(() => { - const content = ref.current; - if (content) - return hideOthers(content); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuContentImpl, { - ...props, - ref: composedRefs, - trapFocus: context.open, - disableOutsidePointerEvents: context.open, - disableOutsideScroll: true, - onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => event.preventDefault(), { checkForDefaultPrevented: false }), - onDismiss: () => context.onOpenChange(false) - }); -}); -var MenuRootContentNonModal = React58.forwardRef((props, forwardedRef) => { - const context = useMenuContext(CONTENT_NAME4, props.__scopeMenu); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuContentImpl, { - ...props, - ref: forwardedRef, - trapFocus: false, - disableOutsidePointerEvents: false, - disableOutsideScroll: false, - onDismiss: () => context.onOpenChange(false) - }); -}); -var MenuContentImpl = React58.forwardRef((props, forwardedRef) => { - const { - __scopeMenu, - loop = false, - trapFocus, - onOpenAutoFocus, - onCloseAutoFocus, - disableOutsidePointerEvents, - onEntryFocus, - onEscapeKeyDown, - onPointerDownOutside, - onFocusOutside, - onInteractOutside, - onDismiss, - disableOutsideScroll, - ...contentProps - } = props; - const context = useMenuContext(CONTENT_NAME4, __scopeMenu); - const rootContext = useMenuRootContext(CONTENT_NAME4, __scopeMenu); - const popperScope = usePopperScope2(__scopeMenu); - const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu); - const getItems = useCollection3(__scopeMenu); - const [currentItemId, setCurrentItemId] = React58.useState(null); - const contentRef = React58.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange); - const timerRef = React58.useRef(0); - const searchRef = React58.useRef(""); - const pointerGraceTimerRef = React58.useRef(0); - const pointerGraceIntentRef = React58.useRef(null); - const pointerDirRef = React58.useRef("right"); - const lastPointerXRef = React58.useRef(0); - const ScrollLockWrapper = disableOutsideScroll ? Combination_default : React58.Fragment; - const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0; - const handleTypeaheadSearch = (key) => { - const search = searchRef.current + key; - const items = getItems().filter((item) => !item.disabled); - const currentItem = document.activeElement; - const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue; - const values = items.map((item) => item.textValue); - const nextMatch = getNextMatch(values, search, currentMatch); - const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current; - (function updateSearch(value) { - searchRef.current = value; - window.clearTimeout(timerRef.current); - if (value !== "") - timerRef.current = window.setTimeout(() => updateSearch(""), 1e3); - })(search); - if (newItem) { - setTimeout(() => newItem.focus()); - } - }; - React58.useEffect(() => { - return () => window.clearTimeout(timerRef.current); - }, []); - useFocusGuards(); - const isPointerMovingToSubmenu = React58.useCallback((event) => { - const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side; - return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuContentProvider, { - scope: __scopeMenu, - searchRef, - onItemEnter: React58.useCallback((event) => { - if (isPointerMovingToSubmenu(event)) - event.preventDefault(); - }, [isPointerMovingToSubmenu]), - onItemLeave: React58.useCallback((event) => { - if (isPointerMovingToSubmenu(event)) - return; - contentRef.current?.focus(); - setCurrentItemId(null); - }, [isPointerMovingToSubmenu]), - onTriggerLeave: React58.useCallback((event) => { - if (isPointerMovingToSubmenu(event)) - event.preventDefault(); - }, [isPointerMovingToSubmenu]), - pointerGraceTimerRef, - onPointerGraceIntentChange: React58.useCallback((intent) => { - pointerGraceIntentRef.current = intent; - }, []), - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(FocusScope, { - asChild: true, - trapped: trapFocus, - onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => { - event.preventDefault(); - contentRef.current?.focus({ preventScroll: true }); - }), - onUnmountAutoFocus: onCloseAutoFocus, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(DismissableLayer, { - asChild: true, - disableOutsidePointerEvents, - onEscapeKeyDown, - onPointerDownOutside, - onFocusOutside, - onInteractOutside, - onDismiss, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Root4, { - asChild: true, - ...rovingFocusGroupScope, - dir: rootContext.dir, - orientation: "vertical", - loop, - currentTabStopId: currentItemId, - onCurrentTabStopIdChange: setCurrentItemId, - onEntryFocus: composeEventHandlers(onEntryFocus, (event) => { - if (!rootContext.isUsingKeyboardRef.current) - event.preventDefault(); - }), - preventScrollOnEntryFocus: true, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Content2, { - role: "menu", - "aria-orientation": "vertical", - "data-state": getOpenState(context.open), - "data-radix-menu-content": "", - dir: rootContext.dir, - ...popperScope, - ...contentProps, - ref: composedRefs, - style: { outline: "none", ...contentProps.style }, - onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => { - const target = event.target; - const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget; - const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; - const isCharacterKey = event.key.length === 1; - if (isKeyDownInside) { - if (event.key === "Tab") - event.preventDefault(); - if (!isModifierKey && isCharacterKey) - handleTypeaheadSearch(event.key); - } - const content = contentRef.current; - if (event.target !== content) - return; - if (!FIRST_LAST_KEYS.includes(event.key)) - return; - event.preventDefault(); - const items = getItems().filter((item) => !item.disabled); - const candidateNodes = items.map((item) => item.ref.current); - if (LAST_KEYS.includes(event.key)) - candidateNodes.reverse(); - focusFirst4(candidateNodes); - }), - onBlur: composeEventHandlers(props.onBlur, (event) => { - if (!event.currentTarget.contains(event.target)) { - window.clearTimeout(timerRef.current); - searchRef.current = ""; - } - }), - onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse((event) => { - const target = event.target; - const pointerXHasChanged = lastPointerXRef.current !== event.clientX; - if (event.currentTarget.contains(target) && pointerXHasChanged) { - const newDir = event.clientX > lastPointerXRef.current ? "right" : "left"; - pointerDirRef.current = newDir; - lastPointerXRef.current = event.clientX; - } - })) - }) - }) - }) - }) }) - }); -}); -MenuContent.displayName = CONTENT_NAME4; -var GROUP_NAME2 = "MenuGroup"; -var MenuGroup = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, ...groupProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef }); -}); -MenuGroup.displayName = GROUP_NAME2; -var LABEL_NAME = "MenuLabel"; -var MenuLabel = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, ...labelProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Primitive.div, { ...labelProps, ref: forwardedRef }); -}); -MenuLabel.displayName = LABEL_NAME; -var ITEM_NAME2 = "MenuItem"; -var ITEM_SELECT = "menu.itemSelect"; -var MenuItem = React58.forwardRef((props, forwardedRef) => { - const { disabled = false, onSelect, ...itemProps } = props; - const ref = React58.useRef(null); - const rootContext = useMenuRootContext(ITEM_NAME2, props.__scopeMenu); - const contentContext = useMenuContentContext(ITEM_NAME2, props.__scopeMenu); - const composedRefs = useComposedRefs(forwardedRef, ref); - const isPointerDownRef = React58.useRef(false); - const handleSelect = () => { - const menuItem = ref.current; - if (!disabled && menuItem) { - const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true }); - menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true }); - dispatchDiscreteCustomEvent(menuItem, itemSelectEvent); - if (itemSelectEvent.defaultPrevented) { - isPointerDownRef.current = false; - } else { - rootContext.onClose(); - } - } - }; - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuItemImpl, { - ...itemProps, - ref: composedRefs, - disabled, - onClick: composeEventHandlers(props.onClick, handleSelect), - onPointerDown: (event) => { - props.onPointerDown?.(event); - isPointerDownRef.current = true; - }, - onPointerUp: composeEventHandlers(props.onPointerUp, (event) => { - if (!isPointerDownRef.current) - event.currentTarget?.click(); - }), - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - const isTypingAhead = contentContext.searchRef.current !== ""; - if (disabled || isTypingAhead && event.key === " ") - return; - if (SELECTION_KEYS.includes(event.key)) { - event.currentTarget.click(); - event.preventDefault(); - } - }) - }); -}); -MenuItem.displayName = ITEM_NAME2; -var MenuItemImpl = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, disabled = false, textValue, ...itemProps } = props; - const contentContext = useMenuContentContext(ITEM_NAME2, __scopeMenu); - const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu); - const ref = React58.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - const [isFocused, setIsFocused] = React58.useState(false); - const [textContent, setTextContent] = React58.useState(""); - React58.useEffect(() => { - const menuItem = ref.current; - if (menuItem) { - setTextContent((menuItem.textContent ?? "").trim()); - } - }, [itemProps.children]); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Collection3.ItemSlot, { - scope: __scopeMenu, - disabled, - textValue: textValue ?? textContent, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Primitive.div, { - role: "menuitem", - "data-highlighted": isFocused ? "" : void 0, - "aria-disabled": disabled || void 0, - "data-disabled": disabled ? "" : void 0, - ...itemProps, - ref: composedRefs, - onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse((event) => { - if (disabled) { - contentContext.onItemLeave(event); - } else { - contentContext.onItemEnter(event); - if (!event.defaultPrevented) { - const item = event.currentTarget; - item.focus({ preventScroll: true }); - } - } - })), - onPointerLeave: composeEventHandlers(props.onPointerLeave, whenMouse((event) => contentContext.onItemLeave(event))), - onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)), - onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false)) - }) }) - }); -}); -var CHECKBOX_ITEM_NAME = "MenuCheckboxItem"; -var MenuCheckboxItem = React58.forwardRef((props, forwardedRef) => { - const { checked = false, onCheckedChange, ...checkboxItemProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuItem, { - role: "menuitemcheckbox", - "aria-checked": isIndeterminate(checked) ? "mixed" : checked, - ...checkboxItemProps, - ref: forwardedRef, - "data-state": getCheckedState(checked), - onSelect: composeEventHandlers(checkboxItemProps.onSelect, () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked), { checkForDefaultPrevented: false }) - }) }); -}); -MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME; -var RADIO_GROUP_NAME = "MenuRadioGroup"; -var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(RADIO_GROUP_NAME, { value: void 0, onValueChange: () => { -} }); -var MenuRadioGroup = React58.forwardRef((props, forwardedRef) => { - const { value, onValueChange, ...groupProps } = props; - const handleValueChange = useCallbackRef(onValueChange); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuGroup, { ...groupProps, ref: forwardedRef }) }); -}); -MenuRadioGroup.displayName = RADIO_GROUP_NAME; -var RADIO_ITEM_NAME = "MenuRadioItem"; -var MenuRadioItem = React58.forwardRef((props, forwardedRef) => { - const { value, ...radioItemProps } = props; - const context = useRadioGroupContext(RADIO_ITEM_NAME, props.__scopeMenu); - const checked = value === context.value; - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuItem, { - role: "menuitemradio", - "aria-checked": checked, - ...radioItemProps, - ref: forwardedRef, - "data-state": getCheckedState(checked), - onSelect: composeEventHandlers(radioItemProps.onSelect, () => context.onValueChange?.(value), { checkForDefaultPrevented: false }) - }) }); -}); -MenuRadioItem.displayName = RADIO_ITEM_NAME; -var ITEM_INDICATOR_NAME = "MenuItemIndicator"; -var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(ITEM_INDICATOR_NAME, { checked: false }); -var MenuItemIndicator = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, forceMount, ...itemIndicatorProps } = props; - const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Presence, { - present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Primitive.span, { - ...itemIndicatorProps, - ref: forwardedRef, - "data-state": getCheckedState(indicatorContext.checked) - }) - }); -}); -MenuItemIndicator.displayName = ITEM_INDICATOR_NAME; -var SEPARATOR_NAME = "MenuSeparator"; -var MenuSeparator = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, ...separatorProps } = props; - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Primitive.div, { - role: "separator", - "aria-orientation": "horizontal", - ...separatorProps, - ref: forwardedRef - }); -}); -MenuSeparator.displayName = SEPARATOR_NAME; -var ARROW_NAME3 = "MenuArrow"; -var MenuArrow = React58.forwardRef((props, forwardedRef) => { - const { __scopeMenu, ...arrowProps } = props; - const popperScope = usePopperScope2(__scopeMenu); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Arrow2, { ...popperScope, ...arrowProps, ref: forwardedRef }); -}); -MenuArrow.displayName = ARROW_NAME3; -var SUB_NAME = "MenuSub"; -var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME); -var MenuSub = (props) => { - const { __scopeMenu, children, open = false, onOpenChange } = props; - const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu); - const popperScope = usePopperScope2(__scopeMenu); - const [trigger2, setTrigger] = React58.useState(null); - const [content, setContent] = React58.useState(null); - const handleOpenChange = useCallbackRef(onOpenChange); - React58.useEffect(() => { - if (parentMenuContext.open === false) - handleOpenChange(false); - return () => handleOpenChange(false); - }, [parentMenuContext.open, handleOpenChange]); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Root23, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuProvider, { - scope: __scopeMenu, - open, - onOpenChange: handleOpenChange, - content, - onContentChange: setContent, - children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuSubProvider, { - scope: __scopeMenu, - contentId: useId2(), - triggerId: useId2(), - trigger: trigger2, - onTriggerChange: setTrigger, - children - }) - }) }); -}; -MenuSub.displayName = SUB_NAME; -var SUB_TRIGGER_NAME = "MenuSubTrigger"; -var MenuSubTrigger = React58.forwardRef((props, forwardedRef) => { - const context = useMenuContext(SUB_TRIGGER_NAME, props.__scopeMenu); - const rootContext = useMenuRootContext(SUB_TRIGGER_NAME, props.__scopeMenu); - const subContext = useMenuSubContext(SUB_TRIGGER_NAME, props.__scopeMenu); - const contentContext = useMenuContentContext(SUB_TRIGGER_NAME, props.__scopeMenu); - const openTimerRef = React58.useRef(null); - const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext; - const scope = { __scopeMenu: props.__scopeMenu }; - const clearOpenTimer = React58.useCallback(() => { - if (openTimerRef.current) - window.clearTimeout(openTimerRef.current); - openTimerRef.current = null; - }, []); - React58.useEffect(() => clearOpenTimer, [clearOpenTimer]); - React58.useEffect(() => { - const pointerGraceTimer = pointerGraceTimerRef.current; - return () => { - window.clearTimeout(pointerGraceTimer); - onPointerGraceIntentChange(null); - }; - }, [pointerGraceTimerRef, onPointerGraceIntentChange]); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuAnchor, { asChild: true, ...scope, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuItemImpl, { - id: subContext.triggerId, - "aria-haspopup": "menu", - "aria-expanded": context.open, - "aria-controls": subContext.contentId, - "data-state": getOpenState(context.open), - ...props, - ref: composeRefs(forwardedRef, subContext.onTriggerChange), - onClick: (event) => { - props.onClick?.(event); - if (props.disabled || event.defaultPrevented) - return; - event.currentTarget.focus(); - if (!context.open) - context.onOpenChange(true); - }, - onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse((event) => { - contentContext.onItemEnter(event); - if (event.defaultPrevented) - return; - if (!props.disabled && !context.open && !openTimerRef.current) { - contentContext.onPointerGraceIntentChange(null); - openTimerRef.current = window.setTimeout(() => { - context.onOpenChange(true); - clearOpenTimer(); - }, 100); - } - })), - onPointerLeave: composeEventHandlers(props.onPointerLeave, whenMouse((event) => { - clearOpenTimer(); - const contentRect = context.content?.getBoundingClientRect(); - if (contentRect) { - const side = context.content?.dataset.side; - const rightSide = side === "right"; - const bleed = rightSide ? -5 : 5; - const contentNearEdge = contentRect[rightSide ? "left" : "right"]; - const contentFarEdge = contentRect[rightSide ? "right" : "left"]; - contentContext.onPointerGraceIntentChange({ - area: [ - { x: event.clientX + bleed, y: event.clientY }, - { x: contentNearEdge, y: contentRect.top }, - { x: contentFarEdge, y: contentRect.top }, - { x: contentFarEdge, y: contentRect.bottom }, - { x: contentNearEdge, y: contentRect.bottom } - ], - side - }); - window.clearTimeout(pointerGraceTimerRef.current); - pointerGraceTimerRef.current = window.setTimeout(() => contentContext.onPointerGraceIntentChange(null), 300); - } else { - contentContext.onTriggerLeave(event); - if (event.defaultPrevented) - return; - contentContext.onPointerGraceIntentChange(null); - } - })), - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - const isTypingAhead = contentContext.searchRef.current !== ""; - if (props.disabled || isTypingAhead && event.key === " ") - return; - if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) { - context.onOpenChange(true); - context.content?.focus(); - event.preventDefault(); - } - }) - }) }); -}); -MenuSubTrigger.displayName = SUB_TRIGGER_NAME; -var SUB_CONTENT_NAME = "MenuSubContent"; -var MenuSubContent = React58.forwardRef((props, forwardedRef) => { - const portalContext = usePortalContext3(CONTENT_NAME4, props.__scopeMenu); - const { forceMount = portalContext.forceMount, ...subContentProps } = props; - const context = useMenuContext(CONTENT_NAME4, props.__scopeMenu); - const rootContext = useMenuRootContext(CONTENT_NAME4, props.__scopeMenu); - const subContext = useMenuSubContext(SUB_CONTENT_NAME, props.__scopeMenu); - const ref = React58.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Collection3.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Collection3.Slot, { scope: props.__scopeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(MenuContentImpl, { - id: subContext.contentId, - "aria-labelledby": subContext.triggerId, - ...subContentProps, - ref: composedRefs, - align: "start", - side: rootContext.dir === "rtl" ? "left" : "right", - disableOutsidePointerEvents: false, - disableOutsideScroll: false, - trapFocus: false, - onOpenAutoFocus: (event) => { - if (rootContext.isUsingKeyboardRef.current) - ref.current?.focus(); - event.preventDefault(); - }, - onCloseAutoFocus: (event) => event.preventDefault(), - onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => { - if (event.target !== subContext.trigger) - context.onOpenChange(false); - }), - onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => { - rootContext.onClose(); - event.preventDefault(); - }), - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - const isKeyDownInside = event.currentTarget.contains(event.target); - const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key); - if (isKeyDownInside && isCloseKey) { - context.onOpenChange(false); - subContext.trigger?.focus(); - event.preventDefault(); - } - }) - }) }) }) }); -}); -MenuSubContent.displayName = SUB_CONTENT_NAME; -function getOpenState(open) { - return open ? "open" : "closed"; -} -function isIndeterminate(checked) { - return checked === "indeterminate"; -} -function getCheckedState(checked) { - return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked"; -} -function focusFirst4(candidates) { - const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement; - for (const candidate of candidates) { - if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) - return; - candidate.focus(); - if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) - return; - } -} -function wrapArray2(array2, startIndex) { - return array2.map((_, index2) => array2[(startIndex + index2) % array2.length]); -} -function getNextMatch(values, search, currentMatch) { - const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]); - const normalizedSearch = isRepeated ? search[0] : search; - const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1; - let wrappedValues = wrapArray2(values, Math.max(currentMatchIndex, 0)); - const excludeCurrentMatch = normalizedSearch.length === 1; - if (excludeCurrentMatch) - wrappedValues = wrappedValues.filter((v) => v !== currentMatch); - const nextMatch = wrappedValues.find((value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())); - return nextMatch !== currentMatch ? nextMatch : void 0; -} -function isPointInPolygon(point, polygon) { - const { x, y } = point; - let inside = false; - for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { - const xi = polygon[i].x; - const yi = polygon[i].y; - const xj = polygon[j].x; - const yj = polygon[j].y; - const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi; - if (intersect) - inside = !inside; - } - return inside; -} -function isPointerInGraceArea(event, area) { - if (!area) - return false; - const cursorPos = { x: event.clientX, y: event.clientY }; - return isPointInPolygon(cursorPos, area); -} -function whenMouse(handler) { - return (event) => event.pointerType === "mouse" ? handler(event) : void 0; -} -var Root32 = Menu; -var Anchor2 = MenuAnchor; -var Portal4 = MenuPortal; -var Content23 = MenuContent; -var Group = MenuGroup; -var Label = MenuLabel; -var Item2 = MenuItem; -var CheckboxItem = MenuCheckboxItem; -var RadioGroup = MenuRadioGroup; -var RadioItem = MenuRadioItem; -var ItemIndicator = MenuItemIndicator; -var Separator = MenuSeparator; -var Arrow22 = MenuArrow; -var Sub = MenuSub; -var SubTrigger = MenuSubTrigger; -var SubContent = MenuSubContent; - -// node_modules/@radix-ui/react-context-menu/dist/index.mjs -var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1); -"use client"; -var CONTEXT_MENU_NAME = "ContextMenu"; -var [createContextMenuContext, createContextMenuScope] = createContextScope(CONTEXT_MENU_NAME, [ - createMenuScope -]); -var useMenuScope = createMenuScope(); -var [ContextMenuProvider, useContextMenuContext] = createContextMenuContext(CONTEXT_MENU_NAME); -var ContextMenu = (props) => { - const { __scopeContextMenu, children, onOpenChange, dir, modal = true } = props; - const [open, setOpen] = React59.useState(false); - const menuScope = useMenuScope(__scopeContextMenu); - const handleOpenChangeProp = useCallbackRef(onOpenChange); - const handleOpenChange = React59.useCallback((open2) => { - setOpen(open2); - handleOpenChangeProp(open2); - }, [handleOpenChangeProp]); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ContextMenuProvider, { - scope: __scopeContextMenu, - open, - onOpenChange: handleOpenChange, - modal, - children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Root32, { - ...menuScope, - dir, - open, - onOpenChange: handleOpenChange, - modal, - children - }) - }); -}; -ContextMenu.displayName = CONTEXT_MENU_NAME; -var TRIGGER_NAME3 = "ContextMenuTrigger"; -var ContextMenuTrigger = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, disabled = false, ...triggerProps } = props; - const context = useContextMenuContext(TRIGGER_NAME3, __scopeContextMenu); - const menuScope = useMenuScope(__scopeContextMenu); - const pointRef = React59.useRef({ x: 0, y: 0 }); - const virtualRef = React59.useRef({ - getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }) - }); - const longPressTimerRef = React59.useRef(0); - const clearLongPress = React59.useCallback(() => window.clearTimeout(longPressTimerRef.current), []); - const handleOpen = (event) => { - pointRef.current = { x: event.clientX, y: event.clientY }; - context.onOpenChange(true); - }; - React59.useEffect(() => clearLongPress, [clearLongPress]); - React59.useEffect(() => void (disabled && clearLongPress()), [disabled, clearLongPress]); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Anchor2, { ...menuScope, virtualRef }), - /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Primitive.span, { - "data-state": context.open ? "open" : "closed", - "data-disabled": disabled ? "" : void 0, - ...triggerProps, - ref: forwardedRef, - style: { WebkitTouchCallout: "none", ...props.style }, - onContextMenu: disabled ? props.onContextMenu : composeEventHandlers(props.onContextMenu, (event) => { - clearLongPress(); - handleOpen(event); - event.preventDefault(); - }), - onPointerDown: disabled ? props.onPointerDown : composeEventHandlers(props.onPointerDown, whenTouchOrPen((event) => { - clearLongPress(); - longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700); - })), - onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, whenTouchOrPen(clearLongPress)), - onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, whenTouchOrPen(clearLongPress)), - onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, whenTouchOrPen(clearLongPress)) - }) - ] }); -}); -ContextMenuTrigger.displayName = TRIGGER_NAME3; -var PORTAL_NAME5 = "ContextMenuPortal"; -var ContextMenuPortal = (props) => { - const { __scopeContextMenu, ...portalProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Portal4, { ...menuScope, ...portalProps }); -}; -ContextMenuPortal.displayName = PORTAL_NAME5; -var CONTENT_NAME5 = "ContextMenuContent"; -var ContextMenuContent = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...contentProps } = props; - const context = useContextMenuContext(CONTENT_NAME5, __scopeContextMenu); - const menuScope = useMenuScope(__scopeContextMenu); - const hasInteractedOutsideRef = React59.useRef(false); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Content23, { - ...menuScope, - ...contentProps, - ref: forwardedRef, - side: "right", - sideOffset: 2, - align: "start", - onCloseAutoFocus: (event) => { - props.onCloseAutoFocus?.(event); - if (!event.defaultPrevented && hasInteractedOutsideRef.current) { - event.preventDefault(); - } - hasInteractedOutsideRef.current = false; - }, - onInteractOutside: (event) => { - props.onInteractOutside?.(event); - if (!event.defaultPrevented && !context.modal) - hasInteractedOutsideRef.current = true; - }, - style: { - ...props.style, - ...{ - "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)", - "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)", - "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)", - "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)", - "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)" - } - } - }); -}); -ContextMenuContent.displayName = CONTENT_NAME5; -var GROUP_NAME3 = "ContextMenuGroup"; -var ContextMenuGroup = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...groupProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Group, { ...menuScope, ...groupProps, ref: forwardedRef }); -}); -ContextMenuGroup.displayName = GROUP_NAME3; -var LABEL_NAME2 = "ContextMenuLabel"; -var ContextMenuLabel = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...labelProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Label, { ...menuScope, ...labelProps, ref: forwardedRef }); -}); -ContextMenuLabel.displayName = LABEL_NAME2; -var ITEM_NAME3 = "ContextMenuItem"; -var ContextMenuItem = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...itemProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Item2, { ...menuScope, ...itemProps, ref: forwardedRef }); -}); -ContextMenuItem.displayName = ITEM_NAME3; -var CHECKBOX_ITEM_NAME2 = "ContextMenuCheckboxItem"; -var ContextMenuCheckboxItem = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...checkboxItemProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef }); -}); -ContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME2; -var RADIO_GROUP_NAME2 = "ContextMenuRadioGroup"; -var ContextMenuRadioGroup = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...radioGroupProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef }); -}); -ContextMenuRadioGroup.displayName = RADIO_GROUP_NAME2; -var RADIO_ITEM_NAME2 = "ContextMenuRadioItem"; -var ContextMenuRadioItem = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...radioItemProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef }); -}); -ContextMenuRadioItem.displayName = RADIO_ITEM_NAME2; -var INDICATOR_NAME = "ContextMenuItemIndicator"; -var ContextMenuItemIndicator = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...itemIndicatorProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef }); -}); -ContextMenuItemIndicator.displayName = INDICATOR_NAME; -var SEPARATOR_NAME2 = "ContextMenuSeparator"; -var ContextMenuSeparator = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...separatorProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef }); -}); -ContextMenuSeparator.displayName = SEPARATOR_NAME2; -var ARROW_NAME4 = "ContextMenuArrow"; -var ContextMenuArrow = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...arrowProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Arrow22, { ...menuScope, ...arrowProps, ref: forwardedRef }); -}); -ContextMenuArrow.displayName = ARROW_NAME4; -var SUB_NAME2 = "ContextMenuSub"; -var ContextMenuSub = (props) => { - const { __scopeContextMenu, children, onOpenChange, open: openProp, defaultOpen } = props; - const menuScope = useMenuScope(__scopeContextMenu); - const [open, setOpen] = useControllableState({ - prop: openProp, - defaultProp: defaultOpen, - onChange: onOpenChange - }); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Sub, { ...menuScope, open, onOpenChange: setOpen, children }); -}; -ContextMenuSub.displayName = SUB_NAME2; -var SUB_TRIGGER_NAME2 = "ContextMenuSubTrigger"; -var ContextMenuSubTrigger = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...triggerItemProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(SubTrigger, { ...menuScope, ...triggerItemProps, ref: forwardedRef }); -}); -ContextMenuSubTrigger.displayName = SUB_TRIGGER_NAME2; -var SUB_CONTENT_NAME2 = "ContextMenuSubContent"; -var ContextMenuSubContent = React59.forwardRef((props, forwardedRef) => { - const { __scopeContextMenu, ...subContentProps } = props; - const menuScope = useMenuScope(__scopeContextMenu); - return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(SubContent, { - ...menuScope, - ...subContentProps, - ref: forwardedRef, - style: { - ...props.style, - ...{ - "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)", - "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)", - "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)", - "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)", - "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)" - } - } - }); -}); -ContextMenuSubContent.displayName = SUB_CONTENT_NAME2; -function whenTouchOrPen(handler) { - return (event) => event.pointerType !== "mouse" ? handler(event) : void 0; -} -var Root25 = ContextMenu; -var Trigger2 = ContextMenuTrigger; -var Portal22 = ContextMenuPortal; -var Content24 = ContextMenuContent; -var CheckboxItem2 = ContextMenuCheckboxItem; - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs -var import_react83 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/kbd-utils.mjs -var isDarwin = typeof window === "undefined" ? false : window.navigator.userAgent.toLowerCase().indexOf("mac") > -1; -var cmdKey = isDarwin ? "\u2318" : "Ctrl"; -var altKey = isDarwin ? "\u2325" : "Alt"; -function kbd(str) { - return str.split(",")[0].split("").map((sub) => { - const subStr = sub.replace(/\$/g, cmdKey).replace(/\?/g, altKey).replace(/!/g, "\u21E7"); - return subStr[0].toUpperCase() + subStr.slice(1); - }); -} -function kbdStr(str) { - return "\u2014 " + kbd(str).join("\u2009"); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Spinner.mjs -var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1); -function Spinner(props) { - return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("svg", { width: 16, height: 16, viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("g", { strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [ - /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("circle", { strokeOpacity: 0.25, cx: 8, cy: 8, r: 7, stroke: "currentColor" }), - /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("path", { strokeLinecap: "round", d: "M15 8c0-4.5-4.5-7-7-7", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("animateTransform", { - attributeName: "transform", - type: "rotate", - from: "0 8 8", - to: "360 8 8", - dur: "1s", - repeatCount: "indefinite" - }) }) - ] }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiDropdownMenu.mjs -var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs -var React60 = __toESM(require_react(), 1); -var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1); -"use client"; -var DROPDOWN_MENU_NAME = "DropdownMenu"; -var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(DROPDOWN_MENU_NAME, [createMenuScope]); -var useMenuScope2 = createMenuScope(); -var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME); -var DropdownMenu = (props) => { - const { - __scopeDropdownMenu, - children, - dir, - open: openProp, - defaultOpen, - onOpenChange, - modal = true - } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - const triggerRef = React60.useRef(null); - const [open = false, setOpen] = useControllableState({ - prop: openProp, - defaultProp: defaultOpen, - onChange: onOpenChange - }); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(DropdownMenuProvider, { - scope: __scopeDropdownMenu, - triggerId: useId2(), - triggerRef, - contentId: useId2(), - open, - onOpenChange: setOpen, - onOpenToggle: React60.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]), - modal, - children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Root32, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children }) - }); -}; -DropdownMenu.displayName = DROPDOWN_MENU_NAME; -var TRIGGER_NAME4 = "DropdownMenuTrigger"; -var DropdownMenuTrigger = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props; - const context = useDropdownMenuContext(TRIGGER_NAME4, __scopeDropdownMenu); - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Anchor2, { asChild: true, ...menuScope, children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Primitive.button, { - type: "button", - id: context.triggerId, - "aria-haspopup": "menu", - "aria-expanded": context.open, - "aria-controls": context.open ? context.contentId : void 0, - "data-state": context.open ? "open" : "closed", - "data-disabled": disabled ? "" : void 0, - disabled, - ...triggerProps, - ref: composeRefs(forwardedRef, context.triggerRef), - onPointerDown: composeEventHandlers(props.onPointerDown, (event) => { - if (!disabled && event.button === 0 && event.ctrlKey === false) { - context.onOpenToggle(); - if (!context.open) - event.preventDefault(); - } - }), - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - if (disabled) - return; - if (["Enter", " "].includes(event.key)) - context.onOpenToggle(); - if (event.key === "ArrowDown") - context.onOpenChange(true); - if (["Enter", " ", "ArrowDown"].includes(event.key)) - event.preventDefault(); - }) - }) }); -}); -DropdownMenuTrigger.displayName = TRIGGER_NAME4; -var PORTAL_NAME6 = "DropdownMenuPortal"; -var DropdownMenuPortal = (props) => { - const { __scopeDropdownMenu, ...portalProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Portal4, { ...menuScope, ...portalProps }); -}; -DropdownMenuPortal.displayName = PORTAL_NAME6; -var CONTENT_NAME6 = "DropdownMenuContent"; -var DropdownMenuContent = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...contentProps } = props; - const context = useDropdownMenuContext(CONTENT_NAME6, __scopeDropdownMenu); - const menuScope = useMenuScope2(__scopeDropdownMenu); - const hasInteractedOutsideRef = React60.useRef(false); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Content23, { - id: context.contentId, - "aria-labelledby": context.triggerId, - ...menuScope, - ...contentProps, - ref: forwardedRef, - onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => { - if (!hasInteractedOutsideRef.current) - context.triggerRef.current?.focus(); - hasInteractedOutsideRef.current = false; - event.preventDefault(); - }), - onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => { - const originalEvent = event.detail.originalEvent; - const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true; - const isRightClick = originalEvent.button === 2 || ctrlLeftClick; - if (!context.modal || isRightClick) - hasInteractedOutsideRef.current = true; - }), - style: { - ...props.style, - ...{ - "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)", - "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)", - "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)", - "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)", - "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)" - } - } - }); -}); -DropdownMenuContent.displayName = CONTENT_NAME6; -var GROUP_NAME4 = "DropdownMenuGroup"; -var DropdownMenuGroup = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...groupProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Group, { ...menuScope, ...groupProps, ref: forwardedRef }); -}); -DropdownMenuGroup.displayName = GROUP_NAME4; -var LABEL_NAME3 = "DropdownMenuLabel"; -var DropdownMenuLabel = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...labelProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Label, { ...menuScope, ...labelProps, ref: forwardedRef }); -}); -DropdownMenuLabel.displayName = LABEL_NAME3; -var ITEM_NAME4 = "DropdownMenuItem"; -var DropdownMenuItem = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...itemProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Item2, { ...menuScope, ...itemProps, ref: forwardedRef }); -}); -DropdownMenuItem.displayName = ITEM_NAME4; -var CHECKBOX_ITEM_NAME3 = "DropdownMenuCheckboxItem"; -var DropdownMenuCheckboxItem = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...checkboxItemProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef }); -}); -DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME3; -var RADIO_GROUP_NAME3 = "DropdownMenuRadioGroup"; -var DropdownMenuRadioGroup = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...radioGroupProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef }); -}); -DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME3; -var RADIO_ITEM_NAME3 = "DropdownMenuRadioItem"; -var DropdownMenuRadioItem = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...radioItemProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef }); -}); -DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME3; -var INDICATOR_NAME2 = "DropdownMenuItemIndicator"; -var DropdownMenuItemIndicator = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...itemIndicatorProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef }); -}); -DropdownMenuItemIndicator.displayName = INDICATOR_NAME2; -var SEPARATOR_NAME3 = "DropdownMenuSeparator"; -var DropdownMenuSeparator = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...separatorProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef }); -}); -DropdownMenuSeparator.displayName = SEPARATOR_NAME3; -var ARROW_NAME5 = "DropdownMenuArrow"; -var DropdownMenuArrow = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...arrowProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Arrow22, { ...menuScope, ...arrowProps, ref: forwardedRef }); -}); -DropdownMenuArrow.displayName = ARROW_NAME5; -var DropdownMenuSub = (props) => { - const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - const [open = false, setOpen] = useControllableState({ - prop: openProp, - defaultProp: defaultOpen, - onChange: onOpenChange - }); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Sub, { ...menuScope, open, onOpenChange: setOpen, children }); -}; -var SUB_TRIGGER_NAME3 = "DropdownMenuSubTrigger"; -var DropdownMenuSubTrigger = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...subTriggerProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef }); -}); -DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME3; -var SUB_CONTENT_NAME3 = "DropdownMenuSubContent"; -var DropdownMenuSubContent = React60.forwardRef((props, forwardedRef) => { - const { __scopeDropdownMenu, ...subContentProps } = props; - const menuScope = useMenuScope2(__scopeDropdownMenu); - return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(SubContent, { - ...menuScope, - ...subContentProps, - ref: forwardedRef, - style: { - ...props.style, - ...{ - "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)", - "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)", - "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)", - "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)", - "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)" - } - } - }); -}); -DropdownMenuSubContent.displayName = SUB_CONTENT_NAME3; -var Root26 = DropdownMenu; -var Trigger3 = DropdownMenuTrigger; -var Portal23 = DropdownMenuPortal; -var Content25 = DropdownMenuContent; -var Group2 = DropdownMenuGroup; -var Item22 = DropdownMenuItem; -var CheckboxItem22 = DropdownMenuCheckboxItem; -var Sub2 = DropdownMenuSub; -var SubTrigger2 = DropdownMenuSubTrigger; -var SubContent2 = DropdownMenuSubContent; - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiDropdownMenu.mjs -function TldrawUiDropdownMenuRoot({ - id, - children, - modal = false, - debugOpen = false -}) { - const [open, onOpenChange] = useMenuIsOpen(id); - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Root26, { - open: debugOpen || open, - dir: "ltr", - modal, - onOpenChange, - children - }); -} -function TldrawUiDropdownMenuTrigger({ children, ...rest }) { - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Trigger3, { - dir: "ltr", - asChild: true, - onTouchEnd: (e) => preventDefault(e), - ...rest, - children - }); -} -function TldrawUiDropdownMenuContent({ - side = "bottom", - align = "start", - sideOffset = 8, - alignOffset = 8, - children -}) { - const container = useContainer(); - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Portal23, { container, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Content25, { - className: "tlui-menu", - side, - sideOffset, - align, - alignOffset, - collisionPadding: 4, - children - }) }); -} -function TldrawUiDropdownMenuSub({ id, children }) { - const [open, onOpenChange] = useMenuIsOpen(id); - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Sub2, { open, onOpenChange, children }); -} -function TldrawUiDropdownMenuSubTrigger({ - id, - label, - title, - disabled -}) { - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SubTrigger2, { dir: "ltr", asChild: true, disabled, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(TldrawUiButton, { - "data-testid": id, - type: "menu", - className: "tlui-menu__submenu__trigger", - disabled, - title, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(TldrawUiButtonLabel, { children: label }), - /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(TldrawUiButtonIcon, { icon: "chevron-right", small: true }) - ] - }) }); -} -function TldrawUiDropdownMenuSubContent({ - id, - alignOffset = -1, - sideOffset = -4, - size: size4 = "small", - children -}) { - const container = useContainer(); - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Portal23, { container, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SubContent2, { - "data-testid": id, - className: "tlui-menu tlui-menu__submenu__content", - alignOffset, - sideOffset, - collisionPadding: 4, - "data-size": size4, - children - }) }); -} -function TldrawUiDropdownMenuGroup({ children }) { - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Group2, { dir: "ltr", className: "tlui-menu__group", children }); -} -function TldrawUiDropdownMenuItem({ noClose, children }) { - return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Item22, { dir: "ltr", asChild: true, onClick: noClose ? preventDefault : void 0, children }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiKbd.mjs -var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1); -function TldrawUiKbd({ children, visibleOnMobileLayout = false }) { - const breakpoint = useBreakpoint(); - if (!visibleOnMobileLayout && breakpoint < PORTRAIT_BREAKPOINT.MOBILE) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("kbd", { className: "tlui-kbd", children: kbd(children).map((k, i) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", { children: k }, i)) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs -function TldrawUiMenuItem({ - disabled = false, - spinner = false, - readonlyOk = false, - id, - kbd: kbd2, - label, - icon, - onSelect, - noClose, - isSelected -}) { - const { type: menuType, sourceId } = useTldrawUiMenuContext(); - const msg2 = useTranslation(); - const [disableClicks, setDisableClicks] = (0, import_react83.useState)(false); - const isReadonlyMode = useReadonly(); - if (isReadonlyMode && !readonlyOk) - return null; - const labelToUse = unwrapLabel(label, menuType); - const kbdTouse = kbd2 ? kbdStr(kbd2) : void 0; - const labelStr = labelToUse ? msg2(labelToUse) : void 0; - const titleStr = labelStr && kbdTouse ? `${labelStr} ${kbdTouse}` : labelStr; - switch (menuType) { - case "menu": { - return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiDropdownMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(TldrawUiButton, { - type: "menu", - "data-testid": `${sourceId}.${id}`, - disabled, - title: titleStr, - onClick: (e) => { - if (noClose) { - preventDefault(e); - } - if (disableClicks) { - setDisableClicks(false); - } else { - onSelect(sourceId); - } - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonLabel, { children: labelStr }), - kbd2 && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiKbd, { children: kbd2 }) - ] - }) }); - } - case "context-menu": { - if (disabled) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(ContextMenuItem, { - dir: "ltr", - title: titleStr, - draggable: false, - className: "tlui-button tlui-button__menu", - "data-testid": `${sourceId}.${id}`, - onSelect: (e) => { - if (noClose) - preventDefault(e); - if (disableClicks) { - setDisableClicks(false); - } else { - onSelect(sourceId); - } - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { className: "tlui-button__label", draggable: false, children: labelStr }), - kbd2 && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiKbd, { children: kbd2 }), - spinner && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(Spinner, {}) - ] - }); - } - case "panel": { - return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(TldrawUiButton, { - "data-testid": `${sourceId}.${id}`, - type: "menu", - title: titleStr, - disabled, - onClick: () => onSelect(sourceId), - children: [ - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonLabel, { children: labelStr }), - icon && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonIcon, { icon }) - ] - }); - } - case "small-icons": - case "icons": { - return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButton, { - "data-testid": `${sourceId}.${id}`, - type: "icon", - title: titleStr, - disabled, - onClick: () => onSelect(sourceId), - children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonIcon, { icon, small: menuType === "small-icons" }) - }); - } - case "keyboard-shortcuts": { - if (!kbd2) { - console.warn(`Menu item '${label}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`); - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { className: "tlui-shortcuts-dialog__key-pair", "data-testid": `${sourceId}.${id}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "tlui-shortcuts-dialog__key-pair__key", children: labelStr }), - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "tlui-shortcuts-dialog__key-pair__value", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiKbd, { visibleOnMobileLayout: true, children: kbd2 }) }) - ] }); - } - case "helper-buttons": { - return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(TldrawUiButton, { type: "low", onClick: () => onSelect(sourceId), children: [ - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonIcon, { icon }), - /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonLabel, { children: labelStr }) - ] }); - } - case "toolbar": { - return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButton, { - type: "tool", - "data-testid": `tools.${id}`, - "aria-label": labelToUse, - "data-value": id, - onClick: () => onSelect("toolbar"), - title: titleStr, - onTouchStart: (e) => { - preventDefault(e); - onSelect("toolbar"); - }, - role: "radio", - "aria-checked": isSelected ? "true" : "false", - children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonIcon, { icon }) - }); - } - case "toolbar-overflow": { - return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiDropdownMenuItem, { "aria-label": label, children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButton, { - type: "icon", - className: "tlui-button-grid__button", - onClick: () => { - onSelect("toolbar"); - }, - "data-testid": `tools.more.${id}`, - title: titleStr, - role: "radio", - "aria-checked": isSelected ? "true" : "false", - "data-value": id, - children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(TldrawUiButtonIcon, { icon }) - }) }); - } - default: { - throw exhaustiveSwitchError(menuType); - } - } -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs -function DefaultActionsMenuContent() { - return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(import_jsx_runtime107.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(AlignMenuItems, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(DistributeMenuItems, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(StackMenuItems, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(ReorderMenuItems, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(ZoomOrRotateMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(RotateCWMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(EditLinkMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(GroupOrUngroupMenuItem, {}) - ] }); -} -function AlignMenuItems() { - const actions = useActions(); - const twoSelected = useUnlockedSelectedShapesCount(2); - const isInSelectState = useIsInSelectState(); - const enabled = twoSelected && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(import_jsx_runtime107.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["align-left"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["align-center-horizontal"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["align-right"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["stretch-horizontal"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["align-top"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["align-center-vertical"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["align-bottom"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["stretch-vertical"], disabled: !enabled }) - ] }); -} -function DistributeMenuItems() { - const actions = useActions(); - const threeSelected = useUnlockedSelectedShapesCount(3); - const isInSelectState = useIsInSelectState(); - const enabled = threeSelected && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(import_jsx_runtime107.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["distribute-horizontal"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["distribute-vertical"], disabled: !enabled }) - ] }); -} -function StackMenuItems() { - const actions = useActions(); - const threeStackableItems = useThreeStackableItems(); - const isInSelectState = useIsInSelectState(); - const enabled = threeStackableItems && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(import_jsx_runtime107.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["stack-horizontal"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["stack-vertical"], disabled: !enabled }) - ] }); -} -function ReorderMenuItems() { - const actions = useActions(); - const oneSelected = useUnlockedSelectedShapesCount(1); - const isInSelectState = useIsInSelectState(); - const enabled = oneSelected && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(import_jsx_runtime107.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["send-to-back"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["send-backward"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["bring-forward"], disabled: !enabled }), - /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["bring-to-front"], disabled: !enabled }) - ] }); -} -function ZoomOrRotateMenuItem() { - const breakpoint = useBreakpoint(); - return breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM ? /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(ZoomTo100MenuItem, {}) : /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(RotateCCWMenuItem, {}); -} -function ZoomTo100MenuItem() { - const actions = useActions(); - const editor = useEditor(); - const isZoomedTo100 = useValue("zoom is 1", () => editor.getZoomLevel() === 1, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["zoom-to-100"], disabled: isZoomedTo100 }); -} -function RotateCCWMenuItem() { - const actions = useActions(); - const oneSelected = useUnlockedSelectedShapesCount(1); - const isInSelectState = useIsInSelectState(); - const enabled = oneSelected && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["rotate-ccw"], disabled: !enabled }); -} -function RotateCWMenuItem() { - const actions = useActions(); - const oneSelected = useUnlockedSelectedShapesCount(1); - const isInSelectState = useIsInSelectState(); - const enabled = oneSelected && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["rotate-cw"], disabled: !enabled }); -} -function EditLinkMenuItem() { - const actions = useActions(); - const showEditLink = useHasLinkShapeSelected(); - const isInSelectState = useIsInSelectState(); - const enabled = showEditLink && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["edit-link"], disabled: !enabled }); -} -function GroupOrUngroupMenuItem() { - const allowGroup = useAllowGroup(); - const allowUngroup = useAllowUngroup(); - return allowGroup ? /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(GroupMenuItem, {}) : allowUngroup ? /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(UngroupMenuItem, {}) : /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(GroupMenuItem, {}); -} -function GroupMenuItem() { - const actions = useActions(); - const twoSelected = useUnlockedSelectedShapesCount(2); - const isInSelectState = useIsInSelectState(); - const enabled = twoSelected && isInSelectState; - return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["group"], disabled: !enabled }); -} -function UngroupMenuItem() { - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(TldrawUiMenuItem, { ...actions["ungroup"] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs -var DefaultActionsMenu = (0, import_react84.memo)(function DefaultActionsMenu2({ - children -}) { - const msg2 = useTranslation(); - const breakpoint = useBreakpoint(); - const isReadonlyMode = useReadonly(); - const editor = useEditor(); - const isInAcceptableReadonlyState = useValue("should display quick actions when in readonly", () => editor.isInAny("hand", "zoom"), [editor]); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DefaultActionsMenuContent, {}); - if (isReadonlyMode && !isInAcceptableReadonlyState) - return; - return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(TldrawUiPopover, { id: "actions-menu", children: [ - /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(TldrawUiPopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "actions-menu.button", - title: msg2("actions-menu.title"), - children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(TldrawUiButtonIcon, { icon: "dots-vertical", small: true }) - }) }), - /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(TldrawUiPopoverContent, { - side: breakpoint >= PORTRAIT_BREAKPOINT.TABLET ? "bottom" : "top", - sideOffset: 6, - children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "tlui-actions-menu tlui-buttons__grid", "data-testid": "actions-menu.content", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(TldrawUiMenuContextProvider, { type: "icons", sourceId: "actions-menu", children: content }) }) - }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs -var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1); -var import_react85 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenuContent.mjs -var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/menu-items.mjs -var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs -var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1); -function TldrawUiMenuCheckboxItem({ - id, - kbd: kbd2, - label, - readonlyOk, - onSelect, - toggle = false, - disabled = false, - checked = false -}) { - const { type: menuType, sourceId } = useTldrawUiMenuContext(); - const isReadonlyMode = useReadonly(); - const msg2 = useTranslation(); - if (isReadonlyMode && !readonlyOk) - return null; - const labelToUse = unwrapLabel(label, menuType); - const labelStr = labelToUse ? msg2(labelToUse) : void 0; - switch (menuType) { - case "menu": { - return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(CheckboxItem22, { - dir: "ltr", - className: "tlui-button tlui-button__menu tlui-button__checkbox", - title: labelStr, - onSelect: (e) => { - onSelect?.(sourceId); - preventDefault(e); - }, - disabled, - checked, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(TldrawUiIcon, { - small: true, - icon: toggle ? checked ? "toggle-on" : "toggle-off" : checked ? "check" : "none" - }), - labelStr && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "tlui-button__label", draggable: false, children: labelStr }), - kbd2 && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(TldrawUiKbd, { children: kbd2 }) - ] - }); - } - case "context-menu": { - return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(CheckboxItem2, { - className: "tlui-button tlui-button__menu tlui-button__checkbox", - dir: "ltr", - title: labelStr, - onSelect: (e) => { - onSelect(sourceId); - preventDefault(e); - }, - disabled, - checked, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(TldrawUiIcon, { - small: true, - icon: toggle ? checked ? "toggle-on" : "toggle-off" : checked ? "check" : "none" - }), - labelStr && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "tlui-button__label", draggable: false, children: labelStr }), - kbd2 && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(TldrawUiKbd, { children: kbd2 }) - ] - }, id); - } - default: { - return null; - } - } -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs -var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1); -function TldrawUiMenuGroup({ id, label, children }) { - const { type: menuType, sourceId } = useTldrawUiMenuContext(); - const msg2 = useTranslation(); - const labelToUse = unwrapLabel(label, menuType); - const labelStr = labelToUse ? msg2(labelToUse) : void 0; - switch (menuType) { - case "panel": { - return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "tlui-menu__group", "data-testid": `${sourceId}-group.${id}`, children }); - } - case "menu": { - return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(TldrawUiDropdownMenuGroup, { "data-testid": `${sourceId}-group.${id}`, children }); - } - case "context-menu": { - return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(ContextMenuGroup, { - dir: "ltr", - className: "tlui-menu__group", - "data-testid": `${sourceId}-group.${id}`, - children - }); - } - case "keyboard-shortcuts": { - return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "tlui-shortcuts-dialog__group", "data-testid": `${sourceId}-group.${id}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("h2", { className: "tlui-shortcuts-dialog__group__title", children: labelStr }), - /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "tlui-shortcuts-dialog__group__content", children }) - ] }); - } - default: { - return children; - } - } -} - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuSubmenu.mjs -var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1); -function TldrawUiMenuSubmenu({ - id, - disabled = false, - label, - size: size4 = "small", - children -}) { - const { type: menuType, sourceId } = useTldrawUiMenuContext(); - const container = useContainer(); - const msg2 = useTranslation(); - const labelToUse = label ? typeof label === "string" ? label : label[menuType] ?? label["default"] : void 0; - const labelStr = labelToUse ? msg2(labelToUse) : void 0; - switch (menuType) { - case "menu": { - return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(TldrawUiDropdownMenuSub, { id: `${sourceId}-sub.${id}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(TldrawUiDropdownMenuSubTrigger, { - id: `${sourceId}-sub.${labelStr ? labelStr.toLowerCase() + "-button" : ""}`, - disabled, - label: labelStr, - title: labelStr - }), - /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(TldrawUiDropdownMenuSubContent, { - id: `${sourceId}-sub.${labelStr ? labelStr.toLowerCase() + "-content" : ""}`, - size: size4, - children - }) - ] }); - } - case "context-menu": { - if (disabled) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(ContextMenuSubWithMenu, { id: `${sourceId}-sub.${id}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(ContextMenuSubTrigger, { dir: "ltr", disabled, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(TldrawUiButton, { - "data-testid": `${sourceId}-sub-trigger.${id}`, - type: "menu", - className: "tlui-menu__submenu__trigger", - children: [ - /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(TldrawUiButtonLabel, { children: labelStr }), - /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(TldrawUiButtonIcon, { icon: "chevron-right", small: true }) - ] - }) }), - /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(ContextMenuPortal, { container, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(ContextMenuSubContent, { - "data-testid": `${sourceId}-sub-content.${id}`, - className: "tlui-menu tlui-menu__submenu__content", - alignOffset: -1, - sideOffset: -4, - collisionPadding: 4, - "data-size": size4, - children - }) }) - ] }); - } - default: { - return children; - } - } -} -function ContextMenuSubWithMenu({ id, children }) { - const [open, onOpenChange] = useMenuIsOpen(id); - return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(ContextMenuSub, { open, onOpenChange, children }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/menu-items.mjs -function ToggleAutoSizeMenuItem() { - const actions = useActions(); - const shouldDisplay = useShowAutoSizeToggle(); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["toggle-auto-size"] }); -} -function EditLinkMenuItem2() { - const actions = useActions(); - const shouldDisplay = useHasLinkShapeSelected(); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["edit-link"] }); -} -function DuplicateMenuItem() { - const actions = useActions(); - const shouldDisplay = useUnlockedSelectedShapesCount(1); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["duplicate"] }); -} -function FlattenMenuItem() { - const actions = useActions(); - const editor = useEditor(); - const shouldDisplay = useValue("should display flatten option", () => { - const selectedShapeIds = editor.getSelectedShapeIds(); - if (selectedShapeIds.length === 0) - return false; - const onlySelectedShape = editor.getOnlySelectedShape(); - if (onlySelectedShape && editor.isShapeOfType(onlySelectedShape, "image")) { - return false; - } - return true; - }, [editor]); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["flatten-to-image"] }); -} -function GroupMenuItem2() { - const actions = useActions(); - const shouldDisplay = useAllowGroup(); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["group"] }); -} -function UngroupMenuItem2() { - const actions = useActions(); - const shouldDisplay = useAllowUngroup(); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["ungroup"] }); -} -function RemoveFrameMenuItem() { - const editor = useEditor(); - const actions = useActions(); - const shouldDisplay = useValue("allow unframe", () => { - const selectedShapes = editor.getSelectedShapes(); - if (selectedShapes.length === 0) - return false; - return selectedShapes.every((shape) => editor.isShapeOfType(shape, "frame")); - }, [editor]); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["remove-frame"] }); -} -function FitFrameToContentMenuItem() { - const editor = useEditor(); - const actions = useActions(); - const shouldDisplay = useValue("allow fit frame to content", () => { - const onlySelectedShape = editor.getOnlySelectedShape(); - if (!onlySelectedShape) - return false; - return editor.isShapeOfType(onlySelectedShape, "frame") && editor.getSortedChildIdsForParent(onlySelectedShape).length > 0; - }, [editor]); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["fit-frame-to-content"] }); -} -function ToggleLockMenuItem() { - const editor = useEditor(); - const actions = useActions(); - const shouldDisplay = useValue("selected shapes", () => editor.getSelectedShapes().length > 0, [ - editor - ]); - if (!shouldDisplay) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["toggle-lock"] }); -} -function ToggleTransparentBgMenuItem() { - const actions = useActions(); - const editor = useEditor(); - const isTransparentBg = useValue("isTransparentBg", () => !editor.getInstanceState().exportBackground, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-transparent"], checked: isTransparentBg, toggle: true }); -} -function UnlockAllMenuItem() { - const editor = useEditor(); - const actions = useActions(); - const shouldDisplay = useValue("any shapes", () => editor.getCurrentPageShapeIds().size > 0, [ - editor - ]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["unlock-all"], disabled: !shouldDisplay }); -} -function ZoomTo100MenuItem2() { - const editor = useEditor(); - const isZoomedTo100 = useValue("zoomed to 100", () => editor.getZoomLevel() === 1, [editor]); - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["zoom-to-100"], noClose: true, disabled: isZoomedTo100 }); -} -function ZoomToFitMenuItem() { - const editor = useEditor(); - const hasShapes = useValue("has shapes", () => editor.getCurrentPageShapeIds().size > 0, [editor]); - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { - ...actions["zoom-to-fit"], - disabled: !hasShapes, - "data-testid": "minimap.zoom-menu.zoom-to-fit", - noClose: true - }); -} -function ZoomToSelectionMenuItem() { - const editor = useEditor(); - const hasSelected = useValue("has shapes", () => editor.getSelectedShapeIds().length > 0, [ - editor - ]); - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { - ...actions["zoom-to-selection"], - disabled: !hasSelected, - "data-testid": "minimap.zoom-menu.zoom-to-selection", - noClose: true - }); -} -function ClipboardMenuGroup() { - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "clipboard", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(CutMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(CopyMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(PasteMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DuplicateMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DeleteMenuItem, {}) - ] }); -} -function CopyAsMenuGroup() { - const editor = useEditor(); - const actions = useActions(); - const atLeastOneShapeOnPage = useValue("atLeastOneShapeOnPage", () => editor.getCurrentPageShapeIds().size > 0, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuSubmenu, { - id: "copy-as", - label: "context-menu.copy-as", - size: "small", - disabled: !atLeastOneShapeOnPage, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "copy-as-group", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["copy-as-svg"] }), - Boolean(window.navigator.clipboard?.write) && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["copy-as-png"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["copy-as-json"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuGroup, { id: "copy-as-bg", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToggleTransparentBgMenuItem, {}) }) - ] - }); -} -function CutMenuItem() { - const actions = useActions(); - const shouldDisplay = useUnlockedSelectedShapesCount(1); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["cut"], disabled: !shouldDisplay }); -} -function CopyMenuItem() { - const actions = useActions(); - const shouldDisplay = useAnySelectedShapesCount(1); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["copy"], disabled: !shouldDisplay }); -} -function PasteMenuItem() { - const actions = useActions(); - const shouldDisplay = showMenuPaste; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["paste"], disabled: !shouldDisplay }); -} -function ConversionsMenuGroup() { - const editor = useEditor(); - const actions = useActions(); - const atLeastOneShapeOnPage = useValue("atLeastOneShapeOnPage", () => editor.getCurrentPageShapeIds().size > 0, [editor]); - if (!atLeastOneShapeOnPage) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "conversions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(CopyAsMenuGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuSubmenu, { id: "export-as", label: "context-menu.export-as", size: "small", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "export-as-group", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["export-as-svg"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["export-as-png"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["export-as-json"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuGroup, { id: "export-as-bg", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToggleTransparentBgMenuItem, {}) }) - ] }) - ] }); -} -function SelectAllMenuItem() { - const actions = useActions(); - const editor = useEditor(); - const atLeastOneShapeOnPage = useValue("atLeastOneShapeOnPage", () => editor.getCurrentPageShapeIds().size > 0, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["select-all"], disabled: !atLeastOneShapeOnPage }); -} -function DeleteMenuItem() { - const actions = useActions(); - const oneSelected = useUnlockedSelectedShapesCount(1); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["delete"], disabled: !oneSelected }); -} -function EditMenuSubmenu() { - if (!useAnySelectedShapesCount(1)) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuSubmenu, { id: "edit", label: "context-menu.edit", size: "small", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(GroupMenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(UngroupMenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(FlattenMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(EditLinkMenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(FitFrameToContentMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(RemoveFrameMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ConvertToEmbedMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ConvertToBookmarkMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToggleAutoSizeMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToggleLockMenuItem, {}) - ] }); -} -function ArrangeMenuSubmenu() { - const twoSelected = useUnlockedSelectedShapesCount(2); - const onlyFlippableShapeSelected = useOnlyFlippableShape(); - const actions = useActions(); - if (!(twoSelected || onlyFlippableShapeSelected)) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuSubmenu, { id: "arrange", label: "context-menu.arrange", size: "small", children: [ - twoSelected && /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "align", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["align-left"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["align-center-horizontal"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["align-right"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["align-top"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["align-center-vertical"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["align-bottom"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DistributeMenuGroup, {}), - twoSelected && /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "stretch", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["stretch-horizontal"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["stretch-vertical"] }) - ] }), - (twoSelected || onlyFlippableShapeSelected) && /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "flip", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["flip-horizontal"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["flip-vertical"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(OrderMenuGroup, {}) - ] }); -} -function DistributeMenuGroup() { - const actions = useActions(); - const threeSelected = useUnlockedSelectedShapesCount(3); - if (!threeSelected) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "distribute", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["distribute-horizontal"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["distribute-vertical"] }) - ] }); -} -function OrderMenuGroup() { - const actions = useActions(); - const twoSelected = useUnlockedSelectedShapesCount(2); - const threeStackableItems = useThreeStackableItems(); - if (!twoSelected) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "order", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["pack"] }), - threeStackableItems && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["stack-horizontal"] }), - threeStackableItems && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["stack-vertical"] }) - ] }); -} -function ReorderMenuSubmenu() { - const actions = useActions(); - const oneSelected = useUnlockedSelectedShapesCount(1); - if (!oneSelected) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuSubmenu, { id: "reorder", label: "context-menu.reorder", size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuGroup, { id: "reorder", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["bring-to-front"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["bring-forward"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["send-backward"] }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["send-to-back"] }) - ] }) }); -} -function MoveToPageMenu() { - const editor = useEditor(); - const pages = useValue("pages", () => editor.getPages(), [editor]); - const currentPageId = useValue("current page id", () => editor.getCurrentPageId(), [editor]); - const { addToast } = useToasts(); - const actions = useActions(); - const trackEvent = useUiEvents(); - const oneSelected = useUnlockedSelectedShapesCount(1); - if (!oneSelected) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(TldrawUiMenuSubmenu, { id: "move-to-page", label: "context-menu.move-to-page", size: "small", children: [ - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuGroup, { id: "pages", children: pages.map((page) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { - id: page.id, - disabled: currentPageId === page.id, - label: page.name, - onSelect: () => { - editor.mark("move_shapes_to_page"); - editor.moveShapesToPage(editor.getSelectedShapeIds(), page.id); - const toPage = editor.getPage(page.id); - if (toPage) { - addToast({ - title: "Changed Page", - description: `Moved to ${toPage.name}.`, - actions: [ - { - label: "Go Back", - type: "primary", - onClick: () => { - editor.mark("change-page"); - editor.setCurrentPage(currentPageId); - } - } - ] - }); - } - trackEvent("move-to-page", { source: "context-menu" }); - } - }, page.id)) }), - /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuGroup, { id: "new-page", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["move-to-new-page"] }) }) - ] }); -} -function ConvertToBookmarkMenuItem() { - const editor = useEditor(); - const actions = useActions(); - const oneEmbedSelected = useValue("oneEmbedSelected", () => { - const onlySelectedShape = editor.getOnlySelectedShape(); - if (!onlySelectedShape) - return false; - return !!(editor.isShapeOfType(onlySelectedShape, "embed") && onlySelectedShape.props.url && !editor.isShapeOrAncestorLocked(onlySelectedShape)); - }, [editor]); - if (!oneEmbedSelected) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["convert-to-bookmark"] }); -} -function ConvertToEmbedMenuItem() { - const editor = useEditor(); - const actions = useActions(); - const oneEmbeddableBookmarkSelected = useValue("oneEmbeddableBookmarkSelected", () => { - const onlySelectedShape = editor.getOnlySelectedShape(); - if (!onlySelectedShape) - return false; - return !!(editor.isShapeOfType(onlySelectedShape, "bookmark") && onlySelectedShape.props.url && getEmbedInfo(onlySelectedShape.props.url) && !editor.isShapeOrAncestorLocked(onlySelectedShape)); - }, [editor]); - if (!oneEmbeddableBookmarkSelected) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["convert-to-embed"] }); -} -function ToggleSnapModeItem() { - const actions = useActions(); - const editor = useEditor(); - const isSnapMode = useValue("isSnapMode", () => editor.user.getIsSnapMode(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-snap-mode"], checked: isSnapMode }); -} -function ToggleToolLockItem() { - const actions = useActions(); - const editor = useEditor(); - const isToolLock = useValue("isToolLock", () => editor.getInstanceState().isToolLocked, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-tool-lock"], checked: isToolLock }); -} -function ToggleGridItem() { - const actions = useActions(); - const editor = useEditor(); - const isGridMode = useValue("isGridMode", () => editor.getInstanceState().isGridMode, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-grid"], checked: isGridMode }); -} -function ToggleWrapModeItem() { - const actions = useActions(); - const editor = useEditor(); - const isWrapMode = useValue("isWrapMode", () => editor.user.getIsWrapMode(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-wrap-mode"], checked: isWrapMode }); -} -function ToggleFocusModeItem() { - const actions = useActions(); - const editor = useEditor(); - const isFocusMode = useValue("isFocusMode", () => editor.getInstanceState().isFocusMode, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-focus-mode"], checked: isFocusMode }); -} -function ToggleEdgeScrollingItem() { - const actions = useActions(); - const editor = useEditor(); - const edgeScrollSpeed = useValue("edgeScrollSpeed", () => editor.user.getEdgeScrollSpeed(), [ - editor - ]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { - ...actions["toggle-edge-scrolling"], - checked: edgeScrollSpeed === 1 - }); -} -function ToggleReduceMotionItem() { - const actions = useActions(); - const editor = useEditor(); - const animationSpeed = useValue("animationSpeed", () => editor.user.getAnimationSpeed(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-reduce-motion"], checked: animationSpeed === 0 }); -} -function ToggleDebugModeItem() { - const actions = useActions(); - const editor = useEditor(); - const isDebugMode = useValue("isDebugMode", () => editor.getInstanceState().isDebugMode, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-debug-mode"], checked: isDebugMode }); -} -function ToggleDynamicSizeModeItem() { - const actions = useActions(); - const editor = useEditor(); - const isDynamicResizeMode = useValue("dynamic resize", () => editor.user.getIsDynamicResizeMode(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { - ...actions["toggle-dynamic-size-mode"], - checked: isDynamicResizeMode - }); -} -function TogglePasteAtCursorItem() { - const actions = useActions(); - const editor = useEditor(); - const pasteAtCursor = useValue("paste at cursor", () => editor.user.getIsPasteAtCursorMode(), [ - editor - ]); - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuCheckboxItem, { ...actions["toggle-paste-at-cursor"], checked: pasteAtCursor }); -} -function CursorChatItem() { - const editor = useEditor(); - const actions = useActions(); - const shouldShow = useValue("show cursor chat", () => editor.getCurrentToolId() === "select" && !editor.getInstanceState().isCoarsePointer, [editor]); - if (!shouldShow) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(TldrawUiMenuItem, { ...actions["open-cursor-chat"] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenuContent.mjs -function DefaultContextMenuContent() { - const editor = useEditor(); - const isMultiplayer = useIsMultiplayer(); - const selectToolActive = useValue("isSelectToolActive", () => editor.getCurrentToolId() === "select", [editor]); - if (!selectToolActive) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_jsx_runtime113.Fragment, { children: [ - isMultiplayer && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(CursorChatItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(TldrawUiMenuGroup, { id: "modify", children: [ - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(EditMenuSubmenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(ArrangeMenuSubmenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(ReorderMenuSubmenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(MoveToPageMenu, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(ClipboardMenuGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(ConversionsMenuGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(TldrawUiMenuGroup, { id: "select-all", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(SelectAllMenuItem, {}) }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs -var DefaultContextMenu = (0, import_react85.memo)(function DefaultContextMenu2({ - children -}) { - const editor = useEditor(); - const { Canvas } = useEditorComponents(); - const cb = (0, import_react85.useCallback)((isOpen2) => { - if (!isOpen2) { - const onlySelectedShape = editor.getOnlySelectedShape(); - if (onlySelectedShape && editor.isShapeOrAncestorLocked(onlySelectedShape)) { - editor.setSelectedShapes([]); - } - } else { - if (editor.getInstanceState().isCoarsePointer) { - const selectedShapes = editor.getSelectedShapes(); - const { - inputs: { currentPagePoint } - } = editor; - const shapesAtPoint = editor.getShapesAtPoint(currentPagePoint); - if (!editor.getSelectedShapes().length || !shapesAtPoint.some((s) => selectedShapes.includes(s))) { - const lockedShapes = shapesAtPoint.filter((s) => editor.isShapeOrAncestorLocked(s)); - if (lockedShapes.length) { - editor.select(...lockedShapes.map((s) => s.id)); - } - } - } - } - }, [editor]); - const container = useContainer(); - const [isOpen, handleOpenChange] = useMenuIsOpen("context menu", cb); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(DefaultContextMenuContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Root25, { dir: "ltr", onOpenChange: handleOpenChange, modal: false, children: [ - /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Trigger2, { onContextMenu: void 0, dir: "ltr", children: Canvas ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Canvas, {}) : null }), - isOpen && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Portal22, { container, children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Content24, { - className: "tlui-menu scrollable", - "data-testid": "context-menu", - alignOffset: -4, - collisionPadding: 4, - onContextMenu: preventDefault, - children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(TldrawUiMenuContextProvider, { type: "context-menu", sourceId: "context-menu", children: content }) - }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/CursorChatBubble.mjs -var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1); -var import_react86 = __toESM(require_react(), 1); -var CHAT_MESSAGE_TIMEOUT_CLOSING = 2e3; -var CHAT_MESSAGE_TIMEOUT_CHATTING = 5e3; -var CursorChatBubble = track(function CursorChatBubble2() { - const editor = useEditor(); - const { isChatting, chatMessage } = editor.getInstanceState(); - const rTimeout = (0, import_react86.useRef)(-1); - const [value, setValue] = (0, import_react86.useState)(""); - (0, import_react86.useEffect)(() => { - const closingUp = !isChatting && chatMessage; - if (closingUp || isChatting) { - const duration = isChatting ? CHAT_MESSAGE_TIMEOUT_CHATTING : CHAT_MESSAGE_TIMEOUT_CLOSING; - rTimeout.current = editor.timers.setTimeout(() => { - editor.updateInstanceState({ chatMessage: "", isChatting: false }); - setValue(""); - editor.focus(); - }, duration); - } - return () => { - clearTimeout(rTimeout.current); - }; - }, [editor, chatMessage, isChatting]); - if (isChatting) - return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(CursorChatInput, { value, setValue, chatMessage }); - return chatMessage.trim() ? /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(NotEditingChatMessage, { chatMessage }) : null; -}); -function usePositionBubble(ref) { - const editor = useEditor(); - (0, import_react86.useLayoutEffect)(() => { - const elm = ref.current; - if (!elm) - return; - const { x, y } = editor.inputs.currentScreenPoint; - ref.current?.style.setProperty("transform", `translate(${x}px, ${y}px)`); - function positionChatBubble(e) { - const { minX, minY } = editor.getViewportScreenBounds(); - ref.current?.style.setProperty("transform", `translate(${e.clientX - minX}px, ${e.clientY - minY}px)`); - } - window.addEventListener("pointermove", positionChatBubble); - return () => { - window.removeEventListener("pointermove", positionChatBubble); - }; - }, [ref, editor]); -} -var NotEditingChatMessage = ({ chatMessage }) => { - const editor = useEditor(); - const ref = (0, import_react86.useRef)(null); - usePositionBubble(ref); - return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("div", { - ref, - className: "tl-cursor-chat tl-cursor-chat__bubble", - style: { backgroundColor: editor.user.getColor() }, - children: chatMessage - }); -}; -var CursorChatInput = track(function CursorChatInput2({ - chatMessage, - value, - setValue -}) { - const editor = useEditor(); - const msg2 = useTranslation(); - const ref = (0, import_react86.useRef)(null); - const placeholder = chatMessage || msg2("cursor-chat.type-to-chat"); - usePositionBubble(ref); - (0, import_react86.useLayoutEffect)(() => { - const elm = ref.current; - if (!elm) - return; - const textMeasurement = editor.textMeasure.measureText(value || placeholder, { - fontFamily: "var(--font-body)", - fontSize: 12, - fontWeight: "500", - fontStyle: "normal", - maxWidth: null, - lineHeight: 1, - padding: "6px" - }); - elm.style.setProperty("width", textMeasurement.w + "px"); - }, [editor, value, placeholder]); - (0, import_react86.useLayoutEffect)(() => { - const raf = editor.timers.requestAnimationFrame(() => { - ref.current?.focus(); - }); - return () => { - cancelAnimationFrame(raf); - }; - }, [editor]); - const stopChatting = (0, import_react86.useCallback)(() => { - editor.updateInstanceState({ isChatting: false }); - editor.focus(); - }, [editor]); - const handleChange = (0, import_react86.useCallback)((e) => { - const { value: value2 } = e.target; - setValue(value2.slice(0, 64)); - editor.updateInstanceState({ chatMessage: value2 }); - }, [editor, setValue]); - const handleKeyDown = (0, import_react86.useCallback)((e) => { - const elm = ref.current; - if (!elm) - return; - const { value: currentValue } = elm; - switch (e.key) { - case "Enter": { - preventDefault(e); - e.stopPropagation(); - if (!currentValue) { - stopChatting(); - return; - } - setValue(""); - break; - } - case "Escape": { - preventDefault(e); - e.stopPropagation(); - stopChatting(); - break; - } - } - }, [stopChatting, setValue]); - const handlePaste = (0, import_react86.useCallback)((e) => { - e.stopPropagation(); - }, []); - return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("input", { - ref, - className: `tl-cursor-chat`, - style: { backgroundColor: editor.user.getColor() }, - onBlur: stopChatting, - onChange: handleChange, - onKeyDown: handleKeyDown, - onPaste: handlePaste, - value, - placeholder, - spellCheck: false - }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/DebugMenu/DefaultDebugMenu.mjs -var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/DebugMenu/DefaultDebugMenuContent.mjs -var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1); -var import_react87 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonCheck.mjs -var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1); -function TldrawUiButtonCheck({ checked }) { - return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(TldrawUiIcon, { icon: checked ? "check" : "none", className: "tlui-button__icon", small: true }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/DebugMenu/DefaultDebugMenuContent.mjs -function DefaultDebugMenuContent() { - const editor = useEditor(); - const { addToast } = useToasts(); - const { addDialog } = useDialogs(); - const [error3, setError] = import_react87.default.useState(false); - return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(TldrawUiMenuGroup, { id: "items", children: [ - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuItem, { - id: "add-toast", - onSelect: () => { - addToast({ - id: uniqueId(), - title: "Something good happened", - description: "Hey, attend to this thing over here. It might be important!", - keepOpen: true, - severity: "success" - }); - addToast({ - id: uniqueId(), - title: "Something happened", - description: "Hey, attend to this thing over here. It might be important!", - keepOpen: true, - severity: "info", - actions: [ - { - label: "Primary", - type: "primary", - onClick: () => { - } - }, - { - label: "Normal", - type: "normal", - onClick: () => { - } - }, - { - label: "Danger", - type: "danger", - onClick: () => { - } - } - ] - }); - addToast({ - id: uniqueId(), - title: "Something maybe bad happened", - description: "Hey, attend to this thing over here. It might be important!", - keepOpen: true, - severity: "warning", - actions: [ - { - label: "Primary", - type: "primary", - onClick: () => { - } - }, - { - label: "Normal", - type: "normal", - onClick: () => { - } - }, - { - label: "Danger", - type: "danger", - onClick: () => { - } - } - ] - }); - addToast({ - id: uniqueId(), - title: "Something bad happened", - severity: "error", - keepOpen: true - }); - }, - label: untranslated("Show toast") - }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuItem, { - id: "show-dialog", - label: "Show dialog", - onSelect: () => { - addDialog({ - component: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(ExampleDialog, { - displayDontShowAgain: true, - onCancel: () => onClose(), - onContinue: () => onClose() - }), - onClose: () => { - } - }); - } - }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuItem, { - id: "create-shapes", - label: "Create 100 shapes", - onSelect: () => createNShapes(editor, 100) - }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuItem, { - id: "count-nodes", - label: "Count shapes / nodes", - onSelect: () => { - const selectedShapes = editor.getSelectedShapes(); - const shapes = selectedShapes.length === 0 ? editor.getRenderingShapes() : selectedShapes; - window.alert(`Shapes ${shapes.length}, DOM nodes:${document.querySelector(".tl-shapes").querySelectorAll("*")?.length}`); - } - }), - (() => { - if (error3) - throw Error("oh no!"); - return null; - })(), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuItem, { id: "throw-error", onSelect: () => setError(true), label: "Throw error" }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuItem, { id: "hard-reset", onSelect: hardResetEditor, label: "Hard reset" }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(TldrawUiMenuGroup, { id: "flags", children: [ - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DebugFlags, {}), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(FeatureFlags, {}) - ] }) - ] }); -} -function DebugFlags() { - const items = Object.values(debugFlags); - if (!items.length) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuSubmenu, { id: "debug flags", label: "Debug Flags", children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuGroup, { id: "debug flags", children: items.map((flag) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DebugFlagToggle, { flag }, flag.name)) }) }); -} -function FeatureFlags() { - const items = Object.values(featureFlags); - if (!items.length) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuSubmenu, { id: "feature flags", label: "Feature Flags", children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuGroup, { id: "feature flags", children: items.map((flag) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DebugFlagToggle, { flag }, flag.name)) }) }); -} -function ExampleDialog({ - title = "title", - body = "hello hello hello", - cancel = "Cancel", - confirm = "Continue", - displayDontShowAgain = false, - onCancel, - onContinue -}) { - const [dontShowAgain, setDontShowAgain] = import_react87.default.useState(false); - return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(TldrawUiDialogHeader, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiDialogTitle, { children: title }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiDialogCloseButton, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiDialogBody, { style: { maxWidth: 350 }, children: body }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(TldrawUiDialogFooter, { className: "tlui-dialog__footer__actions", children: [ - displayDontShowAgain && /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(TldrawUiButton, { - type: "normal", - onClick: () => setDontShowAgain(!dontShowAgain), - style: { marginRight: "auto" }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiButtonCheck, { checked: dontShowAgain }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiButtonLabel, { children: "Don\u2019t show again" }) - ] - }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiButton, { type: "normal", onClick: onCancel, children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiButtonLabel, { children: cancel }) }), - /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiButton, { type: "primary", onClick: async () => onContinue(), children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiButtonLabel, { children: confirm }) }) - ] }) - ] }); -} -var DebugFlagToggle = track(function DebugFlagToggle2({ - flag, - onChange -}) { - const value = flag.get(); - return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(TldrawUiMenuCheckboxItem, { - id: flag.name, - title: flag.name, - label: flag.name.replace(/([a-z0-9])([A-Z])/g, (m) => `${m[0]} ${m[1].toLowerCase()}`).replace(/^[a-z]/, (m) => m.toUpperCase()), - checked: value, - onSelect: () => { - flag.set(!value); - onChange?.(!value); - } - }); -}); -var t = 0; -function createNShapes(editor, n) { - const shapesToCreate = Array(n); - const cols = Math.floor(Math.sqrt(n)); - for (let i = 0; i < n; i++) { - t++; - shapesToCreate[i] = { - id: createShapeId("box" + t), - type: "geo", - x: i % cols * 132, - y: Math.floor(i / cols) * 132 - }; - } - editor.run(() => { - editor.createShapes(shapesToCreate).setSelectedShapes(shapesToCreate.map((s) => s.id)); - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/DebugMenu/DefaultDebugMenu.mjs -function DefaultDebugMenu({ children }) { - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DefaultDebugMenuContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(TldrawUiDropdownMenuRoot, { id: "debug", children: [ - /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(TldrawUiButton, { type: "icon", title: "Debug menu", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(TldrawUiButtonIcon, { icon: "dots-horizontal" }) }) }), - /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(TldrawUiDropdownMenuContent, { side: "top", align: "end", alignOffset: 0, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(TldrawUiMenuContextProvider, { type: "menu", sourceId: "debug-panel", children: content }) }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/DefaultDebugPanel.mjs -var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1); -var import_react88 = __toESM(require_react(), 1); -var DefaultDebugPanel = (0, import_react88.memo)(function DefaultDebugPanel2() { - const { DebugMenu } = useTldrawUiComponents(); - return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("div", { className: "tlui-debug-panel", children: [ - /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(CurrentState, {}), - /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(FPS, {}), - DebugMenu && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(DebugMenu, {}) - ] }); -}); -function useTick2(isEnabled = true) { - const [_, setTick] = (0, import_react88.useState)(0); - const editor = useEditor(); - (0, import_react88.useEffect)(() => { - if (!isEnabled) - return; - const update = () => setTick((tick2) => tick2 + 1); - editor.on("tick", update); - return () => { - editor.off("tick", update); - }; - }, [editor, isEnabled]); -} -var CurrentState = track(function CurrentState2() { - useTick2(); - const editor = useEditor(); - const path = editor.getPath(); - const hoverShape = editor.getHoveredShape(); - const selectedShape = editor.getOnlySelectedShape(); - const shape = path === "select.idle" || !path.includes("select.") ? hoverShape : selectedShape; - const shapeInfo = shape && path.includes("select.") ? ` / ${shape.type || ""}${"geo" in shape.props ? " / " + shape.props.geo : ""} / [${Vec.ToInt(editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint))}]` : ""; - const ruler = path.startsWith("select.") && !path.includes(".idle") ? ` / [${Vec.ToInt(editor.inputs.originPagePoint)}] \u2192 [${Vec.ToInt(editor.inputs.currentPagePoint)}] = ${Vec.Dist(editor.inputs.originPagePoint, editor.inputs.currentPagePoint).toFixed(0)}` : ""; - return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: "tlui-debug-panel__current-state", children: `${path}${shapeInfo}${ruler}` }); -}); -function FPS() { - const editor = useEditor(); - const showFps = useValue("show_fps", () => debugFlags.showFps.get(), [debugFlags]); - const fpsRef = (0, import_react88.useRef)(null); - (0, import_react88.useEffect)(() => { - if (!showFps) - return; - const TICK_LENGTH = 250; - let maxKnownFps = 0; - let raf = -1; - let start = performance.now(); - let currentTickLength = 0; - let framesInCurrentTick = 0; - let isSlow = false; - function loop() { - framesInCurrentTick++; - currentTickLength = performance.now() - start; - if (currentTickLength > TICK_LENGTH) { - const fps = Math.round(framesInCurrentTick * (TICK_LENGTH / currentTickLength) * (1e3 / TICK_LENGTH)); - if (fps > maxKnownFps) { - maxKnownFps = fps; - } - const slowFps = maxKnownFps * 0.75; - if (fps < slowFps && !isSlow || fps >= slowFps && isSlow) { - isSlow = !isSlow; - } - fpsRef.current.innerHTML = `FPS ${fps.toString()}`; - fpsRef.current.className = `tlui-debug-panel__fps` + (isSlow ? ` tlui-debug-panel__fps__slow` : ``); - currentTickLength -= TICK_LENGTH; - framesInCurrentTick = 0; - start = performance.now(); - } - raf = editor.timers.requestAnimationFrame(loop); - } - loop(); - return () => { - cancelAnimationFrame(raf); - }; - }, [showFps, editor]); - if (!showFps) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { ref: fpsRef }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/DefaultMenuPanel.mjs -var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1); -var import_react89 = __toESM(require_react(), 1); -var DefaultMenuPanel = (0, import_react89.memo)(function MenuPanel() { - const breakpoint = useBreakpoint(); - const { MainMenu, QuickActions, ActionsMenu, PageMenu } = useTldrawUiComponents(); - if (!MainMenu && !PageMenu && breakpoint < 6) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: "tlui-menu-zone", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("div", { className: "tlui-buttons__horizontal", children: [ - MainMenu && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(MainMenu, {}), - PageMenu && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(PageMenu, {}), - breakpoint < 6 ? null : /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [ - QuickActions && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(QuickActions, {}), - ActionsMenu && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(ActionsMenu, {}) - ] }) - ] }) }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/DefaultHelperButtons.mjs -var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/DefaultHelperButtonsContent.mjs -var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs -var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1); -var import_react90 = __toESM(require_react(), 1); -function BackToContent() { - const editor = useEditor(); - const actions = useActions(); - const [showBackToContent, setShowBackToContent] = (0, import_react90.useState)(false); - const rIsShowing = (0, import_react90.useRef)(false); - useQuickReactor("toggle showback to content", () => { - const showBackToContentPrev = rIsShowing.current; - const shapeIds = editor.getCurrentPageShapeIds(); - let showBackToContentNow = false; - if (shapeIds.size) { - showBackToContentNow = shapeIds.size === editor.getCulledShapes().size; - } - if (showBackToContentPrev !== showBackToContentNow) { - setShowBackToContent(showBackToContentNow); - rIsShowing.current = showBackToContentNow; - } - }, [editor]); - if (!showBackToContent) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(TldrawUiMenuItem, { - ...actions["back-to-content"], - onSelect: () => { - actions["back-to-content"].onSelect("helper-buttons"); - setShowBackToContent(false); - } - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/ExitPenMode.mjs -var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1); -function ExitPenMode() { - const editor = useEditor(); - const actions = useActions(); - const isPenMode = useValue("is pen mode", () => editor.getInstanceState().isPenMode, [editor]); - if (!isPenMode) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(TldrawUiMenuItem, { ...actions["exit-pen-mode"] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs -var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1); -function StopFollowing() { - const editor = useEditor(); - const actions = useActions(); - const followingUser = useValue("is following user", () => !!editor.getInstanceState().followingUserId, [editor]); - if (!followingUser) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TldrawUiMenuItem, { ...actions["stop-following"] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/DefaultHelperButtonsContent.mjs -function DefaultHelperButtonsContent() { - return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(import_jsx_runtime124.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(ExitPenMode, {}), - /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(BackToContent, {}), - /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(StopFollowing, {}) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/HelperButtons/DefaultHelperButtons.mjs -function DefaultHelperButtons({ children }) { - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(DefaultHelperButtonsContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("div", { className: "tlui-helper-buttons", children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(TldrawUiMenuContextProvider, { type: "helper-buttons", sourceId: "helper-buttons", children: content }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialog.mjs -var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1); -var import_classnames23 = __toESM(require_classnames(), 1); -var import_react91 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs -var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1); -function DefaultKeyboardShortcutsDialogContent() { - const actions = useActions(); - const tools = useTools(); - const isMultiplayer = useIsMultiplayer(); - return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_jsx_runtime126.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(TldrawUiMenuGroup, { label: "shortcuts-dialog.tools", id: "tools", children: [ - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["toggle-tool-lock"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["insert-media"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["select"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["draw"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["eraser"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["hand"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["rectangle"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["ellipse"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["arrow"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["line"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["text"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["frame"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["note"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...tools["laser"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(TldrawUiMenuGroup, { label: "shortcuts-dialog.preferences", id: "preferences", children: [ - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["toggle-dark-mode"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["toggle-focus-mode"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["toggle-grid"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(TldrawUiMenuGroup, { label: "shortcuts-dialog.edit", id: "edit", children: [ - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["undo"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["redo"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["cut"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["copy"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["paste"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["select-all"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["delete"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["duplicate"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(TldrawUiMenuGroup, { label: "shortcuts-dialog.view", id: "view", children: [ - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["zoom-in"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["zoom-out"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["zoom-to-100"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["zoom-to-fit"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["zoom-to-selection"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(TldrawUiMenuGroup, { label: "shortcuts-dialog.transform", id: "transform", children: [ - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["bring-to-front"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["bring-forward"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["send-backward"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["send-to-back"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["group"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["ungroup"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["flip-horizontal"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["flip-vertical"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["align-top"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["align-center-vertical"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["align-bottom"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["align-left"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["align-center-horizontal"] }), - /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["align-right"] }) - ] }), - isMultiplayer && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuGroup, { label: "shortcuts-dialog.collaboration", id: "collaboration", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(TldrawUiMenuItem, { ...actions["open-cursor-chat"] }) }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialog.mjs -var DefaultKeyboardShortcutsDialog = (0, import_react91.memo)(function DefaultKeyboardShortcutsDialog2({ - children -}) { - const msg2 = useTranslation(); - const breakpoint = useBreakpoint(); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(DefaultKeyboardShortcutsDialogContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_jsx_runtime127.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(TldrawUiDialogHeader, { className: "tlui-shortcuts-dialog__header", children: [ - /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(TldrawUiDialogTitle, { children: msg2("shortcuts-dialog.title") }), - /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(TldrawUiDialogCloseButton, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(TldrawUiDialogBody, { - className: (0, import_classnames23.default)("tlui-shortcuts-dialog__body", { - "tlui-shortcuts-dialog__body__mobile": breakpoint <= PORTRAIT_BREAKPOINT.MOBILE_XS, - "tlui-shortcuts-dialog__body__tablet": breakpoint <= PORTRAIT_BREAKPOINT.TABLET - }), - children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(TldrawUiMenuContextProvider, { type: "keyboard-shortcuts", sourceId: "kbd", children: content }) - }), - /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("div", { className: "tlui-dialog__scrim" }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/MainMenu/DefaultMainMenu.mjs -var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1); -var import_react92 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs -var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/ColorSchemeMenu.mjs -var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1); -var COLOR_SCHEMES = [ - { colorScheme: "light", label: "theme.light" }, - { colorScheme: "dark", label: "theme.dark" }, - { colorScheme: "system", label: "theme.system" } -]; -function ColorSchemeMenu() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const currentColorScheme = useValue("colorScheme", () => editor.user.getUserPreferences().colorScheme ?? editor.user.getIsDarkMode() ? "dark" : "light", [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(TldrawUiMenuSubmenu, { id: "help menu color-scheme", label: "menu.theme", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(TldrawUiMenuGroup, { id: "languages", children: COLOR_SCHEMES.map(({ colorScheme, label }) => /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(TldrawUiMenuCheckboxItem, { - id: `color-scheme-${colorScheme}`, - label, - checked: colorScheme === currentColorScheme, - onSelect: () => { - editor.user.updateUserPreferences({ colorScheme }); - trackEvent("color-scheme", { source: "menu", value: colorScheme }); - } - }, colorScheme)) }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/HelpMenu/DefaultHelpMenuContent.mjs -var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/LanguageMenu.mjs -var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1); -function LanguageMenu() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const currentLanguage = useValue("locale", () => editor.user.getLocale(), [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(TldrawUiMenuSubmenu, { id: "help menu language", label: "menu.language", children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(TldrawUiMenuGroup, { id: "languages", children: LANGUAGES.map(({ locale, label }) => /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(TldrawUiMenuCheckboxItem, { - id: `language-${locale}`, - title: locale, - label, - checked: locale === currentLanguage, - onSelect: () => { - editor.user.updateUserPreferences({ locale }); - trackEvent("change-language", { source: "menu", locale }); - } - }, locale)) }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/HelpMenu/DefaultHelpMenuContent.mjs -function DefaultHelpMenuContent() { - return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(LanguageMenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(KeyboardShortcutsMenuItem, {}) - ] }); -} -function KeyboardShortcutsMenuItem() { - const { KeyboardShortcutsDialog } = useTldrawUiComponents(); - const { addDialog } = useDialogs(); - if (!KeyboardShortcutsDialog) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(TldrawUiMenuItem, { - id: "keyboard-shortcuts-button", - label: "help-menu.keyboard-shortcuts", - readonlyOk: true, - onSelect: () => { - addDialog({ component: KeyboardShortcutsDialog }); - } - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs -function DefaultMainMenuContent() { - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(import_jsx_runtime131.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(EditSubmenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ViewSubmenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ExportFileContentSubMenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ExtrasGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(PreferencesGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(HelpGroup, {}) - ] }); -} -function ExportFileContentSubMenu() { - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuSubmenu, { id: "export-all-as", label: "context-menu.export-all-as", size: "small", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "export-all-as-group", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["export-all-as-svg"] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["export-all-as-png"] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["export-all-as-json"] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuGroup, { id: "export-all-as-bg", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleTransparentBgMenuItem, {}) }) - ] }); -} -function EditSubmenu() { - const editor = useEditor(); - const selectToolActive = useValue("isSelectToolActive", () => editor.getCurrentToolId() === "select", [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuSubmenu, { id: "edit", label: "menu.edit", disabled: !selectToolActive, children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(UndoRedoGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ClipboardMenuGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ConversionsMenuGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MiscMenuGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(LockGroup, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuGroup, { id: "select-all", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(SelectAllMenuItem, {}) }) - ] }); -} -function MiscMenuGroup() { - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "misc", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(GroupMenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(UngroupMenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(EditLinkMenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleAutoSizeMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(RemoveFrameMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(FitFrameToContentMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ConvertToEmbedMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ConvertToBookmarkMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(FlattenMenuItem, {}) - ] }); -} -function LockGroup() { - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "lock", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleLockMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(UnlockAllMenuItem, {}) - ] }); -} -function UndoRedoGroup() { - const actions = useActions(); - const canUndo = useCanUndo(); - const canRedo = useCanRedo(); - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "undo-redo", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["undo"], disabled: !canUndo }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["redo"], disabled: !canRedo }) - ] }); -} -function ViewSubmenu() { - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuSubmenu, { id: "view", label: "menu.view", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "view-actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["zoom-in"] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["zoom-out"] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ZoomTo100MenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ZoomToFitMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ZoomToSelectionMenuItem, {}) - ] }) }); -} -function ExtrasGroup() { - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "extras", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["insert-embed"] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { ...actions["insert-media"] }) - ] }); -} -function HelpGroup() { - function openUrl(url) { - window.open(url, "_blank"); - } - return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuGroup, { id: "help", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuSubmenu, { id: "help", label: "menu.help", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "help-actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(KeyboardShortcutsMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuItem, { - id: "about", - label: "help-menu.docs", - icon: "external-link", - readonlyOk: true, - onSelect: () => { - openUrl("https://tldraw.dev"); - } - }) - ] }) }) }); -} -function PreferencesGroup() { - return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuGroup, { id: "preferences", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuSubmenu, { id: "preferences", label: "menu.preferences", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(TldrawUiMenuGroup, { id: "preferences-actions", children: [ - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleSnapModeItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleToolLockItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleGridItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleWrapModeItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleFocusModeItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleEdgeScrollingItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleReduceMotionItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleDynamicSizeModeItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TogglePasteAtCursorItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ToggleDebugModeItem, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuGroup, { id: "color-scheme", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ColorSchemeMenu, {}) }), - /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TldrawUiMenuGroup, { id: "language", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(LanguageMenu, {}) }) - ] }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/MainMenu/DefaultMainMenu.mjs -var DefaultMainMenu = (0, import_react92.memo)(function DefaultMainMenu2({ children }) { - const container = useContainer(); - const [isOpen, onOpenChange] = useMenuIsOpen("main menu"); - const msg2 = useTranslation(); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(DefaultMainMenuContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(Root26, { dir: "ltr", open: isOpen, onOpenChange, modal: false, children: [ - /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Trigger3, { asChild: true, dir: "ltr", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(TldrawUiButton, { type: "icon", "data-testid": "main-menu.button", title: msg2("menu.title"), children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(TldrawUiButtonIcon, { icon: "menu", small: true }) }) }), - /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Portal23, { container, children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Content25, { - className: "tlui-menu", - side: "bottom", - align: "start", - collisionPadding: 4, - alignOffset: 0, - sideOffset: 6, - children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(TldrawUiMenuContextProvider, { type: "menu", sourceId: "main-menu", children: content }) - }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs -var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1); -var React62 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/Minimap/getRgba.mjs -var memo15 = {}; -function getRgba(colorString) { - if (memo15[colorString]) { - return memo15[colorString]; - } - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - context.fillStyle = colorString; - context.fillRect(0, 0, 1, 1); - const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data; - const result = new Float32Array([r / 255, g / 255, b / 255, a / 255]); - memo15[colorString] = result; - return result; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Minimap/minimap-webgl-shapes.mjs -var numArcSegmentsPerCorner = 10; -var roundedRectangleDataSize = 4 * 6 * numArcSegmentsPerCorner + 12 + 4 * 12; -function pie(array2, { - center, - radius, - numArcSegments = 20, - startAngle = 0, - endAngle = PI2, - offset: offset4 = 0 -}) { - const angle = (endAngle - startAngle) / numArcSegments; - let i = offset4; - for (let a = startAngle; a < endAngle; a += angle) { - array2[i++] = center.x; - array2[i++] = center.y; - array2[i++] = center.x + Math.cos(a) * radius; - array2[i++] = center.y + Math.sin(a) * radius; - array2[i++] = center.x + Math.cos(a + angle) * radius; - array2[i++] = center.y + Math.sin(a + angle) * radius; - } - return array2; -} -function rectangle(array2, offset4, x, y, w, h) { - array2[offset4++] = x; - array2[offset4++] = y; - array2[offset4++] = x; - array2[offset4++] = y + h; - array2[offset4++] = x + w; - array2[offset4++] = y; - array2[offset4++] = x + w; - array2[offset4++] = y; - array2[offset4++] = x; - array2[offset4++] = y + h; - array2[offset4++] = x + w; - array2[offset4++] = y + h; -} -function roundedRectangle(data, box, radius) { - const numArcSegments = numArcSegmentsPerCorner; - radius = Math.min(radius, Math.min(box.w, box.h) / 2); - const innerBox = Box.ExpandBy(box, -radius); - if (innerBox.w <= 0 || innerBox.h <= 0) { - pie(data, { center: box.center, radius, numArcSegments: numArcSegmentsPerCorner * 4 }); - return numArcSegmentsPerCorner * 4 * 6; - } - let offset4 = 0; - rectangle(data, offset4, innerBox.minX, innerBox.minY, innerBox.w, innerBox.h); - offset4 += 12; - rectangle(data, offset4, innerBox.minX, box.minY, innerBox.w, radius); - offset4 += 12; - rectangle(data, offset4, innerBox.maxX, innerBox.minY, radius, innerBox.h); - offset4 += 12; - rectangle(data, offset4, innerBox.minX, innerBox.maxY, innerBox.w, radius); - offset4 += 12; - rectangle(data, offset4, box.minX, innerBox.minY, radius, innerBox.h); - offset4 += 12; - pie(data, { - numArcSegments, - offset: offset4, - center: innerBox.point, - radius, - startAngle: PI, - endAngle: PI * 1.5 - }); - offset4 += numArcSegments * 6; - pie(data, { - numArcSegments, - offset: offset4, - center: Vec.Add(innerBox.point, new Vec(innerBox.w, 0)), - radius, - startAngle: PI * 1.5, - endAngle: PI2 - }); - offset4 += numArcSegments * 6; - pie(data, { - numArcSegments, - offset: offset4, - center: Vec.Add(innerBox.point, innerBox.size), - radius, - startAngle: 0, - endAngle: HALF_PI - }); - offset4 += numArcSegments * 6; - pie(data, { - numArcSegments, - offset: offset4, - center: Vec.Add(innerBox.point, new Vec(0, innerBox.h)), - radius, - startAngle: HALF_PI, - endAngle: PI - }); - return roundedRectangleDataSize; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Minimap/minimap-webgl-setup.mjs -function setupWebGl(canvas) { - if (!canvas) - throw new Error("Canvas element not found"); - const context = canvas.getContext("webgl2", { - premultipliedAlpha: false - }); - if (!context) - throw new Error("Failed to get webgl2 context"); - const vertexShaderSourceCode = `#version 300 es - precision mediump float; - - in vec2 shapeVertexPosition; - - uniform vec4 canvasPageBounds; - - // taken (with thanks) from - // https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html - void main() { - // convert the position from pixels to 0.0 to 1.0 - vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw; - - // convert from 0->1 to 0->2 - vec2 zeroToTwo = zeroToOne * 2.0; - - // convert from 0->2 to -1->+1 (clipspace) - vec2 clipSpace = zeroToTwo - 1.0; - - gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); - }`; - const vertexShader = context.createShader(context.VERTEX_SHADER); - if (!vertexShader) { - throw new Error("Failed to create vertex shader"); - } - context.shaderSource(vertexShader, vertexShaderSourceCode); - context.compileShader(vertexShader); - if (!context.getShaderParameter(vertexShader, context.COMPILE_STATUS)) { - throw new Error("Failed to compile vertex shader"); - } - const fragmentShaderSourceCode = `#version 300 es - precision mediump float; - - uniform vec4 fillColor; - out vec4 outputColor; - - void main() { - outputColor = fillColor; - }`; - const fragmentShader = context.createShader(context.FRAGMENT_SHADER); - if (!fragmentShader) { - throw new Error("Failed to create fragment shader"); - } - context.shaderSource(fragmentShader, fragmentShaderSourceCode); - context.compileShader(fragmentShader); - if (!context.getShaderParameter(fragmentShader, context.COMPILE_STATUS)) { - throw new Error("Failed to compile fragment shader"); - } - const program = context.createProgram(); - if (!program) { - throw new Error("Failed to create program"); - } - context.attachShader(program, vertexShader); - context.attachShader(program, fragmentShader); - context.linkProgram(program); - if (!context.getProgramParameter(program, context.LINK_STATUS)) { - throw new Error("Failed to link program"); - } - context.useProgram(program); - const shapeVertexPositionAttributeLocation = context.getAttribLocation(program, "shapeVertexPosition"); - if (shapeVertexPositionAttributeLocation < 0) { - throw new Error("Failed to get shapeVertexPosition attribute location"); - } - context.enableVertexAttribArray(shapeVertexPositionAttributeLocation); - const canvasPageBoundsLocation = context.getUniformLocation(program, "canvasPageBounds"); - const fillColorLocation = context.getUniformLocation(program, "fillColor"); - const selectedShapesBuffer = context.createBuffer(); - if (!selectedShapesBuffer) - throw new Error("Failed to create buffer"); - const unselectedShapesBuffer = context.createBuffer(); - if (!unselectedShapesBuffer) - throw new Error("Failed to create buffer"); - return { - context, - selectedShapes: allocateBuffer(context, 1024), - unselectedShapes: allocateBuffer(context, 4096), - viewport: allocateBuffer(context, roundedRectangleDataSize), - collaborators: allocateBuffer(context, 1024), - prepareTriangles(stuff, len) { - context.bindBuffer(context.ARRAY_BUFFER, stuff.buffer); - context.bufferData(context.ARRAY_BUFFER, stuff.vertices, context.STATIC_DRAW, 0, len); - context.enableVertexAttribArray(shapeVertexPositionAttributeLocation); - context.vertexAttribPointer(shapeVertexPositionAttributeLocation, 2, context.FLOAT, false, 0, 0); - }, - drawTrianglesTransparently(len) { - context.enable(context.BLEND); - context.blendFunc(context.SRC_ALPHA, context.ONE_MINUS_SRC_ALPHA); - context.drawArrays(context.TRIANGLES, 0, len / 2); - context.disable(context.BLEND); - }, - drawTriangles(len) { - context.drawArrays(context.TRIANGLES, 0, len / 2); - }, - setFillColor(color) { - context.uniform4fv(fillColorLocation, color); - }, - setCanvasPageBounds(bounds) { - context.uniform4fv(canvasPageBoundsLocation, bounds); - } - }; -} -function allocateBuffer(context, size4) { - const buffer = context.createBuffer(); - if (!buffer) - throw new Error("Failed to create buffer"); - return { buffer, vertices: new Float32Array(size4) }; -} -function appendVertices(bufferStuff, offset4, data) { - let len = bufferStuff.vertices.length; - while (len < offset4 + data.length) { - len *= 2; - } - if (len != bufferStuff.vertices.length) { - const newVertices = new Float32Array(len); - newVertices.set(bufferStuff.vertices); - bufferStuff.vertices = newVertices; - } - bufferStuff.vertices.set(data, offset4); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs -var __defProp7 = Object.defineProperty; -var __getOwnPropDesc7 = Object.getOwnPropertyDescriptor; -var __decorateClass6 = (decorators, target, key, kind) => { - var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc7(target, key) : target; - for (var i = decorators.length - 1, decorator; i >= 0; i--) - if (decorator = decorators[i]) - result = (kind ? decorator(target, key, result) : decorator(result)) || result; - if (kind && result) - __defProp7(target, key, result); - return result; -}; -var MinimapManager = class { - constructor(editor, elem, container) { - __publicField(this, "disposables", []); - __publicField(this, "close", () => this.disposables.forEach((d) => d())); - __publicField(this, "gl"); - __publicField(this, "shapeGeometryCache"); - __publicField(this, "colors"); - __publicField(this, "id", uniqueId()); - __publicField(this, "canvasBoundingClientRect", atom("canvasBoundingClientRect", new Box())); - __publicField(this, "originPagePoint", new Vec()); - __publicField(this, "originPageCenter", new Vec()); - __publicField(this, "isInViewport", false); - __publicField(this, "getMinimapPagePoint", (clientX, clientY) => { - const canvasPageBounds = this.getCanvasPageBounds(); - const canvasScreenBounds = this.getCanvasScreenBounds(); - let x = clientX - canvasScreenBounds.x; - let y = clientY - canvasScreenBounds.y; - x *= canvasPageBounds.width / canvasScreenBounds.width; - y *= canvasPageBounds.height / canvasScreenBounds.height; - x += canvasPageBounds.minX; - y += canvasPageBounds.minY; - return new Vec(x, y, 1); - }); - __publicField(this, "minimapScreenPointToPagePoint", (x, y, shiftKey = false, clampToBounds = false) => { - const { editor } = this; - const vpPageBounds = editor.getViewportPageBounds(); - let { x: px, y: py } = this.getMinimapPagePoint(x, y); - if (clampToBounds) { - const shapesPageBounds = this.editor.getCurrentPageBounds() ?? new Box(); - const minX = shapesPageBounds.minX - vpPageBounds.width / 2; - const maxX = shapesPageBounds.maxX + vpPageBounds.width / 2; - const minY = shapesPageBounds.minY - vpPageBounds.height / 2; - const maxY = shapesPageBounds.maxY + vpPageBounds.height / 2; - const lx = Math.max(0, minX + vpPageBounds.width - px); - const rx = Math.max(0, -(maxX - vpPageBounds.width - px)); - const ly = Math.max(0, minY + vpPageBounds.height - py); - const ry = Math.max(0, -(maxY - vpPageBounds.height - py)); - px += (lx - rx) / 2; - py += (ly - ry) / 2; - px = clamp(px, minX, maxX); - py = clamp(py, minY, maxY); - } - if (shiftKey) { - const { originPagePoint } = this; - const dx = Math.abs(px - originPagePoint.x); - const dy = Math.abs(py - originPagePoint.y); - if (dx > dy) { - py = originPagePoint.y; - } else { - px = originPagePoint.x; - } - } - return new Vec(px, py); - }); - __publicField(this, "render", () => { - const context = this.gl.context; - const canvasSize2 = this.getCanvasSize(); - this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()); - this.elem.width = canvasSize2.x; - this.elem.height = canvasSize2.y; - context.viewport(0, 0, canvasSize2.x, canvasSize2.y); - context.clearColor(this.colors.background[0], this.colors.background[1], this.colors.background[2], 1); - context.clear(context.COLOR_BUFFER_BIT); - const selectedShapes = new Set(this.editor.getSelectedShapeIds()); - const colors = this.colors; - let selectedShapeOffset = 0; - let unselectedShapeOffset = 0; - const ids = this.editor.getCurrentPageShapeIdsSorted(); - for (let i = 0, len = ids.length; i < len; i++) { - const shapeId = ids[i]; - const geometry = this.shapeGeometryCache.get(shapeId); - if (!geometry) - continue; - const len2 = geometry.length; - if (selectedShapes.has(shapeId)) { - appendVertices(this.gl.selectedShapes, selectedShapeOffset, geometry); - selectedShapeOffset += len2; - } else { - appendVertices(this.gl.unselectedShapes, unselectedShapeOffset, geometry); - unselectedShapeOffset += len2; - } - } - this.drawShapes(this.gl.unselectedShapes, unselectedShapeOffset, colors.shapeFill); - this.drawShapes(this.gl.selectedShapes, selectedShapeOffset, colors.selectFill); - this.drawViewport(); - this.drawCollaborators(); - }); - this.editor = editor; - this.elem = elem; - this.container = container; - this.gl = setupWebGl(elem); - this.shapeGeometryCache = editor.store.createComputedCache("webgl-geometry", (r) => { - const bounds = editor.getShapeMaskedPageBounds(r.id); - if (!bounds) - return null; - const arr = new Float32Array(12); - rectangle(arr, 0, bounds.x, bounds.y, bounds.w, bounds.h); - return arr; - }); - this.colors = this._getColors(); - this.disposables.push(this._listenForCanvasResize(), react("minimap render", this.render)); - } - _getColors() { - const style = getComputedStyle(this.editor.getContainer()); - return { - shapeFill: getRgba(style.getPropertyValue("--color-text-3").trim()), - selectFill: getRgba(style.getPropertyValue("--color-selected").trim()), - viewportFill: getRgba(style.getPropertyValue("--color-muted-1").trim()), - background: getRgba(style.getPropertyValue("--color-low").trim()) - }; - } - updateColors() { - this.colors = this._getColors(); - } - getDpr() { - return this.editor.getInstanceState().devicePixelRatio; - } - getContentPageBounds() { - const viewportPageBounds = this.editor.getViewportPageBounds(); - const commonShapeBounds = this.editor.getCurrentPageBounds(); - return commonShapeBounds ? Box.Expand(commonShapeBounds, viewportPageBounds) : viewportPageBounds; - } - getContentScreenBounds() { - const contentPageBounds = this.getContentPageBounds(); - const topLeft = this.editor.pageToScreen(contentPageBounds.point); - const bottomRight = this.editor.pageToScreen(new Vec(contentPageBounds.maxX, contentPageBounds.maxY)); - return new Box(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); - } - _getCanvasBoundingRect() { - const { x, y, width, height } = this.elem.getBoundingClientRect(); - return new Box(x, y, width, height); - } - getCanvasScreenBounds() { - return this.canvasBoundingClientRect.get(); - } - _listenForCanvasResize() { - const observer = new ResizeObserver(() => { - const rect = this._getCanvasBoundingRect(); - this.canvasBoundingClientRect.set(rect); - }); - observer.observe(this.elem); - observer.observe(this.container); - return () => observer.disconnect(); - } - getCanvasSize() { - const rect = this.canvasBoundingClientRect.get(); - const dpr = this.getDpr(); - return new Vec(rect.width * dpr, rect.height * dpr); - } - getCanvasClientPosition() { - return this.canvasBoundingClientRect.get().point; - } - getCanvasPageBounds() { - const canvasScreenBounds = this.getCanvasScreenBounds(); - const contentPageBounds = this.getContentPageBounds(); - const aspectRatio = canvasScreenBounds.width / canvasScreenBounds.height; - let targetWidth = contentPageBounds.width; - let targetHeight = targetWidth / aspectRatio; - if (targetHeight < contentPageBounds.height) { - targetHeight = contentPageBounds.height; - targetWidth = targetHeight * aspectRatio; - } - const box = new Box(0, 0, targetWidth, targetHeight); - box.center = contentPageBounds.center; - return box; - } - getZoom() { - return this.getCanvasPageBounds().width / this.getCanvasScreenBounds().width; - } - getCanvasPageBoundsArray() { - const { x, y, w, h } = this.getCanvasPageBounds(); - return new Float32Array([x, y, w, h]); - } - drawShapes(stuff, len, color) { - this.gl.prepareTriangles(stuff, len); - this.gl.setFillColor(color); - this.gl.drawTriangles(len); - } - drawViewport() { - const viewport = this.editor.getViewportPageBounds(); - const len = roundedRectangle(this.gl.viewport.vertices, viewport, 4 * this.getZoom()); - this.gl.prepareTriangles(this.gl.viewport, len); - this.gl.setFillColor(this.colors.viewportFill); - this.gl.drawTrianglesTransparently(len); - if (this.editor.environment.isSafari) { - this.gl.drawTrianglesTransparently(len); - this.gl.drawTrianglesTransparently(len); - this.gl.drawTrianglesTransparently(len); - } - } - drawCollaborators() { - const collaborators = this.editor.getCollaboratorsOnCurrentPage(); - if (!collaborators.length) - return; - const numSegmentsPerCircle = 20; - const dataSizePerCircle = numSegmentsPerCircle * 6; - const totalSize = dataSizePerCircle * collaborators.length; - if (this.gl.collaborators.vertices.length < totalSize) { - this.gl.collaborators.vertices = new Float32Array(totalSize); - } - const vertices = this.gl.collaborators.vertices; - let offset4 = 0; - const zoom = this.getZoom(); - for (const { cursor } of collaborators) { - pie(vertices, { - center: Vec.From(cursor), - radius: 3 * zoom, - offset: offset4, - numArcSegments: numSegmentsPerCircle - }); - offset4 += dataSizePerCircle; - } - this.gl.prepareTriangles(this.gl.collaborators, totalSize); - offset4 = 0; - for (const { color } of collaborators) { - this.gl.setFillColor(getRgba(color)); - this.gl.context.drawArrays(this.gl.context.TRIANGLES, offset4 / 2, dataSizePerCircle / 2); - offset4 += dataSizePerCircle; - } - } -}; -__decorateClass6([ - computed -], MinimapManager.prototype, "getDpr", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getContentPageBounds", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getContentScreenBounds", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getCanvasSize", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getCanvasClientPosition", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getCanvasPageBounds", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getZoom", 1); -__decorateClass6([ - computed -], MinimapManager.prototype, "getCanvasPageBoundsArray", 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs -function DefaultMinimap() { - const editor = useEditor(); - const container = useContainer(); - const rCanvas = React62.useRef(null); - const rPointing = React62.useRef(false); - const minimapRef = React62.useRef(); - React62.useEffect(() => { - try { - const minimap = new MinimapManager(editor, rCanvas.current, container); - minimapRef.current = minimap; - return minimapRef.current.close; - } catch (e) { - editor.annotateError(e, { - origin: "minimap", - willCrashApp: false - }); - editor.timers.setTimeout(() => { - throw e; - }); - } - }, [editor, container]); - const onDoubleClick = React62.useCallback((e) => { - if (!editor.getCurrentPageShapeIds().size) - return; - if (!minimapRef.current) - return; - const point = minimapRef.current.minimapScreenPointToPagePoint(e.clientX, e.clientY, false, false); - const clampedPoint = minimapRef.current.minimapScreenPointToPagePoint(e.clientX, e.clientY, false, true); - minimapRef.current.originPagePoint.setTo(clampedPoint); - minimapRef.current.originPageCenter.setTo(editor.getViewportPageBounds().center); - editor.centerOnPoint(point, { animation: { duration: editor.options.animationMediumMs } }); - }, [editor]); - const onPointerDown = React62.useCallback((e) => { - if (!minimapRef.current) - return; - const elm = e.currentTarget; - setPointerCapture(elm, e); - if (!editor.getCurrentPageShapeIds().size) - return; - rPointing.current = true; - minimapRef.current.isInViewport = false; - const point = minimapRef.current.minimapScreenPointToPagePoint(e.clientX, e.clientY, false, false); - const _vpPageBounds = editor.getViewportPageBounds(); - const commonBounds = minimapRef.current.getContentPageBounds(); - const allowedBounds = new Box(commonBounds.x - _vpPageBounds.width / 2, commonBounds.y - _vpPageBounds.height / 2, commonBounds.width + _vpPageBounds.width, commonBounds.height + _vpPageBounds.height); - if (allowedBounds.containsPoint(point) && !_vpPageBounds.containsPoint(point)) { - minimapRef.current.isInViewport = _vpPageBounds.containsPoint(point); - const delta = Vec.Sub(_vpPageBounds.center, _vpPageBounds.point); - const pagePoint = Vec.Add(point, delta); - minimapRef.current.originPagePoint.setTo(pagePoint); - minimapRef.current.originPageCenter.setTo(point); - editor.centerOnPoint(point, { animation: { duration: editor.options.animationMediumMs } }); - } else { - const clampedPoint = minimapRef.current.minimapScreenPointToPagePoint(e.clientX, e.clientY, false, true); - minimapRef.current.isInViewport = _vpPageBounds.containsPoint(clampedPoint); - minimapRef.current.originPagePoint.setTo(clampedPoint); - minimapRef.current.originPageCenter.setTo(_vpPageBounds.center); - } - function release(e2) { - if (elm) { - releasePointerCapture(elm, e2); - } - rPointing.current = false; - document.body.removeEventListener("pointerup", release); - } - document.body.addEventListener("pointerup", release); - }, [editor]); - const onPointerMove = React62.useCallback((e) => { - if (!minimapRef.current) - return; - const point = minimapRef.current.minimapScreenPointToPagePoint(e.clientX, e.clientY, e.shiftKey, true); - if (rPointing.current) { - if (minimapRef.current.isInViewport) { - const delta = minimapRef.current.originPagePoint.clone().sub(minimapRef.current.originPageCenter); - editor.centerOnPoint(Vec.Sub(point, delta)); - return; - } - editor.centerOnPoint(point); - } - const pagePoint = minimapRef.current.getMinimapPagePoint(e.clientX, e.clientY); - const screenPoint = editor.pageToScreen(pagePoint); - const info2 = { - type: "pointer", - target: "canvas", - name: "pointer_move", - ...getPointerInfo(e), - point: screenPoint, - isPen: editor.getInstanceState().isPenMode - }; - editor.dispatch(info2); - }, [editor]); - const onWheel = React62.useCallback((e) => { - const offset4 = normalizeWheel(e); - editor.dispatch({ - type: "wheel", - name: "wheel", - delta: offset4, - point: new Vec(e.clientX, e.clientY), - shiftKey: e.shiftKey, - altKey: e.altKey, - ctrlKey: e.metaKey || e.ctrlKey - }); - }, [editor]); - const isDarkMode = useIsDarkMode(); - React62.useEffect(() => { - editor.timers.setTimeout(() => { - minimapRef.current?.updateColors(); - minimapRef.current?.render(); - }); - }, [isDarkMode, editor]); - return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { className: "tlui-minimap", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("canvas", { - role: "img", - "aria-label": "minimap", - ref: rCanvas, - className: "tlui-minimap__canvas", - onDoubleClick, - onPointerMove, - onPointerDown, - onWheel - }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs -var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1); -var import_react94 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useLocalStorageState.mjs -var import_react93 = __toESM(require_react(), 1); -function useLocalStorageState(key, defaultValue) { - const [state, setState] = import_react93.default.useState(defaultValue); - import_react93.default.useLayoutEffect(() => { - const value = getFromLocalStorage(key); - if (value) { - try { - setState(JSON.parse(value)); - } catch (e) { - console.error(`Could not restore value ${key} from local storage.`); - } - } - }, [key]); - const updateValue = import_react93.default.useCallback((setter) => { - setState((s) => { - const value = typeof setter === "function" ? setter(s) : setter; - setInLocalStorage(key, JSON.stringify(value)); - return value; - }); - }, [key]); - return [state, updateValue]; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs -var DefaultNavigationPanel = (0, import_react94.memo)(function DefaultNavigationPanel2() { - const actions = useActions(); - const msg2 = useTranslation(); - const breakpoint = useBreakpoint(); - const [collapsed, setCollapsed] = useLocalStorageState("minimap", true); - const toggleMinimap = (0, import_react94.useCallback)(() => { - setCollapsed((s) => !s); - }, [setCollapsed]); - const { ZoomMenu, Minimap } = useTldrawUiComponents(); - if (breakpoint < PORTRAIT_BREAKPOINT.MOBILE) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "tlui-navigation-panel", children: [ - /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { className: "tlui-buttons__horizontal", children: ZoomMenu && breakpoint < PORTRAIT_BREAKPOINT.TABLET ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ZoomMenu, {}) : collapsed ? /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { children: [ - ZoomMenu && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ZoomMenu, {}), - Minimap && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "minimap.toggle-button", - title: msg2("navigation-zone.toggle-minimap"), - className: "tlui-navigation-panel__toggle", - onClick: toggleMinimap, - children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButtonIcon, { icon: collapsed ? "chevrons-ne" : "chevrons-sw" }) - }) - ] }) : /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "minimap.zoom-out", - title: `${msg2(unwrapLabel(actions["zoom-out"].label))} ${kbdStr(actions["zoom-out"].kbd)}`, - onClick: () => actions["zoom-out"].onSelect("navigation-zone"), - children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButtonIcon, { icon: "minus" }) - }), - ZoomMenu && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ZoomMenu, {}), - /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "minimap.zoom-in", - title: `${msg2(unwrapLabel(actions["zoom-in"].label))} ${kbdStr(actions["zoom-in"].kbd)}`, - onClick: () => actions["zoom-in"].onSelect("navigation-zone"), - children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButtonIcon, { icon: "plus" }) - }), - Minimap && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "minimap.toggle-button", - title: msg2("navigation-zone.toggle-minimap"), - className: "tlui-navigation-panel__toggle", - onClick: toggleMinimap, - children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(TldrawUiButtonIcon, { icon: collapsed ? "chevrons-ne" : "chevrons-sw" }) - }) - ] }) }), - Minimap && breakpoint >= PORTRAIT_BREAKPOINT.TABLET && !collapsed && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Minimap, {}) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs -var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1); -var import_react97 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs -var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1); -var import_react95 = __toESM(require_react(), 1); -var PageItemInput = function PageItemInput2({ - name, - id, - isCurrentPage -}) { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const rInput = (0, import_react95.useRef)(null); - const handleFocus = (0, import_react95.useCallback)(() => { - editor.mark("rename page"); - }, [editor]); - const handleChange = (0, import_react95.useCallback)((value) => { - editor.renamePage(id, value || "New Page"); - trackEvent("rename-page", { source: "page-menu" }); - }, [editor, id, trackEvent]); - return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(TldrawUiInput, { - className: "tlui-page-menu__item__input", - ref: (el) => rInput.current = el, - defaultValue: name, - onValueChange: handleChange, - onFocus: handleFocus, - shouldManuallyMaintainScrollPositionWhenFocused: true, - autoFocus: isCurrentPage, - autoSelect: true - }); -}; - -// node_modules/tldraw/dist-esm/lib/ui/components/PageMenu/PageItemSubmenu.mjs -var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1); -var import_react96 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/PageMenu/edit-pages-shared.mjs -var onMovePage = (editor, id, from, to, trackEvent) => { - let index2; - const pages = editor.getPages(); - const below = from > to ? pages[to - 1] : pages[to]; - const above = from > to ? pages[to] : pages[to + 1]; - if (below && !above) { - index2 = getIndexAbove(below.index); - } else if (!below && above) { - index2 = getIndexBelow(pages[0].index); - } else { - index2 = getIndexBetween(below.index, above.index); - } - if (index2 !== pages[from].index) { - editor.mark("moving page"); - editor.updatePage({ - id, - index: index2 - }); - trackEvent("move-page", { source: "page-menu" }); - } -}; - -// node_modules/tldraw/dist-esm/lib/ui/components/PageMenu/PageItemSubmenu.mjs -var PageItemSubmenu = track(function PageItemSubmenu2({ - index: index2, - listSize, - item, - onRename -}) { - const editor = useEditor(); - const msg2 = useTranslation(); - const pages = editor.getPages(); - const trackEvent = useUiEvents(); - const onDuplicate = (0, import_react96.useCallback)(() => { - editor.mark("creating page"); - const newId = PageRecordType.createId(); - editor.duplicatePage(item.id, newId); - trackEvent("duplicate-page", { source: "page-menu" }); - }, [editor, item, trackEvent]); - const onMoveUp = (0, import_react96.useCallback)(() => { - onMovePage(editor, item.id, index2, index2 - 1, trackEvent); - }, [editor, item, index2, trackEvent]); - const onMoveDown = (0, import_react96.useCallback)(() => { - onMovePage(editor, item.id, index2, index2 + 1, trackEvent); - }, [editor, item, index2, trackEvent]); - const onDelete = (0, import_react96.useCallback)(() => { - editor.mark("deleting page"); - editor.deletePage(item.id); - trackEvent("delete-page", { source: "page-menu" }); - }, [editor, item, trackEvent]); - return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(TldrawUiDropdownMenuRoot, { id: `page item submenu ${index2}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiButton, { type: "icon", title: msg2("page-menu.submenu.title"), children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiButtonIcon, { icon: "dots-vertical" }) }) }), - /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiDropdownMenuContent, { alignOffset: 0, side: "right", sideOffset: -4, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(TldrawUiMenuContextProvider, { type: "menu", sourceId: "page-menu", children: [ - /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(TldrawUiMenuGroup, { id: "modify", children: [ - onRename && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiMenuItem, { id: "rename", label: "page-menu.submenu.rename", onSelect: onRename }), - /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiMenuItem, { - id: "duplicate", - label: "page-menu.submenu.duplicate-page", - onSelect: onDuplicate, - disabled: pages.length >= editor.options.maxPages - }), - index2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiMenuItem, { - id: "move-up", - onSelect: onMoveUp, - label: "page-menu.submenu.move-up" - }), - index2 < listSize - 1 && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiMenuItem, { - id: "move-down", - label: "page-menu.submenu.move-down", - onSelect: onMoveDown - }) - ] }), - listSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiMenuGroup, { id: "delete", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(TldrawUiMenuItem, { id: "delete", onSelect: onDelete, label: "page-menu.submenu.delete" }) }) - ] }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs -var DefaultPageMenu = (0, import_react97.memo)(function DefaultPageMenu2() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const msg2 = useTranslation(); - const breakpoint = useBreakpoint(); - const handleOpenChange = (0, import_react97.useCallback)(() => setIsEditing(false), []); - const [isOpen, onOpenChange] = useMenuIsOpen("page-menu", handleOpenChange); - const ITEM_HEIGHT = 36; - const rSortableContainer = (0, import_react97.useRef)(null); - const pages = useValue("pages", () => editor.getPages(), [editor]); - const currentPage = useValue("currentPage", () => editor.getCurrentPage(), [editor]); - const currentPageId = useValue("currentPageId", () => editor.getCurrentPageId(), [editor]); - const isReadonlyMode = useReadonly(); - const maxPageCountReached = useValue("maxPageCountReached", () => editor.getPages().length >= editor.options.maxPages, [editor]); - const isCoarsePointer = useValue("isCoarsePointer", () => editor.getInstanceState().isCoarsePointer, [editor]); - const [isEditing, setIsEditing] = (0, import_react97.useState)(false); - const toggleEditing = (0, import_react97.useCallback)(() => { - if (isReadonlyMode) - return; - setIsEditing((s) => !s); - }, [isReadonlyMode]); - const rMutables = (0, import_react97.useRef)({ - isPointing: false, - status: "idle", - pointing: null, - startY: 0, - startIndex: 0, - dragIndex: 0 - }); - const [sortablePositionItems, setSortablePositionItems] = (0, import_react97.useState)(Object.fromEntries(pages.map((page, i) => [page.id, { y: i * ITEM_HEIGHT, offsetY: 0, isSelected: false }]))); - (0, import_react97.useLayoutEffect)(() => { - setSortablePositionItems(Object.fromEntries(pages.map((page, i) => [page.id, { y: i * ITEM_HEIGHT, offsetY: 0, isSelected: false }]))); - }, [ITEM_HEIGHT, pages]); - (0, import_react97.useEffect)(() => { - if (!isOpen) - return; - editor.timers.requestAnimationFrame(() => { - const elm = document.querySelector(`[data-testid="page-menu-item-${currentPageId}"]`); - if (elm) { - const container = rSortableContainer.current; - if (!container) - return; - const elmTopPosition = elm.offsetTop; - const containerScrollTopPosition = container.scrollTop; - if (elmTopPosition < containerScrollTopPosition) { - container.scrollTo({ top: elmTopPosition }); - } - const elmBottomPosition = elmTopPosition + ITEM_HEIGHT; - const containerScrollBottomPosition = container.scrollTop + container.offsetHeight; - if (elmBottomPosition > containerScrollBottomPosition) { - container.scrollTo({ top: elmBottomPosition - container.offsetHeight }); - } - } - }); - }, [ITEM_HEIGHT, currentPageId, isOpen, editor]); - const handlePointerDown = (0, import_react97.useCallback)((e) => { - const { clientY, currentTarget } = e; - const { - dataset: { id, index: index2 } - } = currentTarget; - if (!id || !index2) - return; - const mut = rMutables.current; - setPointerCapture(e.currentTarget, e); - mut.status = "pointing"; - mut.pointing = { id, index: +index2 }; - const current = sortablePositionItems[id]; - const dragY = current.y; - mut.startY = clientY; - mut.startIndex = Math.max(0, Math.min(Math.round(dragY / ITEM_HEIGHT), pages.length - 1)); - }, [ITEM_HEIGHT, pages.length, sortablePositionItems]); - const handlePointerMove = (0, import_react97.useCallback)((e) => { - const mut = rMutables.current; - if (mut.status === "pointing") { - const { clientY } = e; - const offset4 = clientY - mut.startY; - if (Math.abs(offset4) > 5) { - mut.status = "dragging"; - } - } - if (mut.status === "dragging") { - const { clientY } = e; - const offsetY = clientY - mut.startY; - const current = sortablePositionItems[mut.pointing.id]; - const { startIndex, pointing } = mut; - const dragY = current.y + offsetY; - const dragIndex = Math.max(0, Math.min(Math.round(dragY / ITEM_HEIGHT), pages.length - 1)); - const next = { ...sortablePositionItems }; - next[pointing.id] = { - y: current.y, - offsetY, - isSelected: true - }; - if (dragIndex !== mut.dragIndex) { - mut.dragIndex = dragIndex; - for (let i = 0; i < pages.length; i++) { - const item = pages[i]; - if (item.id === mut.pointing.id) { - continue; - } - let { y } = next[item.id]; - if (dragIndex === startIndex) { - y = i * ITEM_HEIGHT; - } else if (dragIndex < startIndex) { - if (dragIndex <= i && i < startIndex) { - y = (i + 1) * ITEM_HEIGHT; - } else { - y = i * ITEM_HEIGHT; - } - } else if (dragIndex > startIndex) { - if (dragIndex >= i && i > startIndex) { - y = (i - 1) * ITEM_HEIGHT; - } else { - y = i * ITEM_HEIGHT; - } - } - if (y !== next[item.id].y) { - next[item.id] = { y, offsetY: 0, isSelected: true }; - } - } - } - setSortablePositionItems(next); - } - }, [ITEM_HEIGHT, pages, sortablePositionItems]); - const handlePointerUp = (0, import_react97.useCallback)((e) => { - const mut = rMutables.current; - if (mut.status === "dragging") { - const { id, index: index2 } = mut.pointing; - onMovePage(editor, id, index2, mut.dragIndex, trackEvent); - } - releasePointerCapture(e.currentTarget, e); - mut.status = "idle"; - }, [editor, trackEvent]); - const handleKeyDown = (0, import_react97.useCallback)((e) => { - const mut = rMutables.current; - if (e.key === "Escape") { - if (mut.status === "dragging") { - setSortablePositionItems(Object.fromEntries(pages.map((page, i) => [ - page.id, - { y: i * ITEM_HEIGHT, offsetY: 0, isSelected: false } - ]))); - } - mut.status = "idle"; - } - }, [ITEM_HEIGHT, pages]); - const handleCreatePageClick = (0, import_react97.useCallback)(() => { - if (isReadonlyMode) - return; - editor.run(() => { - editor.mark("creating page"); - const newPageId = PageRecordType.createId(); - editor.createPage({ name: msg2("page-menu.new-page-initial-name"), id: newPageId }); - editor.setCurrentPage(newPageId); - setIsEditing(true); - }); - trackEvent("new-page", { source: "page-menu" }); - }, [editor, msg2, isReadonlyMode, trackEvent]); - const changePage = (0, import_react97.useCallback)((id) => { - editor.setCurrentPage(id); - trackEvent("change-page", { source: "page-menu" }); - }, [editor, trackEvent]); - const renamePage = (0, import_react97.useCallback)((id, name) => { - editor.renamePage(id, name); - trackEvent("rename-page", { source: "page-menu" }); - }, [editor, trackEvent]); - return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(TldrawUiPopover, { id: "pages", onOpenChange, open: isOpen, children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiPopoverTrigger, { "data-testid": "main.page-menu", children: /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(TldrawUiButton, { - type: "menu", - title: currentPage.name, - "data-testid": "page-menu.button", - className: "tlui-page-menu__trigger", - children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "tlui-page-menu__name", children: currentPage.name }), - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonIcon, { icon: "chevron-down", small: true }) - ] - }) }), - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiPopoverContent, { side: "bottom", align: "start", sideOffset: 6, children: /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { className: "tlui-page-menu__wrapper", children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { className: "tlui-page-menu__header", children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "tlui-page-menu__header__title", children: msg2("page-menu.title") }), - !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { className: "tlui-buttons__horizontal", children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "page-menu.edit", - title: msg2(isEditing ? "page-menu.edit-done" : "page-menu.edit-start"), - onClick: toggleEditing, - children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonIcon, { icon: isEditing ? "check" : "edit" }) - }), - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": "page-menu.create", - title: msg2(maxPageCountReached ? "page-menu.max-page-count-reached" : "page-menu.create-new-page"), - disabled: maxPageCountReached, - onClick: handleCreatePageClick, - children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonIcon, { icon: "plus" }) - }) - ] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { - "data-testid": "page-menu.list", - className: "tlui-page-menu__list tlui-menu__group", - style: { height: ITEM_HEIGHT * pages.length + 4 }, - ref: rSortableContainer, - children: pages.map((page, index2) => { - const position = sortablePositionItems[page.id] ?? { - position: index2 * 40, - offsetY: 0 - }; - return isEditing ? /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { - "data-testid": "page-menu.item", - className: "tlui-page_menu__item__sortable", - style: { - zIndex: page.id === currentPage.id ? 888 : index2, - transform: `translate(0px, ${position.y + position.offsetY}px)` - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButton, { - type: "icon", - tabIndex: -1, - className: "tlui-page_menu__item__sortable__handle", - onPointerDown: handlePointerDown, - onPointerUp: handlePointerUp, - onPointerMove: handlePointerMove, - onKeyDown: handleKeyDown, - "data-id": page.id, - "data-index": index2, - children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonIcon, { icon: "drag-handle-dots" }) - }), - breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && isCoarsePointer ? /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(TldrawUiButton, { - type: "normal", - className: "tlui-page-menu__item__button", - onClick: () => { - const name = window.prompt("Rename page", page.name); - if (name && name !== page.name) { - renamePage(page.id, name); - } - }, - onDoubleClick: toggleEditing, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonCheck, { checked: page.id === currentPage.id }), - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonLabel, { children: page.name }) - ] - }) : /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { - className: "tlui-page_menu__item__sortable__title", - style: { height: ITEM_HEIGHT }, - children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(PageItemInput, { - id: page.id, - name: page.name, - isCurrentPage: page.id === currentPage.id - }) - }), - !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "tlui-page_menu__item__submenu", "data-isediting": isEditing, children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(PageItemSubmenu, { index: index2, item: page, listSize: pages.length }) }) - ] - }, page.id + "_editing") : /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { "data-testid": "page-menu.item", className: "tlui-page-menu__item", children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(TldrawUiButton, { - type: "normal", - className: "tlui-page-menu__item__button", - onClick: () => changePage(page.id), - onDoubleClick: toggleEditing, - title: msg2("page-menu.go-to-page"), - children: [ - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonCheck, { checked: page.id === currentPage.id }), - /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(TldrawUiButtonLabel, { children: page.name }) - ] - }), - !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "tlui-page_menu__item__submenu", children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(PageItemSubmenu, { - index: index2, - item: page, - listSize: pages.length, - onRename: () => { - if (editor.environment.isIos) { - const name = window.prompt("Rename page", page.name); - if (name && name !== page.name) { - renamePage(page.id, name); - } - } else { - setIsEditing(true); - if (currentPageId !== page.id) { - changePage(page.id); - } - } - } - }) }) - ] }, page.id); - }) - }) - ] }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/QuickActions/DefaultQuickActions.mjs -var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1); -var import_react98 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/QuickActions/DefaultQuickActionsContent.mjs -var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1); -function DefaultQuickActionsContent() { - const actions = useActions(); - const editor = useEditor(); - const canUndo = useCanUndo(); - const canRedo = useCanRedo(); - const oneSelected = useUnlockedSelectedShapesCount(1); - const isReadonlyMode = useReadonly(); - const isInAcceptableReadonlyState = useValue("should display quick actions", () => editor.isInAny("select", "hand", "zoom"), [editor]); - const isInSelectState = useIsInSelectState(); - const selectDependentActionsEnabled = oneSelected && isInSelectState; - if (isReadonlyMode && !isInAcceptableReadonlyState) - return; - return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(import_jsx_runtime138.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TldrawUiMenuItem, { ...actions["undo"], disabled: !canUndo }), - /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TldrawUiMenuItem, { ...actions["redo"], disabled: !canRedo }), - /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TldrawUiMenuItem, { ...actions["delete"], disabled: !selectDependentActionsEnabled }), - /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TldrawUiMenuItem, { ...actions["duplicate"], disabled: !selectDependentActionsEnabled }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/QuickActions/DefaultQuickActions.mjs -var DefaultQuickActions = (0, import_react98.memo)(function DefaultQuickActions2({ - children -}) { - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(DefaultQuickActionsContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(TldrawUiMenuContextProvider, { type: "small-icons", sourceId: "quick-actions", children: content }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/DefaultSharePanel.mjs -var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs -var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/PeopleMenuAvatar.mjs -var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1); -function PeopleMenuAvatar({ userId }) { - const presence = usePresence(userId); - if (!presence) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { - className: "tlui-people-menu__avatar", - style: { - backgroundColor: presence.color - }, - children: presence.userName === "New User" ? "" : presence.userName[0] ?? "" - }, userId); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs -var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1); -var import_react99 = __toESM(require_react(), 1); -var PeopleMenuItem = track(function PeopleMenuItem2({ userId }) { - const editor = useEditor(); - const msg2 = useTranslation(); - const trackEvent = useUiEvents(); - const presence = usePresence(userId); - const handleFollowClick = (0, import_react99.useCallback)(() => { - if (editor.getInstanceState().followingUserId === userId) { - editor.stopFollowingUser(); - trackEvent("stop-following", { source: "people-menu" }); - } else { - editor.startFollowingUser(userId); - trackEvent("start-following", { source: "people-menu" }); - } - }, [editor, userId, trackEvent]); - const theyAreFollowingYou = presence?.followingUserId === editor.user.getId(); - const youAreFollowingThem = editor.getInstanceState().followingUserId === userId; - if (!presence) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "tlui-people-menu__item tlui-buttons__horizontal", children: [ - /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(TldrawUiButton, { - type: "menu", - className: "tlui-people-menu__item__button", - onClick: () => editor.zoomToUser(userId), - onDoubleClick: handleFollowClick, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(TldrawUiIcon, { icon: "color", color: presence.color }), - /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("div", { className: "tlui-people-menu__name", children: presence.userName ?? "New User" }) - ] - }), - /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(TldrawUiButton, { - type: "icon", - className: "tlui-people-menu__item__follow", - title: theyAreFollowingYou ? msg2("people-menu.leading") : youAreFollowingThem ? msg2("people-menu.following") : msg2("people-menu.follow"), - onClick: handleFollowClick, - disabled: theyAreFollowingYou, - "data-active": youAreFollowingThem || theyAreFollowingYou, - children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(TldrawUiButtonIcon, { - icon: theyAreFollowingYou ? "leading" : youAreFollowingThem ? "following" : "follow" - }) - }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/PeopleMenuMore.mjs -var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1); -function PeopleMenuMore({ count: count3 }) { - return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("div", { className: "tlui-people-menu__more", children: "+" + Math.abs(count3) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/UserPresenceEditor.mjs -var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1); -var import_react101 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs -var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1); -var import_react100 = __toESM(require_react(), 1); -var UserPresenceColorPicker = track(function UserPresenceColorPicker2() { - const editor = useEditor(); - const container = useContainer(); - const msg2 = useTranslation(); - const trackEvent = useUiEvents(); - const rPointing = (0, import_react100.useRef)(false); - const [isOpen, setIsOpen] = (0, import_react100.useState)(false); - const handleOpenChange = (0, import_react100.useCallback)((isOpen2) => { - setIsOpen(isOpen2); - }, []); - const value = editor.user.getColor(); - const onValueChange = (0, import_react100.useCallback)((item) => { - editor.user.updateUserPreferences({ color: item }); - trackEvent("set-color", { source: "people-menu" }); - }, [editor, trackEvent]); - const { - handleButtonClick, - handleButtonPointerDown, - handleButtonPointerEnter, - handleButtonPointerUp - } = import_react100.default.useMemo(() => { - const handlePointerUp = () => { - rPointing.current = false; - window.removeEventListener("pointerup", handlePointerUp); - }; - const handleButtonClick2 = (e) => { - const { id } = e.currentTarget.dataset; - if (!id) - return; - if (value === id) - return; - onValueChange(id); - }; - const handleButtonPointerDown2 = (e) => { - const { id } = e.currentTarget.dataset; - if (!id) - return; - onValueChange(id); - rPointing.current = true; - window.addEventListener("pointerup", handlePointerUp); - }; - const handleButtonPointerEnter2 = (e) => { - if (!rPointing.current) - return; - const { id } = e.currentTarget.dataset; - if (!id) - return; - onValueChange(id); - }; - const handleButtonPointerUp2 = (e) => { - const { id } = e.currentTarget.dataset; - if (!id) - return; - onValueChange(id); - }; - return { - handleButtonClick: handleButtonClick2, - handleButtonPointerDown: handleButtonPointerDown2, - handleButtonPointerEnter: handleButtonPointerEnter2, - handleButtonPointerUp: handleButtonPointerUp2 - }; - }, [value, onValueChange]); - return /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(Root24, { onOpenChange: handleOpenChange, open: isOpen, children: [ - /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Trigger, { dir: "ltr", asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(TldrawUiButton, { - type: "icon", - className: "tlui-people-menu__user__color", - style: { color: editor.user.getColor() }, - title: msg2("people-menu.change-color"), - children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(TldrawUiButtonIcon, { icon: "color" }) - }) }), - /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Portal3, { container, children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Content22, { - dir: "ltr", - className: "tlui-menu tlui-people-menu__user__color-picker", - align: "start", - side: "left", - sideOffset: 8, - children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { className: "tlui-buttons__grid", children: USER_COLORS.map((item) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(TldrawUiButton, { - type: "icon", - "data-id": item, - "data-testid": item, - "aria-label": item, - "data-state": value === item ? "hinted" : void 0, - title: item, - className: "tlui-button-grid__button", - style: { color: item }, - onPointerEnter: handleButtonPointerEnter, - onPointerDown: handleButtonPointerDown, - onPointerUp: handleButtonPointerUp, - onClick: handleButtonClick, - children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(TldrawUiButtonIcon, { icon: "color" }) - }, item)) }) - }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/UserPresenceEditor.mjs -function UserPresenceEditor() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - const userName = useValue("userName", () => editor.user.getName(), []); - const msg2 = useTranslation(); - const rOriginalName = (0, import_react101.useRef)(userName); - const rCurrentName = (0, import_react101.useRef)(userName); - const [isEditingName, setIsEditingName] = (0, import_react101.useState)(false); - const toggleEditingName = (0, import_react101.useCallback)(() => { - setIsEditingName((s) => !s); - }, []); - const handleValueChange = (0, import_react101.useCallback)((value) => { - rCurrentName.current = value; - editor.user.updateUserPreferences({ name: value }); - }, [editor]); - const handleBlur = (0, import_react101.useCallback)(() => { - if (rOriginalName.current === rCurrentName.current) - return; - trackEvent("change-user-name", { source: "people-menu" }); - rOriginalName.current = rCurrentName.current; - }, [trackEvent]); - return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)("div", { className: "tlui-people-menu__user", children: [ - /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(UserPresenceColorPicker, {}), - isEditingName ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(TldrawUiInput, { - className: "tlui-people-menu__user__input", - defaultValue: userName, - onValueChange: handleValueChange, - onComplete: toggleEditingName, - onCancel: toggleEditingName, - onBlur: handleBlur, - shouldManuallyMaintainScrollPositionWhenFocused: true, - autoFocus: true, - autoSelect: true - }) : /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { - className: "tlui-people-menu__user__name", - onDoubleClick: () => { - if (!isEditingName) - setIsEditingName(true); - }, - children: userName - }), - userName === "New User" ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "tlui-people-menu__user__label", children: msg2("people-menu.user") }) : null - ] }), - /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(TldrawUiButton, { - type: "icon", - className: "tlui-people-menu__user__edit", - "data-testid": "people-menu.change-name", - title: msg2("people-menu.change-name"), - onClick: toggleEditingName, - children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(TldrawUiButtonIcon, { icon: isEditingName ? "check" : "edit" }) - }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs -var PeopleMenu = track(function PeopleMenu2({ children }) { - const msg2 = useTranslation(); - const container = useContainer(); - const editor = useEditor(); - const userIds = usePeerIds(); - const userColor = useValue("user", () => editor.user.getColor(), [editor]); - const userName = useValue("user", () => editor.user.getName(), [editor]); - const [isOpen, onOpenChange] = useMenuIsOpen("people menu"); - return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(Root24, { onOpenChange, open: isOpen, children: [ - /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Trigger, { dir: "ltr", asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)("button", { className: "tlui-people-menu__avatars-button", title: msg2("people-menu.title"), children: [ - userIds.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PeopleMenuMore, { count: userIds.length - 5 }), - /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)("div", { className: "tlui-people-menu__avatars", children: [ - userIds.slice(-5).map((userId) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PeopleMenuAvatar, { userId }, userId)), - /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { - className: "tlui-people-menu__avatar", - style: { - backgroundColor: userColor - }, - children: userName === "New User" ? "" : userName[0] ?? "" - }) - ] }) - ] }) }), - /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Portal3, { container, children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Content22, { - dir: "ltr", - className: "tlui-menu", - align: "end", - side: "bottom", - sideOffset: 2, - alignOffset: -5, - children: /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)("div", { className: "tlui-people-menu__wrapper", children: [ - /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { className: "tlui-people-menu__section", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(UserPresenceEditor, {}) }), - userIds.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { className: "tlui-people-menu__section", children: userIds.map((userId) => { - return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PeopleMenuItem, { userId }, userId + "_presence"); - }) }), - children - ] }) - }) }) - ] }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/SharePanel/DefaultSharePanel.mjs -function DefaultSharePanel() { - return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("div", { className: "tlui-share-zone", draggable: false, children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(PeopleMenu, {}) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs -var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1); -var import_classnames25 = __toESM(require_classnames(), 1); -var import_react105 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useRelevantStyles.mjs -var selectToolStyles = Object.freeze([ - DefaultColorStyle, - DefaultDashStyle, - DefaultFillStyle, - DefaultSizeStyle -]); -function useRelevantStyles(stylesToCheck = selectToolStyles) { - const editor = useEditor(); - return useValue("getRelevantStyles", () => { - const styles3 = new SharedStyleMap(editor.getSharedStyles()); - const isInShapeSpecificTool = !!editor.root.getCurrent()?.shapeType; - const hasShapesSelected = editor.isIn("select") && editor.getSelectedShapeIds().length > 0; - if (styles3.size === 0 && editor.isIn("select") && editor.getSelectedShapeIds().length === 0) { - for (const style of stylesToCheck) { - styles3.applyValue(style, editor.getStyleForNextShape(style)); - } - } - if (isInShapeSpecificTool || hasShapesSelected || styles3.size > 0) { - return styles3; - } - return null; - }, [editor]); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs -var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1); -var import_react104 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/styles.mjs -var STYLES = { - color: [ - { value: "black", icon: "color" }, - { value: "grey", icon: "color" }, - { value: "light-violet", icon: "color" }, - { value: "violet", icon: "color" }, - { value: "blue", icon: "color" }, - { value: "light-blue", icon: "color" }, - { value: "yellow", icon: "color" }, - { value: "orange", icon: "color" }, - { value: "green", icon: "color" }, - { value: "light-green", icon: "color" }, - { value: "light-red", icon: "color" }, - { value: "red", icon: "color" } - ], - fill: [ - { value: "none", icon: "fill-none" }, - { value: "semi", icon: "fill-semi" }, - { value: "solid", icon: "fill-solid" }, - { value: "pattern", icon: "fill-pattern" } - ], - dash: [ - { value: "draw", icon: "dash-draw" }, - { value: "dashed", icon: "dash-dashed" }, - { value: "dotted", icon: "dash-dotted" }, - { value: "solid", icon: "dash-solid" } - ], - size: [ - { value: "s", icon: "size-small" }, - { value: "m", icon: "size-medium" }, - { value: "l", icon: "size-large" }, - { value: "xl", icon: "size-extra-large" } - ], - font: [ - { value: "draw", icon: "font-draw" }, - { value: "sans", icon: "font-sans" }, - { value: "serif", icon: "font-serif" }, - { value: "mono", icon: "font-mono" } - ], - textAlign: [ - { value: "start", icon: "text-align-left" }, - { value: "middle", icon: "text-align-center" }, - { value: "end", icon: "text-align-right" } - ], - horizontalAlign: [ - { value: "start", icon: "horizontal-align-start" }, - { value: "middle", icon: "horizontal-align-middle" }, - { value: "end", icon: "horizontal-align-end" } - ], - verticalAlign: [ - { value: "start", icon: "vertical-align-start" }, - { value: "middle", icon: "vertical-align-middle" }, - { value: "end", icon: "vertical-align-end" } - ], - geo: [ - { value: "rectangle", icon: "geo-rectangle" }, - { value: "ellipse", icon: "geo-ellipse" }, - { value: "triangle", icon: "geo-triangle" }, - { value: "diamond", icon: "geo-diamond" }, - { value: "star", icon: "geo-star" }, - { value: "pentagon", icon: "geo-pentagon" }, - { value: "hexagon", icon: "geo-hexagon" }, - { value: "octagon", icon: "geo-octagon" }, - { value: "rhombus", icon: "geo-rhombus" }, - { value: "rhombus-2", icon: "geo-rhombus-2" }, - { value: "oval", icon: "geo-oval" }, - { value: "trapezoid", icon: "geo-trapezoid" }, - { value: "arrow-left", icon: "geo-arrow-left" }, - { value: "arrow-up", icon: "geo-arrow-up" }, - { value: "arrow-down", icon: "geo-arrow-down" }, - { value: "arrow-right", icon: "geo-arrow-right" }, - { value: "cloud", icon: "geo-cloud" }, - { value: "x-box", icon: "geo-x-box" }, - { value: "check-box", icon: "geo-check-box" }, - { value: "heart", icon: "geo-heart" } - ], - arrowheadStart: [ - { value: "none", icon: "arrowhead-none" }, - { value: "arrow", icon: "arrowhead-arrow" }, - { value: "triangle", icon: "arrowhead-triangle" }, - { value: "square", icon: "arrowhead-square" }, - { value: "dot", icon: "arrowhead-dot" }, - { value: "diamond", icon: "arrowhead-diamond" }, - { value: "inverted", icon: "arrowhead-triangle-inverted" }, - { value: "bar", icon: "arrowhead-bar" } - ], - arrowheadEnd: [ - { value: "none", icon: "arrowhead-none" }, - { value: "arrow", icon: "arrowhead-arrow" }, - { value: "triangle", icon: "arrowhead-triangle" }, - { value: "square", icon: "arrowhead-square" }, - { value: "dot", icon: "arrowhead-dot" }, - { value: "diamond", icon: "arrowhead-diamond" }, - { value: "inverted", icon: "arrowhead-triangle-inverted" }, - { value: "bar", icon: "arrowhead-bar" } - ], - spline: [ - { value: "line", icon: "spline-line" }, - { value: "cubic", icon: "spline-cubic" } - ] -}; - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs -var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1); -var import_classnames24 = __toESM(require_classnames(), 1); -var import_react102 = __toESM(require_react(), 1); -var TldrawUiButtonPicker = (0, import_react102.memo)(function TldrawUiButtonPicker2(props) { - const { - uiType, - items, - title, - style, - value, - onValueChange, - theme - } = props; - const editor = useEditor(); - const msg2 = useTranslation(); - const rPointing = (0, import_react102.useRef)(false); - const rPointingOriginalActiveElement = (0, import_react102.useRef)(null); - const { - handleButtonClick, - handleButtonPointerDown, - handleButtonPointerEnter, - handleButtonPointerUp - } = (0, import_react102.useMemo)(() => { - const handlePointerUp = () => { - rPointing.current = false; - window.removeEventListener("pointerup", handlePointerUp); - const origActiveEl = rPointingOriginalActiveElement.current; - if (origActiveEl && ["TEXTAREA", "INPUT"].includes(origActiveEl.nodeName)) { - origActiveEl.focus(); - } - rPointingOriginalActiveElement.current = null; - }; - const handleButtonClick2 = (e) => { - const { id } = e.currentTarget.dataset; - if (value.type === "shared" && value.value === id) - return; - editor.mark("point picker item"); - onValueChange(style, id); - }; - const handleButtonPointerDown2 = (e) => { - const { id } = e.currentTarget.dataset; - editor.mark("point picker item"); - onValueChange(style, id); - rPointing.current = true; - rPointingOriginalActiveElement.current = document.activeElement; - window.addEventListener("pointerup", handlePointerUp); - }; - const handleButtonPointerEnter2 = (e) => { - if (!rPointing.current) - return; - const { id } = e.currentTarget.dataset; - onValueChange(style, id); - }; - const handleButtonPointerUp2 = (e) => { - const { id } = e.currentTarget.dataset; - if (value.type === "shared" && value.value === id) - return; - onValueChange(style, id); - }; - return { - handleButtonClick: handleButtonClick2, - handleButtonPointerDown: handleButtonPointerDown2, - handleButtonPointerEnter: handleButtonPointerEnter2, - handleButtonPointerUp: handleButtonPointerUp2 - }; - }, [value, editor, onValueChange, style]); - return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { "data-testid": `style.${uiType}`, className: (0, import_classnames24.default)("tlui-buttons__grid"), children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(TldrawUiButton, { - type: "icon", - "data-id": item.value, - "data-testid": `style.${uiType}.${item.value}`, - "aria-label": item.value, - "data-state": value.type === "shared" && value.value === item.value ? "hinted" : void 0, - title: title + " \u2014 " + msg2(`${uiType}-style.${item.value}`), - className: (0, import_classnames24.default)("tlui-button-grid__button"), - style: style === DefaultColorStyle ? { color: theme[item.value].solid } : void 0, - onPointerEnter: handleButtonPointerEnter, - onPointerDown: handleButtonPointerDown, - onPointerUp: handleButtonPointerUp, - onClick: handleButtonClick, - children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(TldrawUiButtonIcon, { icon: item.icon }) - }, item.value)) }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs -var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1); - -// node_modules/@radix-ui/react-slider/dist/index.mjs -var React66 = __toESM(require_react(), 1); - -// node_modules/@radix-ui/react-slider/node_modules/@radix-ui/number/dist/index.mjs -function clamp3(value, [min3, max2]) { - return Math.min(max2, Math.max(min3, value)); -} - -// node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-previous/dist/index.mjs -var React65 = __toESM(require_react(), 1); -function usePrevious(value) { - const ref = React65.useRef({ value, previous: value }); - return React65.useMemo(() => { - if (ref.current.value !== value) { - ref.current.previous = ref.current.value; - ref.current.value = value; - } - return ref.current.previous; - }, [value]); -} - -// node_modules/@radix-ui/react-slider/dist/index.mjs -var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1); -"use client"; -var PAGE_KEYS = ["PageUp", "PageDown"]; -var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]; -var BACK_KEYS = { - "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"], - "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"], - "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"], - "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"] -}; -var SLIDER_NAME = "Slider"; -var [Collection4, useCollection4, createCollectionScope4] = createCollection(SLIDER_NAME); -var [createSliderContext, createSliderScope] = createContextScope(SLIDER_NAME, [ - createCollectionScope4 -]); -var [SliderProvider, useSliderContext] = createSliderContext(SLIDER_NAME); -var Slider = React66.forwardRef((props, forwardedRef) => { - const { - name, - min: min3 = 0, - max: max2 = 100, - step = 1, - orientation = "horizontal", - disabled = false, - minStepsBetweenThumbs = 0, - defaultValue = [min3], - value, - onValueChange = () => { - }, - onValueCommit = () => { - }, - inverted = false, - ...sliderProps - } = props; - const thumbRefs = React66.useRef(/* @__PURE__ */ new Set()); - const valueIndexToChangeRef = React66.useRef(0); - const isHorizontal = orientation === "horizontal"; - const SliderOrientation = isHorizontal ? SliderHorizontal : SliderVertical; - const [values = [], setValues] = useControllableState({ - prop: value, - defaultProp: defaultValue, - onChange: (value2) => { - const thumbs = [...thumbRefs.current]; - thumbs[valueIndexToChangeRef.current]?.focus(); - onValueChange(value2); - } - }); - const valuesBeforeSlideStartRef = React66.useRef(values); - function handleSlideStart(value2) { - const closestIndex = getClosestValueIndex(values, value2); - updateValues(value2, closestIndex); - } - function handleSlideMove(value2) { - updateValues(value2, valueIndexToChangeRef.current); - } - function handleSlideEnd() { - const prevValue = valuesBeforeSlideStartRef.current[valueIndexToChangeRef.current]; - const nextValue = values[valueIndexToChangeRef.current]; - const hasChanged = nextValue !== prevValue; - if (hasChanged) - onValueCommit(values); - } - function updateValues(value2, atIndex, { commit } = { commit: false }) { - const decimalCount = getDecimalCount(step); - const snapToStep = roundValue(Math.round((value2 - min3) / step) * step + min3, decimalCount); - const nextValue = clamp3(snapToStep, [min3, max2]); - setValues((prevValues = []) => { - const nextValues = getNextSortedValues(prevValues, nextValue, atIndex); - if (hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step)) { - valueIndexToChangeRef.current = nextValues.indexOf(nextValue); - const hasChanged = String(nextValues) !== String(prevValues); - if (hasChanged && commit) - onValueCommit(nextValues); - return hasChanged ? nextValues : prevValues; - } else { - return prevValues; - } - }); - } - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderProvider, { - scope: props.__scopeSlider, - name, - disabled, - min: min3, - max: max2, - valueIndexToChangeRef, - thumbs: thumbRefs.current, - values, - orientation, - children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Collection4.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Collection4.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderOrientation, { - "aria-disabled": disabled, - "data-disabled": disabled ? "" : void 0, - ...sliderProps, - ref: forwardedRef, - onPointerDown: composeEventHandlers(sliderProps.onPointerDown, () => { - if (!disabled) - valuesBeforeSlideStartRef.current = values; - }), - min: min3, - max: max2, - inverted, - onSlideStart: disabled ? void 0 : handleSlideStart, - onSlideMove: disabled ? void 0 : handleSlideMove, - onSlideEnd: disabled ? void 0 : handleSlideEnd, - onHomeKeyDown: () => !disabled && updateValues(min3, 0, { commit: true }), - onEndKeyDown: () => !disabled && updateValues(max2, values.length - 1, { commit: true }), - onStepKeyDown: ({ event, direction: stepDirection }) => { - if (!disabled) { - const isPageKey = PAGE_KEYS.includes(event.key); - const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.includes(event.key); - const multiplier = isSkipKey ? 10 : 1; - const atIndex = valueIndexToChangeRef.current; - const value2 = values[atIndex]; - const stepInDirection = step * multiplier * stepDirection; - updateValues(value2 + stepInDirection, atIndex, { commit: true }); - } - } - }) }) }) - }); -}); -Slider.displayName = SLIDER_NAME; -var [SliderOrientationProvider, useSliderOrientationContext] = createSliderContext(SLIDER_NAME, { - startEdge: "left", - endEdge: "right", - size: "width", - direction: 1 -}); -var SliderHorizontal = React66.forwardRef((props, forwardedRef) => { - const { - min: min3, - max: max2, - dir, - inverted, - onSlideStart, - onSlideMove, - onSlideEnd, - onStepKeyDown, - ...sliderProps - } = props; - const [slider, setSlider] = React66.useState(null); - const composedRefs = useComposedRefs(forwardedRef, (node) => setSlider(node)); - const rectRef = React66.useRef(); - const direction = useDirection(dir); - const isDirectionLTR = direction === "ltr"; - const isSlidingFromLeft = isDirectionLTR && !inverted || !isDirectionLTR && inverted; - function getValueFromPointer(pointerPosition) { - const rect = rectRef.current || slider.getBoundingClientRect(); - const input = [0, rect.width]; - const output = isSlidingFromLeft ? [min3, max2] : [max2, min3]; - const value = linearScale(input, output); - rectRef.current = rect; - return value(pointerPosition - rect.left); - } - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderOrientationProvider, { - scope: props.__scopeSlider, - startEdge: isSlidingFromLeft ? "left" : "right", - endEdge: isSlidingFromLeft ? "right" : "left", - direction: isSlidingFromLeft ? 1 : -1, - size: "width", - children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderImpl, { - dir: direction, - "data-orientation": "horizontal", - ...sliderProps, - ref: composedRefs, - style: { - ...sliderProps.style, - ["--radix-slider-thumb-transform"]: "translateX(-50%)" - }, - onSlideStart: (event) => { - const value = getValueFromPointer(event.clientX); - onSlideStart?.(value); - }, - onSlideMove: (event) => { - const value = getValueFromPointer(event.clientX); - onSlideMove?.(value); - }, - onSlideEnd: () => { - rectRef.current = void 0; - onSlideEnd?.(); - }, - onStepKeyDown: (event) => { - const slideDirection = isSlidingFromLeft ? "from-left" : "from-right"; - const isBackKey = BACK_KEYS[slideDirection].includes(event.key); - onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 }); - } - }) - }); -}); -var SliderVertical = React66.forwardRef((props, forwardedRef) => { - const { - min: min3, - max: max2, - inverted, - onSlideStart, - onSlideMove, - onSlideEnd, - onStepKeyDown, - ...sliderProps - } = props; - const sliderRef = React66.useRef(null); - const ref = useComposedRefs(forwardedRef, sliderRef); - const rectRef = React66.useRef(); - const isSlidingFromBottom = !inverted; - function getValueFromPointer(pointerPosition) { - const rect = rectRef.current || sliderRef.current.getBoundingClientRect(); - const input = [0, rect.height]; - const output = isSlidingFromBottom ? [max2, min3] : [min3, max2]; - const value = linearScale(input, output); - rectRef.current = rect; - return value(pointerPosition - rect.top); - } - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderOrientationProvider, { - scope: props.__scopeSlider, - startEdge: isSlidingFromBottom ? "bottom" : "top", - endEdge: isSlidingFromBottom ? "top" : "bottom", - size: "height", - direction: isSlidingFromBottom ? 1 : -1, - children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderImpl, { - "data-orientation": "vertical", - ...sliderProps, - ref, - style: { - ...sliderProps.style, - ["--radix-slider-thumb-transform"]: "translateY(50%)" - }, - onSlideStart: (event) => { - const value = getValueFromPointer(event.clientY); - onSlideStart?.(value); - }, - onSlideMove: (event) => { - const value = getValueFromPointer(event.clientY); - onSlideMove?.(value); - }, - onSlideEnd: () => { - rectRef.current = void 0; - onSlideEnd?.(); - }, - onStepKeyDown: (event) => { - const slideDirection = isSlidingFromBottom ? "from-bottom" : "from-top"; - const isBackKey = BACK_KEYS[slideDirection].includes(event.key); - onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 }); - } - }) - }); -}); -var SliderImpl = React66.forwardRef((props, forwardedRef) => { - const { - __scopeSlider, - onSlideStart, - onSlideMove, - onSlideEnd, - onHomeKeyDown, - onEndKeyDown, - onStepKeyDown, - ...sliderProps - } = props; - const context = useSliderContext(SLIDER_NAME, __scopeSlider); - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Primitive.span, { - ...sliderProps, - ref: forwardedRef, - onKeyDown: composeEventHandlers(props.onKeyDown, (event) => { - if (event.key === "Home") { - onHomeKeyDown(event); - event.preventDefault(); - } else if (event.key === "End") { - onEndKeyDown(event); - event.preventDefault(); - } else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) { - onStepKeyDown(event); - event.preventDefault(); - } - }), - onPointerDown: composeEventHandlers(props.onPointerDown, (event) => { - const target = event.target; - target.setPointerCapture(event.pointerId); - event.preventDefault(); - if (context.thumbs.has(target)) { - target.focus(); - } else { - onSlideStart(event); - } - }), - onPointerMove: composeEventHandlers(props.onPointerMove, (event) => { - const target = event.target; - if (target.hasPointerCapture(event.pointerId)) - onSlideMove(event); - }), - onPointerUp: composeEventHandlers(props.onPointerUp, (event) => { - const target = event.target; - if (target.hasPointerCapture(event.pointerId)) { - target.releasePointerCapture(event.pointerId); - onSlideEnd(event); - } - }) - }); -}); -var TRACK_NAME = "SliderTrack"; -var SliderTrack = React66.forwardRef((props, forwardedRef) => { - const { __scopeSlider, ...trackProps } = props; - const context = useSliderContext(TRACK_NAME, __scopeSlider); - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Primitive.span, { - "data-disabled": context.disabled ? "" : void 0, - "data-orientation": context.orientation, - ...trackProps, - ref: forwardedRef - }); -}); -SliderTrack.displayName = TRACK_NAME; -var RANGE_NAME = "SliderRange"; -var SliderRange = React66.forwardRef((props, forwardedRef) => { - const { __scopeSlider, ...rangeProps } = props; - const context = useSliderContext(RANGE_NAME, __scopeSlider); - const orientation = useSliderOrientationContext(RANGE_NAME, __scopeSlider); - const ref = React66.useRef(null); - const composedRefs = useComposedRefs(forwardedRef, ref); - const valuesCount = context.values.length; - const percentages = context.values.map((value) => convertValueToPercentage(value, context.min, context.max)); - const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0; - const offsetEnd = 100 - Math.max(...percentages); - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Primitive.span, { - "data-orientation": context.orientation, - "data-disabled": context.disabled ? "" : void 0, - ...rangeProps, - ref: composedRefs, - style: { - ...props.style, - [orientation.startEdge]: offsetStart + "%", - [orientation.endEdge]: offsetEnd + "%" - } - }); -}); -SliderRange.displayName = RANGE_NAME; -var THUMB_NAME = "SliderThumb"; -var SliderThumb = React66.forwardRef((props, forwardedRef) => { - const getItems = useCollection4(props.__scopeSlider); - const [thumb, setThumb] = React66.useState(null); - const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node)); - const index2 = React66.useMemo(() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1, [getItems, thumb]); - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(SliderThumbImpl, { ...props, ref: composedRefs, index: index2 }); -}); -var SliderThumbImpl = React66.forwardRef((props, forwardedRef) => { - const { __scopeSlider, index: index2, name, ...thumbProps } = props; - const context = useSliderContext(THUMB_NAME, __scopeSlider); - const orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider); - const [thumb, setThumb] = React66.useState(null); - const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node)); - const isFormControl = thumb ? Boolean(thumb.closest("form")) : true; - const size4 = useSize(thumb); - const value = context.values[index2]; - const percent = value === void 0 ? 0 : convertValueToPercentage(value, context.min, context.max); - const label = getLabel(index2, context.values.length); - const orientationSize = size4?.[orientation.size]; - const thumbInBoundsOffset = orientationSize ? getThumbInBoundsOffset(orientationSize, percent, orientation.direction) : 0; - React66.useEffect(() => { - if (thumb) { - context.thumbs.add(thumb); - return () => { - context.thumbs.delete(thumb); - }; - } - }, [thumb, context.thumbs]); - return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("span", { - style: { - transform: "var(--radix-slider-thumb-transform)", - position: "absolute", - [orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)` - }, - children: [ - /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Collection4.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Primitive.span, { - role: "slider", - "aria-label": props["aria-label"] || label, - "aria-valuemin": context.min, - "aria-valuenow": value, - "aria-valuemax": context.max, - "aria-orientation": context.orientation, - "data-orientation": context.orientation, - "data-disabled": context.disabled ? "" : void 0, - tabIndex: context.disabled ? void 0 : 0, - ...thumbProps, - ref: composedRefs, - style: value === void 0 ? { display: "none" } : props.style, - onFocus: composeEventHandlers(props.onFocus, () => { - context.valueIndexToChangeRef.current = index2; - }) - }) }), - isFormControl && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(BubbleInput, { - name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0), - value - }, index2) - ] - }); -}); -SliderThumb.displayName = THUMB_NAME; -var BubbleInput = (props) => { - const { value, ...inputProps } = props; - const ref = React66.useRef(null); - const prevValue = usePrevious(value); - React66.useEffect(() => { - const input = ref.current; - const inputProto = window.HTMLInputElement.prototype; - const descriptor = Object.getOwnPropertyDescriptor(inputProto, "value"); - const setValue = descriptor.set; - if (prevValue !== value && setValue) { - const event = new Event("input", { bubbles: true }); - setValue.call(input, value); - input.dispatchEvent(event); - } - }, [prevValue, value]); - return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("input", { style: { display: "none" }, ...inputProps, ref, defaultValue: value }); -}; -function getNextSortedValues(prevValues = [], nextValue, atIndex) { - const nextValues = [...prevValues]; - nextValues[atIndex] = nextValue; - return nextValues.sort((a, b) => a - b); -} -function convertValueToPercentage(value, min3, max2) { - const maxSteps = max2 - min3; - const percentPerStep = 100 / maxSteps; - const percentage = percentPerStep * (value - min3); - return clamp3(percentage, [0, 100]); -} -function getLabel(index2, totalValues) { - if (totalValues > 2) { - return `Value ${index2 + 1} of ${totalValues}`; - } else if (totalValues === 2) { - return ["Minimum", "Maximum"][index2]; - } else { - return void 0; - } -} -function getClosestValueIndex(values, nextValue) { - if (values.length === 1) - return 0; - const distances = values.map((value) => Math.abs(value - nextValue)); - const closestDistance = Math.min(...distances); - return distances.indexOf(closestDistance); -} -function getThumbInBoundsOffset(width, left, direction) { - const halfWidth = width / 2; - const halfPercent = 50; - const offset4 = linearScale([0, halfPercent], [0, halfWidth]); - return (halfWidth - offset4(left) * direction) * direction; -} -function getStepsBetweenValues(values) { - return values.slice(0, -1).map((value, index2) => values[index2 + 1] - value); -} -function hasMinStepsBetweenValues(values, minStepsBetweenValues) { - if (minStepsBetweenValues > 0) { - const stepsBetweenValues = getStepsBetweenValues(values); - const actualMinStepsBetweenValues = Math.min(...stepsBetweenValues); - return actualMinStepsBetweenValues >= minStepsBetweenValues; - } - return true; -} -function linearScale(input, output) { - return (value) => { - if (input[0] === input[1] || output[0] === output[1]) - return output[0]; - const ratio = (output[1] - output[0]) / (input[1] - input[0]); - return output[0] + ratio * (value - input[0]); - }; -} -function getDecimalCount(value) { - return (String(value).split(".")[1] || "").length; -} -function roundValue(value, decimalCount) { - const rounder = Math.pow(10, decimalCount); - return Math.round(value * rounder) / rounder; -} -var Root5 = Slider; -var Track = SliderTrack; -var Range2 = SliderRange; -var Thumb = SliderThumb; - -// node_modules/tldraw/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs -var import_react103 = __toESM(require_react(), 1); -var TldrawUiSlider = (0, import_react103.memo)(function Slider2(props) { - const { title, steps, value, label, onValueChange } = props; - const editor = useEditor(); - const msg2 = useTranslation(); - const handleValueChange = (0, import_react103.useCallback)((value2) => { - onValueChange(value2[0]); - }, [onValueChange]); - const handlePointerDown = (0, import_react103.useCallback)(() => { - editor.mark("click slider"); - }, [editor]); - const handlePointerUp = (0, import_react103.useCallback)(() => { - if (!value) - return; - onValueChange(value); - }, [value, onValueChange]); - return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("div", { className: "tlui-slider__container", children: /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(Root5, { - "data-testid": props["data-testid"], - className: "tlui-slider", - "area-label": "Opacity", - dir: "ltr", - min: 0, - max: steps, - step: 1, - value: value ? [value] : void 0, - onPointerDown: handlePointerDown, - onValueChange: handleValueChange, - onPointerUp: handlePointerUp, - title: title + " \u2014 " + msg2(label), - children: [ - /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(Track, { className: "tlui-slider__track", dir: "ltr", children: value !== null && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(Range2, { className: "tlui-slider__range", dir: "ltr" }) }), - value !== null && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(Thumb, { className: "tlui-slider__thumb", dir: "ltr" }) - ] - }) }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs -var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1); -var React67 = __toESM(require_react(), 1); -function _DoubleDropdownPicker({ - label, - uiTypeA, - uiTypeB, - labelA, - labelB, - itemsA, - itemsB, - styleA, - styleB, - valueA, - valueB, - onValueChange -}) { - const msg2 = useTranslation(); - const iconA = React67.useMemo(() => itemsA.find((item) => valueA.type === "shared" && valueA.value === item.value)?.icon ?? "mixed", [itemsA, valueA]); - const iconB = React67.useMemo(() => itemsB.find((item) => valueB.type === "shared" && valueB.value === item.value)?.icon ?? "mixed", [itemsB, valueB]); - if (valueA === void 0 && valueB === void 0) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)("div", { className: "tlui-style-panel__double-select-picker", children: [ - /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("div", { title: msg2(label), className: "tlui-style-panel__double-select-picker-label", children: msg2(label) }), - /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)("div", { className: "tlui-buttons__horizontal", children: [ - /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(TldrawUiDropdownMenuRoot, { id: `style panel ${uiTypeA} A`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": `style.${uiTypeA}`, - title: msg2(labelA) + " \u2014 " + (valueA === null || valueA.type === "mixed" ? msg2("style-panel.mixed") : msg2(`${uiTypeA}-style.${valueA.value}`)), - children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButtonIcon, { icon: iconA, small: true, invertIcon: true }) - }) }), - /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiDropdownMenuContent, { side: "left", align: "center", sideOffset: 80, alignOffset: 0, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("div", { className: "tlui-buttons__grid", children: itemsA.map((item, i) => { - return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiDropdownMenuItem, { "data-testid": `style.${uiTypeA}.${item.value}`, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButton, { - type: "icon", - onClick: () => onValueChange(styleA, item.value), - title: `${msg2(labelA)} \u2014 ${msg2(`${uiTypeA}-style.${item.value}`)}`, - children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButtonIcon, { icon: item.icon, invertIcon: true }) - }, item.value) }, i); - }) }) }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(TldrawUiDropdownMenuRoot, { id: `style panel ${uiTypeB}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": `style.${uiTypeB}`, - title: msg2(labelB) + " \u2014 " + (valueB === null || valueB.type === "mixed" ? msg2("style-panel.mixed") : msg2(`${uiTypeB}-style.${valueB.value}`)), - children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButtonIcon, { icon: iconB, small: true }) - }) }), - /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiDropdownMenuContent, { side: "left", align: "center", sideOffset: 116, alignOffset: 0, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("div", { className: "tlui-buttons__grid", children: itemsB.map((item) => { - return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiDropdownMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButton, { - type: "icon", - title: `${msg2(labelB)} \u2014 ${msg2(`${uiTypeB}-style.${item.value}`)}`, - "data-testid": `style.${uiTypeB}.${item.value}`, - onClick: () => onValueChange(styleB, item.value), - children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(TldrawUiButtonIcon, { icon: item.icon }) - }) }, item.value); - }) }) }) - ] }) - ] }) - ] }); -} -var DoubleDropdownPicker = React67.memo(_DoubleDropdownPicker); - -// node_modules/tldraw/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs -var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1); -var React68 = __toESM(require_react(), 1); -function _DropdownPicker({ - id, - label, - uiType, - style, - items, - type, - value, - onValueChange -}) { - const msg2 = useTranslation(); - const editor = useEditor(); - const icon = React68.useMemo(() => items.find((item) => value.type === "shared" && item.value === value.value)?.icon, [items, value]); - const titleStr = value.type === "mixed" ? msg2("style-panel.mixed") : msg2(`${uiType}-style.${value.value}`); - const labelStr = label ? msg2(label) : ""; - return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(TldrawUiDropdownMenuRoot, { id: `style panel ${id}`, children: [ - /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(TldrawUiButton, { type, "data-testid": `style.${uiType}`, title: titleStr, children: [ - /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiButtonLabel, { children: labelStr }), - /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiButtonIcon, { icon: icon ?? "mixed" }) - ] }) }), - /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiDropdownMenuContent, { side: "left", align: "center", alignOffset: 0, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "tlui-buttons__grid", children: items.map((item) => { - return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiDropdownMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiButton, { - type: "icon", - "data-testid": `style.${uiType}.${item.value}`, - title: msg2(`${uiType}-style.${item.value}`), - onClick: () => { - editor.mark("select style dropdown item"); - onValueChange(style, item.value); - }, - children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(TldrawUiButtonIcon, { icon: item.icon }) - }) }, item.value); - }) }) }) - ] }); -} -var DropdownPicker = React68.memo(_DropdownPicker); - -// node_modules/tldraw/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs -function DefaultStylePanelContent({ styles: styles3 }) { - const isDarkMode = useIsDarkMode(); - if (!styles3) - return null; - const geo = styles3.get(GeoShapeGeoStyle); - const arrowheadEnd = styles3.get(ArrowShapeArrowheadEndStyle); - const arrowheadStart = styles3.get(ArrowShapeArrowheadStartStyle); - const spline = styles3.get(LineShapeSplineStyle); - const font = styles3.get(DefaultFontStyle); - const hideGeo = geo === void 0; - const hideArrowHeads = arrowheadEnd === void 0 && arrowheadStart === void 0; - const hideSpline = spline === void 0; - const hideText = font === void 0; - const theme = getDefaultColorTheme({ isDarkMode }); - return /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_jsx_runtime152.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(CommonStylePickerSet, { theme, styles: styles3 }), - !hideText && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TextStylePickerSet, { theme, styles: styles3 }), - !(hideGeo && hideArrowHeads && hideSpline) && /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("div", { className: "tlui-style-panel__section", "aria-label": "style panel styles", children: [ - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(GeoStylePickerSet, { styles: styles3 }), - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(ArrowheadStylePickerSet, { styles: styles3 }), - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(SplineStylePickerSet, { styles: styles3 }) - ] }) - ] }); -} -function useStyleChangeCallback() { - const editor = useEditor(); - const trackEvent = useUiEvents(); - return import_react104.default.useMemo(() => function handleStyleChange(style, value) { - editor.run(() => { - if (editor.isIn("select")) { - editor.setStyleForSelectedShapes(style, value); - } - editor.setStyleForNextShapes(style, value); - editor.updateInstanceState({ isChangingStyle: true }); - }); - trackEvent("set-style", { source: "style-panel", id: style.id, value }); - }, [editor, trackEvent]); -} -function CommonStylePickerSet({ styles: styles3, theme }) { - const msg2 = useTranslation(); - const editor = useEditor(); - const handleValueChange = useStyleChangeCallback(); - const color = styles3.get(DefaultColorStyle); - const fill = styles3.get(DefaultFillStyle); - const dash = styles3.get(DefaultDashStyle); - const size4 = styles3.get(DefaultSizeStyle); - const showPickers = fill !== void 0 || dash !== void 0 || size4 !== void 0; - return /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_jsx_runtime152.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("div", { - tabIndex: -1, - className: "tlui-style-panel__section__common", - "aria-label": "style panel styles", - "data-testid": "style.panel", - children: [ - color === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.color"), - uiType: "color", - style: DefaultColorStyle, - items: STYLES.color, - value: color, - onValueChange: handleValueChange, - theme - }), - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(OpacitySlider, {}) - ] - }), - showPickers && /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("div", { className: "tlui-style-panel__section", "aria-label": "style panel styles", children: [ - fill === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.fill"), - uiType: "fill", - style: DefaultFillStyle, - items: STYLES.fill, - value: fill, - onValueChange: handleValueChange, - theme - }), - dash === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.dash"), - uiType: "dash", - style: DefaultDashStyle, - items: STYLES.dash, - value: dash, - onValueChange: handleValueChange, - theme - }), - size4 === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.size"), - uiType: "size", - style: DefaultSizeStyle, - items: STYLES.size, - value: size4, - onValueChange: (style, value) => { - handleValueChange(style, value); - const selectedShapeIds = editor.getSelectedShapeIds(); - if (selectedShapeIds.length > 0) { - kickoutOccludedShapes(editor, selectedShapeIds); - } - }, - theme - }) - ] }) - ] }); -} -function TextStylePickerSet({ theme, styles: styles3 }) { - const msg2 = useTranslation(); - const handleValueChange = useStyleChangeCallback(); - const font = styles3.get(DefaultFontStyle); - const textAlign = styles3.get(DefaultTextAlignStyle); - const labelAlign = styles3.get(DefaultHorizontalAlignStyle); - const verticalLabelAlign = styles3.get(DefaultVerticalAlignStyle); - if (font === void 0 && labelAlign === void 0) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("div", { className: "tlui-style-panel__section", "aria-label": "style panel text", children: [ - font === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.font"), - uiType: "font", - style: DefaultFontStyle, - items: STYLES.font, - value: font, - onValueChange: handleValueChange, - theme - }), - textAlign === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("div", { className: "tlui-style-panel__row", children: [ - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.align"), - uiType: "align", - style: DefaultTextAlignStyle, - items: STYLES.textAlign, - value: textAlign, - onValueChange: handleValueChange, - theme - }), - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { className: "tlui-style-panel__row__extra-button", children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButton, { - type: "icon", - title: msg2("style-panel.vertical-align"), - "data-testid": "vertical-align", - disabled: true, - children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonIcon, { icon: "vertical-align-middle" }) - }) }) - ] }), - labelAlign === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("div", { className: "tlui-style-panel__row", children: [ - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonPicker, { - title: msg2("style-panel.align"), - uiType: "align", - style: DefaultHorizontalAlignStyle, - items: STYLES.horizontalAlign, - value: labelAlign, - onValueChange: handleValueChange, - theme - }), - /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { className: "tlui-style-panel__row__extra-button", children: verticalLabelAlign === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButton, { - type: "icon", - title: msg2("style-panel.vertical-align"), - "data-testid": "vertical-align", - disabled: true, - children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiButtonIcon, { icon: "vertical-align-middle" }) - }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(DropdownPicker, { - type: "icon", - id: "geo-vertical-alignment", - uiType: "verticalAlign", - style: DefaultVerticalAlignStyle, - items: STYLES.verticalAlign, - value: verticalLabelAlign, - onValueChange: handleValueChange - }) }) - ] }) - ] }); -} -function GeoStylePickerSet({ styles: styles3 }) { - const handleValueChange = useStyleChangeCallback(); - const geo = styles3.get(GeoShapeGeoStyle); - if (geo === void 0) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(DropdownPicker, { - id: "geo", - type: "menu", - label: "style-panel.geo", - uiType: "geo", - style: GeoShapeGeoStyle, - items: STYLES.geo, - value: geo, - onValueChange: handleValueChange - }); -} -function SplineStylePickerSet({ styles: styles3 }) { - const handleValueChange = useStyleChangeCallback(); - const spline = styles3.get(LineShapeSplineStyle); - if (spline === void 0) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(DropdownPicker, { - id: "spline", - type: "menu", - label: "style-panel.spline", - uiType: "spline", - style: LineShapeSplineStyle, - items: STYLES.spline, - value: spline, - onValueChange: handleValueChange - }); -} -function ArrowheadStylePickerSet({ styles: styles3 }) { - const handleValueChange = useStyleChangeCallback(); - const arrowheadEnd = styles3.get(ArrowShapeArrowheadEndStyle); - const arrowheadStart = styles3.get(ArrowShapeArrowheadStartStyle); - if (!arrowheadEnd || !arrowheadStart) { - return null; - } - return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(DoubleDropdownPicker, { - label: "style-panel.arrowheads", - uiTypeA: "arrowheadStart", - styleA: ArrowShapeArrowheadStartStyle, - itemsA: STYLES.arrowheadStart, - valueA: arrowheadStart, - uiTypeB: "arrowheadEnd", - styleB: ArrowShapeArrowheadEndStyle, - itemsB: STYLES.arrowheadEnd, - valueB: arrowheadEnd, - onValueChange: handleValueChange, - labelA: "style-panel.arrowhead-start", - labelB: "style-panel.arrowhead-end" - }); -} -var tldrawSupportedOpacities = [0.1, 0.25, 0.5, 0.75, 1]; -function OpacitySlider() { - const editor = useEditor(); - const opacity = useValue("opacity", () => editor.getSharedOpacity(), [editor]); - const trackEvent = useUiEvents(); - const msg2 = useTranslation(); - const handleOpacityValueChange = import_react104.default.useCallback((value) => { - const item = tldrawSupportedOpacities[value]; - editor.run(() => { - if (editor.isIn("select")) { - editor.setOpacityForSelectedShapes(item); - } - editor.setOpacityForNextShapes(item); - editor.updateInstanceState({ isChangingStyle: true }); - }); - trackEvent("set-style", { source: "style-panel", id: "opacity", value }); - }, [editor, trackEvent]); - if (opacity === void 0) - return null; - const opacityIndex = opacity.type === "mixed" ? -1 : tldrawSupportedOpacities.indexOf(minBy(tldrawSupportedOpacities, (supportedOpacity) => Math.abs(supportedOpacity - opacity.value))); - return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(TldrawUiSlider, { - "data-testid": "style.opacity", - value: opacityIndex >= 0 ? opacityIndex : tldrawSupportedOpacities.length - 1, - label: opacity.type === "mixed" ? "style-panel.mixed" : `opacity-style.${opacity.value}`, - onValueChange: handleOpacityValueChange, - steps: tldrawSupportedOpacities.length - 1, - title: msg2("style-panel.opacity") - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs -var DefaultStylePanel = (0, import_react105.memo)(function DefaultStylePanel2({ - isMobile, - children -}) { - const editor = useEditor(); - const styles3 = useRelevantStyles(); - const handlePointerOut = (0, import_react105.useCallback)(() => { - if (!isMobile) { - editor.updateInstanceState({ isChangingStyle: false }); - } - }, [editor, isMobile]); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DefaultStylePanelContent, { styles: styles3 }); - return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { - className: (0, import_classnames25.default)("tlui-style-panel", { "tlui-style-panel__wrapper": !isMobile }), - "data-ismobile": isMobile, - onPointerLeave: handlePointerOut, - children: content - }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs -var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1); -var import_react109 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/MobileStylePanel.mjs -var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1); -var import_react106 = __toESM(require_react(), 1); -function MobileStylePanel() { - const editor = useEditor(); - const msg2 = useTranslation(); - const relevantStyles = useRelevantStyles(); - const color = relevantStyles?.get(DefaultColorStyle); - const theme = getDefaultColorTheme({ isDarkMode: editor.user.getIsDarkMode() }); - const currentColor = (color?.type === "shared" ? theme[color.value] : theme.black).solid; - const disableStylePanel = useValue("disable style panel", () => editor.isInAny("hand", "zoom", "eraser", "laser"), [editor]); - const handleStylesOpenChange = (0, import_react106.useCallback)((isOpen) => { - if (!isOpen) { - editor.updateInstanceState({ isChangingStyle: false }); - } - }, [editor]); - const { StylePanel } = useTldrawUiComponents(); - if (!StylePanel) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(TldrawUiPopover, { id: "mobile style menu", onOpenChange: handleStylesOpenChange, children: [ - /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(TldrawUiPopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(TldrawUiButton, { - type: "tool", - "data-testid": "mobile-styles.button", - style: { - color: disableStylePanel ? "var(--color-muted-1)" : currentColor - }, - title: msg2("style-panel.title"), - disabled: disableStylePanel, - children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(TldrawUiButtonIcon, { - icon: disableStylePanel ? "blob" : color?.type === "mixed" ? "mixed" : "blob" - }) - }) }), - /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(TldrawUiPopoverContent, { side: "top", align: "end", children: StylePanel && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(StylePanel, { isMobile: true }) }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/DefaultToolbarContent.mjs -var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1); -function DefaultToolbarContent() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_jsx_runtime155.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(SelectToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(HandToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(DrawToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(EraserToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ArrowToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(TextToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(NoteToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(AssetToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RectangleToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(EllipseToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(TriangleToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(DiamondToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(HexagonToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(OvalToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RhombusToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(StarToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(CloudToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(HeartToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(XBoxToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(CheckBoxToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ArrowLeftToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ArrowUpToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ArrowDownToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ArrowRightToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(LineToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(HighlightToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(LaserToolbarItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(FrameToolbarItem, {}) - ] }); -} -function useIsToolSelected(tool) { - const editor = useEditor(); - const geo = tool.meta?.geo; - return useValue("is tool selected", () => { - const activeToolId = editor.getCurrentToolId(); - const geoState = editor.getSharedStyles().getAsKnownValue(GeoShapeGeoStyle); - return geo ? activeToolId === "geo" && geoState === geo : activeToolId === tool.id; - }, [editor, tool.id, geo]); -} -function ToolbarItem({ tool }) { - const tools = useTools(); - const isSelected = useIsToolSelected(tools[tool]); - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(TldrawUiMenuItem, { ...tools[tool], isSelected }); -} -function SelectToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "select" }); -} -function HandToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "hand" }); -} -function DrawToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "draw" }); -} -function EraserToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "eraser" }); -} -function ArrowToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "arrow" }); -} -function TextToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "text" }); -} -function NoteToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "note" }); -} -function AssetToolbarItem() { - const tools = useTools(); - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(TldrawUiMenuItem, { ...tools["asset"] }); -} -function RectangleToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "rectangle" }); -} -function EllipseToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "ellipse" }); -} -function DiamondToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "diamond" }); -} -function TriangleToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "triangle" }); -} -function RhombusToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "rhombus" }); -} -function HeartToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "heart" }); -} -function HexagonToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "hexagon" }); -} -function CloudToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "cloud" }); -} -function StarToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "star" }); -} -function OvalToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "oval" }); -} -function XBoxToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "x-box" }); -} -function CheckBoxToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "check-box" }); -} -function ArrowLeftToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "arrow-left" }); -} -function ArrowUpToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "arrow-up" }); -} -function ArrowDownToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "arrow-down" }); -} -function ArrowRightToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "arrow-right" }); -} -function LineToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "line" }); -} -function HighlightToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "highlight" }); -} -function FrameToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "frame" }); -} -function LaserToolbarItem() { - return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ToolbarItem, { tool: "laser" }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs -var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1); -var import_classnames26 = __toESM(require_classnames(), 1); - -// node_modules/hotkeys-js/dist/hotkeys.esm.js -var isff = typeof navigator !== "undefined" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false; -function addEvent(object2, event, method, useCapture) { - if (object2.addEventListener) { - object2.addEventListener(event, method, useCapture); - } else if (object2.attachEvent) { - object2.attachEvent("on".concat(event), method); - } -} -function removeEvent(object2, event, method, useCapture) { - if (object2.removeEventListener) { - object2.removeEventListener(event, method, useCapture); - } else if (object2.detachEvent) { - object2.detachEvent("on".concat(event), method); - } -} -function getMods(modifier, key) { - const mods = key.slice(0, key.length - 1); - for (let i = 0; i < mods.length; i++) - mods[i] = modifier[mods[i].toLowerCase()]; - return mods; -} -function getKeys(key) { - if (typeof key !== "string") - key = ""; - key = key.replace(/\s/g, ""); - const keys = key.split(","); - let index2 = keys.lastIndexOf(""); - for (; index2 >= 0; ) { - keys[index2 - 1] += ","; - keys.splice(index2, 1); - index2 = keys.lastIndexOf(""); - } - return keys; -} -function compareArray(a1, a2) { - const arr1 = a1.length >= a2.length ? a1 : a2; - const arr2 = a1.length >= a2.length ? a2 : a1; - let isIndex = true; - for (let i = 0; i < arr1.length; i++) { - if (arr2.indexOf(arr1[i]) === -1) - isIndex = false; - } - return isIndex; -} -var _keyMap = { - backspace: 8, - "\u232B": 8, - tab: 9, - clear: 12, - enter: 13, - "\u21A9": 13, - return: 13, - esc: 27, - escape: 27, - space: 32, - left: 37, - up: 38, - right: 39, - down: 40, - del: 46, - delete: 46, - ins: 45, - insert: 45, - home: 36, - end: 35, - pageup: 33, - pagedown: 34, - capslock: 20, - num_0: 96, - num_1: 97, - num_2: 98, - num_3: 99, - num_4: 100, - num_5: 101, - num_6: 102, - num_7: 103, - num_8: 104, - num_9: 105, - num_multiply: 106, - num_add: 107, - num_enter: 108, - num_subtract: 109, - num_decimal: 110, - num_divide: 111, - "\u21EA": 20, - ",": 188, - ".": 190, - "/": 191, - "`": 192, - "-": isff ? 173 : 189, - "=": isff ? 61 : 187, - ";": isff ? 59 : 186, - "'": 222, - "[": 219, - "]": 221, - "\\": 220 -}; -var _modifier = { - "\u21E7": 16, - shift: 16, - "\u2325": 18, - alt: 18, - option: 18, - "\u2303": 17, - ctrl: 17, - control: 17, - "\u2318": 91, - cmd: 91, - command: 91 -}; -var modifierMap = { - 16: "shiftKey", - 18: "altKey", - 17: "ctrlKey", - 91: "metaKey", - shiftKey: 16, - ctrlKey: 17, - altKey: 18, - metaKey: 91 -}; -var _mods = { - 16: false, - 18: false, - 17: false, - 91: false -}; -var _handlers = {}; -for (let k = 1; k < 20; k++) { - _keyMap["f".concat(k)] = 111 + k; -} -var _downKeys = []; -var winListendFocus = null; -var _scope = "all"; -var elementEventMap = /* @__PURE__ */ new Map(); -var code = (x) => _keyMap[x.toLowerCase()] || _modifier[x.toLowerCase()] || x.toUpperCase().charCodeAt(0); -var getKey = (x) => Object.keys(_keyMap).find((k) => _keyMap[k] === x); -var getModifier = (x) => Object.keys(_modifier).find((k) => _modifier[k] === x); -function setScope(scope) { - _scope = scope || "all"; -} -function getScope() { - return _scope || "all"; -} -function getPressedKeyCodes() { - return _downKeys.slice(0); -} -function getPressedKeyString() { - return _downKeys.map((c) => getKey(c) || getModifier(c) || String.fromCharCode(c)); -} -function getAllKeyCodes() { - const result = []; - Object.keys(_handlers).forEach((k) => { - _handlers[k].forEach((_ref) => { - let { - key, - scope, - mods, - shortcut - } = _ref; - result.push({ - scope, - shortcut, - mods, - keys: key.split("+").map((v) => code(v)) - }); - }); - }); - return result; -} -function filter(event) { - const target = event.target || event.srcElement; - const { - tagName - } = target; - let flag = true; - const isInput = tagName === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(target.type); - if (target.isContentEditable || (isInput || tagName === "TEXTAREA" || tagName === "SELECT") && !target.readOnly) { - flag = false; - } - return flag; -} -function isPressed(keyCode) { - if (typeof keyCode === "string") { - keyCode = code(keyCode); - } - return _downKeys.indexOf(keyCode) !== -1; -} -function deleteScope(scope, newScope) { - let handlers; - let i; - if (!scope) - scope = getScope(); - for (const key in _handlers) { - if (Object.prototype.hasOwnProperty.call(_handlers, key)) { - handlers = _handlers[key]; - for (i = 0; i < handlers.length; ) { - if (handlers[i].scope === scope) { - const deleteItems = handlers.splice(i, 1); - deleteItems.forEach((_ref2) => { - let { - element - } = _ref2; - return removeKeyEvent(element); - }); - } else { - i++; - } - } - } - } - if (getScope() === scope) - setScope(newScope || "all"); -} -function clearModifier(event) { - let key = event.keyCode || event.which || event.charCode; - const i = _downKeys.indexOf(key); - if (i >= 0) { - _downKeys.splice(i, 1); - } - if (event.key && event.key.toLowerCase() === "meta") { - _downKeys.splice(0, _downKeys.length); - } - if (key === 93 || key === 224) - key = 91; - if (key in _mods) { - _mods[key] = false; - for (const k in _modifier) - if (_modifier[k] === key) - hotkeys[k] = false; - } -} -function unbind(keysInfo) { - if (typeof keysInfo === "undefined") { - Object.keys(_handlers).forEach((key) => { - Array.isArray(_handlers[key]) && _handlers[key].forEach((info2) => eachUnbind(info2)); - delete _handlers[key]; - }); - removeKeyEvent(null); - } else if (Array.isArray(keysInfo)) { - keysInfo.forEach((info2) => { - if (info2.key) - eachUnbind(info2); - }); - } else if (typeof keysInfo === "object") { - if (keysInfo.key) - eachUnbind(keysInfo); - } else if (typeof keysInfo === "string") { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - let [scope, method] = args; - if (typeof scope === "function") { - method = scope; - scope = ""; - } - eachUnbind({ - key: keysInfo, - scope, - method, - splitKey: "+" - }); - } -} -var eachUnbind = (_ref3) => { - let { - key, - scope, - method, - splitKey = "+" - } = _ref3; - const multipleKeys = getKeys(key); - multipleKeys.forEach((originKey) => { - const unbindKeys = originKey.split(splitKey); - const len = unbindKeys.length; - const lastKey = unbindKeys[len - 1]; - const keyCode = lastKey === "*" ? "*" : code(lastKey); - if (!_handlers[keyCode]) - return; - if (!scope) - scope = getScope(); - const mods = len > 1 ? getMods(_modifier, unbindKeys) : []; - const unbindElements = []; - _handlers[keyCode] = _handlers[keyCode].filter((record) => { - const isMatchingMethod = method ? record.method === method : true; - const isUnbind = isMatchingMethod && record.scope === scope && compareArray(record.mods, mods); - if (isUnbind) - unbindElements.push(record.element); - return !isUnbind; - }); - unbindElements.forEach((element) => removeKeyEvent(element)); - }); -}; -function eventHandler(event, handler, scope, element) { - if (handler.element !== element) { - return; - } - let modifiersMatch; - if (handler.scope === scope || handler.scope === "all") { - modifiersMatch = handler.mods.length > 0; - for (const y in _mods) { - if (Object.prototype.hasOwnProperty.call(_mods, y)) { - if (!_mods[y] && handler.mods.indexOf(+y) > -1 || _mods[y] && handler.mods.indexOf(+y) === -1) { - modifiersMatch = false; - } - } - } - if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === "*") { - handler.keys = []; - handler.keys = handler.keys.concat(_downKeys); - if (handler.method(event, handler) === false) { - if (event.preventDefault) - event.preventDefault(); - else - event.returnValue = false; - if (event.stopPropagation) - event.stopPropagation(); - if (event.cancelBubble) - event.cancelBubble = true; - } - } - } -} -function dispatch(event, element) { - const asterisk = _handlers["*"]; - let key = event.keyCode || event.which || event.charCode; - if (!hotkeys.filter.call(this, event)) - return; - if (key === 93 || key === 224) - key = 91; - if (_downKeys.indexOf(key) === -1 && key !== 229) - _downKeys.push(key); - ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((keyName) => { - const keyNum = modifierMap[keyName]; - if (event[keyName] && _downKeys.indexOf(keyNum) === -1) { - _downKeys.push(keyNum); - } else if (!event[keyName] && _downKeys.indexOf(keyNum) > -1) { - _downKeys.splice(_downKeys.indexOf(keyNum), 1); - } else if (keyName === "metaKey" && event[keyName] && _downKeys.length === 3) { - if (!(event.ctrlKey || event.shiftKey || event.altKey)) { - _downKeys = _downKeys.slice(_downKeys.indexOf(keyNum)); - } - } - }); - if (key in _mods) { - _mods[key] = true; - for (const k in _modifier) { - if (_modifier[k] === key) - hotkeys[k] = true; - } - if (!asterisk) - return; - } - for (const e in _mods) { - if (Object.prototype.hasOwnProperty.call(_mods, e)) { - _mods[e] = event[modifierMap[e]]; - } - } - if (event.getModifierState && !(event.altKey && !event.ctrlKey) && event.getModifierState("AltGraph")) { - if (_downKeys.indexOf(17) === -1) { - _downKeys.push(17); - } - if (_downKeys.indexOf(18) === -1) { - _downKeys.push(18); - } - _mods[17] = true; - _mods[18] = true; - } - const scope = getScope(); - if (asterisk) { - for (let i = 0; i < asterisk.length; i++) { - if (asterisk[i].scope === scope && (event.type === "keydown" && asterisk[i].keydown || event.type === "keyup" && asterisk[i].keyup)) { - eventHandler(event, asterisk[i], scope, element); - } - } - } - if (!(key in _handlers)) - return; - const handlerKey = _handlers[key]; - const keyLen = handlerKey.length; - for (let i = 0; i < keyLen; i++) { - if (event.type === "keydown" && handlerKey[i].keydown || event.type === "keyup" && handlerKey[i].keyup) { - if (handlerKey[i].key) { - const record = handlerKey[i]; - const { - splitKey - } = record; - const keyShortcut = record.key.split(splitKey); - const _downKeysCurrent = []; - for (let a = 0; a < keyShortcut.length; a++) { - _downKeysCurrent.push(code(keyShortcut[a])); - } - if (_downKeysCurrent.sort().join("") === _downKeys.sort().join("")) { - eventHandler(event, record, scope, element); - } - } - } - } -} -function hotkeys(key, option, method) { - _downKeys = []; - const keys = getKeys(key); - let mods = []; - let scope = "all"; - let element = document; - let i = 0; - let keyup = false; - let keydown = true; - let splitKey = "+"; - let capture = false; - let single = false; - if (method === void 0 && typeof option === "function") { - method = option; - } - if (Object.prototype.toString.call(option) === "[object Object]") { - if (option.scope) - scope = option.scope; - if (option.element) - element = option.element; - if (option.keyup) - keyup = option.keyup; - if (option.keydown !== void 0) - keydown = option.keydown; - if (option.capture !== void 0) - capture = option.capture; - if (typeof option.splitKey === "string") - splitKey = option.splitKey; - if (option.single === true) - single = true; - } - if (typeof option === "string") - scope = option; - if (single) - unbind(key, scope); - for (; i < keys.length; i++) { - key = keys[i].split(splitKey); - mods = []; - if (key.length > 1) - mods = getMods(_modifier, key); - key = key[key.length - 1]; - key = key === "*" ? "*" : code(key); - if (!(key in _handlers)) - _handlers[key] = []; - _handlers[key].push({ - keyup, - keydown, - scope, - mods, - shortcut: keys[i], - method, - key: keys[i], - splitKey, - element - }); - } - if (typeof element !== "undefined" && window) { - if (!elementEventMap.has(element)) { - const keydownListener = function() { - let event = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event; - return dispatch(event, element); - }; - const keyupListenr = function() { - let event = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event; - dispatch(event, element); - clearModifier(event); - }; - elementEventMap.set(element, { - keydownListener, - keyupListenr, - capture - }); - addEvent(element, "keydown", keydownListener, capture); - addEvent(element, "keyup", keyupListenr, capture); - } - if (!winListendFocus) { - const listener = () => { - _downKeys = []; - }; - winListendFocus = { - listener, - capture - }; - addEvent(window, "focus", listener, capture); - } - } -} -function trigger(shortcut) { - let scope = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all"; - Object.keys(_handlers).forEach((key) => { - const dataList = _handlers[key].filter((item) => item.scope === scope && item.shortcut === shortcut); - dataList.forEach((data) => { - if (data && data.method) { - data.method(); - } - }); - }); -} -function removeKeyEvent(element) { - const values = Object.values(_handlers).flat(); - const findindex = values.findIndex((_ref4) => { - let { - element: el - } = _ref4; - return el === element; - }); - if (findindex < 0) { - const { - keydownListener, - keyupListenr, - capture - } = elementEventMap.get(element) || {}; - if (keydownListener && keyupListenr) { - removeEvent(element, "keyup", keyupListenr, capture); - removeEvent(element, "keydown", keydownListener, capture); - elementEventMap.delete(element); - } - } - if (values.length <= 0 || elementEventMap.size <= 0) { - const eventKeys = Object.keys(elementEventMap); - eventKeys.forEach((el) => { - const { - keydownListener, - keyupListenr, - capture - } = elementEventMap.get(el) || {}; - if (keydownListener && keyupListenr) { - removeEvent(el, "keyup", keyupListenr, capture); - removeEvent(el, "keydown", keydownListener, capture); - elementEventMap.delete(el); - } - }); - elementEventMap.clear(); - Object.keys(_handlers).forEach((key) => delete _handlers[key]); - if (winListendFocus) { - const { - listener, - capture - } = winListendFocus; - removeEvent(window, "focus", listener, capture); - winListendFocus = null; - } - } -} -var _api = { - getPressedKeyString, - setScope, - getScope, - deleteScope, - getPressedKeyCodes, - getAllKeyCodes, - isPressed, - filter, - trigger, - unbind, - keyMap: _keyMap, - modifier: _modifier, - modifierMap -}; -for (const a in _api) { - if (Object.prototype.hasOwnProperty.call(_api, a)) { - hotkeys[a] = _api[a]; - } -} -if (typeof window !== "undefined") { - const _hotkeys = window.hotkeys; - hotkeys.noConflict = (deep) => { - if (deep && window.hotkeys === hotkeys) { - window.hotkeys = _hotkeys; - } - return hotkeys; - }; - window.hotkeys = hotkeys; -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs -var import_react108 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs -var import_react107 = __toESM(require_react(), 1); -var SKIP_KBDS = [ - "copy", - "cut", - "paste", - "asset" -]; -function useKeyboardShortcuts() { - const editor = useEditor(); - const isReadonlyMode = useReadonly(); - const actions = useActions(); - const tools = useTools(); - const isFocused = useValue("is focused", () => editor.getInstanceState().isFocused, [editor]); - (0, import_react107.useEffect)(() => { - if (!isFocused) - return; - const disposables = new Array(); - const hot = (keys, callback) => { - hotkeys(keys, { element: document.body }, callback); - disposables.push(() => { - hotkeys.unbind(keys, callback); - }); - }; - const hotUp = (keys, callback) => { - hotkeys(keys, { element: document.body, keyup: true, keydown: false }, callback); - disposables.push(() => { - hotkeys.unbind(keys, callback); - }); - }; - for (const action of Object.values(actions)) { - if (!action.kbd) - continue; - if (isReadonlyMode && !action.readonlyOk) - continue; - if (SKIP_KBDS.includes(action.id)) - continue; - hot(getHotkeysStringFromKbd(action.kbd), (event) => { - if (areShortcutsDisabled(editor)) - return; - preventDefault(event); - action.onSelect("kbd"); - }); - } - for (const tool of Object.values(tools)) { - if (!tool.kbd || !tool.readonlyOk && editor.getInstanceState().isReadonly) { - continue; - } - if (SKIP_KBDS.includes(tool.id)) - continue; - hot(getHotkeysStringFromKbd(tool.kbd), (event) => { - if (areShortcutsDisabled(editor)) - return; - preventDefault(event); - tool.onSelect("kbd"); - }); - } - hot(",", (e) => { - if (areShortcutsDisabled(editor)) - return; - if (editor.inputs.keys.has("Comma")) - return; - preventDefault(e); - editor.focus(); - editor.inputs.keys.add("Comma"); - const { x, y, z } = editor.inputs.currentScreenPoint; - const info2 = { - type: "pointer", - name: "pointer_down", - point: { x, y, z }, - shiftKey: e.shiftKey, - altKey: e.altKey, - ctrlKey: e.metaKey || e.ctrlKey, - pointerId: 0, - button: 0, - isPen: editor.getInstanceState().isPenMode, - target: "canvas" - }; - editor.dispatch(info2); - }); - hotUp(",", (e) => { - if (areShortcutsDisabled(editor)) - return; - if (!editor.inputs.keys.has("Comma")) - return; - editor.inputs.keys.delete("Comma"); - const { x, y, z } = editor.inputs.currentScreenPoint; - const info2 = { - type: "pointer", - name: "pointer_up", - point: { x, y, z }, - shiftKey: e.shiftKey, - altKey: e.altKey, - ctrlKey: e.metaKey || e.ctrlKey, - pointerId: 0, - button: 0, - isPen: editor.getInstanceState().isPenMode, - target: "canvas" - }; - editor.dispatch(info2); - }); - return () => { - disposables.forEach((d) => d()); - }; - }, [actions, tools, isReadonlyMode, editor, isFocused]); -} -function getHotkeysStringFromKbd(kbd2) { - return getKeys2(kbd2).map((kbd22) => { - let str = ""; - const chars = kbd22.split(""); - if (chars.length === 1) { - str = chars[0]; - } else { - if (chars[0] === "!") { - str = `shift+${chars[1]}`; - } else if (chars[0] === "?") { - if (chars.length === 3 && chars[1] === "!") { - str = `alt+shift+${chars[2]}`; - } else { - str = `alt+${chars[1]}`; - } - } else if (chars[0] === "$") { - if (chars[1] === "!") { - str = `cmd+shift+${chars[2]},ctrl+shift+${chars[2]}`; - } else if (chars[1] === "?") { - str = `cmd+\u2325+${chars[2]},ctrl+alt+${chars[2]}`; - } else { - str = `cmd+${chars[1]},ctrl+${chars[1]}`; - } - } else { - str = kbd22; - } - } - return str; - }).join(","); -} -function getKeys2(key) { - if (typeof key !== "string") - key = ""; - key = key.replace(/\s/g, ""); - const keys = key.split(","); - let index2 = keys.lastIndexOf(""); - for (; index2 >= 0; ) { - keys[index2 - 1] += ","; - keys.splice(index2, 1); - index2 = keys.lastIndexOf(""); - } - return keys; -} -function areShortcutsDisabled(editor) { - return editor.getIsMenuOpen() || editor.getEditingShapeId() !== null || editor.getCrashingError(); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs -var IsInOverflowContext = (0, import_react108.createContext)(false); -function OverflowingToolbar({ children }) { - const editor = useEditor(); - const id = useSafeId(); - const breakpoint = useBreakpoint(); - const msg2 = useTranslation(); - const overflowIndex = Math.min(8, 5 + breakpoint); - const [totalItems, setTotalItems] = (0, import_react108.useState)(0); - const mainToolsRef = (0, import_react108.useRef)(null); - const [lastActiveOverflowItem, setLastActiveOverflowItem] = (0, import_react108.useState)(null); - const css = (0, import_react108.useMemo)(() => { - const activeCss = lastActiveOverflowItem ? `:not([data-value="${lastActiveOverflowItem}"])` : ""; - return ` - #${id}_main > *:nth-child(n + ${overflowIndex + (lastActiveOverflowItem ? 1 : 2)})${activeCss} { - display: none; - } - #${id}_more > *:nth-child(-n + ${overflowIndex}) { - display: none; - } - `; - }, [lastActiveOverflowItem, id, overflowIndex]); - const onDomUpdate = useEvent(() => { - if (!mainToolsRef.current) - return; - const children2 = Array.from(mainToolsRef.current.children); - setTotalItems(children2.length); - const lastActiveElementIdx = children2.findIndex((el) => el.getAttribute("data-value") === lastActiveOverflowItem); - if (lastActiveElementIdx <= overflowIndex) { - setLastActiveOverflowItem(null); - } - const activeElementIdx = Array.from(mainToolsRef.current.children).findIndex((el) => el.getAttribute("aria-checked") === "true"); - if (activeElementIdx === -1) - return; - if (activeElementIdx >= overflowIndex) { - setLastActiveOverflowItem(children2[activeElementIdx].getAttribute("data-value")); - } - }); - (0, import_react108.useLayoutEffect)(() => { - onDomUpdate(); - }); - (0, import_react108.useLayoutEffect)(() => { - if (!mainToolsRef.current) - return; - const mutationObserver = new MutationObserver(onDomUpdate); - mutationObserver.observe(mainToolsRef.current, { - childList: true, - subtree: true, - attributeFilter: ["data-value", "aria-checked"] - }); - return () => { - mutationObserver.disconnect(); - }; - }, [onDomUpdate]); - (0, import_react108.useEffect)(() => { - const keys = [ - ["1", 0], - ["2", 1], - ["3", 2], - ["4", 3], - ["5", 4], - ["6", 5], - ["7", 6], - ["8", 7], - ["9", 8], - ["0", 9] - ]; - for (const [key, index2] of keys) { - hotkeys(key, (event) => { - if (areShortcutsDisabled(editor)) - return; - preventDefault(event); - const relevantEls = Array.from(mainToolsRef.current?.children ?? []).filter((el2) => { - if (!(el2 instanceof HTMLElement)) - return false; - if (el2.tagName.toLowerCase() !== "button") - return false; - return !!(el2.offsetWidth || el2.offsetHeight); - }); - const el = relevantEls[index2]; - if (el) - el.click(); - }); - } - return () => { - hotkeys.unbind("1,2,3,4,5,6,7,8,9,0"); - }; - }, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(import_jsx_runtime156.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("style", { children: css }), - /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("div", { - className: (0, import_classnames26.default)("tlui-toolbar__tools", { - "tlui-toolbar__tools__mobile": breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM - }), - role: "radiogroup", - children: [ - /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { id: `${id}_main`, ref: mainToolsRef, className: "tlui-toolbar__tools__list", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(TldrawUiMenuContextProvider, { type: "toolbar", sourceId: "toolbar", children }) }), - totalItems > overflowIndex + 1 && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(IsInOverflowContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(TldrawUiDropdownMenuRoot, { id: "toolbar overflow", modal: false, children: [ - /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(TldrawUiButton, { - title: msg2("tool-panel.more"), - type: "tool", - className: "tlui-toolbar__overflow", - "data-testid": "tools.more-button", - children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(TldrawUiButtonIcon, { icon: "chevron-up" }) - }) }), - /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(TldrawUiDropdownMenuContent, { side: "top", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { - className: "tlui-buttons__grid", - "data-testid": "tools.more-content", - id: `${id}_more`, - children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(TldrawUiMenuContextProvider, { type: "toolbar-overflow", sourceId: "toolbar", children }) - }) }) - ] }) }) - ] - }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs -var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1); -var import_classnames27 = __toESM(require_classnames(), 1); -function ToggleToolLockedButton({ activeToolId }) { - const editor = useEditor(); - const breakpoint = useBreakpoint(); - const msg2 = useTranslation(); - const isToolLocked = useValue("is tool locked", () => editor.getInstanceState().isToolLocked, [ - editor - ]); - const tool = useValue("current tool", () => editor.getCurrentTool(), [editor]); - if (!activeToolId || !tool.isLockable) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(TldrawUiButton, { - type: "normal", - title: msg2("action.toggle-tool-lock"), - "data-testid": "tool-lock", - className: (0, import_classnames27.default)("tlui-toolbar__lock-button", { - "tlui-toolbar__lock-button__mobile": breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM - }), - onClick: () => editor.updateInstanceState({ isToolLocked: !isToolLocked }), - children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(TldrawUiButtonIcon, { icon: isToolLocked ? "lock" : "unlock", small: true }) - }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs -var DefaultToolbar = (0, import_react109.memo)(function DefaultToolbar2({ children }) { - const editor = useEditor(); - const breakpoint = useBreakpoint(); - const isReadonlyMode = useReadonly(); - const activeToolId = useValue("current tool id", () => editor.getCurrentToolId(), [editor]); - const { ActionsMenu, QuickActions } = useTldrawUiComponents(); - return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "tlui-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "tlui-toolbar__inner", children: [ - /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "tlui-toolbar__left", children: [ - !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "tlui-toolbar__extras", children: [ - breakpoint < PORTRAIT_BREAKPOINT.TABLET && /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "tlui-toolbar__extras__controls tlui-buttons__horizontal", children: [ - QuickActions && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(QuickActions, {}), - ActionsMenu && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ActionsMenu, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ToggleToolLockedButton, { activeToolId }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(OverflowingToolbar, { children: children ?? /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(DefaultToolbarContent, {}) }) - ] }), - breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "tlui-toolbar__tools", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(MobileStylePanel, {}) }) - ] }) }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs -var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs -var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1); -var import_classnames28 = __toESM(require_classnames(), 1); -function OfflineIndicator() { - const msg2 = useTranslation(); - return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)("div", { className: (0, import_classnames28.default)("tlui-offline-indicator"), children: [ - msg2("status.offline"), - /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(TldrawUiIcon, { "aria-label": "offline", icon: "status-offline", small: true }) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs -var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1); -var import_react110 = __toESM(require_react(), 1); -function CenteredTopPanelContainer({ - maxWidth: maxWidth2 = 420, - ignoreRightWidth = 0, - stylePanelWidth = 148, - marginBetweenZones = 12, - squeezeAmount = 52, - children -}) { - const ref = (0, import_react110.useRef)(null); - const breakpoint = useBreakpoint(); - const updateLayout = (0, import_react110.useCallback)(() => { - const element = ref.current; - if (!element) - return; - const layoutTop = element.parentElement.parentElement; - const leftPanel = layoutTop.querySelector(".tlui-layout__top__left"); - const rightPanel = layoutTop.querySelector(".tlui-layout__top__right"); - const totalWidth = layoutTop.offsetWidth; - const leftWidth = leftPanel.offsetWidth; - const rightWidth = rightPanel.offsetWidth; - const selfWidth = element.offsetWidth - ignoreRightWidth; - let xCoordIfCentered = (totalWidth - selfWidth) / 2; - if (totalWidth % 2 !== 0) { - xCoordIfCentered -= 0.5; - } - const xCoordIfLeftAligned = leftWidth + marginBetweenZones; - const left = element.offsetLeft; - const maxWidthProperty = Math.min(totalWidth - rightWidth - leftWidth - 2 * marginBetweenZones, maxWidth2); - const xCoord = Math.max(xCoordIfCentered, xCoordIfLeftAligned) - left; - if (rightPanel.offsetWidth > stylePanelWidth && breakpoint <= 6) { - element.style.setProperty("max-width", maxWidthProperty - squeezeAmount + "px"); - } else { - element.style.setProperty("max-width", maxWidthProperty + "px"); - } - element.style.setProperty("transform", `translate(${xCoord}px, 0px)`); - }, [breakpoint, ignoreRightWidth, marginBetweenZones, maxWidth2, squeezeAmount, stylePanelWidth]); - (0, import_react110.useLayoutEffect)(() => { - const element = ref.current; - if (!element) - return; - const layoutTop = element.parentElement.parentElement; - const leftPanel = layoutTop.querySelector(".tlui-layout__top__left"); - const rightPanel = layoutTop.querySelector(".tlui-layout__top__right"); - const observer = new ResizeObserver(updateLayout); - observer.observe(leftPanel); - observer.observe(rightPanel); - observer.observe(layoutTop); - observer.observe(element); - updateLayout(); - return () => { - observer.disconnect(); - }; - }, [updateLayout]); - (0, import_react110.useLayoutEffect)(() => { - updateLayout(); - }); - return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { ref, className: "tlui-top-panel__container", children }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs -function DefaultTopPanel() { - const isOffline = useMultiplayerStatus() === "offline"; - return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(CenteredTopPanelContainer, { children: isOffline && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(OfflineIndicator, {}) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs -var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1); -var import_react111 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenuContent.mjs -var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1); -function DefaultZoomMenuContent() { - const actions = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(TldrawUiMenuItem, { ...actions["zoom-in"], noClose: true }), - /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(TldrawUiMenuItem, { ...actions["zoom-out"], noClose: true }), - /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ZoomTo100MenuItem2, {}), - /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ZoomToFitMenuItem, {}), - /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ZoomToSelectionMenuItem, {}) - ] }); -} - -// node_modules/tldraw/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs -var DefaultZoomMenu = (0, import_react111.memo)(function DefaultZoomMenu2({ children }) { - const container = useContainer(); - const [isOpen, onOpenChange] = useMenuIsOpen("zoom menu"); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(DefaultZoomMenuContent, {}); - return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(Root26, { dir: "ltr", open: isOpen, onOpenChange, modal: false, children: [ - /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Trigger3, { asChild: true, dir: "ltr", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(ZoomTriggerButton, {}) }), - /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Portal23, { container, children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Content25, { - className: "tlui-menu", - side: "top", - align: "start", - alignOffset: 0, - sideOffset: 8, - collisionPadding: 4, - children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(TldrawUiMenuContextProvider, { type: "menu", sourceId: "zoom-menu", children: content }) - }) }) - ] }); -}); -var ZoomTriggerButton = (0, import_react111.forwardRef)(function ZoomTriggerButton2(props, ref) { - const editor = useEditor(); - const breakpoint = useBreakpoint(); - const zoom = useValue("zoom", () => editor.getZoomLevel(), [editor]); - const msg2 = useTranslation(); - const handleDoubleClick = (0, import_react111.useCallback)(() => { - editor.resetZoom(editor.getViewportScreenCenter(), { - animation: { duration: editor.options.animationMediumMs } - }); - }, [editor]); - return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(TldrawUiButton, { - ref, - ...props, - type: "icon", - title: `${msg2("navigation-zone.zoom")}`, - "data-testid": "minimap.zoom-menu-button", - className: breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM ? "tlui-zoom-menu__button" : "tlui-zoom-menu__button__pct", - onDoubleClick: handleDoubleClick, - icon: breakpoint < PORTRAIT_BREAKPOINT.MOBILE ? "zoom-in" : void 0, - children: breakpoint < PORTRAIT_BREAKPOINT.MOBILE ? null : /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("span", { style: { flexGrow: 0, textAlign: "center" }, children: [ - Math.floor(zoom * 100), - "%" - ] }) - }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/context/components.mjs -var TldrawUiComponentsContext = (0, import_react112.createContext)(null); -function TldrawUiComponentsProvider({ - overrides = {}, - children -}) { - const _overrides = useShallowObjectIdentity(overrides); - const isMultiplayer = useIsMultiplayer(); - return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(TldrawUiComponentsContext.Provider, { - value: (0, import_react112.useMemo)(() => ({ - ContextMenu: DefaultContextMenu, - ActionsMenu: DefaultActionsMenu, - HelpMenu: null, - ZoomMenu: DefaultZoomMenu, - MainMenu: DefaultMainMenu, - Minimap: DefaultMinimap, - StylePanel: DefaultStylePanel, - PageMenu: DefaultPageMenu, - NavigationPanel: DefaultNavigationPanel, - Toolbar: DefaultToolbar, - KeyboardShortcutsDialog: DefaultKeyboardShortcutsDialog, - QuickActions: DefaultQuickActions, - HelperButtons: DefaultHelperButtons, - DebugPanel: DefaultDebugPanel, - DebugMenu: DefaultDebugMenu, - MenuPanel: DefaultMenuPanel, - SharePanel: isMultiplayer ? DefaultSharePanel : null, - CursorChatBubble: isMultiplayer ? CursorChatBubble : null, - TopPanel: isMultiplayer ? DefaultTopPanel : null, - ..._overrides - }), [_overrides, isMultiplayer]), - children - }); -} -function useTldrawUiComponents() { - const components = (0, import_react112.useContext)(TldrawUiComponentsContext); - if (!components) { - throw new Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider"); - } - return components; -} - -// node_modules/tldraw/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs -function TldrawUiContextProvider({ - overrides, - components, - assetUrls, - onUiEvent, - forceMobile, - children -}) { - return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(AssetUrlsProvider, { assetUrls: useDefaultUiAssetUrlsWithOverrides(assetUrls), children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(TranslationProvider, { overrides: useMergedTranslationOverrides(overrides), children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(UiEventsProvider, { onEvent: onUiEvent, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(ToastsProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(DialogsProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(BreakPointProvider, { forceMobile, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(TldrawUiComponentsProvider, { overrides: components, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(InternalProviders, { overrides, children }) }) }) }) }) }) }) }); -} -function InternalProviders({ - overrides, - children -}) { - const mergedOverrides = useMergedOverrides(overrides); - return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(ActionsProvider, { overrides: mergedOverrides.actions, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(ToolsProvider, { overrides: mergedOverrides.tools, children }) }); -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/useEditorEvents.mjs -var import_react113 = __toESM(require_react(), 1); -function useEditorEvents() { - const editor = useEditor(); - const { addToast } = useToasts(); - (0, import_react113.useEffect)(() => { - function handleMaxShapes({ name, count: count3 }) { - addToast({ - title: "Maximum Shapes Reached", - description: `You've reached the maximum number of shapes allowed on ${name} (${count3}). Please delete some shapes or move to a different page to continue.`, - severity: "warning" - }); - } - editor.addListener("max-shapes", handleMaxShapes); - return () => { - editor.removeListener("max-shapes", handleMaxShapes); - }; - }, [editor, addToast]); -} - -// node_modules/tldraw/dist-esm/lib/ui/TldrawUi.mjs -var TldrawUi = import_react114.default.memo(function TldrawUi2({ - renderDebugMenuItems, - children, - hideUi, - components, - ...rest -}) { - return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(TldrawUiContextProvider, { ...rest, components, children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(TldrawUiInner, { hideUi, renderDebugMenuItems, children }) }); -}); -var TldrawUiInner = import_react114.default.memo(function TldrawUiInner2({ - children, - hideUi, - ...rest -}) { - return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(import_jsx_runtime166.Fragment, { children: [ - children, - hideUi ? null : /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(TldrawUiContent, { ...rest }) - ] }); -}); -var TldrawUiContent = import_react114.default.memo(function TldrawUI() { - const editor = useEditor(); - const msg2 = useTranslation(); - const breakpoint = useBreakpoint(); - const isReadonlyMode = useReadonly(); - const isFocusMode = useValue("focus", () => editor.getInstanceState().isFocusMode, [editor]); - const isDebugMode = useValue("debug", () => editor.getInstanceState().isDebugMode, [editor]); - const { - SharePanel, - TopPanel, - MenuPanel: MenuPanel2, - StylePanel, - Toolbar, - HelpMenu, - NavigationPanel, - HelperButtons, - DebugPanel, - CursorChatBubble: CursorChatBubble3 - } = useTldrawUiComponents(); - useKeyboardShortcuts(); - useNativeClipboardEvents(); - useEditorEvents(); - const { "toggle-focus-mode": toggleFocus } = useActions(); - return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { - className: (0, import_classnames29.default)("tlui-layout", { - "tlui-layout__mobile": breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM - }), - "data-breakpoint": breakpoint, - children: [ - isFocusMode ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "tlui-layout__top", children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(TldrawUiButton, { - type: "icon", - className: "tlui-focus-button", - title: msg2("focus-mode.toggle-focus-mode"), - onClick: () => toggleFocus.onSelect("menu"), - children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(TldrawUiButtonIcon, { icon: "dot" }) - }) }) : /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(import_jsx_runtime166.Fragment, { children: [ - /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "tlui-layout__top", children: [ - /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "tlui-layout__top__left", children: [ - MenuPanel2 && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(MenuPanel2, {}), - HelperButtons && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(HelperButtons, {}) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "tlui-layout__top__center", children: TopPanel && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(TopPanel, {}) }), - /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "tlui-layout__top__right", children: [ - SharePanel && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(SharePanel, {}), - StylePanel && breakpoint >= PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(StylePanel, {}) - ] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "tlui-layout__bottom", children: [ - /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "tlui-layout__bottom__main", children: [ - NavigationPanel && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(NavigationPanel, {}), - Toolbar && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Toolbar, {}), - HelpMenu && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(HelpMenu, {}) - ] }), - isDebugMode && DebugPanel && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(DebugPanel, {}) - ] }) - ] }), - /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Toasts, {}), - /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Dialogs, {}), - /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(ToastViewport2, {}), - /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(FollowingIndicator, {}), - CursorChatBubble3 && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(CursorChatBubble3, {}) - ] - }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/hooks/usePreloadAssets.mjs -var import_react115 = __toESM(require_react(), 1); - -// node_modules/tldraw/dist-esm/lib/utils/assets/preload-font.mjs -async function preloadFont(id, font) { - const { - url, - style = "normal", - weight = "500", - display, - featureSettings, - stretch, - unicodeRange, - variant, - format - } = font; - const descriptors = { - style, - weight, - display, - featureSettings, - stretch, - unicodeRange, - variant - }; - const fontInstance = new FontFace(id, `url(${url})`, descriptors); - await fontInstance.load(); - document.fonts.add(fontInstance); - fontInstance.$$_url = url; - fontInstance.$$_fontface = ` -@font-face { - font-family: ${fontInstance.family}; - font-stretch: ${fontInstance.stretch}; - font-weight: ${fontInstance.weight}; - font-style: ${fontInstance.style}; - src: url("${url}") format("${format}") -}`; - return fontInstance; -} - -// node_modules/tldraw/dist-esm/lib/ui/hooks/usePreloadAssets.mjs -var usePreloadFont = (id, font) => { - const [state, setState] = (0, import_react115.useState)(2); - (0, import_react115.useEffect)(() => { - let cancelled = false; - setState(2); - preloadFont(id, font).then(() => { - if (cancelled) - return; - setState(0); - }).catch((err) => { - if (cancelled) - return; - console.error(err); - setState(1); - }); - return () => { - cancelled = true; - }; - }, [id, font]); - return state; -}; -function getTypefaces(assetUrls) { - return { - draw: { - url: assetUrls.fonts.draw, - format: assetUrls.fonts.draw.split(".").pop() - }, - serif: { - url: assetUrls.fonts.serif, - format: assetUrls.fonts.serif.split(".").pop() - }, - sansSerif: { - url: assetUrls.fonts.sansSerif, - format: assetUrls.fonts.sansSerif.split(".").pop() - }, - monospace: { - url: assetUrls.fonts.monospace, - format: assetUrls.fonts.monospace.split(".").pop() - } - }; -} -function usePreloadAssets(assetUrls) { - const typefaces = (0, import_react115.useMemo)(() => getTypefaces(assetUrls), [assetUrls]); - const results = [ - usePreloadFont("tldraw_draw", typefaces.draw), - usePreloadFont("tldraw_serif", typefaces.serif), - usePreloadFont("tldraw_sans", typefaces.sansSerif), - usePreloadFont("tldraw_mono", typefaces.monospace) - ]; - return { - error: results.some((result) => result === 1), - done: !results.some((result) => result === 2) - }; -} - -// node_modules/tldraw/dist-esm/lib/TldrawImage.mjs -var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1); -var import_react117 = __toESM(require_react(), 1); -var TldrawImage = (0, import_react117.memo)(function TldrawImage2(props) { - const [url, setUrl] = (0, import_react117.useState)(null); - const [container, setContainer] = (0, import_react117.useState)(null); - const shapeUtils = useShallowArrayIdentity(props.shapeUtils ?? []); - const shapeUtilsWithDefaults = (0, import_react117.useMemo)(() => [...defaultShapeUtils, ...shapeUtils], [shapeUtils]); - const bindingUtils = useShallowArrayIdentity(props.bindingUtils ?? []); - const bindingUtilsWithDefaults = (0, import_react117.useMemo)(() => [...defaultBindingUtils, ...bindingUtils], [bindingUtils]); - const store = useTLStore({ snapshot: props.snapshot, shapeUtils: shapeUtilsWithDefaults }); - const assets = useDefaultEditorAssetsWithOverrides(); - const { done: preloadingComplete, error: preloadingError } = usePreloadAssets(assets); - const { - pageId, - bounds, - scale, - background, - padding, - darkMode, - preserveAspectRatio, - format = "svg", - licenseKey - } = props; - (0, import_react117.useLayoutEffect)(() => { - if (!container) - return; - if (!store) - return; - if (!preloadingComplete) - return; - let isCancelled = false; - const tempElm = document.createElement("div"); - container.appendChild(tempElm); - container.classList.add("tl-container", "tl-theme__light"); - const editor = new Editor({ - store, - shapeUtils: shapeUtilsWithDefaults, - bindingUtils: bindingUtilsWithDefaults, - tools: [], - getContainer: () => tempElm, - licenseKey - }); - if (pageId) - editor.setCurrentPage(pageId); - const shapeIds = editor.getCurrentPageShapeIds(); - async function setSvg() { - const svgResult = await editor.getSvgString([...shapeIds], { - bounds, - scale, - background, - padding, - darkMode, - preserveAspectRatio - }); - if (svgResult && !isCancelled) { - if (format === "svg") { - if (!isCancelled) { - const blob = new Blob([svgResult.svg], { type: "image/svg+xml" }); - const url2 = URL.createObjectURL(blob); - setUrl(url2); - } - } else if (format === "png") { - const blob = await getSvgAsImage(editor, svgResult.svg, { - type: format, - quality: 1, - scale: 2, - width: svgResult.width, - height: svgResult.height - }); - if (blob && !isCancelled) { - const url2 = URL.createObjectURL(blob); - setUrl(url2); - } - } - } - editor.dispose(); - } - setSvg(); - return () => { - isCancelled = true; - }; - }, [ - format, - container, - store, - shapeUtilsWithDefaults, - bindingUtilsWithDefaults, - pageId, - bounds, - scale, - background, - padding, - darkMode, - preserveAspectRatio, - preloadingComplete, - preloadingError, - licenseKey - ]); - if (preloadingError) { - return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(ErrorScreen, { children: "Could not load assets." }); - } - if (!preloadingComplete) { - return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(LoadingScreen, { children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(DefaultSpinner, {}) }); - } - return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("div", { ref: setContainer, style: { position: "relative", width: "100%", height: "100%" }, children: url && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("img", { - src: url, - referrerPolicy: "strict-origin-when-cross-origin", - style: { width: "100%", height: "100%" } - }) }); -}); - -// node_modules/tldraw/dist-esm/lib/ui/components/HelpMenu/DefaultHelpMenu.mjs -var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1); -var import_react118 = __toESM(require_react(), 1); -var DefaultHelpMenu = (0, import_react118.memo)(function DefaultHelpMenu2({ children }) { - const msg2 = useTranslation(); - const breakpoint = useBreakpoint(); - const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(DefaultHelpMenuContent, {}); - if (breakpoint < PORTRAIT_BREAKPOINT.MOBILE) - return null; - return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("div", { className: "tlui-help-menu", children: /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(TldrawUiDropdownMenuRoot, { id: "help menu", children: [ - /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(TldrawUiButton, { type: "help", title: msg2("help-menu.title"), "data-testid": "help-menu.button", children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(TldrawUiButtonIcon, { icon: "question-mark", small: true }) }) }), - /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(TldrawUiDropdownMenuContent, { side: "top", align: "end", alignOffset: 0, sideOffset: 8, children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(TldrawUiMenuContextProvider, { type: "menu", sourceId: "help-menu", children: content }) }) - ] }) }); -}); - -// node_modules/tldraw/dist-esm/lib/utils/tldr/file.mjs -var schemaV1 = validation_exports.object({ - schemaVersion: validation_exports.literal(1), - storeVersion: validation_exports.positiveInteger, - recordVersions: validation_exports.dict(validation_exports.string, validation_exports.object({ - version: validation_exports.positiveInteger, - subTypeVersions: validation_exports.dict(validation_exports.string, validation_exports.positiveInteger).optional(), - subTypeKey: validation_exports.string.optional() - })) -}); -var schemaV2 = validation_exports.object({ - schemaVersion: validation_exports.literal(2), - sequences: validation_exports.dict(validation_exports.string, validation_exports.positiveInteger) -}); -var tldrawFileValidator = validation_exports.object({ - tldrawFileFormatVersion: validation_exports.nonZeroInteger, - schema: validation_exports.numberUnion("schemaVersion", { - 1: schemaV1, - 2: schemaV2 - }), - records: validation_exports.arrayOf(validation_exports.object({ - id: validation_exports.string, - typeName: validation_exports.string - }).allowUnknownProperties()) -}); - -// src/tldraw/writing/tldraw-writing-editor.tsx -var import_react121 = __toESM(require_react()); - -// src/utils/tldraw-helpers.ts -var import_react119 = __toESM(require_react()); - -// src/notices/stroke-limit-notice.ts -var import_timers2 = require("timers"); -function showStrokeLimitTips_maybe(plugin) { - if (plugin.settings.onboardingTips.strokeLimitTipRead) - return; - showStrokeLimitTips_debounced(plugin); -} -var tips_timeouts = []; -var tipsShowingOrDismissed2 = false; -function showStrokeLimitTips_debounced(plugin) { - while (tips_timeouts.length > 0) { - (0, import_timers2.clearTimeout)(tips_timeouts.pop()); - } - const newTimeout = setTimeout(() => { - showStrokeLimitTips(plugin); - }, 5e3); - tips_timeouts.push(newTimeout); -} -function showStrokeLimitTips(plugin) { - if (tipsShowingOrDismissed2) - return; - tipsShowingOrDismissed2 = true; - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`Lines disappearing?`); - noticeBody.createEl("p").setText(`You may have noticed that your handwriting lines have started disapearing...`); - const { - primaryBtnEl, - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - primaryLabel: "Learn why", - tertiaryLabel: "Dismiss for now" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (tertiaryBtnEl) { - tertiaryBtnEl.addEventListener("click", () => { - notice.hide(); - }); - } - if (primaryBtnEl) { - primaryBtnEl.addEventListener("click", () => { - notice.hide(); - showFullStrokeLimitTip(plugin); - }); - } -} -function showFullStrokeLimitTip(plugin) { - const noticeBody = createInkNoticeTemplate(); - noticeBody.createEl("h1").setText(`To help keep writing smooth...`); - noticeBody.createEl("p").setText(`Hiding old strokes helps keep pen latency down and the writing experience smooth.`); - noticeBody.createEl("p").setText(`Never fear though, all your strokes still exist and will become visible again later.`); - noticeBody.createEl("p").setText(`You can adjust the stroke limit in the settings.`); - const { - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - tertiaryLabel: "Dismiss" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (tertiaryBtnEl) { - tertiaryBtnEl.addEventListener("click", () => { - notice.hide(); - tipsShowingOrDismissed2 = false; - plugin.settings.onboardingTips.strokeLimitTipRead = true; - plugin.saveSettings(); - }); - } -} - -// node_modules/chalk/source/vendor/ansi-styles/index.js -var ANSI_BACKGROUND_OFFSET = 10; -var wrapAnsi16 = (offset4 = 0) => (code2) => `\x1B[${code2 + offset4}m`; -var wrapAnsi256 = (offset4 = 0) => (code2) => `\x1B[${38 + offset4};5;${code2}m`; -var wrapAnsi16m = (offset4 = 0) => (red, green, blue) => `\x1B[${38 + offset4};2;${red};${green};${blue}m`; -var styles = { - modifier: { - reset: [0, 0], - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - overline: [53, 55], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - blackBright: [90, 39], - gray: [90, 39], - grey: [90, 39], - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], - bgBlackBright: [100, 49], - bgGray: [100, 49], - bgGrey: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } -}; -var modifierNames = Object.keys(styles.modifier); -var foregroundColorNames = Object.keys(styles.color); -var backgroundColorNames = Object.keys(styles.bgColor); -var colorNames = [...foregroundColorNames, ...backgroundColorNames]; -function assembleStyles() { - const codes = /* @__PURE__ */ new Map(); - for (const [groupName, group] of Object.entries(styles)) { - for (const [styleName, style] of Object.entries(group)) { - styles[styleName] = { - open: `\x1B[${style[0]}m`, - close: `\x1B[${style[1]}m` - }; - group[styleName] = styles[styleName]; - codes.set(style[0], style[1]); - } - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - } - Object.defineProperty(styles, "codes", { - value: codes, - enumerable: false - }); - styles.color.close = "\x1B[39m"; - styles.bgColor.close = "\x1B[49m"; - styles.color.ansi = wrapAnsi16(); - styles.color.ansi256 = wrapAnsi256(); - styles.color.ansi16m = wrapAnsi16m(); - styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); - styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); - styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); - Object.defineProperties(styles, { - rgbToAnsi256: { - value(red, green, blue) { - if (red === green && green === blue) { - if (red < 8) { - return 16; - } - if (red > 248) { - return 231; - } - return Math.round((red - 8) / 247 * 24) + 232; - } - return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); - }, - enumerable: false - }, - hexToRgb: { - value(hex) { - const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); - if (!matches) { - return [0, 0, 0]; - } - let [colorString] = matches; - if (colorString.length === 3) { - colorString = [...colorString].map((character) => character + character).join(""); - } - const integer2 = Number.parseInt(colorString, 16); - return [ - integer2 >> 16 & 255, - integer2 >> 8 & 255, - integer2 & 255 - ]; - }, - enumerable: false - }, - hexToAnsi256: { - value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), - enumerable: false - }, - ansi256ToAnsi: { - value(code2) { - if (code2 < 8) { - return 30 + code2; - } - if (code2 < 16) { - return 90 + (code2 - 8); - } - let red; - let green; - let blue; - if (code2 >= 232) { - red = ((code2 - 232) * 10 + 8) / 255; - green = red; - blue = red; - } else { - code2 -= 16; - const remainder = code2 % 36; - red = Math.floor(code2 / 36) / 5; - green = Math.floor(remainder / 6) / 5; - blue = remainder % 6 / 5; - } - const value = Math.max(red, green, blue) * 2; - if (value === 0) { - return 30; - } - let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); - if (value === 2) { - result += 60; - } - return result; - }, - enumerable: false - }, - rgbToAnsi: { - value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), - enumerable: false - }, - hexToAnsi: { - value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), - enumerable: false - } - }); - return styles; -} -var ansiStyles = assembleStyles(); -var ansi_styles_default = ansiStyles; - -// node_modules/chalk/source/vendor/supports-color/browser.js -var level = (() => { - if (!("navigator" in globalThis)) { - return 0; - } - if (globalThis.navigator.userAgentData) { - const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium"); - if (brand && brand.version > 93) { - return 3; - } - } - if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) { - return 1; - } - return 0; -})(); -var colorSupport = level !== 0 && { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 -}; -var supportsColor = { - stdout: colorSupport, - stderr: colorSupport -}; -var browser_default = supportsColor; - -// node_modules/chalk/source/utilities.js -function stringReplaceAll(string2, substring, replacer) { - let index2 = string2.indexOf(substring); - if (index2 === -1) { - return string2; - } - const substringLength = substring.length; - let endIndex = 0; - let returnValue = ""; - do { - returnValue += string2.slice(endIndex, index2) + substring + replacer; - endIndex = index2 + substringLength; - index2 = string2.indexOf(substring, endIndex); - } while (index2 !== -1); - returnValue += string2.slice(endIndex); - return returnValue; -} -function stringEncaseCRLFWithFirstIndex(string2, prefix, postfix, index2) { - let endIndex = 0; - let returnValue = ""; - do { - const gotCR = string2[index2 - 1] === "\r"; - returnValue += string2.slice(endIndex, gotCR ? index2 - 1 : index2) + prefix + (gotCR ? "\r\n" : "\n") + postfix; - endIndex = index2 + 1; - index2 = string2.indexOf("\n", endIndex); - } while (index2 !== -1); - returnValue += string2.slice(endIndex); - return returnValue; -} - -// node_modules/chalk/source/index.js -var { stdout: stdoutColor, stderr: stderrColor } = browser_default; -var GENERATOR = Symbol("GENERATOR"); -var STYLER = Symbol("STYLER"); -var IS_EMPTY = Symbol("IS_EMPTY"); -var levelMapping = [ - "ansi", - "ansi", - "ansi256", - "ansi16m" -]; -var styles2 = /* @__PURE__ */ Object.create(null); -var applyOptions = (object2, options = {}) => { - if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { - throw new Error("The `level` option should be an integer from 0 to 3"); - } - const colorLevel = stdoutColor ? stdoutColor.level : 0; - object2.level = options.level === void 0 ? colorLevel : options.level; -}; -var chalkFactory = (options) => { - const chalk2 = (...strings) => strings.join(" "); - applyOptions(chalk2, options); - Object.setPrototypeOf(chalk2, createChalk.prototype); - return chalk2; -}; -function createChalk(options) { - return chalkFactory(options); -} -Object.setPrototypeOf(createChalk.prototype, Function.prototype); -for (const [styleName, style] of Object.entries(ansi_styles_default)) { - styles2[styleName] = { - get() { - const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); - Object.defineProperty(this, styleName, { value: builder }); - return builder; - } - }; -} -styles2.visible = { - get() { - const builder = createBuilder(this, this[STYLER], true); - Object.defineProperty(this, "visible", { value: builder }); - return builder; - } -}; -var getModelAnsi = (model2, level2, type, ...arguments_) => { - if (model2 === "rgb") { - if (level2 === "ansi16m") { - return ansi_styles_default[type].ansi16m(...arguments_); - } - if (level2 === "ansi256") { - return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_)); - } - return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_)); - } - if (model2 === "hex") { - return getModelAnsi("rgb", level2, type, ...ansi_styles_default.hexToRgb(...arguments_)); - } - return ansi_styles_default[type][model2](...arguments_); -}; -var usedModels = ["rgb", "hex", "ansi256"]; -for (const model2 of usedModels) { - styles2[model2] = { - get() { - const { level: level2 } = this; - return function(...arguments_) { - const styler = createStyler(getModelAnsi(model2, levelMapping[level2], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]); - return createBuilder(this, styler, this[IS_EMPTY]); - }; - } - }; - const bgModel = "bg" + model2[0].toUpperCase() + model2.slice(1); - styles2[bgModel] = { - get() { - const { level: level2 } = this; - return function(...arguments_) { - const styler = createStyler(getModelAnsi(model2, levelMapping[level2], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]); - return createBuilder(this, styler, this[IS_EMPTY]); - }; - } - }; -} -var proto = Object.defineProperties(() => { -}, { - ...styles2, - level: { - enumerable: true, - get() { - return this[GENERATOR].level; - }, - set(level2) { - this[GENERATOR].level = level2; - } - } -}); -var createStyler = (open, close, parent) => { - let openAll; - let closeAll; - if (parent === void 0) { - openAll = open; - closeAll = close; - } else { - openAll = parent.openAll + open; - closeAll = close + parent.closeAll; - } - return { - open, - close, - openAll, - closeAll, - parent - }; -}; -var createBuilder = (self2, _styler, _isEmpty) => { - const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); - Object.setPrototypeOf(builder, proto); - builder[GENERATOR] = self2; - builder[STYLER] = _styler; - builder[IS_EMPTY] = _isEmpty; - return builder; -}; -var applyStyle = (self2, string2) => { - if (self2.level <= 0 || !string2) { - return self2[IS_EMPTY] ? "" : string2; - } - let styler = self2[STYLER]; - if (styler === void 0) { - return string2; - } - const { openAll, closeAll } = styler; - if (string2.includes("\x1B")) { - while (styler !== void 0) { - string2 = stringReplaceAll(string2, styler.close, styler.open); - styler = styler.parent; - } - } - const lfIndex = string2.indexOf("\n"); - if (lfIndex !== -1) { - string2 = stringEncaseCRLFWithFirstIndex(string2, closeAll, openAll, lfIndex); - } - return openAll + string2 + closeAll; -}; -Object.defineProperties(createChalk.prototype, styles2); -var chalk = createChalk(); -var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 }); -var source_default = chalk; - -// src/utils/log-to-console.ts -function getTimestamp2() { - const now = new Date(); - const hours = String(now.getHours()).padStart(2, "0"); - const minutes = String(now.getMinutes()).padStart(2, "0"); - const seconds = String(now.getSeconds()).padStart(2, "0"); - const milliseconds = String(now.getMilliseconds()).padStart(3, "0"); - return `${hours}:${minutes}:${seconds}.${milliseconds}`; -} -function info(_data, _options = {}) { - print(source_default.blue.bold("Ink info:"), _data, _options); -} -function warn(_data, _options = {}) { - print(source_default.yellow.bold("Ink warn:"), _data, _options); -} -function error(_data, _options = {}) { - print(source_default.red.bold("Ink error:"), _data, _options); -} -function debug(_data, _options = {}) { - if (true) - return; - print(source_default.green.bold("Ink debug:"), _data, _options); -} -function verbose(_data, _options = {}) { - if (true) - return; - print(source_default.cyan.bold("Ink verbose:"), _data, _options); -} -function print(_label, _data, _options = {}) { - if (_data instanceof Array) { - printArray(_label, _data, _options); - } else if (_data instanceof Object) { - printTimestampAndLabel(_label); - printObj(_data, _options); - printEmptyLine(); - } else { - printStr(`${getTimestampAndLabel(_label)} ${_data}`); - } -} -function printArray(_label, _data, _options = {}) { - let accString = ""; - if (_data[0] instanceof Object) { - printTimestampAndLabel(_label); - } - for (let i = 0; i < _data.length; i++) { - if (_data[i] instanceof Object) { - if (accString.length) { - printStr(accString); - accString = ""; - } - printObj(_data[i], _options); - } else { - if (i === 0) { - accString = `${getTimestampAndLabel(_label)} ${_data[i]}`; - } else { - if (accString.length) { - accString = `${accString} ${_data[i]}`; - } else { - accString = `${_label} ${_data[i]}`; - } - } - if (i === _data.length - 1) { - printStr(accString); - } - } - } - if (_data[_data.length - 1] instanceof Object) { - printEmptyLine(); - } -} -function printStr(_str) { - console.log(`${_str}`); -} -function printObj(_data, _options) { - let data; - if (_options.freeze) { - data = JSON.parse(JSON.stringify(_data)); - } else { - data = _data; - } - if (_options.stringify) { - data = JSON.stringify(data, null, 2); - } - console.log(data); -} -function printTimestampAndLabel(_label) { - console.log(getTimestampAndLabel(_label)); -} -function printEmptyLine() { - console.log(""); -} -function getTimestampAndLabel(_label) { - return `${source_default.grey(getTimestamp2())} ${_label}`; -} - -// src/utils/tldraw-helpers.ts -function getActivityType(entry) { - const activitySummary = getActivitySummary(entry); - if (activitySummary.drawShapesCompleted) - return 5 /* DrawingCompleted */; - if (activitySummary.drawShapesStarted) - return 3 /* DrawingStarted */; - if (activitySummary.drawShapesContinued) - return 4 /* DrawingContinued */; - if (activitySummary.drawShapesRemoved) - return 6 /* DrawingErased */; - if (activitySummary.cameraMoved && activitySummary.pointerMoved) - return 1 /* CameraMovedManually */; - if (activitySummary.cameraMoved && !activitySummary.pointerMoved) - return 2 /* CameraMovedAutomatically */; - if (activitySummary.pointerMoved) - return 0 /* PointerMoved */; - return 8 /* Unclassified */; -} -function getActivitySummary(entry) { - const summary = { - pointerMoved: false, - pointerScribbled: false, - cameraMoved: false, - drawShapesStarted: 0, - drawShapesContinued: 0, - drawShapesCompleted: 0, - drawShapesRemoved: 0 - }; - const addedRecords = Object.values(entry.changes.added); - if (addedRecords) { - for (let i = 0; i < addedRecords.length; i++) { - const record = addedRecords[i]; - if (record.typeName == "shape" && record.type == "draw") { - summary.drawShapesStarted += 1; - if ("isComplete" in record.props && record.props.isComplete === true) { - summary.drawShapesCompleted += 1; - } - ; - } - } - } - const updatedRecords = Object.values(entry.changes.updated); - if (updatedRecords) { - for (let i = 0; i < updatedRecords.length; i++) { - const recordFinalState = updatedRecords[i][1]; - if (recordFinalState.typeName == "shape" && recordFinalState.type == "draw") { - if ("isComplete" in recordFinalState.props && recordFinalState.props.isComplete === true) { - summary.drawShapesCompleted += 1; - } else { - summary.drawShapesContinued += 1; - } - } else if (recordFinalState.typeName == "pointer") { - summary.pointerMoved = true; - } else if (recordFinalState.typeName == "camera") { - summary.cameraMoved = true; - } else if (recordFinalState.typeName == "instance") { - if (recordFinalState.scribbles) - summary.pointerScribbled = true; - } - } - } - const removedRecords = Object.values(entry.changes.removed); - if (removedRecords) { - for (let i = 0; i < removedRecords.length; i++) { - const record = removedRecords[i]; - if (record.typeName == "shape" && record.type == "draw") { - summary.drawShapesRemoved += 1; - } - } - } - return summary; -} -function preventTldrawCanvasesCausingObsidianGestures(tlEditor) { - const tlContainer = tlEditor.getContainer(); - const tlCanvas = tlContainer.getElementsByClassName("tl-canvas")[0]; - if (!tlCanvas) - return; - tlCanvas.addEventListener("touchmove", (e) => { - e.stopPropagation(); - }); -} -function initWritingCamera(editor, topMarginPx = 0) { - let canvasWidth = editor.getContainer().innerWidth; - let containerMargin = 0; - let containerWidth = 2e3; - let visibleWidth = containerWidth + 2 * containerMargin; - const zoom = canvasWidth / visibleWidth; - let x = containerMargin; - let y = topMarginPx; - silentlyChangeStore(editor, () => { - editor.setCamera({ - x, - y, - z: zoom - }); - }); -} -function initDrawingCamera(editor) { - const allShapesBounds = editor.getCurrentPageBounds(); - if (!allShapesBounds) { - const curCameraProps = editor.getCamera(); - editor.setCamera({ ...curCameraProps, z: 0.3 }); - return; - } - ; - const targetZoom = 1; - editor.zoomToBounds(allShapesBounds, { targetZoom }); -} -function initWritingCameraLimits(editor) { - return { - x: { - min: editor.getCamera().x, - max: editor.getCamera().x - }, - zoom: { - min: editor.getCamera().z, - max: editor.getCamera().z - } - }; -} -function restrictWritingCamera(editor, cameraLimits) { - const bounds = editor.getCurrentPageBounds(); - if (!bounds) - return; - const yMin = bounds.minY - 500; - const yMax = bounds.maxY + 1e3; - let x = editor.getCamera().x; - let y = editor.getCamera().y; - let zoom = editor.getZoomLevel(); - x = Math.max(x, cameraLimits.x.min); - x = Math.min(x, cameraLimits.x.max); - y = Math.max(y, yMin); - y = Math.min(y, yMax); - zoom = Math.max(zoom, cameraLimits.zoom.min); - zoom = Math.min(zoom, cameraLimits.zoom.max); - silentlyChangeStore(editor, () => { - editor.setCamera({ - x, - y, - z: zoom - }); - }); -} -function adaptTldrawToObsidianThemeMode(editor) { - const isDarkMode = document.body.classList.contains("theme-dark"); - if (isDarkMode) { - setUserPreferences({ - id: "dummy-id", - colorScheme: "dark" - }); - } else { - setUserPreferences({ - id: "dummy-id", - colorScheme: "light" - }); - } -} -function getCompleteShapes(editor) { - const allShapes = editor.getCurrentPageShapes(); - let completeShapes = []; - for (let i = 0; i < allShapes.length; i++) { - const shape = allShapes[i]; - if ("isComplete" in shape.props && shape.props.isComplete === true) { - completeShapes.push(shape); - } - } - completeShapes.sort((a, b) => { - return a.y - b.y; - }); - return completeShapes; -} -var useStash = (plugin) => { - const stash = (0, import_react119.useRef)([]); - const stashStaleContent = (editor) => { - const completeShapes = getCompleteShapes(editor); - const staleShapeIds = []; - const staleShapes = []; - for (let i = 0; i <= completeShapes.length - plugin.settings.writingStrokeLimit; i++) { - const record = completeShapes[i]; - if (record.type !== "draw") - return; - staleShapeIds.push(record.id); - staleShapes.push(record); - } - stash.current.push(...staleShapes); - silentlyChangeStore(editor, () => { - editor.store.remove(staleShapeIds); - }); - try { - if (staleShapeIds.length >= 5) - showStrokeLimitTips_maybe(plugin); - } catch (error3) { - verbose("Error from stashing stale content (when calling showStrokeLimitTips_maybe)", error3); - } - }; - const unstashStaleContent = (editor) => { - silentlyChangeStore(editor, () => { - editor.store.put(stash.current); - }); - stash.current.length = 0; - }; - return { stashStaleContent, unstashStaleContent }; -}; -var hideWritingTemplate = (editor) => { - hideWritingContainer(editor); - hideWritingLines(editor); -}; -var unhideWritingTemplate = (editor) => { - unhideWritingContainer(editor); - unhideWritingLines(editor); -}; -var hideWritingContainer = (editor) => { - const writingContainerShape = editor.getShape("shape:writing-container"); - if (!writingContainerShape) - return; - const savedH = writingContainerShape.props.h; - silentlyChangeStore(editor, () => { - unlockShape(editor, writingContainerShape); - editor.updateShape({ - id: writingContainerShape.id, - type: writingContainerShape.type, - props: { - h: 0 - }, - meta: { - savedH - } - }); - lockShape(editor, writingContainerShape); - }); -}; -var hideWritingLines = (editor) => { - const writingLinesShape = editor.getShape("shape:writing-lines"); - if (!writingLinesShape) - return; - const savedH = writingLinesShape.props.h; - editor.store.update(writingLinesShape.id, (record) => { - record.isLocked = false; - return record; - }); - silentlyChangeStore(editor, () => { - unlockShape(editor, writingLinesShape); - editor.updateShape({ - id: writingLinesShape.id, - type: writingLinesShape.type, - props: { - h: 0 - }, - meta: { - savedH - } - }); - lockShape(editor, writingLinesShape); - }); -}; -var unhideWritingContainer = (editor) => { - const writingContainerShape = editor.getShape("shape:writing-container"); - if (!writingContainerShape) - return; - const h = writingContainerShape.meta.savedH; - silentlyChangeStore(editor, () => { - unlockShape(editor, writingContainerShape); - editor.updateShape({ - id: writingContainerShape.id, - type: writingContainerShape.type, - props: { - h - }, - meta: { - savedH: void 0 - } - }); - lockShape(editor, writingContainerShape); - }); -}; -var unhideWritingLines = (editor) => { - const writingLinesShape = editor.getShape("shape:writing-lines"); - if (!writingLinesShape) - return; - const h = writingLinesShape.meta.savedH; - silentlyChangeStore(editor, () => { - unlockShape(editor, writingLinesShape); - editor.updateShape({ - id: writingLinesShape.id, - type: writingLinesShape.type, - props: { - h - }, - meta: { - savedH: void 0 - } - }); - lockShape(editor, writingLinesShape); - }); -}; -var silentlyChangeStore = (editor, func) => { - editor.run(() => { - editor.store.mergeRemoteChanges(func); - }, { - history: "ignore" - }); -}; -function prepareWritingSnapshot(TLEditorSnapshot4) { - return deleteObsoleteWritingTemplateShapes(TLEditorSnapshot4); -} -function prepareDrawingSnapshot(tlEditorSnapshot) { - return tlEditorSnapshot; -} -function deleteObsoleteWritingTemplateShapes(TLEditorSnapshot4) { - const updatedSnapshot = JSON.parse(JSON.stringify(TLEditorSnapshot4)); - let obsoleteShapeIds = [ - "shape:primary_container", - "shape:handwriting_lines" - ]; - let updatedStore = TLEditorSnapshot4?.document?.store; - if (!updatedStore) { - updatedStore = TLEditorSnapshot4.store; - } - const filteredStore = Object.entries(updatedStore).filter(([key, tlRecord]) => { - const isObsoleteObj = obsoleteShapeIds.some((obsId) => tlRecord.id === obsId); - if (isObsoleteObj) { - info(["Removing old ink elements to update file:", tlRecord]); - return false; - } - return true; - }); - updatedStore = Object.fromEntries(filteredStore); - return updatedSnapshot; -} -var updateWritingStoreIfNeeded = (editor) => { - addNewTemplateShapes(editor); -}; -function addNewTemplateShapes(editor) { - const hasLines = editor.store.has("shape:writing-lines"); - if (!hasLines) { - editor.createShape({ - id: "shape:writing-lines", - type: "writing-lines" - }); - } - const hasContainer = editor.store.has("shape:writing-container"); - if (!hasContainer) { - editor.createShape({ - id: "shape:writing-container", - type: "writing-container" - }); - } -} -function unlockShape(editor, shape) { - editor.store.update(shape.id, (record) => { - const newRecord = JSON.parse(JSON.stringify(record)); - newRecord.isLocked = false; - return newRecord; - }); -} -function lockShape(editor, shape) { - editor.store.update(shape.id, (record) => { - const newRecord = JSON.parse(JSON.stringify(record)); - newRecord.isLocked = true; - return newRecord; - }); -} -function getWritingContainerBounds(editor) { - const bounds = editor.getShapePageBounds("shape:writing-container"); - if (bounds) { - return bounds; - } else { - return new Box(); - } -} -async function getWritingSvg(editor) { - let svgObj; - resizeWritingTemplateTightly(editor); - const allShapeIds = Array.from(editor.getCurrentPageShapeIds().values()); - svgObj = await editor.getSvgString(allShapeIds); - resizeWritingTemplateInvitingly(editor); - return svgObj; -} -function getAllStrokeBounds(editor) { - const allStrokeBounds = getDrawShapeBounds(editor); - allStrokeBounds.x = 0; - allStrokeBounds.w = WRITING_PAGE_WIDTH; - allStrokeBounds.h += allStrokeBounds.y; - allStrokeBounds.y = 0; - return allStrokeBounds; -} -function getDrawShapeBounds(editor) { - hideWritingTemplate(editor); - let bounds = editor.getCurrentPageBounds() || new Box(0, 0); - unhideWritingTemplate(editor); - return bounds; -} -function cropWritingStrokeHeightTightly(height) { - const numFilledLines = Math.ceil(height / WRITING_LINE_HEIGHT); - const newLineHeight = (numFilledLines + 0.5) * WRITING_LINE_HEIGHT; - return Math.max(newLineHeight, WRITING_MIN_PAGE_HEIGHT); -} -function cropWritingStrokeHeightInvitingly(height) { - const numFilledLines = Math.ceil(height / WRITING_LINE_HEIGHT); - const newLineHeight = (numFilledLines + 2 + 0.5) * WRITING_LINE_HEIGHT; - return Math.max(newLineHeight, WRITING_MIN_PAGE_HEIGHT); -} -var resizeWritingTemplateInvitingly = (editor) => { - verbose("resizeWritingTemplateInvitingly"); - let contentBounds = getAllStrokeBounds(editor); - if (!contentBounds) - return; - contentBounds.h = cropWritingStrokeHeightInvitingly(contentBounds.h); - const writingLinesShape = editor.getShape("shape:writing-lines"); - const writingContainerShape = editor.getShape("shape:writing-container"); - if (!writingLinesShape) - return; - if (!writingContainerShape) - return; - silentlyChangeStore(editor, () => { - unlockShape(editor, writingContainerShape); - unlockShape(editor, writingLinesShape); - editor.updateShape({ - id: writingContainerShape.id, - type: writingContainerShape.type, - props: { - h: contentBounds.h - } - }); - editor.updateShape({ - id: writingLinesShape.id, - type: writingLinesShape.type, - props: { - h: contentBounds.h - } - }); - lockShape(editor, writingContainerShape); - lockShape(editor, writingLinesShape); - }); -}; -var resizeWritingTemplateTightly = (editor) => { - verbose("resizeWritingTemplateTightly"); - let contentBounds = getAllStrokeBounds(editor); - if (!contentBounds) - return; - contentBounds.h = cropWritingStrokeHeightTightly(contentBounds.h); - const writingLinesShape = editor.getShape("shape:writing-lines"); - const writingContainerShape = editor.getShape("shape:writing-container"); - silentlyChangeStore(editor, () => { - unlockShape(editor, writingContainerShape); - unlockShape(editor, writingLinesShape); - editor.updateShape({ - id: writingContainerShape.id, - type: writingContainerShape.type, - props: { - h: contentBounds.h - } - }); - editor.updateShape({ - id: writingLinesShape.id, - type: writingLinesShape.type, - props: { - h: contentBounds.h - } - }); - lockShape(editor, writingContainerShape); - lockShape(editor, writingLinesShape); - }); -}; -async function getDrawingSvg(editor) { - const allShapeIds = Array.from(editor.getCurrentPageShapeIds().values()); - const svgObj = await editor.getSvgString(allShapeIds); - return svgObj; -} -function focusChildTldrawEditor(containerEl) { - if (containerEl) { - containerEl.find(".tl-container").focus({ preventScroll: true }); - } -} - -// src/tldraw/writing-shapes/writing-container.tsx -var React71 = __toESM(require_react()); -var WritingContainerUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - this.canBind = (opts) => false; - this.hideRotateHandle = (shape) => true; - this.onTranslate = (initShape, newShape) => { - return initShape; - }; - this.onResize = (shape, info2) => { - return resizeBox(shape, info2, { - minWidth: WRITING_PAGE_WIDTH, - maxWidth: WRITING_PAGE_WIDTH, - minHeight: WRITING_MIN_PAGE_HEIGHT, - maxHeight: 5e4 - }); - }; - } - getDefaultProps() { - return { - w: WRITING_PAGE_WIDTH, - h: WRITING_MIN_PAGE_HEIGHT - }; - } - getGeometry(shape) { - return new Rectangle2d({ - width: shape.props.w, - height: shape.props.h, - isFilled: false - }); - } - component(shape) { - return /* @__PURE__ */ React71.createElement(SVGContainer, null, this.createSvg(shape)); - } - indicator(shape) { - return /* @__PURE__ */ React71.createElement(React71.Fragment, null, /* @__PURE__ */ React71.createElement("rect", { - width: shape.props.w, - height: shape.props.h, - rx: 20, - ry: 20 - })); - } - toSvg(shape, ctx) { - return this.createSvg(shape); - } - createSvg(shape) { - this.isAspectRatioLocked(shape); - return /* @__PURE__ */ React71.createElement(React71.Fragment, null, /* @__PURE__ */ React71.createElement("rect", { - width: shape.props.w, - height: shape.props.h, - opacity: 0 - })); - } -}; -WritingContainerUtil.type = "writing-container"; - -// src/tldraw/writing-menu/writing-menu.tsx -var React75 = __toESM(require_react()); - -// src/graphics/icons/write-icon.tsx -var React72 = __toESM(require_react()); -var WriteIcon = (props) => /* @__PURE__ */ React72.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React72.createElement("path", { - d: "m499-287 335-335-52-52-335 335 52 52Zm-379-62q0 29 20 45t66 21q16 2 25.5 14.5T240-240q-1 17-12 28t-27 9q-81-10-121-46.5T40-349q0-65 53.5-105.5T242-503q39-3 58.5-12.5T320-542q0-22-21-34.5T230-596q-16-2-25.5-15t-7.5-29q2-17 14-27.5t28-8.5q83 12 122 44.5t39 89.5q0 53-38.5 83T248-423q-64 5-96 23.5T120-349Zm398 156L353-358l382-382q20-20 47.5-20t47.5 20l70 70q20 20 20 47.5T900-575L518-193Zm-159 33q-17 4-30-9t-9-30l33-159 165 165-159 33Z" -})); - -// src/graphics/icons/erase-icon.tsx -var React73 = __toESM(require_react()); -var EraseIcon = (props) => /* @__PURE__ */ React73.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React73.createElement("path", { - d: "M690-240h150q17 0 28.5 11.5T880-200q0 17-11.5 28.5T840-160H610l80-80Zm-483 80q-8 0-15.5-3t-13.5-9l-73-73q-23-23-23.5-57t22.5-58l440-456q23-24 56.5-24t56.5 23l199 199q23 23 23 57t-23 57L532-172q-6 6-13.5 9t-15.5 3H207Zm279-80 314-322-198-198-442 456 64 64h262Zm-6-240Z" -})); - -// src/graphics/icons/select-icon.tsx -var React74 = __toESM(require_react()); -var SelectIcon = (props) => /* @__PURE__ */ React74.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React74.createElement("path", { - d: "m320-410 79-110h170L320-716v306Zm286 305q-23 11-46 2.5T526-134L406-392l-93 130q-17 24-45 15t-28-38v-513q0-25 22.5-36t42.5 5l404 318q23 17 13.5 44T684-440H516l119 255q11 23 2.5 46T606-105ZM399-520Z" -})); - -// src/tldraw/writing-menu/writing-menu.tsx -var import_classnames30 = __toESM(require_classnames()); -var WritingMenu = (props) => { - const [curTool, setCurTool] = React75.useState("draw" /* draw */); - function undo() { - const tlEditor = props.getTlEditor(); - if (!tlEditor) - return; - silentlyChangeStore(tlEditor, () => { - tlEditor.undo(); - }); - props.onStoreChange(tlEditor); - } - function redo() { - const tlEditor = props.getTlEditor(); - if (!tlEditor) - return; - silentlyChangeStore(tlEditor, () => { - tlEditor.redo(); - }); - props.onStoreChange(tlEditor); - } - function activateSelectTool() { - const tlEditor = props.getTlEditor(); - if (!tlEditor) - return; - tlEditor.setCurrentTool("select"); - setCurTool("select" /* select */); - } - function activateDrawTool() { - const tlEditor = props.getTlEditor(); - if (!tlEditor) - return; - tlEditor.setCurrentTool("draw"); - setCurTool("draw" /* draw */); - } - function activateEraseTool() { - const tlEditor = props.getTlEditor(); - if (!tlEditor) - return; - tlEditor.setCurrentTool("eraser"); - setCurTool("eraser" /* eraser */); - } - return /* @__PURE__ */ React75.createElement(React75.Fragment, null, /* @__PURE__ */ React75.createElement("div", { - className: (0, import_classnames30.default)([ - "ink_menu-bar", - "ink_menu-bar_full" - ]) - }, /* @__PURE__ */ React75.createElement("div", { - className: "ink_tool-menu" - }, /* @__PURE__ */ React75.createElement("button", { - onPointerDown: activateSelectTool, - disabled: curTool === "select" /* select */ - }, /* @__PURE__ */ React75.createElement(SelectIcon, null)), /* @__PURE__ */ React75.createElement("button", { - onPointerDown: activateDrawTool, - disabled: curTool === "draw" /* draw */ - }, /* @__PURE__ */ React75.createElement(WriteIcon, null)), /* @__PURE__ */ React75.createElement("button", { - onPointerDown: activateEraseTool, - disabled: curTool === "eraser" /* eraser */ - }, /* @__PURE__ */ React75.createElement(EraseIcon, null))), /* @__PURE__ */ React75.createElement("div", { - className: "ink_other-menu" - }))); -}; - -// src/tldraw/writing/tldraw-writing-editor.tsx -var React86 = __toESM(require_react()); - -// src/tldraw/primary-menu-bar/primary-menu-bar.tsx -var import_classnames31 = __toESM(require_classnames()); -var React76 = __toESM(require_react()); -var PrimaryMenuBar = (props) => { - const scrollContainerElRef = React76.useRef(null); - const primaryMenuBarElRef = React76.useRef(null); - const [menuActive, setMenuActive] = React76.useState(true); - React76.useEffect(() => { - initScrollHandler(); - return () => { - cleanUpScrollHandler(); - }; - }); - return /* @__PURE__ */ React76.createElement(React76.Fragment, null, /* @__PURE__ */ React76.createElement("div", { - ref: primaryMenuBarElRef, - className: (0, import_classnames31.default)([ - "ink_primary-menu-bar", - menuActive && "ddc_ink_active" - ]) - }, props.children)); - function initScrollHandler() { - const primaryMenuBar = primaryMenuBarElRef.current; - const scrollEl = primaryMenuBar?.closest(".cm-scroller"); - if (!scrollEl) - return; - scrollEl.addEventListener("scroll", handleScrolling); - scrollEl.dispatchEvent(new CustomEvent("scroll")); - } - function cleanUpScrollHandler() { - const scrollEl = scrollContainerElRef.current; - scrollEl?.removeEventListener("scroll", handleScrolling); - } - function handleScrolling(e) { - const scrollAreaEl = e.target; - const pageScrollY = scrollAreaEl.scrollTop; - const primaryMenuBar = primaryMenuBarElRef.current; - const embedEl = primaryMenuBar?.parentElement; - if (!primaryMenuBar) - return; - if (!embedEl) - return; - const menuBarHeight = primaryMenuBar.getBoundingClientRect().height; - const embedHeight = embedEl.getBoundingClientRect().height; - let embedPosY = embedEl.getBoundingClientRect().top - scrollAreaEl.getBoundingClientRect().top || 0; - if (menuActive) { - embedPosY -= Number(menuBarHeight); - } - const embedOffsetY = embedPosY; - const embedTopScrolledOffTop = embedOffsetY < 0; - const embedBottomScrolledOffTop = embedOffsetY + embedHeight < 0; - if (embedBottomScrolledOffTop) { - const top = embedHeight + "px"; - primaryMenuBar.style.top = top; - } else if (embedTopScrolledOffTop) { - const top = embedOffsetY * -1 + "px"; - primaryMenuBar.style.top = top; - } else { - primaryMenuBar.style.removeProperty("top"); - } - } -}; - -// src/graphics/icons/lock-icon.tsx -var React77 = __toESM(require_react()); -var LockIcon = (props) => /* @__PURE__ */ React77.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React77.createElement("path", { - d: "M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80ZM240-160v-400 400Z" -})); - -// src/tldraw/extended-writing-menu/extended-writing-menu.tsx -var React80 = __toESM(require_react()); - -// src/tldraw/overflow-menu/overflow-menu.tsx -var import_obsidian6 = require("obsidian"); -var React79 = __toESM(require_react()); - -// src/graphics/icons/overflow-icon.tsx -var React78 = __toESM(require_react()); -var OverflowIcon = (props) => /* @__PURE__ */ React78.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React78.createElement("path", { - d: "M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z" -})); - -// src/tldraw/overflow-menu/overflow-menu.tsx -var OverflowMenu = (props) => { - const menu = new import_obsidian6.Menu(); - props.menuOptions.forEach((menuOption) => { - menu.addItem((item) => item.setTitle(menuOption.text).onClick(() => { - menuOption.action(); - })); - }); - return /* @__PURE__ */ React79.createElement(React79.Fragment, null, /* @__PURE__ */ React79.createElement("div", { - className: "ddc_ink_overflow-button-and-menu" - }, /* @__PURE__ */ React79.createElement("button", { - className: "ddc_ink_btn-slim", - onClick: (e) => { - menu.showAtMouseEvent(e.nativeEvent); - } - }, /* @__PURE__ */ React79.createElement(OverflowIcon, null)))); - { - } - { - } -}; -var overflow_menu_default = OverflowMenu; - -// src/tldraw/extended-writing-menu/extended-writing-menu.tsx -var ExtendedWritingMenu = (props) => { - return /* @__PURE__ */ React80.createElement(React80.Fragment, null, /* @__PURE__ */ React80.createElement("div", { - className: "ink_extended-writing-menu" - }, /* @__PURE__ */ React80.createElement("button", { - onPointerDown: () => props.onLockClick() - }, /* @__PURE__ */ React80.createElement(LockIcon, null)), /* @__PURE__ */ React80.createElement(overflow_menu_default, { - menuOptions: props.menuOptions - }))); -}; -var extended_writing_menu_default = ExtendedWritingMenu; - -// src/tldraw/writing/tldraw-writing-editor.tsx -var import_classnames34 = __toESM(require_classnames()); - -// src/tldraw/writing-shapes/writing-lines.tsx -var React81 = __toESM(require_react()); -var WritingLinesUtil = class extends ShapeUtil { - constructor() { - super(...arguments); - this.canBind = (opts) => false; - this.hideRotateHandle = (shape) => true; - this.onTranslate = (initShape, newShape) => { - return initShape; - }; - this.onResize = (shape, info2) => { - return resizeBox(shape, info2, { - minWidth: WRITING_PAGE_WIDTH, - maxWidth: WRITING_PAGE_WIDTH, - minHeight: WRITING_MIN_PAGE_HEIGHT, - maxHeight: 5e4 - }); - }; - } - getDefaultProps() { - return { - x: 0, - y: 0, - w: WRITING_PAGE_WIDTH, - h: WRITING_MIN_PAGE_HEIGHT - }; - } - getGeometry(shape) { - return new Rectangle2d({ - width: shape.props.w, - height: shape.props.h, - isFilled: false - }); - } - indicator(shape) { - return /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement("rect", { - width: shape.props.w, - height: shape.props.h, - rx: 20, - ry: 20 - })); - } - component(shape) { - return /* @__PURE__ */ React81.createElement(SVGContainer, null, this.createSvg(shape)); - } - toSvg(shape, ctx) { - return this.createSvg(shape); - } - createSvg(shape) { - const numberOfLines = Math.floor(shape.props.h / WRITING_LINE_HEIGHT); - const margin = 0.05 * shape.props.w; - this.isAspectRatioLocked(shape); - const lines = Array.from({ length: numberOfLines }, (_, index2) => /* @__PURE__ */ React81.createElement("line", { - key: index2, - x1: margin, - y1: (index2 + 1) * WRITING_LINE_HEIGHT, - x2: shape.props.w - margin, - y2: (index2 + 1) * WRITING_LINE_HEIGHT - })); - return /* @__PURE__ */ React81.createElement(React81.Fragment, null, lines); - } -}; -WritingLinesUtil.type = "writing-lines"; - -// node_modules/jotai/esm/vanilla.mjs -var import_meta = {}; -var keyCount = 0; -function atom2(read, write) { - const key = `atom${++keyCount}`; - const config = { - toString() { - return (import_meta.env ? import_meta.env.MODE : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key; - } - }; - if (typeof read === "function") { - config.read = read; - } else { - config.init = read; - config.read = defaultRead; - config.write = defaultWrite; - } - if (write) { - config.write = write; - } - return config; -} -function defaultRead(get) { - return get(this); -} -function defaultWrite(get, set, arg) { - return set(this, typeof arg === "function" ? arg(get(this)) : arg); -} -var isSelfAtom = (atom3, a) => atom3.unstable_is ? atom3.unstable_is(a) : a === atom3; -var hasInitialValue = (atom3) => "init" in atom3; -var isActuallyWritableAtom = (atom3) => !!atom3.write; -var CONTINUE_PROMISE = Symbol((import_meta.env ? import_meta.env.MODE : void 0) !== "production" ? "CONTINUE_PROMISE" : ""); -var PENDING = "pending"; -var FULFILLED = "fulfilled"; -var REJECTED = "rejected"; -var isContinuablePromise = (promise) => typeof promise === "object" && promise !== null && CONTINUE_PROMISE in promise; -var continuablePromiseMap = /* @__PURE__ */ new WeakMap(); -var createContinuablePromise = (promise, abort, complete) => { - if (!continuablePromiseMap.has(promise)) { - let continuePromise; - const p = new Promise((resolve, reject) => { - let curr = promise; - const onFulfilled = (me) => (v) => { - if (curr === me) { - p.status = FULFILLED; - p.value = v; - resolve(v); - complete(); - } - }; - const onRejected = (me) => (e) => { - if (curr === me) { - p.status = REJECTED; - p.reason = e; - reject(e); - complete(); - } - }; - promise.then(onFulfilled(promise), onRejected(promise)); - continuePromise = (nextPromise, nextAbort) => { - if (nextPromise) { - continuablePromiseMap.set(nextPromise, p); - curr = nextPromise; - nextPromise.then(onFulfilled(nextPromise), onRejected(nextPromise)); - abort(); - abort = nextAbort; - } - }; - }); - p.status = PENDING; - p[CONTINUE_PROMISE] = continuePromise; - continuablePromiseMap.set(promise, p); - } - return continuablePromiseMap.get(promise); -}; -var isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function"; -var isAtomStateInitialized = (atomState) => "v" in atomState || "e" in atomState; -var returnAtomValue = (atomState) => { - if ("e" in atomState) { - throw atomState.e; - } - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && !("v" in atomState)) { - throw new Error("[Bug] atom state is not initialized"); - } - return atomState.v; -}; -var getPendingContinuablePromise = (atomState) => { - const value = atomState.v; - if (isContinuablePromise(value) && value.status === PENDING) { - return value; - } - return null; -}; -var addPendingContinuablePromiseToDependency = (atom3, promise, dependencyAtomState) => { - if (!dependencyAtomState.p.has(atom3)) { - dependencyAtomState.p.add(atom3); - promise.then(() => { - dependencyAtomState.p.delete(atom3); - }, () => { - dependencyAtomState.p.delete(atom3); - }); - } -}; -var addDependency = (pending, atom3, atomState, a, aState) => { - var _a; - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && a === atom3) { - throw new Error("[Bug] atom cannot depend on itself"); - } - atomState.d.set(a, aState.n); - const continuablePromise = getPendingContinuablePromise(atomState); - if (continuablePromise) { - addPendingContinuablePromiseToDependency(atom3, continuablePromise, aState); - } - (_a = aState.m) == null ? void 0 : _a.t.add(atom3); - if (pending) { - addPendingDependent(pending, a, atom3); - } -}; -var createPending = () => [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set()]; -var addPendingAtom = (pending, atom3, atomState) => { - if (!pending[0].has(atom3)) { - pending[0].set(atom3, /* @__PURE__ */ new Set()); - } - pending[1].set(atom3, atomState); -}; -var addPendingDependent = (pending, atom3, dependent) => { - const dependents = pending[0].get(atom3); - if (dependents) { - dependents.add(dependent); - } -}; -var getPendingDependents = (pending, atom3) => pending[0].get(atom3); -var addPendingFunction = (pending, fn) => { - pending[2].add(fn); -}; -var flushPending = (pending) => { - while (pending[1].size || pending[2].size) { - pending[0].clear(); - const atomStates = new Set(pending[1].values()); - pending[1].clear(); - const functions = new Set(pending[2]); - pending[2].clear(); - atomStates.forEach((atomState) => { - var _a; - return (_a = atomState.m) == null ? void 0 : _a.l.forEach((l) => l()); - }); - functions.forEach((fn) => fn()); - } -}; -var buildStore = (getAtomState) => { - let debugMountedAtoms; - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") { - debugMountedAtoms = /* @__PURE__ */ new Set(); - } - const setAtomStateValueOrPromise = (atom3, atomState, valueOrPromise, abortPromise = () => { - }, completePromise = () => { - }) => { - const hasPrevValue = "v" in atomState; - const prevValue = atomState.v; - const pendingPromise = getPendingContinuablePromise(atomState); - if (isPromiseLike(valueOrPromise)) { - if (pendingPromise) { - if (pendingPromise !== valueOrPromise) { - pendingPromise[CONTINUE_PROMISE](valueOrPromise, abortPromise); - ++atomState.n; - } - } else { - const continuablePromise = createContinuablePromise(valueOrPromise, abortPromise, completePromise); - if (continuablePromise.status === PENDING) { - for (const a of atomState.d.keys()) { - addPendingContinuablePromiseToDependency(atom3, continuablePromise, getAtomState(a, atomState)); - } - } - atomState.v = continuablePromise; - delete atomState.e; - } - } else { - if (pendingPromise) { - pendingPromise[CONTINUE_PROMISE](Promise.resolve(valueOrPromise), abortPromise); - } - atomState.v = valueOrPromise; - delete atomState.e; - } - if (!hasPrevValue || !Object.is(prevValue, atomState.v)) { - ++atomState.n; - } - }; - const readAtomState = (pending, atom3, atomState, force) => { - if (!(force == null ? void 0 : force(atom3)) && isAtomStateInitialized(atomState)) { - if (atomState.m) { - return atomState; - } - if (Array.from(atomState.d).every(([a, n]) => readAtomState(pending, a, getAtomState(a, atomState), force).n === n)) { - return atomState; - } - } - atomState.d.clear(); - let isSync = true; - const getter = (a) => { - if (isSelfAtom(atom3, a)) { - const aState2 = getAtomState(a, atomState); - if (!isAtomStateInitialized(aState2)) { - if (hasInitialValue(a)) { - setAtomStateValueOrPromise(a, aState2, a.init); - } else { - throw new Error("no atom init"); - } - } - return returnAtomValue(aState2); - } - const aState = readAtomState(pending, a, getAtomState(a, atomState), force); - if (isSync) { - addDependency(pending, atom3, atomState, a, aState); - } else { - const pending2 = createPending(); - addDependency(pending2, atom3, atomState, a, aState); - mountDependencies(pending2, atom3, atomState); - flushPending(pending2); - } - return returnAtomValue(aState); - }; - let controller; - let setSelf; - const options = { - get signal() { - if (!controller) { - controller = new AbortController(); - } - return controller.signal; - }, - get setSelf() { - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom3)) { - console.warn("setSelf function cannot be used with read-only atom"); - } - if (!setSelf && isActuallyWritableAtom(atom3)) { - setSelf = (...args) => { - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && isSync) { - console.warn("setSelf function cannot be called in sync"); - } - if (!isSync) { - return writeAtom(atom3, ...args); - } - }; - } - return setSelf; - } - }; - try { - const valueOrPromise = atom3.read(getter, options); - setAtomStateValueOrPromise(atom3, atomState, valueOrPromise, () => controller == null ? void 0 : controller.abort(), () => { - if (atomState.m) { - const pending2 = createPending(); - mountDependencies(pending2, atom3, atomState); - flushPending(pending2); - } - }); - return atomState; - } catch (error3) { - delete atomState.v; - atomState.e = error3; - ++atomState.n; - return atomState; - } finally { - isSync = false; - } - }; - const readAtom = (atom3) => returnAtomValue(readAtomState(void 0, atom3, getAtomState(atom3))); - const getDependents = (pending, atom3, atomState) => { - var _a, _b; - const dependents = /* @__PURE__ */ new Map(); - for (const a of ((_a = atomState.m) == null ? void 0 : _a.t) || []) { - dependents.set(a, getAtomState(a, atomState)); - } - for (const atomWithPendingContinuablePromise of atomState.p) { - dependents.set(atomWithPendingContinuablePromise, getAtomState(atomWithPendingContinuablePromise, atomState)); - } - (_b = getPendingDependents(pending, atom3)) == null ? void 0 : _b.forEach((dependent) => { - dependents.set(dependent, getAtomState(dependent, atomState)); - }); - return dependents; - }; - const recomputeDependents = (pending, atom3, atomState) => { - const topsortedAtoms = []; - const markedAtoms = /* @__PURE__ */ new Set(); - const visit = (a, aState) => { - if (markedAtoms.has(a)) { - return; - } - markedAtoms.add(a); - for (const [d, s] of getDependents(pending, a, aState)) { - if (a !== d) { - visit(d, s); - } - } - topsortedAtoms.push([a, aState, aState.n]); - }; - visit(atom3, atomState); - const changedAtoms = /* @__PURE__ */ new Set([atom3]); - const isMarked = (a) => markedAtoms.has(a); - for (let i = topsortedAtoms.length - 1; i >= 0; --i) { - const [a, aState, prevEpochNumber] = topsortedAtoms[i]; - let hasChangedDeps = false; - for (const dep of aState.d.keys()) { - if (dep !== a && changedAtoms.has(dep)) { - hasChangedDeps = true; - break; - } - } - if (hasChangedDeps) { - readAtomState(pending, a, aState, isMarked); - mountDependencies(pending, a, aState); - if (prevEpochNumber !== aState.n) { - addPendingAtom(pending, a, aState); - changedAtoms.add(a); - } - } - markedAtoms.delete(a); - } - }; - const writeAtomState = (pending, atom3, atomState, ...args) => { - const getter = (a) => returnAtomValue(readAtomState(pending, a, getAtomState(a, atomState))); - const setter = (a, ...args2) => { - const aState = getAtomState(a, atomState); - let r; - if (isSelfAtom(atom3, a)) { - if (!hasInitialValue(a)) { - throw new Error("atom not writable"); - } - const hasPrevValue = "v" in aState; - const prevValue = aState.v; - const v = args2[0]; - setAtomStateValueOrPromise(a, aState, v); - mountDependencies(pending, a, aState); - if (!hasPrevValue || !Object.is(prevValue, aState.v)) { - addPendingAtom(pending, a, aState); - recomputeDependents(pending, a, aState); - } - } else { - r = writeAtomState(pending, a, aState, ...args2); - } - flushPending(pending); - return r; - }; - const result = atom3.write(getter, setter, ...args); - return result; - }; - const writeAtom = (atom3, ...args) => { - const pending = createPending(); - const result = writeAtomState(pending, atom3, getAtomState(atom3), ...args); - flushPending(pending); - return result; - }; - const mountDependencies = (pending, atom3, atomState) => { - if (atomState.m && !getPendingContinuablePromise(atomState)) { - for (const a of atomState.d.keys()) { - if (!atomState.m.d.has(a)) { - const aMounted = mountAtom(pending, a, getAtomState(a, atomState)); - aMounted.t.add(atom3); - atomState.m.d.add(a); - } - } - for (const a of atomState.m.d || []) { - if (!atomState.d.has(a)) { - atomState.m.d.delete(a); - const aMounted = unmountAtom(pending, a, getAtomState(a, atomState)); - aMounted == null ? void 0 : aMounted.t.delete(atom3); - } - } - } - }; - const mountAtom = (pending, atom3, atomState) => { - if (!atomState.m) { - readAtomState(pending, atom3, atomState); - for (const a of atomState.d.keys()) { - const aMounted = mountAtom(pending, a, getAtomState(a, atomState)); - aMounted.t.add(atom3); - } - atomState.m = { - l: /* @__PURE__ */ new Set(), - d: new Set(atomState.d.keys()), - t: /* @__PURE__ */ new Set() - }; - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") { - debugMountedAtoms.add(atom3); - } - if (isActuallyWritableAtom(atom3) && atom3.onMount) { - const mounted = atomState.m; - const { onMount } = atom3; - addPendingFunction(pending, () => { - const onUnmount = onMount((...args) => writeAtomState(pending, atom3, atomState, ...args)); - if (onUnmount) { - mounted.u = onUnmount; - } - }); - } - } - return atomState.m; - }; - const unmountAtom = (pending, atom3, atomState) => { - if (atomState.m && !atomState.m.l.size && !Array.from(atomState.m.t).some((a) => { - var _a; - return (_a = getAtomState(a, atomState).m) == null ? void 0 : _a.d.has(atom3); - })) { - const onUnmount = atomState.m.u; - if (onUnmount) { - addPendingFunction(pending, onUnmount); - } - delete atomState.m; - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") { - debugMountedAtoms.delete(atom3); - } - for (const a of atomState.d.keys()) { - const aMounted = unmountAtom(pending, a, getAtomState(a, atomState)); - aMounted == null ? void 0 : aMounted.t.delete(atom3); - } - const pendingPromise = getPendingContinuablePromise(atomState); - if (pendingPromise) { - pendingPromise[CONTINUE_PROMISE](void 0, () => { - }); - } - return void 0; - } - return atomState.m; - }; - const subscribeAtom = (atom3, listener) => { - const pending = createPending(); - const atomState = getAtomState(atom3); - const mounted = mountAtom(pending, atom3, atomState); - flushPending(pending); - const listeners = mounted.l; - listeners.add(listener); - return () => { - listeners.delete(listener); - const pending2 = createPending(); - unmountAtom(pending2, atom3, atomState); - flushPending(pending2); - }; - }; - const unstable_derive = (fn) => buildStore(...fn(getAtomState)); - const store = { - get: readAtom, - set: writeAtom, - sub: subscribeAtom, - unstable_derive - }; - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") { - const devStore = { - dev4_get_internal_weak_map: () => ({ - get: (atom3) => { - const atomState = getAtomState(atom3); - if (atomState.n === 0) { - return void 0; - } - return atomState; - } - }), - dev4_get_mounted_atoms: () => debugMountedAtoms, - dev4_restore_atoms: (values) => { - const pending = createPending(); - for (const [atom3, value] of values) { - if (hasInitialValue(atom3)) { - const atomState = getAtomState(atom3); - const hasPrevValue = "v" in atomState; - const prevValue = atomState.v; - setAtomStateValueOrPromise(atom3, atomState, value); - mountDependencies(pending, atom3, atomState); - if (!hasPrevValue || !Object.is(prevValue, atomState.v)) { - addPendingAtom(pending, atom3, atomState); - recomputeDependents(pending, atom3, atomState); - } - } - } - flushPending(pending); - } - }; - Object.assign(store, devStore); - } - return store; -}; -var createStore = () => { - const atomStateMap = /* @__PURE__ */ new WeakMap(); - const getAtomState = (atom3) => { - let atomState = atomStateMap.get(atom3); - if (!atomState) { - atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }; - atomStateMap.set(atom3, atomState); - } - return atomState; - }; - return buildStore(getAtomState); -}; -var defaultStore; -var getDefaultStore = () => { - if (!defaultStore) { - defaultStore = createStore(); - if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") { - globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore); - if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) { - console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"); - } - } - } - return defaultStore; -}; - -// node_modules/jotai/esm/react.mjs -var import_react120 = __toESM(require_react(), 1); -var import_meta2 = {}; -"use client"; -var StoreContext = (0, import_react120.createContext)(void 0); -var useStore = (options) => { - const store = (0, import_react120.useContext)(StoreContext); - return (options == null ? void 0 : options.store) || store || getDefaultStore(); -}; -var Provider = ({ - children, - store -}) => { - const storeRef = (0, import_react120.useRef)(); - if (!store && !storeRef.current) { - storeRef.current = createStore(); - } - return (0, import_react120.createElement)(StoreContext.Provider, { - value: store || storeRef.current - }, children); -}; -var isPromiseLike2 = (x) => typeof (x == null ? void 0 : x.then) === "function"; -var use = import_react120.default.use || ((promise) => { - if (promise.status === "pending") { - throw promise; - } else if (promise.status === "fulfilled") { - return promise.value; - } else if (promise.status === "rejected") { - throw promise.reason; - } else { - promise.status = "pending"; - promise.then((v) => { - promise.status = "fulfilled"; - promise.value = v; - }, (e) => { - promise.status = "rejected"; - promise.reason = e; - }); - throw promise; - } -}); -function useAtomValue(atom3, options) { - const store = useStore(options); - const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = (0, import_react120.useReducer)((prev) => { - const nextValue = store.get(atom3); - if (Object.is(prev[0], nextValue) && prev[1] === store && prev[2] === atom3) { - return prev; - } - return [nextValue, store, atom3]; - }, void 0, () => [store.get(atom3), store, atom3]); - let value = valueFromReducer; - if (storeFromReducer !== store || atomFromReducer !== atom3) { - rerender(); - value = store.get(atom3); - } - const delay = options == null ? void 0 : options.delay; - (0, import_react120.useEffect)(() => { - const unsub = store.sub(atom3, () => { - if (typeof delay === "number") { - setTimeout(rerender, delay); - return; - } - rerender(); - }); - rerender(); - return unsub; - }, [store, atom3, delay]); - (0, import_react120.useDebugValue)(value); - return isPromiseLike2(value) ? use(value) : value; -} -function useSetAtom(atom3, options) { - const store = useStore(options); - const setAtom = (0, import_react120.useCallback)((...args) => { - if ((import_meta2.env ? import_meta2.env.MODE : void 0) !== "production" && !("write" in atom3)) { - throw new Error("not writable atom"); - } - return store.set(atom3, ...args); - }, [store, atom3]); - return setAtom; -} - -// src/utils/getInkFileData.ts -async function getInkFileData(plugin, file) { - const v = plugin.app.vault; - const inkFileDataStr = await v.read(file); - const inkFileData = JSON.parse(inkFileDataStr); - return inkFileData; -} - -// src/tldraw/secondary-menu-bar/secondary-menu-bar.tsx -var import_classnames32 = __toESM(require_classnames()); -var React82 = __toESM(require_react()); -var SecondaryMenuBar = (props) => { - const scrollContainerElRef = React82.useRef(null); - const SecondaryMenuBarElRef = React82.useRef(null); - const [menuActive, setMenuActive] = React82.useState(true); - React82.useEffect(() => { - initScrollHandler(); - return () => { - cleanUpScrollHandler(); - }; - }); - return /* @__PURE__ */ React82.createElement(React82.Fragment, null, /* @__PURE__ */ React82.createElement("div", { - ref: SecondaryMenuBarElRef, - className: (0, import_classnames32.default)([ - "ink_secondary-menu-bar", - menuActive && "ddc_ink_active" - ]) - }, props.children)); - function initScrollHandler() { - const SecondaryMenuBar2 = SecondaryMenuBarElRef.current; - const scrollEl = SecondaryMenuBar2?.closest(".cm-scroller"); - if (!scrollEl) - return; - scrollEl.addEventListener("scroll", handleScrolling); - setTimeout(() => { - scrollEl.dispatchEvent(new CustomEvent("scroll")); - }, 500); - } - function cleanUpScrollHandler() { - const scrollEl = scrollContainerElRef.current; - scrollEl?.removeEventListener("scroll", handleScrolling); - } - function handleScrolling(e) { - const scrollAreaEl = e.target; - const pageScrollY = scrollAreaEl.scrollTop; - const SecondaryMenuBar2 = SecondaryMenuBarElRef.current; - const embedEl = SecondaryMenuBar2?.parentElement; - if (!SecondaryMenuBar2) - return; - if (!embedEl) - return; - const scrollAreaHeight = scrollAreaEl.getBoundingClientRect().height; - const menuBarHeight = SecondaryMenuBar2.getBoundingClientRect().height; - const embedHeight = embedEl.getBoundingClientRect().height; - let embedPosY = embedEl.getBoundingClientRect().top - scrollAreaEl.getBoundingClientRect().top || 0; - if (menuActive) { - embedPosY += Number(menuBarHeight); - } - const embedOffsetY = embedPosY; - const embedBottomScrolledOffScrollAreaBottom = embedOffsetY + embedHeight - menuBarHeight / 2 > scrollAreaHeight; - const embedTopScrolledOffScrollAreaBottom = embedOffsetY > scrollAreaHeight; - if (embedTopScrolledOffScrollAreaBottom) { - const bottom = embedHeight + "px"; - SecondaryMenuBar2.style.bottom = bottom; - } else if (embedBottomScrolledOffScrollAreaBottom) { - const bottom = embedOffsetY + embedHeight - scrollAreaHeight - menuBarHeight / 2 + "px"; - SecondaryMenuBar2.style.bottom = bottom; - } else { - SecondaryMenuBar2.style.removeProperty("bottom"); - } - } -}; - -// src/tldraw/modify-menu/modify-menu.tsx -var React85 = __toESM(require_react()); - -// src/graphics/icons/undo-icon.tsx -var React83 = __toESM(require_react()); -var UndoIcon = (props) => /* @__PURE__ */ React83.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React83.createElement("path", { - d: "M320-200q-17 0-28.5-11.5T280-240q0-17 11.5-28.5T320-280h244q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l76 76q11 11 11 28t-11 28q-11 11-28 11t-28-11L188-572q-6-6-8.5-13t-2.5-15q0-8 2.5-15t8.5-13l144-144q11-11 28-11t28 11q11 11 11 28t-11 28l-76 76h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H320Z" -})); - -// src/graphics/icons/redo-icon.tsx -var React84 = __toESM(require_react()); -var RedoIcon = (props) => /* @__PURE__ */ React84.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: 24, - viewBox: "0 -960 960 960", - width: 24, - ...props -}, /* @__PURE__ */ React84.createElement("path", { - d: "M648-560H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h244q17 0 28.5 11.5T680-240q0 17-11.5 28.5T640-200H396q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252l-76-76q-11-11-11-28t11-28q11-11 28-11t28 11l144 144q6 6 8.5 13t2.5 15q0 8-2.5 15t-8.5 13L628-428q-11 11-28 11t-28-11q-11-11-11-28t11-28l76-76Z" -})); - -// src/tldraw/modify-menu/modify-menu.tsx -var import_classnames33 = __toESM(require_classnames()); -var ModifyMenu = React85.forwardRef((props, ref) => { - const [canUndo, setCanUndo] = React85.useState(false); - const [canRedo, setCanRedo] = React85.useState(false); - React85.useEffect(() => { - let removeUserActionListener; - const mountDelayMs = 100; - setTimeout(() => { - const tlEditor = props.getTlEditor(); - if (!tlEditor) - return; - let timeout; - removeUserActionListener = tlEditor.store.listen((entry) => { - clearTimeout(timeout); - timeout = setTimeout(() => { - setCanUndo(tlEditor.getCanUndo()); - setCanRedo(tlEditor.getCanRedo()); - }, 100); - }, { - source: "all", - scope: "all" - }); - }, mountDelayMs); - return () => removeUserActionListener(); - }, []); - function undo() { - const editor = props.getTlEditor(); - if (!editor) - return; - silentlyChangeStore(editor, () => { - editor.undo(); - }); - props.onStoreChange(editor); - } - function redo() { - const editor = props.getTlEditor(); - if (!editor) - return; - silentlyChangeStore(editor, () => { - editor.redo(); - }); - props.onStoreChange(editor); - } - return /* @__PURE__ */ React85.createElement(React85.Fragment, null, /* @__PURE__ */ React85.createElement("div", { - ref, - className: (0, import_classnames33.default)([ - "ink_menu-bar", - "ink_menu-bar_floating" - ]) - }, /* @__PURE__ */ React85.createElement("div", { - className: "ink_modify-menu" - }, /* @__PURE__ */ React85.createElement("button", { - onPointerDown: undo, - disabled: !canUndo - }, /* @__PURE__ */ React85.createElement(UndoIcon, null)), /* @__PURE__ */ React85.createElement("button", { - onPointerDown: redo, - disabled: !canRedo - }, /* @__PURE__ */ React85.createElement(RedoIcon, null))))); -}); -var modify_menu_default = ModifyMenu; - -// src/tldraw/writing/tldraw-writing-editor.tsx -var TldrawWritingEditorWrapper = (props) => { - const editorActive = useAtomValue(editorActiveAtom); - if (editorActive) { - return /* @__PURE__ */ React86.createElement(TldrawWritingEditor, { - ...props - }); - } else { - return /* @__PURE__ */ React86.createElement(React86.Fragment, null); - } -}; -var MyCustomShapes = [WritingContainerUtil, WritingLinesUtil]; -var tlOptions = { - defaultSvgPadding: 0 -}; -function TldrawWritingEditor(props) { - const [tlEditorSnapshot, setTlEditorSnapshot] = React86.useState(); - const setEmbedState = useSetAtom(embedStateAtom); - const shortDelayPostProcessTimeoutRef = (0, import_react121.useRef)(); - const longDelayPostProcessTimeoutRef = (0, import_react121.useRef)(); - const tlEditorRef = (0, import_react121.useRef)(); - const editorWrapperRefEl = (0, import_react121.useRef)(null); - const { stashStaleContent, unstashStaleContent } = useStash(props.plugin); - const cameraLimitsRef = (0, import_react121.useRef)(); - const [preventTransitions, setPreventTransitions] = React86.useState(true); - React86.useEffect(() => { - verbose("EDITOR mounted"); - fetchFileData(); - return () => { - verbose("EDITOR unmounting"); - }; - }, []); - if (!tlEditorSnapshot) - return /* @__PURE__ */ React86.createElement(React86.Fragment, null); - verbose("EDITOR snapshot loaded"); - const defaultComponents = { - Scribble: TldrawScribble, - ShapeIndicators: TldrawShapeIndicators, - CollaboratorScribble: TldrawScribble, - SelectionForeground: TldrawSelectionForeground, - SelectionBackground: TldrawSelectionBackground, - Handles: TldrawHandles - }; - const handleMount = (_editor) => { - const editor = tlEditorRef.current = _editor; - setEmbedState("editor" /* editor */); - focusChildTldrawEditor(editorWrapperRefEl.current); - preventTldrawCanvasesCausingObsidianGestures(editor); - resizeContainerIfEmbed(tlEditorRef.current); - if (editorWrapperRefEl.current) { - editorWrapperRefEl.current.style.opacity = "1"; - } - updateWritingStoreIfNeeded(editor); - adaptTldrawToObsidianThemeMode(editor); - resizeWritingTemplateInvitingly(editor); - resizeContainerIfEmbed(editor); - if (props.embedded) { - initWritingCamera(editor); - editor.setCameraOptions({ - isLocked: true - }); - } else { - initWritingCamera(editor, MENUBAR_HEIGHT_PX); - cameraLimitsRef.current = initWritingCameraLimits(editor); - } - const removeUserActionListener = editor.store.listen((entry) => { - const activity = getActivityType(entry); - switch (activity) { - case 0 /* PointerMoved */: - break; - case 2 /* CameraMovedAutomatically */: - case 1 /* CameraMovedManually */: - if (cameraLimitsRef.current) - restrictWritingCamera(editor, cameraLimitsRef.current); - unstashStaleContent(editor); - break; - case 3 /* DrawingStarted */: - resetInputPostProcessTimers(); - stashStaleContent(editor); - break; - case 4 /* DrawingContinued */: - resetInputPostProcessTimers(); - break; - case 5 /* DrawingCompleted */: - queueOrRunStorePostProcesses(editor); - break; - case 6 /* DrawingErased */: - queueOrRunStorePostProcesses(editor); - break; - default: - verbose("Activity not recognised."); - verbose(["entry", entry], { freeze: true }); - } - }, { - source: "user", - scope: "all" - }); - const unmountActions = () => { - resetInputPostProcessTimers(); - removeUserActionListener(); - }; - if (props.saveControlsReference) { - props.saveControlsReference({ - saveAndHalt: async () => { - await completeSave(editor); - unmountActions(); - }, - resize: () => { - const camera = editor.getCamera(); - const cameraY = camera.y; - initWritingCamera(editor); - editor.setCamera({ x: camera.x, y: cameraY }); - } - }); - } - return () => { - unmountActions(); - }; - }; - function resizeContainerIfEmbed(editor) { - if (!props.embedded || !props.onResize) - return; - const embedBounds = editor.getViewportScreenBounds(); - const contentBounds = getWritingContainerBounds(editor); - if (contentBounds) { - const contentRatio = contentBounds.w / contentBounds.h; - const newEmbedHeight = embedBounds.w / contentRatio; - props.onResize(newEmbedHeight); - } - } - const queueOrRunStorePostProcesses = (editor) => { - instantInputPostProcess(editor); - smallDelayInputPostProcess(editor); - longDelayInputPostProcess(editor); - }; - const instantInputPostProcess = (editor) => { - resizeWritingTemplateInvitingly(editor); - resizeContainerIfEmbed(editor); - }; - const smallDelayInputPostProcess = (editor) => { - resetShortPostProcessTimer(); - shortDelayPostProcessTimeoutRef.current = setTimeout(() => { - incrementalSave(editor); - }, WRITE_SHORT_DELAY_MS); - }; - const longDelayInputPostProcess = (editor) => { - resetLongPostProcessTimer(); - longDelayPostProcessTimeoutRef.current = setTimeout(() => { - completeSave(editor); - }, WRITE_LONG_DELAY_MS); - }; - const resetShortPostProcessTimer = () => { - clearTimeout(shortDelayPostProcessTimeoutRef.current); - }; - const resetLongPostProcessTimer = () => { - clearTimeout(longDelayPostProcessTimeoutRef.current); - }; - const resetInputPostProcessTimers = () => { - resetShortPostProcessTimer(); - resetLongPostProcessTimer(); - }; - const incrementalSave = async (editor) => { - verbose("incrementalSave"); - unstashStaleContent(editor); - const tlEditorSnapshot2 = getSnapshot(editor.store); - stashStaleContent(editor); - const pageData = buildWritingFileData({ - tlEditorSnapshot: tlEditorSnapshot2, - previewIsOutdated: true - }); - props.save(pageData); - }; - const completeSave = async (editor) => { - verbose("completeSave"); - let previewUri; - unstashStaleContent(editor); - const tlEditorSnapshot2 = getSnapshot(editor.store); - const svgObj = await getWritingSvg(editor); - stashStaleContent(editor); - if (svgObj) { - previewUri = svgObj.svg; - } - if (previewUri) { - const pageData = buildWritingFileData({ - tlEditorSnapshot: tlEditorSnapshot2, - previewUri - }); - props.save(pageData); - } else { - const pageData = buildWritingFileData({ - tlEditorSnapshot: tlEditorSnapshot2 - }); - props.save(pageData); - } - return; - }; - const getTlEditor = () => { - return tlEditorRef.current; - }; - return /* @__PURE__ */ React86.createElement(React86.Fragment, null, /* @__PURE__ */ React86.createElement("div", { - ref: editorWrapperRefEl, - className: (0, import_classnames34.default)([ - "ddc_ink_writing-editor" - ]), - style: { - height: "100%", - position: "relative", - opacity: 0 - } - }, /* @__PURE__ */ React86.createElement(TldrawEditor, { - options: tlOptions, - shapeUtils: [...defaultShapeUtils, ...MyCustomShapes], - tools: [...defaultTools, ...defaultShapeTools], - initialState: "draw", - snapshot: tlEditorSnapshot, - components: defaultComponents, - onMount: handleMount, - autoFocus: false - }), /* @__PURE__ */ React86.createElement(PrimaryMenuBar, null, /* @__PURE__ */ React86.createElement(WritingMenu, { - getTlEditor, - onStoreChange: (tlEditor) => queueOrRunStorePostProcesses(tlEditor) - }), props.embedded && props.extendedMenu && /* @__PURE__ */ React86.createElement(extended_writing_menu_default, { - onLockClick: async () => { - if (props.closeEditor) - props.closeEditor(); - }, - menuOptions: props.extendedMenu - })), /* @__PURE__ */ React86.createElement(SecondaryMenuBar, null, /* @__PURE__ */ React86.createElement(modify_menu_default, { - getTlEditor, - onStoreChange: (tlEditor) => queueOrRunStorePostProcesses(tlEditor) - })))); - async function fetchFileData() { - const inkFileData = await getInkFileData(props.plugin, props.writingFile); - if (inkFileData.tldraw) { - const snapshot = prepareWritingSnapshot(inkFileData.tldraw); - setTlEditorSnapshot(snapshot); - } - } -} - -// src/utils/rememberDrawingFile.ts -var import_obsidian9 = require("obsidian"); - -// src/utils/storage.ts -var saveLocally = (key, value) => { - if (typeof value === "boolean") { - value = value.toString(); - } - localStorage.setItem(`${PLUGIN_KEY}_${key}`, value); -}; -var fetchLocally = (key) => { - let value = localStorage.getItem(`${PLUGIN_KEY}_${key}`); - if (value === null) - return null; - if (value === "true") - value = true; - if (value === "false") - value = false; - return value; -}; -var deleteLocally = (key) => { - localStorage.removeItem(`${PLUGIN_KEY}_${key}`); -}; -var activateNextEmbed = () => { - saveLocally("activateNextEmbed", true); -}; -var embedShouldActivateImmediately = () => { - const result = fetchLocally("activateNextEmbed"); - deleteLocally("activateNextEmbed"); - return result; -}; - -// src/utils/file-manipulation.ts -var import_obsidian8 = require("obsidian"); - -// src/utils/getDateFilename.ts -function getDateFilename() { - const date = new Date(); - let monthStr = (date.getMonth() + 1).toString(); - let dateStr = date.getDate().toString(); - let hours = date.getHours(); - let minutesStr = date.getMinutes().toString(); - let suffix = hours < 12 ? "am" : "pm"; - if (minutesStr.length < 2) - minutesStr = "0" + minutesStr; - let filename = date.getFullYear() + "." + monthStr + "." + dateStr + " - " + hours + "." + minutesStr + suffix; - return filename; -} - -// src/utils/getVersionedFilepath.ts -var import_obsidian7 = require("obsidian"); - -// src/utils/parseFilepath.ts -function parseFilepath(filepath) { - const segments = filepath.split("/"); - let folderpath = segments[0] === "" ? "/" : ""; - const filename = segments.pop() || ""; - const extIndex = filename.lastIndexOf("."); - const ext = extIndex >= 0 ? filename.slice(extIndex) : ""; - const basename = extIndex >= 0 ? filename.slice(0, extIndex) : filename; - folderpath = segments.join("/"); - return { folderpath, basename, ext: ext.startsWith(".") ? ext.slice(1) : ext }; -} - -// src/utils/getVersionedFilepath.ts -var getVersionedFilepath = async (plugin, seedFilepath) => { - try { - const { - folderpath, - basename, - ext - } = parseFilepath(seedFilepath); - let pathAndBasename = folderpath + "/" + basename; - let pathAndVersionedBasename = pathAndBasename; - let version2 = 1; - while (await plugin.app.vault.adapter.exists(`${pathAndVersionedBasename}.${ext}`)) { - version2++; - pathAndVersionedBasename = pathAndBasename + " (" + version2 + ")"; - } - return `${pathAndVersionedBasename}.${ext}`; - } catch (err) { - console.warn(err); - new import_obsidian7.Notice(`There was an error finding a non-conflicting filename.`, 0); - return ""; - } -}; - -// src/utils/getBaseAttachmentPath.ts -var getBaseAttachmentPath = async (plugin, options) => { - let baseAttachmentPath = ""; - let attachmentFolderLocation; - if (options.instigatingFileFolderPath) { - if (plugin.settings.customAttachmentFolders) { - attachmentFolderLocation = plugin.settings.noteAttachmentFolderLocation; - } else { - attachmentFolderLocation = DEFAULT_SETTINGS.noteAttachmentFolderLocation; - } - } else { - if (plugin.settings.customAttachmentFolders) { - attachmentFolderLocation = plugin.settings.notelessAttachmentFolderLocation; - } else { - attachmentFolderLocation = DEFAULT_SETTINGS.notelessAttachmentFolderLocation; - } - } - if (attachmentFolderLocation === "obsidian") { - if (options.obsAttachmentFolderPath) { - baseAttachmentPath = options.obsAttachmentFolderPath; - } else { - baseAttachmentPath = ""; - } - } else if (attachmentFolderLocation === "note") { - if (options.instigatingFileFolderPath) { - baseAttachmentPath = options.instigatingFileFolderPath; - } else { - warn(`There was an error accessing the note's folder. Placing the new file in the vault's root instead.`); - baseAttachmentPath = ""; - } - } else { - baseAttachmentPath = ""; - } - return baseAttachmentPath; -}; - -// src/utils/getSubfolderPaths.ts -var getWritingSubfolderPath = (plugin) => { - let subFolderPath = DEFAULT_SETTINGS.writingSubfolder; - if (plugin.settings.customAttachmentFolders) { - subFolderPath = plugin.settings.writingSubfolder || ""; - } - return subFolderPath.trim(); -}; -var getDrawingSubfolderPath = (plugin) => { - let subFolderPath = DEFAULT_SETTINGS.drawingSubfolder; - if (plugin.settings.customAttachmentFolders) { - subFolderPath = plugin.settings.drawingSubfolder || ""; - } - return subFolderPath.trim(); -}; - -// src/utils/obsidian-interfaces.ts -async function getObsidianAttachmentFolderPath(plugin) { - let attachmentPath = null; - try { - const returnedObsPath = await plugin.app.fileManager.getAvailablePathForAttachment("dummy"); - if (returnedObsPath.contains("/")) { - const { folderpath } = parseFilepath(returnedObsPath); - attachmentPath = folderpath; - } - } catch (err) { - return null; - } - return attachmentPath; -} - -// src/utils/file-manipulation.ts -var getNewTimestampedWritingFilepath = async (plugin, instigatingFile) => { - const obsAttachmentFolderPath = await getObsidianAttachmentFolderPath(plugin); - const instigatingFileFolderPath = instigatingFile ? parseFilepath(instigatingFile?.path).folderpath : null; - let basePath = await getBaseAttachmentPath(plugin, { - obsAttachmentFolderPath, - instigatingFileFolderPath - }); - let subFolderPath = getWritingSubfolderPath(plugin); - const fullPath = await getNewTimestampedFilepath(plugin, WRITE_FILE_EXT, `${basePath}/${subFolderPath}`); - return fullPath; -}; -var getNewTimestampedDrawingFilepath = async (plugin, instigatingFile) => { - const obsAttachmentFolderPath = await getObsidianAttachmentFolderPath(plugin); - const instigatingFileFolderPath = instigatingFile ? parseFilepath(instigatingFile?.path).folderpath : null; - let basePath = await getBaseAttachmentPath(plugin, { - obsAttachmentFolderPath, - instigatingFileFolderPath - }); - let subFolderPath = getDrawingSubfolderPath(plugin); - const fullPath = await getNewTimestampedFilepath(plugin, DRAW_FILE_EXT, `${basePath}/${subFolderPath}`); - return fullPath; -}; -var getNewTimestampedFilepath = async (plugin, ext, folderPath) => { - const filename = getDateFilename() + "." + ext; - const versionedFilepath = await getVersionedFilepath(plugin, `${folderPath}/${filename}`); - return (0, import_obsidian8.normalizePath)(versionedFilepath); -}; - -// src/utils/rememberDrawingFile.ts -var rememberDrawingFile = async (plugin, existingFileRef) => { - const v = plugin.app.vault; - if (!(existingFileRef instanceof import_obsidian9.TFile)) { - new import_obsidian9.Notice("No file found to copy"); - return; - } - saveLocally("rememberedDrawingFile", existingFileRef.path); - new import_obsidian9.Notice(`Drawing file copied. -Run 'Copied Drawing' where desired in a note.`); -}; -var rememberWritingFile = async (plugin, existingFileRef) => { - const v = plugin.app.vault; - if (!(existingFileRef instanceof import_obsidian9.TFile)) { - new import_obsidian9.Notice("No file found to copy"); - return null; - } - saveLocally("rememberedWritingFile", existingFileRef.path); - new import_obsidian9.Notice(`Writing file copied. -Run 'Copied Writing Section' where desired in a note.`); -}; -var duplicateDrawingFile = async (plugin, existingFileRef, instigatingFile) => { - const v = plugin.app.vault; - const newFilePath = await getNewTimestampedDrawingFilepath(plugin, instigatingFile); - const newFile = await v.copy(existingFileRef, newFilePath); - return newFile; -}; -var duplicateWritingFile = async (plugin, existingFileRef, instigatingFile) => { - const v = plugin.app.vault; - const newFilePath = await getNewTimestampedWritingFilepath(plugin, instigatingFile); - const newFile = await v.copy(existingFileRef, newFilePath); - return newFile; -}; - -// src/tldraw/writing/writing-embed-preview/writing-embed-preview.tsx -var import_classnames35 = __toESM(require_classnames()); -var React88 = __toESM(require_react()); - -// node_modules/react-inlinesvg/dist/index.mjs -var import_react122 = __toESM(require_react(), 1); - -// node_modules/react-from-dom/dist/index.mjs -var React87 = __toESM(require_react(), 1); -var styleToObject = (input) => { - if (typeof input !== "string") { - return {}; - } - return input.split(/ ?; ?/).reduce((acc, item) => { - const [key, value] = item.split(/ ?: ?/).map((d, index2) => index2 === 0 ? d.replace(/\s+/g, "") : d.trim()); - if (key && value) { - const nextKey = key.replace(/(\w)-(\w)/g, (_$0, $1, $2) => `${$1}${$2.toUpperCase()}`); - let nextValue = value.trim(); - if (!Number.isNaN(Number(value))) { - nextValue = Number(value); - } - acc[key.startsWith("-") ? key : nextKey] = nextValue; - } - return acc; - }, {}); -}; -function randomString(length = 6) { - const characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - let result = ""; - for (let index2 = length; index2 > 0; --index2) { - result += characters[Math.round(Math.random() * (characters.length - 1))]; - } - return result; -} -var noTextChildNodes = [ - "br", - "col", - "colgroup", - "dl", - "hr", - "iframe", - "img", - "input", - "link", - "menuitem", - "meta", - "ol", - "param", - "select", - "table", - "tbody", - "tfoot", - "thead", - "tr", - "ul", - "wbr" -]; -var possibleStandardNames = { - "accept-charset": "acceptCharset", - acceptcharset: "acceptCharset", - accesskey: "accessKey", - allowfullscreen: "allowFullScreen", - autocapitalize: "autoCapitalize", - autocomplete: "autoComplete", - autocorrect: "autoCorrect", - autofocus: "autoFocus", - autoplay: "autoPlay", - autosave: "autoSave", - cellpadding: "cellPadding", - cellspacing: "cellSpacing", - charset: "charSet", - class: "className", - classid: "classID", - classname: "className", - colspan: "colSpan", - contenteditable: "contentEditable", - contextmenu: "contextMenu", - controlslist: "controlsList", - crossorigin: "crossOrigin", - dangerouslysetinnerhtml: "dangerouslySetInnerHTML", - datetime: "dateTime", - defaultchecked: "defaultChecked", - defaultvalue: "defaultValue", - enctype: "encType", - for: "htmlFor", - formmethod: "formMethod", - formaction: "formAction", - formenctype: "formEncType", - formnovalidate: "formNoValidate", - formtarget: "formTarget", - frameborder: "frameBorder", - hreflang: "hrefLang", - htmlfor: "htmlFor", - httpequiv: "httpEquiv", - "http-equiv": "httpEquiv", - icon: "icon", - innerhtml: "innerHTML", - inputmode: "inputMode", - itemid: "itemID", - itemprop: "itemProp", - itemref: "itemRef", - itemscope: "itemScope", - itemtype: "itemType", - keyparams: "keyParams", - keytype: "keyType", - marginwidth: "marginWidth", - marginheight: "marginHeight", - maxlength: "maxLength", - mediagroup: "mediaGroup", - minlength: "minLength", - nomodule: "noModule", - novalidate: "noValidate", - playsinline: "playsInline", - radiogroup: "radioGroup", - readonly: "readOnly", - referrerpolicy: "referrerPolicy", - rowspan: "rowSpan", - spellcheck: "spellCheck", - srcdoc: "srcDoc", - srclang: "srcLang", - srcset: "srcSet", - tabindex: "tabIndex", - typemustmatch: "typeMustMatch", - usemap: "useMap", - accentheight: "accentHeight", - "accent-height": "accentHeight", - alignmentbaseline: "alignmentBaseline", - "alignment-baseline": "alignmentBaseline", - allowreorder: "allowReorder", - arabicform: "arabicForm", - "arabic-form": "arabicForm", - attributename: "attributeName", - attributetype: "attributeType", - autoreverse: "autoReverse", - basefrequency: "baseFrequency", - baselineshift: "baselineShift", - "baseline-shift": "baselineShift", - baseprofile: "baseProfile", - calcmode: "calcMode", - capheight: "capHeight", - "cap-height": "capHeight", - clippath: "clipPath", - "clip-path": "clipPath", - clippathunits: "clipPathUnits", - cliprule: "clipRule", - "clip-rule": "clipRule", - colorinterpolation: "colorInterpolation", - "color-interpolation": "colorInterpolation", - colorinterpolationfilters: "colorInterpolationFilters", - "color-interpolation-filters": "colorInterpolationFilters", - colorprofile: "colorProfile", - "color-profile": "colorProfile", - colorrendering: "colorRendering", - "color-rendering": "colorRendering", - contentscripttype: "contentScriptType", - contentstyletype: "contentStyleType", - diffuseconstant: "diffuseConstant", - dominantbaseline: "dominantBaseline", - "dominant-baseline": "dominantBaseline", - edgemode: "edgeMode", - enablebackground: "enableBackground", - "enable-background": "enableBackground", - externalresourcesrequired: "externalResourcesRequired", - fillopacity: "fillOpacity", - "fill-opacity": "fillOpacity", - fillrule: "fillRule", - "fill-rule": "fillRule", - filterres: "filterRes", - filterunits: "filterUnits", - floodopacity: "floodOpacity", - "flood-opacity": "floodOpacity", - floodcolor: "floodColor", - "flood-color": "floodColor", - fontfamily: "fontFamily", - "font-family": "fontFamily", - fontsize: "fontSize", - "font-size": "fontSize", - fontsizeadjust: "fontSizeAdjust", - "font-size-adjust": "fontSizeAdjust", - fontstretch: "fontStretch", - "font-stretch": "fontStretch", - fontstyle: "fontStyle", - "font-style": "fontStyle", - fontvariant: "fontVariant", - "font-variant": "fontVariant", - fontweight: "fontWeight", - "font-weight": "fontWeight", - glyphname: "glyphName", - "glyph-name": "glyphName", - glyphorientationhorizontal: "glyphOrientationHorizontal", - "glyph-orientation-horizontal": "glyphOrientationHorizontal", - glyphorientationvertical: "glyphOrientationVertical", - "glyph-orientation-vertical": "glyphOrientationVertical", - glyphref: "glyphRef", - gradienttransform: "gradientTransform", - gradientunits: "gradientUnits", - horizadvx: "horizAdvX", - "horiz-adv-x": "horizAdvX", - horizoriginx: "horizOriginX", - "horiz-origin-x": "horizOriginX", - imagerendering: "imageRendering", - "image-rendering": "imageRendering", - kernelmatrix: "kernelMatrix", - kernelunitlength: "kernelUnitLength", - keypoints: "keyPoints", - keysplines: "keySplines", - keytimes: "keyTimes", - lengthadjust: "lengthAdjust", - letterspacing: "letterSpacing", - "letter-spacing": "letterSpacing", - lightingcolor: "lightingColor", - "lighting-color": "lightingColor", - limitingconeangle: "limitingConeAngle", - markerend: "markerEnd", - "marker-end": "markerEnd", - markerheight: "markerHeight", - markermid: "markerMid", - "marker-mid": "markerMid", - markerstart: "markerStart", - "marker-start": "markerStart", - markerunits: "markerUnits", - markerwidth: "markerWidth", - maskcontentunits: "maskContentUnits", - maskunits: "maskUnits", - numoctaves: "numOctaves", - overlineposition: "overlinePosition", - "overline-position": "overlinePosition", - overlinethickness: "overlineThickness", - "overline-thickness": "overlineThickness", - paintorder: "paintOrder", - "paint-order": "paintOrder", - "panose-1": "panose1", - pathlength: "pathLength", - patterncontentunits: "patternContentUnits", - patterntransform: "patternTransform", - patternunits: "patternUnits", - pointerevents: "pointerEvents", - "pointer-events": "pointerEvents", - pointsatx: "pointsAtX", - pointsaty: "pointsAtY", - pointsatz: "pointsAtZ", - preservealpha: "preserveAlpha", - preserveaspectratio: "preserveAspectRatio", - primitiveunits: "primitiveUnits", - refx: "refX", - refy: "refY", - renderingintent: "renderingIntent", - "rendering-intent": "renderingIntent", - repeatcount: "repeatCount", - repeatdur: "repeatDur", - requiredextensions: "requiredExtensions", - requiredfeatures: "requiredFeatures", - shaperendering: "shapeRendering", - "shape-rendering": "shapeRendering", - specularconstant: "specularConstant", - specularexponent: "specularExponent", - spreadmethod: "spreadMethod", - startoffset: "startOffset", - stddeviation: "stdDeviation", - stitchtiles: "stitchTiles", - stopcolor: "stopColor", - "stop-color": "stopColor", - stopopacity: "stopOpacity", - "stop-opacity": "stopOpacity", - strikethroughposition: "strikethroughPosition", - "strikethrough-position": "strikethroughPosition", - strikethroughthickness: "strikethroughThickness", - "strikethrough-thickness": "strikethroughThickness", - strokedasharray: "strokeDasharray", - "stroke-dasharray": "strokeDasharray", - strokedashoffset: "strokeDashoffset", - "stroke-dashoffset": "strokeDashoffset", - strokelinecap: "strokeLinecap", - "stroke-linecap": "strokeLinecap", - strokelinejoin: "strokeLinejoin", - "stroke-linejoin": "strokeLinejoin", - strokemiterlimit: "strokeMiterlimit", - "stroke-miterlimit": "strokeMiterlimit", - strokewidth: "strokeWidth", - "stroke-width": "strokeWidth", - strokeopacity: "strokeOpacity", - "stroke-opacity": "strokeOpacity", - suppresscontenteditablewarning: "suppressContentEditableWarning", - suppresshydrationwarning: "suppressHydrationWarning", - surfacescale: "surfaceScale", - systemlanguage: "systemLanguage", - tablevalues: "tableValues", - targetx: "targetX", - targety: "targetY", - textanchor: "textAnchor", - "text-anchor": "textAnchor", - textdecoration: "textDecoration", - "text-decoration": "textDecoration", - textlength: "textLength", - textrendering: "textRendering", - "text-rendering": "textRendering", - underlineposition: "underlinePosition", - "underline-position": "underlinePosition", - underlinethickness: "underlineThickness", - "underline-thickness": "underlineThickness", - unicodebidi: "unicodeBidi", - "unicode-bidi": "unicodeBidi", - unicoderange: "unicodeRange", - "unicode-range": "unicodeRange", - unitsperem: "unitsPerEm", - "units-per-em": "unitsPerEm", - unselectable: "unselectable", - valphabetic: "vAlphabetic", - "v-alphabetic": "vAlphabetic", - vectoreffect: "vectorEffect", - "vector-effect": "vectorEffect", - vertadvy: "vertAdvY", - "vert-adv-y": "vertAdvY", - vertoriginx: "vertOriginX", - "vert-origin-x": "vertOriginX", - vertoriginy: "vertOriginY", - "vert-origin-y": "vertOriginY", - vhanging: "vHanging", - "v-hanging": "vHanging", - videographic: "vIdeographic", - "v-ideographic": "vIdeographic", - viewbox: "viewBox", - viewtarget: "viewTarget", - vmathematical: "vMathematical", - "v-mathematical": "vMathematical", - wordspacing: "wordSpacing", - "word-spacing": "wordSpacing", - writingmode: "writingMode", - "writing-mode": "writingMode", - xchannelselector: "xChannelSelector", - xheight: "xHeight", - "x-height": "xHeight", - xlinkactuate: "xlinkActuate", - "xlink:actuate": "xlinkActuate", - xlinkarcrole: "xlinkArcrole", - "xlink:arcrole": "xlinkArcrole", - xlinkhref: "xlinkHref", - "xlink:href": "xlinkHref", - xlinkrole: "xlinkRole", - "xlink:role": "xlinkRole", - xlinkshow: "xlinkShow", - "xlink:show": "xlinkShow", - xlinktitle: "xlinkTitle", - "xlink:title": "xlinkTitle", - xlinktype: "xlinkType", - "xlink:type": "xlinkType", - xmlbase: "xmlBase", - "xml:base": "xmlBase", - xmllang: "xmlLang", - "xml:lang": "xmlLang", - "xml:space": "xmlSpace", - xmlnsxlink: "xmlnsXlink", - "xmlns:xlink": "xmlnsXlink", - xmlspace: "xmlSpace", - ychannelselector: "yChannelSelector", - zoomandpan: "zoomAndPan", - onblur: "onBlur", - onchange: "onChange", - onclick: "onClick", - oncontextmenu: "onContextMenu", - ondoubleclick: "onDoubleClick", - ondrag: "onDrag", - ondragend: "onDragEnd", - ondragenter: "onDragEnter", - ondragexit: "onDragExit", - ondragleave: "onDragLeave", - ondragover: "onDragOver", - ondragstart: "onDragStart", - ondrop: "onDrop", - onerror: "onError", - onfocus: "onFocus", - oninput: "onInput", - oninvalid: "onInvalid", - onkeydown: "onKeyDown", - onkeypress: "onKeyPress", - onkeyup: "onKeyUp", - onload: "onLoad", - onmousedown: "onMouseDown", - onmouseenter: "onMouseEnter", - onmouseleave: "onMouseLeave", - onmousemove: "onMouseMove", - onmouseout: "onMouseOut", - onmouseover: "onMouseOver", - onmouseup: "onMouseUp", - onscroll: "onScroll", - onsubmit: "onSubmit", - ontouchcancel: "onTouchCancel", - ontouchend: "onTouchEnd", - ontouchmove: "onTouchMove", - ontouchstart: "onTouchStart", - onwheel: "onWheel" -}; -function getReactNode(node, options) { - const { key, level: level2, ...rest } = options; - switch (node.nodeType) { - case 1: { - return React87.createElement(parseName(node.nodeName), parseAttributes(node, key), parseChildren(node.childNodes, level2, rest)); - } - case 3: { - const nodeText = node.nodeValue?.toString() ?? ""; - if (!rest.allowWhiteSpaces && /^\s+$/.test(nodeText) && !/[\u00A0\u202F]/.test(nodeText)) { - return null; - } - if (!node.parentNode) { - return nodeText; - } - const parentNodeName = node.parentNode.nodeName.toLowerCase(); - if (noTextChildNodes.includes(parentNodeName)) { - if (/\S/.test(nodeText)) { - console.warn(`A textNode is not allowed inside '${parentNodeName}'. Your text "${nodeText}" will be ignored`); - } - return null; - } - return nodeText; - } - case 8: { - return null; - } - case 11: { - return parseChildren(node.childNodes, level2, options); - } - default: { - return null; - } - } -} -function parseAttributes(node, reactKey) { - const attributes = { - key: reactKey - }; - if (node instanceof Element) { - const nodeClassNames = node.getAttribute("class"); - if (nodeClassNames) { - attributes.className = nodeClassNames; - } - [...node.attributes].forEach((d) => { - switch (d.name) { - case "class": - break; - case "style": - attributes[d.name] = styleToObject(d.value); - break; - case "allowfullscreen": - case "allowpaymentrequest": - case "async": - case "autofocus": - case "autoplay": - case "checked": - case "controls": - case "default": - case "defer": - case "disabled": - case "formnovalidate": - case "hidden": - case "ismap": - case "itemscope": - case "loop": - case "multiple": - case "muted": - case "nomodule": - case "novalidate": - case "open": - case "readonly": - case "required": - case "reversed": - case "selected": - case "typemustmatch": - attributes[possibleStandardNames[d.name] || d.name] = true; - break; - default: - attributes[possibleStandardNames[d.name] || d.name] = d.value; - } - }); - } - return attributes; -} -function parseChildren(childNodeList, level2, options) { - const children = [...childNodeList].map((node, index2) => convertFromNode(node, { - ...options, - index: index2, - level: level2 + 1 - })).filter(Boolean); - if (!children.length) { - return null; - } - return children; -} -function parseName(nodeName) { - if (/[a-z]+[A-Z]+[a-z]+/.test(nodeName)) { - return nodeName; - } - return nodeName.toLowerCase(); -} -function convertFromNode(input, options = {}) { - if (!input || !(input instanceof Node)) { - return null; - } - const { actions = [], index: index2 = 0, level: level2 = 0, randomKey } = options; - let node = input; - let key = `${level2}-${index2}`; - const result = []; - if (randomKey && level2 === 0) { - key = `${randomString()}-${key}`; - } - if (Array.isArray(actions)) { - actions.forEach((action) => { - if (action.condition(node, key, level2)) { - if (typeof action.pre === "function") { - node = action.pre(node, key, level2); - if (!(node instanceof Node)) { - node = input; - if (false) { - console.warn("The `pre` method always must return a valid DomNode (instanceof Node) - your modification will be ignored (Hint: if you want to render a React-component, use the `post` method instead)"); - } - } - } - if (typeof action.post === "function") { - result.push(action.post(node, key, level2)); - } - } - }); - } - if (result.length) { - return result; - } - return getReactNode(node, { key, level: level2, ...options }); -} -function convertFromString(input, options = {}) { - if (!input || typeof input !== "string") { - return null; - } - const { - includeAllNodes = false, - nodeOnly = false, - selector = "body > *", - type = "text/html" - } = options; - try { - const parser = new DOMParser(); - const document2 = parser.parseFromString(input, type); - if (includeAllNodes) { - const { childNodes } = document2.body; - if (nodeOnly) { - return childNodes; - } - return [...childNodes].map((node2) => convertFromNode(node2, options)); - } - const node = document2.querySelector(selector) || document2.body.childNodes[0]; - if (!(node instanceof Node)) { - throw new TypeError("Error parsing input"); - } - if (nodeOnly) { - return node; - } - return convertFromNode(node, options); - } catch (error3) { - if (false) { - console.error(error3); - } - } - return null; -} -function convert(input, options = {}) { - if (typeof input === "string") { - return convertFromString(input, options); - } - if (input instanceof Node) { - return convertFromNode(input, options); - } - return null; -} - -// node_modules/react-inlinesvg/dist/index.mjs -var import_react123 = __toESM(require_react(), 1); -var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1); -"use client"; -var __defProp8 = Object.defineProperty; -var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField2 = (obj, key, value) => { - __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); - return value; -}; -var CACHE_NAME = "react-inlinesvg"; -var CACHE_MAX_RETRIES = 10; -var STATUS = { - IDLE: "idle", - LOADING: "loading", - LOADED: "loaded", - FAILED: "failed", - READY: "ready", - UNSUPPORTED: "unsupported" -}; -function canUseDOM() { - return !!(typeof window !== "undefined" && window.document && window.document.createElement); -} -function isSupportedEnvironment() { - return supportsInlineSVG() && typeof window !== "undefined" && window !== null; -} -async function request(url, options) { - const response = await fetch(url, options); - const contentType = response.headers.get("content-type"); - const [fileType] = (contentType ?? "").split(/ ?; ?/); - if (response.status > 299) { - throw new Error("Not found"); - } - if (!["image/svg+xml", "text/plain"].some((d) => fileType.includes(d))) { - throw new Error(`Content type isn't valid: ${fileType}`); - } - return response.text(); -} -function sleep(seconds = 1) { - return new Promise((resolve) => { - setTimeout(resolve, seconds * 1e3); - }); -} -function supportsInlineSVG() { - if (!document) { - return false; - } - const div = document.createElement("div"); - div.innerHTML = "<svg />"; - const svg = div.firstChild; - return !!svg && svg.namespaceURI === "http://www.w3.org/2000/svg"; -} -function randomCharacter(character) { - return character[Math.floor(Math.random() * character.length)]; -} -function randomString2(length) { - const letters = "abcdefghijklmnopqrstuvwxyz"; - const numbers = "1234567890"; - const charset = `${letters}${letters.toUpperCase()}${numbers}`; - let R = ""; - for (let index2 = 0; index2 < length; index2++) { - R += randomCharacter(charset); - } - return R; -} -function omit(input, ...filter2) { - const output = {}; - for (const key in input) { - if ({}.hasOwnProperty.call(input, key)) { - if (!filter2.includes(key)) { - output[key] = input[key]; - } - } - } - return output; -} -var CacheStore = class { - constructor() { - __publicField2(this, "cacheApi"); - __publicField2(this, "cacheStore"); - __publicField2(this, "subscribers", []); - __publicField2(this, "isReady", false); - this.cacheStore = /* @__PURE__ */ new Map(); - let cacheName = CACHE_NAME; - let usePersistentCache = false; - if (canUseDOM()) { - cacheName = window.REACT_INLINESVG_CACHE_NAME ?? CACHE_NAME; - usePersistentCache = !!window.REACT_INLINESVG_PERSISTENT_CACHE && "caches" in window; - } - if (usePersistentCache) { - caches.open(cacheName).then((cache) => { - this.cacheApi = cache; - this.isReady = true; - this.subscribers.forEach((callback) => callback()); - }).catch((error3) => { - this.isReady = true; - console.error(`Failed to open cache: ${error3.message}`); - }); - } else { - this.isReady = true; - } - } - onReady(callback) { - if (this.isReady) { - callback(); - } else { - this.subscribers.push(callback); - } - } - async get(url, fetchOptions) { - await (this.cacheApi ? this.fetchAndAddToPersistentCache(url, fetchOptions) : this.fetchAndAddToInternalCache(url, fetchOptions)); - return this.cacheStore.get(url)?.content ?? ""; - } - set(url, data) { - this.cacheStore.set(url, data); - } - isCached(url) { - return this.cacheStore.get(url)?.status === STATUS.LOADED; - } - async fetchAndAddToInternalCache(url, fetchOptions) { - const cache = this.cacheStore.get(url); - if (cache?.status === STATUS.LOADING) { - await this.handleLoading(url, async () => { - this.cacheStore.set(url, { content: "", status: STATUS.IDLE }); - await this.fetchAndAddToInternalCache(url, fetchOptions); - }); - return; - } - if (!cache?.content) { - this.cacheStore.set(url, { content: "", status: STATUS.LOADING }); - try { - const content = await request(url, fetchOptions); - this.cacheStore.set(url, { content, status: STATUS.LOADED }); - } catch (error3) { - this.cacheStore.set(url, { content: "", status: STATUS.FAILED }); - throw error3; - } - } - } - async fetchAndAddToPersistentCache(url, fetchOptions) { - const cache = this.cacheStore.get(url); - if (cache?.status === STATUS.LOADED) { - return; - } - if (cache?.status === STATUS.LOADING) { - await this.handleLoading(url, async () => { - this.cacheStore.set(url, { content: "", status: STATUS.IDLE }); - await this.fetchAndAddToPersistentCache(url, fetchOptions); - }); - return; - } - this.cacheStore.set(url, { content: "", status: STATUS.LOADING }); - const data = await this.cacheApi?.match(url); - if (data) { - const content = await data.text(); - this.cacheStore.set(url, { content, status: STATUS.LOADED }); - return; - } - try { - await this.cacheApi?.add(new Request(url, fetchOptions)); - const response = await this.cacheApi?.match(url); - const content = await response?.text() ?? ""; - this.cacheStore.set(url, { content, status: STATUS.LOADED }); - } catch (error3) { - this.cacheStore.set(url, { content: "", status: STATUS.FAILED }); - throw error3; - } - } - async handleLoading(url, callback) { - let retryCount = 0; - while (this.cacheStore.get(url)?.status === STATUS.LOADING && retryCount < CACHE_MAX_RETRIES) { - await sleep(0.1); - retryCount += 1; - } - if (retryCount >= CACHE_MAX_RETRIES) { - await callback(); - } - } - keys() { - return [...this.cacheStore.keys()]; - } - data() { - return [...this.cacheStore.entries()].map(([key, value]) => ({ [key]: value })); - } - async delete(url) { - if (this.cacheApi) { - await this.cacheApi.delete(url); - } - this.cacheStore.delete(url); - } - async clear() { - if (this.cacheApi) { - const keys = await this.cacheApi.keys(); - for (const key of keys) { - await this.cacheApi.delete(key); - } - } - this.cacheStore.clear(); - } -}; -function usePrevious2(state) { - const ref = (0, import_react123.useRef)(); - (0, import_react123.useEffect)(() => { - ref.current = state; - }); - return ref.current; -} -function getNode(options) { - const { - baseURL, - content, - description, - handleError, - hash, - preProcessor, - title, - uniquifyIDs = false - } = options; - try { - const svgText = processSVG(content, preProcessor); - const node = convert(svgText, { nodeOnly: true }); - if (!node || !(node instanceof SVGSVGElement)) { - throw new Error("Could not convert the src to a DOM Node"); - } - const svg = updateSVGAttributes(node, { baseURL, hash, uniquifyIDs }); - if (description) { - const originalDesc = svg.querySelector("desc"); - if (originalDesc?.parentNode) { - originalDesc.parentNode.removeChild(originalDesc); - } - const descElement = document.createElementNS("http://www.w3.org/2000/svg", "desc"); - descElement.innerHTML = description; - svg.prepend(descElement); - } - if (typeof title !== "undefined") { - const originalTitle = svg.querySelector("title"); - if (originalTitle?.parentNode) { - originalTitle.parentNode.removeChild(originalTitle); - } - if (title) { - const titleElement = document.createElementNS("http://www.w3.org/2000/svg", "title"); - titleElement.innerHTML = title; - svg.prepend(titleElement); - } - } - return svg; - } catch (error3) { - return handleError(error3); - } -} -function processSVG(content, preProcessor) { - if (preProcessor) { - return preProcessor(content); - } - return content; -} -function updateSVGAttributes(node, options) { - const { baseURL = "", hash, uniquifyIDs } = options; - const replaceableAttributes = ["id", "href", "xlink:href", "xlink:role", "xlink:arcrole"]; - const linkAttributes = ["href", "xlink:href"]; - const isDataValue = (name, value) => linkAttributes.includes(name) && (value ? !value.includes("#") : false); - if (!uniquifyIDs) { - return node; - } - [...node.children].forEach((d) => { - if (d.attributes?.length) { - const attributes = Object.values(d.attributes).map((a) => { - const attribute = a; - const match = /url\((.*?)\)/.exec(a.value); - if (match?.[1]) { - attribute.value = a.value.replace(match[0], `url(${baseURL}${match[1]}__${hash})`); - } - return attribute; - }); - replaceableAttributes.forEach((r) => { - const attribute = attributes.find((a) => a.name === r); - if (attribute && !isDataValue(r, attribute.value)) { - attribute.value = `${attribute.value}__${hash}`; - } - }); - } - if (d.children.length) { - return updateSVGAttributes(d, options); - } - return d; - }); - return node; -} -var cacheStore; -function ReactInlineSVG(props) { - const { - cacheRequests = true, - children = null, - description, - fetchOptions, - innerRef, - loader = null, - onError, - onLoad, - src, - title, - uniqueHash - } = props; - const [state, setState] = (0, import_react122.useReducer)((previousState2, nextState) => ({ - ...previousState2, - ...nextState - }), { - content: "", - element: null, - isCached: cacheRequests && cacheStore.isCached(props.src), - status: STATUS.IDLE - }); - const { content, element, isCached, status } = state; - const previousProps = usePrevious2(props); - const previousState = usePrevious2(state); - const hash = (0, import_react122.useRef)(uniqueHash ?? randomString2(8)); - const isActive = (0, import_react122.useRef)(false); - const isInitialized = (0, import_react122.useRef)(false); - const handleError = (0, import_react122.useCallback)((error3) => { - if (isActive.current) { - setState({ - status: error3.message === "Browser does not support SVG" ? STATUS.UNSUPPORTED : STATUS.FAILED - }); - onError?.(error3); - } - }, [onError]); - const handleLoad = (0, import_react122.useCallback)((loadedContent, hasCache = false) => { - if (isActive.current) { - setState({ - content: loadedContent, - isCached: hasCache, - status: STATUS.LOADED - }); - } - }, []); - const fetchContent = (0, import_react122.useCallback)(async () => { - const responseContent = await request(src, fetchOptions); - handleLoad(responseContent); - }, [fetchOptions, handleLoad, src]); - const getElement = (0, import_react122.useCallback)(() => { - try { - const node = getNode({ ...props, handleError, hash: hash.current, content }); - const convertedElement = convert(node); - if (!convertedElement || !(0, import_react122.isValidElement)(convertedElement)) { - throw new Error("Could not convert the src to a React element"); - } - setState({ - element: convertedElement, - status: STATUS.READY - }); - } catch (error3) { - handleError(new Error(error3.message)); - } - }, [content, handleError, props]); - const getContent = (0, import_react122.useCallback)(async () => { - const dataURI = /^data:image\/svg[^,]*?(;base64)?,(.*)/u.exec(src); - let inlineSrc; - if (dataURI) { - inlineSrc = dataURI[1] ? window.atob(dataURI[2]) : decodeURIComponent(dataURI[2]); - } else if (src.includes("<svg")) { - inlineSrc = src; - } - if (inlineSrc) { - handleLoad(inlineSrc); - return; - } - try { - if (cacheRequests) { - const cachedContent = await cacheStore.get(src, fetchOptions); - handleLoad(cachedContent, true); - } else { - await fetchContent(); - } - } catch (error3) { - handleError(error3); - } - }, [cacheRequests, fetchContent, fetchOptions, handleError, handleLoad, src]); - const load = (0, import_react122.useCallback)(async () => { - if (isActive.current) { - setState({ - content: "", - element: null, - isCached: false, - status: STATUS.LOADING - }); - } - }, []); - (0, import_react122.useEffect)(() => { - isActive.current = true; - if (!canUseDOM() || isInitialized.current) { - return () => void 0; - } - try { - if (status === STATUS.IDLE) { - if (!isSupportedEnvironment()) { - throw new Error("Browser does not support SVG"); - } - if (!src) { - throw new Error("Missing src"); - } - load(); - } - } catch (error3) { - handleError(error3); - } - isInitialized.current = true; - return () => { - isActive.current = false; - }; - }, []); - (0, import_react122.useEffect)(() => { - if (!canUseDOM()) { - return; - } - if (!previousProps) { - return; - } - if (previousProps.src !== src) { - if (!src) { - handleError(new Error("Missing src")); - return; - } - load(); - } else if (previousProps.title !== title || previousProps.description !== description) { - getElement(); - } - }, [description, getElement, handleError, load, previousProps, src, title]); - (0, import_react122.useEffect)(() => { - if (!previousState) { - return; - } - if (previousState.status !== STATUS.LOADING && status === STATUS.LOADING) { - getContent(); - } - if (previousState.status !== STATUS.LOADED && status === STATUS.LOADED) { - getElement(); - } - if (previousState.status !== STATUS.READY && status === STATUS.READY) { - onLoad?.(src, isCached); - } - }, [getContent, getElement, isCached, onLoad, previousState, src, status]); - const elementProps = omit(props, "baseURL", "cacheRequests", "children", "description", "fetchOptions", "innerRef", "loader", "onError", "onLoad", "preProcessor", "src", "title", "uniqueHash", "uniquifyIDs"); - if (!canUseDOM()) { - return loader; - } - if (element) { - return (0, import_react122.cloneElement)(element, { ref: innerRef, ...elementProps }); - } - if ([STATUS.UNSUPPORTED, STATUS.FAILED].includes(status)) { - return children; - } - return loader; -} -function InlineSVG(props) { - if (!cacheStore) { - cacheStore = new CacheStore(); - } - const { loader } = props; - const hasCallback = (0, import_react122.useRef)(false); - const [isReady, setReady] = (0, import_react122.useState)(cacheStore.isReady); - (0, import_react122.useEffect)(() => { - if (!hasCallback.current) { - cacheStore.onReady(() => { - setReady(true); - }); - hasCallback.current = true; - } - }, []); - if (!isReady) { - return loader; - } - return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(ReactInlineSVG, { ...props }); -} - -// src/tldraw/writing/writing-embed-preview/writing-embed-preview.tsx -var emptyWritingSvg = require_empty_writing_embed(); -var WritingEmbedPreviewWrapper = (props) => { - const previewActive = useAtomValue(previewActiveAtom); - if (previewActive) { - return /* @__PURE__ */ React88.createElement(WritingEmbedPreview, { - ...props - }); - } else { - return /* @__PURE__ */ React88.createElement(React88.Fragment, null); - } -}; -var WritingEmbedPreview = (props) => { - const containerElRef = React88.useRef(null); - const setEmbedState = useSetAtom(embedStateAtom); - const [fileSrc, setFileSrc] = React88.useState(emptyWritingSvg); - React88.useEffect(() => { - fetchFileData(); - return () => { - }; - }); - const isImg = fileSrc.slice(0, 4) === "data"; - return /* @__PURE__ */ React88.createElement(React88.Fragment, null, /* @__PURE__ */ React88.createElement("div", { - ref: containerElRef, - className: (0, import_classnames35.default)([ - "ddc_ink_writing-embed-preview", - props.plugin.settings.writingLinesWhenLocked && "ddc_ink_visible-lines", - props.plugin.settings.writingBackgroundWhenLocked && "ddc_ink_visible-background" - ]), - style: { - position: "absolute", - width: "100%" - }, - onClick: props.onClick - }, isImg && /* @__PURE__ */ React88.createElement(React88.Fragment, null, /* @__PURE__ */ React88.createElement("img", { - src: fileSrc, - style: { - width: "100%", - cursor: "pointer", - pointerEvents: "all" - }, - onLoad - })), !isImg && /* @__PURE__ */ React88.createElement(React88.Fragment, null, /* @__PURE__ */ React88.createElement(InlineSVG, { - src: fileSrc, - style: { - width: "100%", - height: "unset", - cursor: "pointer" - }, - pointerEvents: "visible", - onLoad - })))); - function onLoad() { - recalcHeight(); - setTimeout(() => { - setEmbedState("preview" /* preview */); - }, 100); - } - async function fetchFileData() { - const inkFileData = await getInkFileData(props.plugin, props.writingFile); - if (inkFileData.previewUri) - setFileSrc(inkFileData.previewUri); - } - function recalcHeight() { - if (!containerElRef.current) - return; - const observer = new IntersectionObserver((entries) => { - entries.forEach((entry) => { - if (entry.target !== containerElRef.current) - return; - if (!entry.isIntersecting) - return; - const rect = containerElRef.current.getBoundingClientRect(); - props.onResize(rect.height); - observer.unobserve(containerElRef.current); - }); - }); - observer.observe(containerElRef.current); - } -}; - -// src/tldraw/writing/writing-embed.tsx -var import_classnames36 = __toESM(require_classnames()); -var embedStateAtom = atom2("preview" /* preview */); -var previewActiveAtom = atom2((get) => { - const embedState = get(embedStateAtom); - return embedState !== "editor" /* editor */; -}); -var editorActiveAtom = atom2((get) => { - const embedState = get(embedStateAtom); - return embedState !== "preview" /* preview */; -}); -function WritingEmbed(props) { - const embedContainerElRef = (0, import_react124.useRef)(null); - const resizeContainerElRef = (0, import_react124.useRef)(null); - const editorControlsRef = (0, import_react124.useRef)(); - const setEmbedState = useSetAtom(embedStateAtom); - React89.useEffect(() => { - if (embedShouldActivateImmediately()) { - setTimeout(() => { - switchToEditMode(); - }, 200); - } - }, []); - const commonExtendedOptions = [ - { - text: "Copy writing", - action: async () => { - await rememberWritingFile(props.plugin, props.writingFileRef); - } - }, - { - text: "Remove embed", - action: () => { - props.remove(); - } - } - ]; - return /* @__PURE__ */ React89.createElement(React89.Fragment, null, /* @__PURE__ */ React89.createElement("div", { - ref: embedContainerElRef, - className: (0, import_classnames36.default)([ - "ddc_ink_embed", - "ddc_ink_writing-embed" - ]), - style: { - paddingTop: "1em", - paddingBottom: "0.5em" - } - }, /* @__PURE__ */ React89.createElement("div", { - className: "ddc_ink_resize-container", - ref: resizeContainerElRef - }, /* @__PURE__ */ React89.createElement(WritingEmbedPreviewWrapper, { - plugin: props.plugin, - onResize: (height) => resizeContainer(height), - writingFile: props.writingFileRef, - onClick: async (event) => { - switchToEditMode(); - } - }), /* @__PURE__ */ React89.createElement(TldrawWritingEditorWrapper, { - plugin: props.plugin, - onResize: (height) => resizeContainer(height), - writingFile: props.writingFileRef, - save: props.save, - embedded: true, - saveControlsReference: registerEditorControls, - closeEditor: saveAndSwitchToPreviewMode, - extendedMenu: commonExtendedOptions - })))); - function registerEditorControls(handlers) { - editorControlsRef.current = handlers; - } - function resizeContainer(height) { - if (!resizeContainerElRef.current) - return; - resizeContainerElRef.current.style.height = height + "px"; - setTimeout(() => { - if (!resizeContainerElRef.current) - return; - resizeContainerElRef.current.classList.add("ddc_ink_smooth-transition"); - }, 100); - } - function switchToEditMode() { - verbose("Set WritingEmbedState: loadingEditor"); - setEmbedState("loadingEditor" /* loadingEditor */); - } - async function saveAndSwitchToPreviewMode() { - verbose("Set WritingEmbedState: loadingPreview"); - if (editorControlsRef.current) { - await editorControlsRef.current.saveAndHalt(); - } - setEmbedState("unloadingEditor" /* loadingPreview */); - } -} -var writing_embed_default = WritingEmbed; - -// src/extensions/widgets/writing-embed-widget.tsx -function registerWritingEmbed(plugin) { - plugin.registerMarkdownCodeBlockProcessor(WRITE_EMBED_KEY, (source, el, ctx) => { - const embedData = JSON.parse(source); - const embedCtrls = { - removeEmbed: () => removeEmbed(plugin, ctx, el) - }; - if (embedData.filepath) { - ctx.addChild(new WritingEmbedWidget(el, plugin, embedData, embedCtrls)); - } - }); -} -var WritingEmbedWidget = class extends import_obsidian10.MarkdownRenderChild { - constructor(el, plugin, embedData, embedCtrls) { - super(el); - this.save = async (pageData) => { - if (!this.fileRef) - return; - const pageDataStr = stringifyPageData(pageData); - await this.plugin.app.vault.modify(this.fileRef, pageDataStr); - }; - this.el = el; - this.plugin = plugin; - this.embedData = embedData; - this.embedCtrls = embedCtrls; - } - async onload() { - const v = this.plugin.app.vault; - this.fileRef = v.getAbstractFileByPath(this.embedData.filepath); - if (!this.fileRef || !(this.fileRef instanceof import_obsidian10.TFile)) { - this.el.createEl("p").textContent = "Ink writing file not found: " + this.embedData.filepath; - return; - } - const pageDataStr = await v.read(this.fileRef); - const pageData = JSON.parse(pageDataStr); - if (!this.root) - this.root = (0, import_client2.createRoot)(this.el); - this.root.render(/* @__PURE__ */ React90.createElement(Provider, null, /* @__PURE__ */ React90.createElement(writing_embed_default, { - plugin: this.plugin, - writingFileRef: this.fileRef, - pageData, - save: this.save, - remove: this.embedCtrls.removeEmbed - }))); - applyCommonAncestorStyling(this.el); - } - async onunload() { - this.root?.unmount(); - } -}; - -// src/commands/insert-existing-writing-file.ts -var import_obsidian11 = require("obsidian"); -var insertExistingWritingFile = (plugin, editor) => { - new SelectHandwritingFileModal(plugin.app, (filepath) => { - let embedStr = buildWritingEmbed(filepath); - editor.replaceRange(embedStr, editor.getCursor()); - }).open(); -}; -var SelectHandwritingFileModal = class extends import_obsidian11.FuzzySuggestModal { - constructor(app, onSubmit) { - super(app); - this.onSubmit = onSubmit; - } - getItems() { - const allFiles = this.app.vault.getFiles(); - const files = []; - for (let i = 0; i < allFiles.length; i++) { - const file = allFiles[i]; - if (file.extension === WRITE_FILE_EXT) - files.push(file); - } - return files; - } - getItemText(file) { - return file.basename; - } - onChooseItem(file, evt) { - this.onSubmit(file.path); - } -}; -var insert_existing_writing_file_default = insertExistingWritingFile; - -// src/defaults/default-tleditor-writing-snapshot.ts -var defaultTLEditorWritingSnapshot = { - "document": { - "store": { - "document:document": { - "gridSize": 10, - "name": "", - "meta": {}, - "id": "document:document", - "typeName": "document" - }, - "page:3qj9EtNgqSCW_6knX2K9_": { - "meta": {}, - "id": "page:3qj9EtNgqSCW_6knX2K9_", - "name": "Handwritten Note", - "index": "a1", - "typeName": "page" - }, - "shape:writing-lines": { - "x": 0, - "y": 0, - "rotation": 0, - "isLocked": true, - "opacity": 1, - "meta": {}, - "type": "writing-lines", - "parentId": "page:3qj9EtNgqSCW_6knX2K9_", - "index": "a1", - "props": { - "x": 0, - "y": 0, - "w": WRITING_PAGE_WIDTH, - "h": WRITING_MIN_PAGE_HEIGHT - }, - "id": "shape:writing-lines", - "typeName": "shape" - }, - "shape:writing-container": { - "x": 0, - "y": 0, - "rotation": 0, - "isLocked": true, - "opacity": 1, - "meta": {}, - "type": "writing-container", - "parentId": "page:3qj9EtNgqSCW_6knX2K9_", - "index": "a1", - "props": { - "x": 0, - "y": 0, - "w": WRITING_PAGE_WIDTH, - "h": WRITING_MIN_PAGE_HEIGHT - }, - "id": "shape:writing-container", - "typeName": "shape" - } - }, - "schema": { - "schemaVersion": 1, - "storeVersion": 4, - "recordVersions": { - "asset": { - "version": 1, - "subTypeKey": "type", - "subTypeVersions": { - "image": 2, - "video": 2, - "bookmark": 0 - } - }, - "camera": { - "version": 1 - }, - "document": { - "version": 2 - }, - "instance": { - "version": 21 - }, - "instance_page_state": { - "version": 5 - }, - "page": { - "version": 1 - }, - "shape": { - "version": 3, - "subTypeKey": "type", - "subTypeVersions": { - "group": 0, - "text": 1, - "bookmark": 1, - "draw": 1, - "geo": 7, - "note": 4, - "line": 1, - "frame": 0, - "arrow": 1, - "highlight": 0, - "embed": 4, - "image": 2, - "video": 1, - "writing-container": 0 - } - }, - "instance_presence": { - "version": 5 - }, - "pointer": { - "version": 1 - } - } - } - }, - "session": { - "version": 0, - "currentPageId": "page:writingPage1", - "exportBackground": true, - "isFocusMode": false, - "isDebugMode": true, - "isToolLocked": false, - "isGridMode": false, - "pageStates": [ - { - "pageId": "page:writingPage1", - "camera": { - "x": 0, - "y": 100, - "z": 0.376 - }, - "selectedShapeIds": [], - "focusedGroupId": null - } - ] - } -}; - -// src/utils/createFoldersForFilepath.ts -var createFoldersForFilepath = async (plugin, filePath) => { - const splitPath = filePath.split("/"); - splitPath.pop(); - let prevPath = []; - for (let i = 0; i < splitPath.length; i++) { - const folderName = splitPath[i]; - const cascadePath = prevPath.length > 0 ? `${prevPath.join("/")}/${folderName}` : folderName; - try { - if (!plugin.app.vault.getAbstractFileByPath(cascadePath)) { - await plugin.app.vault.createFolder(cascadePath); - debug(`Created path: ${cascadePath}`); - } - } catch (e) { - error(`Couldn't create attachment folder for ${cascadePath}`, e); - } - prevPath.push(folderName); - } - ; -}; - -// src/commands/create-new-writing-file.ts -var createNewWritingFile = async (plugin, instigatingFile) => { - const filepath = await getNewTimestampedWritingFilepath(plugin, instigatingFile); - const pageData = buildWritingFileData({ - tlEditorSnapshot: defaultTLEditorWritingSnapshot - }); - await createFoldersForFilepath(plugin, filepath); - const fileRef = await plugin.app.vault.create(filepath, stringifyPageData(pageData)); - return fileRef; -}; -var create_new_writing_file_default = createNewWritingFile; - -// src/commands/insert-new-writing-file.ts -var insertNewWritingFile = async (plugin, editor) => { - const activeFile = plugin.app.workspace.getActiveFile(); - const fileRef = await create_new_writing_file_default(plugin, activeFile); - let embedStr = buildWritingEmbed(fileRef.path); - activateNextEmbed(); - const positionForEmbed = editor.getCursor(); - editor.replaceRange(embedStr, positionForEmbed); - const positionForCursor = { ...positionForEmbed }; - const embedLines = embedStr.split(/\r\n|\r|\n/); - positionForCursor.line += embedLines.length; - editor.setCursor(positionForCursor); -}; -var insert_new_writing_file_default = insertNewWritingFile; - -// src/views/writing-view.tsx -var import_obsidian12 = require("obsidian"); -var React91 = __toESM(require_react()); -var import_client3 = __toESM(require_client()); -var WRITING_VIEW_TYPE = "ink_writing-view"; -function registerWritingView(plugin) { - plugin.registerView(WRITING_VIEW_TYPE, (leaf) => new WritingView(leaf, plugin)); - plugin.registerExtensions([WRITE_FILE_EXT], WRITING_VIEW_TYPE); -} -var WritingView = class extends import_obsidian12.TextFileView { - constructor(leaf, plugin) { - super(leaf); - this.tldrawControls = {}; - this.getDisplayText = () => { - return this.file?.basename || "Handwritten note"; - }; - this.setViewData = (fileContents, clear) => { - if (!this.file) - return; - const pageData = JSON.parse(fileContents); - this.pageData = pageData; - const viewContent = this.containerEl.children[1]; - viewContent.setAttr("style", "padding: 0;"); - if (this.root) - this.clear(); - this.root = (0, import_client3.createRoot)(viewContent); - this.root.render(/* @__PURE__ */ React91.createElement(TldrawWritingEditor, { - plugin: this.plugin, - writingFile: this.file, - save: this.saveFile, - saveControlsReference: (controls) => { - this.tldrawControls.resize = controls.resize; - } - })); - }; - this.saveFile = (pageData) => { - this.pageData = pageData; - this.save(false); - }; - this.getViewData = () => { - return stringifyPageData(this.pageData); - }; - this.clear = () => { - this.root?.unmount(); - }; - this.onResize = () => { - }; - this.plugin = plugin; - } - getViewType() { - return WRITING_VIEW_TYPE; - } -}; - -// src/defaults/default-tleditor-drawing-snapshot.ts -var defaultTLEditorDrawingSnapshot = { - "document": { - "store": { - "document:document": { - "gridSize": 10, - "name": "", - "meta": {}, - "id": "document:document", - "typeName": "document" - }, - "page:3qj9EtNgqSCW_6knX2K9_": { - "meta": {}, - "id": "page:3qj9EtNgqSCW_6knX2K9_", - "name": "Handwritten Note", - "index": "a1", - "typeName": "page" - } - }, - "schema": { - "schemaVersion": 2, - "sequences": { - "com.tldraw.store": 4, - "com.tldraw.asset": 1, - "com.tldraw.camera": 1, - "com.tldraw.document": 2, - "com.tldraw.instance": 25, - "com.tldraw.instance_page_state": 5, - "com.tldraw.page": 1, - "com.tldraw.instance_presence": 5, - "com.tldraw.pointer": 1, - "com.tldraw.shape": 4, - "com.tldraw.asset.bookmark": 2, - "com.tldraw.asset.image": 5, - "com.tldraw.asset.video": 5, - "com.tldraw.shape.group": 0, - "com.tldraw.shape.text": 2, - "com.tldraw.shape.bookmark": 2, - "com.tldraw.shape.draw": 2, - "com.tldraw.shape.geo": 9, - "com.tldraw.shape.note": 7, - "com.tldraw.shape.line": 5, - "com.tldraw.shape.frame": 0, - "com.tldraw.shape.arrow": 5, - "com.tldraw.shape.highlight": 1, - "com.tldraw.shape.embed": 4, - "com.tldraw.shape.image": 4, - "com.tldraw.shape.video": 2 - } - } - }, - "session": { - "version": 0, - "currentPageId": "page:page1", - "exportBackground": true, - "isFocusMode": false, - "isDebugMode": true, - "isToolLocked": false, - "isGridMode": true, - "pageStates": [ - { - "pageId": "page:page1", - "camera": { - "x": 0, - "y": 0, - "z": 0.3 - }, - "selectedShapeIds": [], - "focusedGroupId": null - } - ] - } -}; - -// src/commands/create-new-drawing-file.ts -var createNewDrawingFile = async (plugin, instigatingFile) => { - const filepath = await getNewTimestampedDrawingFilepath(plugin, instigatingFile); - const pageData = buildDrawingFileData({ - tlEditorSnapshot: defaultTLEditorDrawingSnapshot - }); - await createFoldersForFilepath(plugin, filepath); - const fileRef = await plugin.app.vault.create(filepath, stringifyPageData(pageData)); - return fileRef; -}; -var create_new_drawing_file_default = createNewDrawingFile; - -// src/commands/insert-new-drawing-file.ts -var insertNewDrawingFile = async (plugin, editor) => { - const activeFile = plugin.app.workspace.getActiveFile(); - const fileRef = await create_new_drawing_file_default(plugin, activeFile); - let embedStr = buildDrawingEmbed(fileRef.path); - activateNextEmbed(); - const positionForEmbed = editor.getCursor(); - editor.replaceRange(embedStr, positionForEmbed); - const positionForCursor = { ...positionForEmbed }; - const embedLines = embedStr.split(/\r\n|\r|\n/); - positionForCursor.line += embedLines.length; - editor.setCursor(positionForCursor); -}; -var insert_new_drawing_file_default = insertNewDrawingFile; - -// src/commands/insert-existing-drawing-file.ts -var import_obsidian13 = require("obsidian"); -var insertExistingDrawingFile = (plugin, editor) => { - new SelectHandwritingFileModal2(plugin.app, (filepath) => { - let embedStr = buildDrawingEmbed(filepath); - editor.replaceRange(embedStr, editor.getCursor()); - }).open(); -}; -var SelectHandwritingFileModal2 = class extends import_obsidian13.FuzzySuggestModal { - constructor(app, onSubmit) { - super(app); - this.onSubmit = onSubmit; - } - getItems() { - const allFiles = this.app.vault.getFiles(); - const files = []; - for (let i = 0; i < allFiles.length; i++) { - const file = allFiles[i]; - if (file.extension === DRAW_FILE_EXT) - files.push(file); - } - return files; - } - getItemText(file) { - return file.basename; - } - onChooseItem(file, evt) { - this.onSubmit(file.path); - } -}; -var insert_existing_drawing_file_default = insertExistingDrawingFile; - -// src/views/drawing-view.tsx -var import_obsidian14 = require("obsidian"); -var React100 = __toESM(require_react()); -var import_client4 = __toESM(require_client()); - -// src/tldraw/drawing/tldraw-drawing-editor.tsx -var import_react126 = __toESM(require_react()); -var React99 = __toESM(require_react()); - -// src/tldraw/drawing-menu/drawing-menu.tsx -var React93 = __toESM(require_react()); - -// src/graphics/icons/draw-icon.tsx -var React92 = __toESM(require_react()); -var DrawIcon = (props) => /* @__PURE__ */ React92.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: "1em", - viewBox: "0 -960 960 960", - width: "1em", - ...props -}, /* @__PURE__ */ React92.createElement("path", { - d: "M554-120q-54 0-91-37t-37-89q0-76 61.5-137.5T641-460q-3-36-18-54.5T582-533q-30 0-65 25t-83 82q-78 93-114.5 121T241-277q-51 0-86-38t-35-92q0-54 23.5-110.5T223-653q19-26 28-44t9-29q0-7-2.5-10.5T250-740q-5 0-12 3t-15 11q-15 14-34.5 15T155-724q-15-16-15.5-37.5T155-797q24-21 48-32t47-11q46 0 78 32t32 80q0 29-15 64t-50 84q-38 54-56.5 95T220-413q0 17 5.5 26.5T241-377q10 0 17.5-5.5T286-409q13-14 31-34.5t44-50.5q63-75 114-107t107-32q67 0 110 45t49 123h49q21 0 35.5 14.5T840-415q0 21-14.5 35.5T790-365h-49q-8 112-58.5 178.5T554-120Zm2-100q32 0 54-36.5T640-358q-46 11-80 43.5T526-250q0 14 8 22t22 8Z" -})); - -// src/tldraw/drawing-menu/drawing-menu.tsx -var import_classnames37 = __toESM(require_classnames()); -var DrawingMenu = React93.forwardRef((props, ref) => { - const [curTool, setCurTool] = React93.useState("draw" /* draw */); - function undo() { - const editor = props.getTlEditor(); - if (!editor) - return; - silentlyChangeStore(editor, () => { - editor.undo(); - }); - props.onStoreChange(editor); - } - function redo() { - const editor = props.getTlEditor(); - if (!editor) - return; - silentlyChangeStore(editor, () => { - editor.redo(); - }); - props.onStoreChange(editor); - } - function activateSelectTool() { - const editor = props.getTlEditor(); - if (!editor) - return; - editor.setCurrentTool("select"); - setCurTool("select" /* select */); - } - function activateDrawTool() { - const editor = props.getTlEditor(); - if (!editor) - return; - editor.setCurrentTool("draw"); - setCurTool("draw" /* draw */); - } - function activateEraseTool() { - const editor = props.getTlEditor(); - if (!editor) - return; - editor.setCurrentTool("eraser"); - setCurTool("eraser" /* eraser */); - } - return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement("div", { - ref, - className: (0, import_classnames37.default)([ - "ink_menu-bar", - "ink_menu-bar_full" - ]) - }, /* @__PURE__ */ React93.createElement("div", { - className: "ink_tool-menu" - }, /* @__PURE__ */ React93.createElement("button", { - onPointerDown: activateSelectTool, - disabled: curTool === "select" /* select */ - }, /* @__PURE__ */ React93.createElement(SelectIcon, null)), /* @__PURE__ */ React93.createElement("button", { - onPointerDown: activateDrawTool, - disabled: curTool === "draw" /* draw */ - }, /* @__PURE__ */ React93.createElement(DrawIcon, null)), /* @__PURE__ */ React93.createElement("button", { - onPointerDown: activateEraseTool, - disabled: curTool === "eraser" /* eraser */ - }, /* @__PURE__ */ React93.createElement(EraseIcon, null))), /* @__PURE__ */ React93.createElement("div", { - className: "ink_other-menu" - }))); -}); -var drawing_menu_default = DrawingMenu; - -// src/tldraw/extended-drawing-menu/extended-drawing-menu.tsx -var React94 = __toESM(require_react()); -var ExtendedDrawingMenu = (props) => { - return /* @__PURE__ */ React94.createElement(React94.Fragment, null, /* @__PURE__ */ React94.createElement("div", { - className: "ink_extended-writing-menu" - }, props.onLockClick && /* @__PURE__ */ React94.createElement("button", { - onPointerDown: () => props.onLockClick?.() - }, /* @__PURE__ */ React94.createElement(LockIcon, null)), /* @__PURE__ */ React94.createElement(overflow_menu_default, { - menuOptions: props.menuOptions - }))); -}; -var extended_drawing_menu_default = ExtendedDrawingMenu; - -// src/tldraw/drawing/tldraw-drawing-editor.tsx -var import_classnames41 = __toESM(require_classnames()); - -// src/tldraw/drawing/drawing-embed.tsx -var React96 = __toESM(require_react()); -var import_react125 = __toESM(require_react()); - -// src/tldraw/drawing/drawing-embed-preview/drawing-embed-preview.tsx -var import_classnames38 = __toESM(require_classnames()); -var React95 = __toESM(require_react()); -var emptyDrawingSvg = require_empty_drawing_embed(); -var DrawingEmbedPreviewWrapper = (props) => { - const previewActive = useAtomValue(previewActiveAtom2); - if (previewActive) { - return /* @__PURE__ */ React95.createElement(DrawingEmbedPreview, { - ...props - }); - } else { - return /* @__PURE__ */ React95.createElement(React95.Fragment, null); - } -}; -var DrawingEmbedPreview = (props) => { - const svgRef = React95.useRef(null); - const containerElRef = React95.useRef(null); - const setEmbedState = useSetAtom(embedStateAtom2); - const [fileSrc, setFileSrc] = React95.useState(emptyDrawingSvg); - React95.useEffect(() => { - fetchFileData(); - return () => { - }; - }); - const isImg = fileSrc.slice(0, 4) === "data"; - return /* @__PURE__ */ React95.createElement(React95.Fragment, null, /* @__PURE__ */ React95.createElement("div", { - ref: containerElRef, - className: (0, import_classnames38.default)([ - "ddc_ink_drawing-embed-preview", - props.plugin.settings.drawingFrameWhenLocked && "ddc_ink_visible-frame", - props.plugin.settings.drawingBackgroundWhenLocked && "ddc_ink_visible-background" - ]), - style: { - position: "absolute", - width: "100%", - height: "100%", - pointerEvents: "all" - }, - onClick: props.onClick - }, isImg && /* @__PURE__ */ React95.createElement("img", { - src: fileSrc, - style: { - height: "100%", - cursor: "pointer", - pointerEvents: "all" - }, - onLoad - }), !isImg && /* @__PURE__ */ React95.createElement(InlineSVG, { - src: fileSrc, - style: { - maxWidth: "100%", - maxHeight: "100%", - cursor: "pointer" - }, - pointerEvents: "visible", - onLoad - }))); - function onLoad() { - setTimeout(() => { - setEmbedState("preview" /* preview */); - props.onReady(); - }, 100); - } - async function fetchFileData() { - const inkFileData = await getInkFileData(props.plugin, props.drawingFile); - if (inkFileData.previewUri) - setFileSrc(inkFileData.previewUri); - } -}; - -// src/utils/open-file.ts -async function openInkFile(plugin, fileRef) { - openInActiveView(plugin, fileRef); -} -async function openInActiveView(plugin, fileRef) { - let { workspace } = plugin.app; - let leaf = workspace.getLeaf(); - await leaf.openFile(fileRef); -} - -// src/tldraw/drawing/drawing-embed.tsx -var import_classnames39 = __toESM(require_classnames()); - -// src/utils/getFullPageWidth.ts -function getFullPageWidth(childEl) { - const visiblePageAreaEl = childEl?.closest(".cm-scroller"); - if (!visiblePageAreaEl) - return 500; - const maxWidth2 = visiblePageAreaEl.getBoundingClientRect().width; - return maxWidth2; -} - -// src/tldraw/drawing/drawing-embed.tsx -var emptyDrawingSvgStr = require_empty_drawing_embed(); -var embedStateAtom2 = atom2("preview" /* preview */); -var previewActiveAtom2 = atom2((get) => { - const embedState = get(embedStateAtom2); - return embedState !== "editor" /* editor */; -}); -var editorActiveAtom2 = atom2((get) => { - const embedState = get(embedStateAtom2); - return embedState !== "preview" /* preview */; -}); -function DrawingEmbed(props) { - const embedContainerElRef = (0, import_react125.useRef)(null); - const resizeContainerElRef = (0, import_react125.useRef)(null); - const editorControlsRef = (0, import_react125.useRef)(); - const embedWidthRef = (0, import_react125.useRef)(props.width || DRAWING_INITIAL_WIDTH); - const embedAspectRatioRef = (0, import_react125.useRef)(props.aspectRatio || DRAWING_INITIAL_ASPECT_RATIO); - const setEmbedState = useSetAtom(embedStateAtom2); - React96.useEffect(() => { - if (embedShouldActivateImmediately()) { - setTimeout(() => { - switchToEditMode(); - }, 200); - } - window.addEventListener("resize", handleResize); - handleResize(); - return () => { - window.removeEventListener("resize", handleResize); - }; - }, []); - const commonExtendedOptions = [ - { - text: "Copy drawing", - action: async () => { - await rememberDrawingFile(props.plugin, props.drawingFileRef); - } - }, - { - text: "Open drawing", - action: async () => { - openInkFile(props.plugin, props.drawingFileRef); - } - }, - { - text: "Remove embed", - action: () => { - props.remove(); - } - } - ]; - return /* @__PURE__ */ React96.createElement(React96.Fragment, null, /* @__PURE__ */ React96.createElement("div", { - ref: embedContainerElRef, - className: (0, import_classnames39.default)([ - "ddc_ink_embed", - "ddc_ink_drawing-embed" - ]), - style: { - paddingTop: "1em", - paddingBottom: "0.5em" - } - }, /* @__PURE__ */ React96.createElement("div", { - className: "ddc_ink_resize-container", - ref: resizeContainerElRef, - style: { - width: embedWidthRef.current + "px", - height: embedWidthRef.current / embedAspectRatioRef.current + "px", - position: "relative", - left: "50%", - translate: "-50%" - } - }, /* @__PURE__ */ React96.createElement(DrawingEmbedPreviewWrapper, { - plugin: props.plugin, - onReady: () => { - }, - drawingFile: props.drawingFileRef, - onClick: async () => { - switchToEditMode(); - } - }), /* @__PURE__ */ React96.createElement(TldrawDrawingEditorWrapper, { - onReady: () => { - }, - plugin: props.plugin, - drawingFile: props.drawingFileRef, - save: props.saveSrcFile, - embedded: true, - saveControlsReference: registerEditorControls, - closeEditor: saveAndSwitchToPreviewMode, - extendedMenu: commonExtendedOptions, - resizeEmbed - })))); - function registerEditorControls(handlers) { - editorControlsRef.current = handlers; - } - function resizeEmbed(pxWidthDiff, pxHeightDiff) { - if (!resizeContainerElRef.current) - return; - const maxWidth2 = getFullPageWidth(embedContainerElRef.current); - if (!maxWidth2) - return; - let destWidth = embedWidthRef.current + pxWidthDiff; - if (destWidth < 350) - destWidth = 350; - if (destWidth > maxWidth2) - destWidth = maxWidth2; - const curHeight = resizeContainerElRef.current.getBoundingClientRect().height; - let destHeight = curHeight + pxHeightDiff; - if (destHeight < 150) - destHeight = 150; - embedWidthRef.current = destWidth; - embedAspectRatioRef.current = destWidth / destHeight; - resizeContainerElRef.current.style.width = embedWidthRef.current + "px"; - resizeContainerElRef.current.style.height = destHeight + "px"; - } - function applyEmbedHeight() { - if (!resizeContainerElRef.current) - return; - resizeContainerElRef.current.style.width = embedWidthRef.current + "px"; - const curWidth = resizeContainerElRef.current.getBoundingClientRect().width; - resizeContainerElRef.current.style.height = curWidth / embedAspectRatioRef.current + "px"; - } - function switchToEditMode() { - verbose("Set DrawingEmbedState: loadingEditor"); - applyEmbedHeight(); - setEmbedState("loadingEditor" /* loadingEditor */); - } - async function saveAndSwitchToPreviewMode() { - verbose("Set DrawingEmbedState: loadingPreview"); - if (editorControlsRef.current) { - await editorControlsRef.current.saveAndHalt(); - } - setEmbedState("unloadingEditor" /* loadingPreview */); - props.setEmbedProps(embedWidthRef.current, embedAspectRatioRef.current); - } - function handleResize() { - const maxWidth2 = getFullPageWidth(embedContainerElRef.current); - if (resizeContainerElRef.current) { - resizeContainerElRef.current.style.maxWidth = maxWidth2 + "px"; - const curWidth = resizeContainerElRef.current.getBoundingClientRect().width; - resizeContainerElRef.current.style.height = curWidth / embedAspectRatioRef.current + "px"; - } - } - ; -} -var drawing_embed_default = DrawingEmbed; - -// src/components/jsx-components/resize-handle/resize-handle.tsx -var import_classnames40 = __toESM(require_classnames()); -var React98 = __toESM(require_react()); - -// src/graphics/icons/resize-diagonal-icon.tsx -var React97 = __toESM(require_react()); -var ResizeDiagonalIcon = (props) => /* @__PURE__ */ React97.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - height: "1em", - viewBox: "0 0 24 24", - width: "1em", - ...props -}, /* @__PURE__ */ React97.createElement("path", { - d: "M19.071 12.414a1 1 0 0 1 1 1v5.657a1 1 0 0 1-1 1h-5.657a1 1 0 0 1 0-2h4.657v-4.657a1 1 0 0 1 1-1ZM3.929 4.929a1 1 0 0 1 1-1h5.657a1 1 0 0 1 0 2H5.929v4.657a1 1 0 0 1-2 0V4.929Z" -}), /* @__PURE__ */ React97.createElement("path", { - d: "M4.222 4.222a.999.999 0 0 1 1.414 0l14.142 14.142a.999.999 0 1 1-1.414 1.414L4.222 5.636a.999.999 0 0 1 0-1.414Z" -})); - -// src/components/jsx-components/resize-handle/resize-handle.tsx -var ResizeHandle = (props) => { - const lastPointerXPosition = React98.useRef(); - const lastPointerYPosition = React98.useRef(); - return /* @__PURE__ */ React98.createElement("button", { - className: (0, import_classnames40.default)([ - "ddc_ink_resize-handle", - "ddc_ink_vertical" - ]), - onPointerDown: startResizing - }, /* @__PURE__ */ React98.createElement(ResizeDiagonalIcon, null)); - function startResizing(e) { - document.addEventListener("mousemove", handleMouseResizing); - document.addEventListener("mouseup", stopResizing); - document.addEventListener("touchmove", handleTouchResizing, { passive: false }); - document.addEventListener("touchend", stopResizing); - } - function stopResizing(e) { - document.removeEventListener("mousemove", handleMouseResizing); - document.removeEventListener("mouseup", stopResizing); - document.removeEventListener("touchmove", handleTouchResizing); - document.removeEventListener("touchend", stopResizing); - delete lastPointerXPosition.current; - delete lastPointerYPosition.current; - } - function handleMouseResizing(e) { - let horzDiff = e.movementX; - horzDiff *= 2; - let vertDiff = e.movementY; - props.resizeEmbed(horzDiff, vertDiff); - } - function handleTouchResizing(e) { - e.preventDefault(); - e.stopPropagation(); - const touchPointer = e.changedTouches.item(0); - if (!touchPointer || e.changedTouches.length !== 1) - return; - if (lastPointerXPosition.current && lastPointerYPosition.current) { - let horzDiff = touchPointer.pageX - lastPointerXPosition.current; - horzDiff *= 2; - const vertDiff = touchPointer.pageY - lastPointerYPosition.current; - props.resizeEmbed(horzDiff, vertDiff); - } - lastPointerXPosition.current = touchPointer.pageX; - lastPointerYPosition.current = touchPointer.pageY; - } -}; - -// src/tldraw/drawing/tldraw-drawing-editor.tsx -var TldrawDrawingEditorWrapper = (props) => { - const editorActive = useAtomValue(editorActiveAtom2); - if (editorActive) { - return /* @__PURE__ */ React99.createElement(TldrawDrawingEditor2, { - ...props - }); - } else { - return /* @__PURE__ */ React99.createElement(React99.Fragment, null); - } -}; -var myOverrides = {}; -var tlOptions2 = { - defaultSvgPadding: 10 -}; -function TldrawDrawingEditor2(props) { - const [tlEditorSnapshot, setTlEditorSnapshot] = React99.useState(); - const setEmbedState = useSetAtom(embedStateAtom2); - const shortDelayPostProcessTimeoutRef = (0, import_react126.useRef)(); - const longDelayPostProcessTimeoutRef = (0, import_react126.useRef)(); - const tlEditorRef = (0, import_react126.useRef)(); - const editorWrapperRefEl = (0, import_react126.useRef)(null); - React99.useEffect(() => { - verbose("EDITOR mounted"); - fetchFileData(); - return () => { - verbose("EDITOR unmounting"); - }; - }, []); - if (!tlEditorSnapshot) - return /* @__PURE__ */ React99.createElement(React99.Fragment, null); - verbose("EDITOR snapshot loaded"); - const defaultComponents = { - Scribble: TldrawScribble, - ShapeIndicators: TldrawShapeIndicators, - CollaboratorScribble: TldrawScribble, - SelectionForeground: TldrawSelectionForeground, - SelectionBackground: TldrawSelectionBackground, - Handles: TldrawHandles - }; - const handleMount = (_editor) => { - const editor = tlEditorRef.current = _editor; - setEmbedState("editor" /* editor */); - focusChildTldrawEditor(editorWrapperRefEl.current); - preventTldrawCanvasesCausingObsidianGestures(editor); - adaptTldrawToObsidianThemeMode(editor); - editor.updateInstanceState({ - isGridMode: true - }); - initDrawingCamera(editor); - if (props.embedded) { - editor.setCameraOptions({ - isLocked: true - }); - } - if (editorWrapperRefEl.current) { - editorWrapperRefEl.current.style.opacity = "1"; - } - const removeUserActionListener = editor.store.listen((entry) => { - const activity = getActivityType(entry); - switch (activity) { - case 0 /* PointerMoved */: - break; - case 2 /* CameraMovedAutomatically */: - case 1 /* CameraMovedManually */: - break; - case 3 /* DrawingStarted */: - resetInputPostProcessTimers(); - break; - case 4 /* DrawingContinued */: - resetInputPostProcessTimers(); - break; - case 5 /* DrawingCompleted */: - queueOrRunStorePostProcesses(editor); - embedPostProcess(editor); - break; - case 6 /* DrawingErased */: - queueOrRunStorePostProcesses(editor); - embedPostProcess(editor); - break; - default: - queueOrRunStorePostProcesses(editor); - verbose("Activity not recognised."); - verbose(["entry", entry], { freeze: true }); - } - }, { - source: "user", - scope: "all" - }); - const unmountActions = () => { - resetInputPostProcessTimers(); - removeUserActionListener(); - }; - if (props.saveControlsReference) { - props.saveControlsReference({ - save: () => completeSave(editor), - saveAndHalt: async () => { - await completeSave(editor); - unmountActions(); - } - }); - } - if (props.onReady) - props.onReady(); - return () => { - unmountActions(); - }; - }; - async function fetchFileData() { - const inkFileData = await getInkFileData(props.plugin, props.drawingFile); - if (inkFileData.tldraw) { - const snapshot = prepareDrawingSnapshot(inkFileData.tldraw); - setTlEditorSnapshot(snapshot); - } - } - const embedPostProcess = (editor) => { - }; - const queueOrRunStorePostProcesses = (editor) => { - instantInputPostProcess(editor); - smallDelayInputPostProcess(editor); - longDelayInputPostProcess(editor); - }; - const instantInputPostProcess = (editor) => { - }; - const smallDelayInputPostProcess = (editor) => { - resetShortPostProcessTimer(); - shortDelayPostProcessTimeoutRef.current = setTimeout(() => { - incrementalSave(editor); - }, DRAW_SHORT_DELAY_MS); - }; - const longDelayInputPostProcess = (editor) => { - resetLongPostProcessTimer(); - longDelayPostProcessTimeoutRef.current = setTimeout(() => { - completeSave(editor); - }, DRAW_LONG_DELAY_MS); - }; - const resetShortPostProcessTimer = () => { - clearTimeout(shortDelayPostProcessTimeoutRef.current); - }; - const resetLongPostProcessTimer = () => { - clearTimeout(longDelayPostProcessTimeoutRef.current); - }; - const resetInputPostProcessTimers = () => { - resetShortPostProcessTimer(); - resetLongPostProcessTimer(); - }; - const incrementalSave = async (editor) => { - verbose("incrementalSave"); - const tlEditorSnapshot2 = getSnapshot(editor.store); - const pageData = buildDrawingFileData({ - tlEditorSnapshot: tlEditorSnapshot2, - previewIsOutdated: true - }); - props.save(pageData); - }; - const completeSave = async (editor) => { - verbose("completeSave"); - let previewUri; - const tlEditorSnapshot2 = getSnapshot(editor.store); - const svgObj = await getDrawingSvg(editor); - if (svgObj) { - previewUri = svgObj.svg; - } - if (previewUri) { - const pageData = buildDrawingFileData({ - tlEditorSnapshot: tlEditorSnapshot2, - previewUri - }); - props.save(pageData); - } else { - const pageData = buildDrawingFileData({ - tlEditorSnapshot: tlEditorSnapshot2 - }); - props.save(pageData); - } - return; - }; - const getTlEditor = () => { - return tlEditorRef.current; - }; - const customExtendedMenu = [ - { - text: "Grid on/off", - action: () => { - const editor = getTlEditor(); - if (editor) { - editor.updateInstanceState({ isGridMode: !editor.getInstanceState().isGridMode }); - } - } - }, - ...props.extendedMenu || [] - ]; - return /* @__PURE__ */ React99.createElement(React99.Fragment, null, /* @__PURE__ */ React99.createElement("div", { - ref: editorWrapperRefEl, - className: (0, import_classnames41.default)([ - "ddc_ink_drawing-editor" - ]), - style: { - height: "100%", - position: "relative", - opacity: 0 - } - }, /* @__PURE__ */ React99.createElement(TldrawEditor, { - options: tlOptions2, - shapeUtils: [...defaultShapeUtils], - tools: [...defaultTools, ...defaultShapeTools], - initialState: "draw", - overrides: myOverrides, - snapshot: tlEditorSnapshot, - components: defaultComponents, - onMount: handleMount, - autoFocus: false - }), /* @__PURE__ */ React99.createElement(PrimaryMenuBar, null, /* @__PURE__ */ React99.createElement(drawing_menu_default, { - getTlEditor, - onStoreChange: (tlEditor) => queueOrRunStorePostProcesses(tlEditor) - }), props.embedded && props.extendedMenu && /* @__PURE__ */ React99.createElement(extended_drawing_menu_default, { - onLockClick: async () => { - if (props.closeEditor) - props.closeEditor(); - }, - menuOptions: customExtendedMenu - }), !props.embedded && props.extendedMenu && /* @__PURE__ */ React99.createElement(extended_drawing_menu_default, { - menuOptions: customExtendedMenu - })), /* @__PURE__ */ React99.createElement(SecondaryMenuBar, null, /* @__PURE__ */ React99.createElement(modify_menu_default, { - getTlEditor, - onStoreChange: (tlEditor) => queueOrRunStorePostProcesses(tlEditor) - }))), props.resizeEmbed && /* @__PURE__ */ React99.createElement(ResizeHandle, { - resizeEmbed - })); - function resizeEmbed(pxWidthDiff, pxHeightDiff) { - if (!props.resizeEmbed) - return; - props.resizeEmbed(pxWidthDiff, pxHeightDiff); - } -} - -// src/views/drawing-view.tsx -var DRAWING_VIEW_TYPE = "ink_drawing-view"; -function getExtendedOptions(plugin, fileRef) { - return [ - { - text: "Copy drawing", - action: async () => { - await rememberDrawingFile(plugin, fileRef); - } - } - ]; -} -function registerDrawingView(plugin) { - plugin.registerView(DRAWING_VIEW_TYPE, (leaf) => new DrawingView(leaf, plugin)); - plugin.registerExtensions([DRAW_FILE_EXT], DRAWING_VIEW_TYPE); -} -var DrawingView = class extends import_obsidian14.TextFileView { - constructor(leaf, plugin) { - super(leaf); - this.getDisplayText = () => { - return this.file?.basename || "Drawing"; - }; - this.setViewData = (fileContents, clear) => { - if (!this.file) - return; - const pageData = JSON.parse(fileContents); - this.pageData = pageData; - const viewContent = this.containerEl.children[1]; - viewContent.setAttr("style", "padding: 0;"); - if (this.root) - this.clear(); - this.root = (0, import_client4.createRoot)(viewContent); - this.root.render(/* @__PURE__ */ React100.createElement(Provider, null, /* @__PURE__ */ React100.createElement(TldrawDrawingEditor2, { - onReady: () => { - }, - plugin: this.plugin, - drawingFile: this.file, - save: this.saveFile, - extendedMenu: getExtendedOptions(this.plugin, this.file) - }))); - }; - this.saveFile = (pageData) => { - this.pageData = pageData; - this.save(false); - }; - this.getViewData = () => { - return stringifyPageData(this.pageData); - }; - this.clear = () => { - this.root?.unmount(); - }; - this.plugin = plugin; - } - getViewType() { - return DRAWING_VIEW_TYPE; - } -}; - -// src/extensions/widgets/drawing-embed-widget.tsx -var import_obsidian15 = require("obsidian"); -var React101 = __toESM(require_react()); -var import_client5 = __toESM(require_client()); -function registerDrawingEmbed(plugin) { - plugin.registerMarkdownCodeBlockProcessor(DRAW_EMBED_KEY, (source, el, ctx) => { - const embedData = JSON.parse(source); - const embedCtrls = { - removeEmbed: () => removeEmbed(plugin, ctx, el) - }; - if (embedData.filepath) { - ctx.addChild(new DrawingEmbedWidget(el, plugin, embedData, embedCtrls, (newEmbedData) => updateEmbed(plugin, ctx, el, newEmbedData))); - } - }); -} -function updateEmbed(plugin, ctx, el, embedData) { - const cmEditor = plugin.app.workspace.activeEditor?.editor; - if (!cmEditor) - return; - const sectionInfo = ctx.getSectionInfo(el); - if (sectionInfo?.lineStart === void 0 || sectionInfo.lineEnd === void 0) - return; - const embedStart = { - line: sectionInfo.lineStart + 1, - ch: 0 - }; - const embedEnd = { - line: sectionInfo.lineEnd - 1, - ch: 1 - }; - cmEditor.replaceRange(stringifyEmbedData(embedData), embedStart, embedEnd); - cmEditor.setCursor(embedStart); -} -var DrawingEmbedWidget = class extends import_obsidian15.MarkdownRenderChild { - constructor(el, plugin, embedData, embedCtrls, updateEmbed2) { - super(el); - this.save = async (pageData) => { - if (!this.fileRef) - return; - const pageDataStr = stringifyPageData(pageData); - await this.plugin.app.vault.modify(this.fileRef, pageDataStr); - }; - this.setEmbedProps = async (width, aspectRatio) => { - const newEmbedData = { - ...this.embedData, - width, - aspectRatio - }; - this.updateEmbed(newEmbedData); - }; - this.el = el; - this.plugin = plugin; - this.embedData = embedData; - this.embedCtrls = embedCtrls; - this.updateEmbed = updateEmbed2; - } - async onload() { - const v = this.plugin.app.vault; - this.fileRef = v.getAbstractFileByPath(this.embedData.filepath); - if (!this.fileRef || !(this.fileRef instanceof import_obsidian15.TFile)) { - this.el.createEl("p").textContent = "Ink drawing file not found."; - return; - } - const pageDataStr = await v.read(this.fileRef); - const pageData = JSON.parse(pageDataStr); - this.root = (0, import_client5.createRoot)(this.el); - this.root.render(/* @__PURE__ */ React101.createElement(Provider, null, /* @__PURE__ */ React101.createElement(drawing_embed_default, { - plugin: this.plugin, - drawingFileRef: this.fileRef, - pageData, - saveSrcFile: this.save, - setEmbedProps: this.setEmbedProps, - remove: this.embedCtrls.removeEmbed, - width: this.embedData.width, - aspectRatio: this.embedData.aspectRatio - }))); - applyCommonAncestorStyling(this.el); - } - async onunload() { - this.root?.unmount(); - } -}; - -// src/commands/insert-remembered-drawing-file.ts -var import_obsidian17 = require("obsidian"); - -// src/modals/confirmation-modal/insert-copied-file-modal.ts -var import_obsidian16 = require("obsidian"); -var InsertCopiedFileModal = class extends import_obsidian16.Modal { - constructor(options) { - super(options.plugin.app); - this.filetype = options.filetype; - this.instanceAction = options.instanceAction; - this.duplicateAction = options.duplicateAction; - this.cancelAction = options.cancelAction; - } - onOpen() { - const { titleEl, contentEl } = this; - titleEl.setText(`Insert copied ${this.filetype} file`); - new import_obsidian16.Setting(contentEl).setClass("ddc_ink_primary-2-button-set").addButton((btn) => { - btn.setClass("ddc_ink_button"); - btn.setCta(); - btn.setButtonText("Reference existing file"); - btn.onClick(() => { - this.close(); - this.instanceAction(); - }); - }).addButton((btn) => { - btn.setClass("ddc_ink_button"); - btn.setCta(); - btn.setButtonText("Make duplicate"); - btn.onClick(() => { - this.close(); - this.duplicateAction(); - }); - }); - new import_obsidian16.Setting(contentEl).setClass("ddc_ink_modal-actions").addButton((btn) => { - btn.setClass("ddc_ink_backward-button"); - btn.setButtonText("Cancel"); - btn.onClick(() => { - this.close(); - this.cancelAction(); - }); - }); - } - onClose() { - } -}; - -// src/commands/insert-remembered-drawing-file.ts -var insertRememberedDrawingFile = async (plugin, editor) => { - const v = plugin.app.vault; - const existingFilePath = fetchLocally("rememberedDrawingFile"); - if (!existingFilePath || typeof existingFilePath !== "string") { - new import_obsidian17.Notice("Copy a drawing embed first."); - return; - } - const existingFileRef = v.getAbstractFileByPath(existingFilePath); - if (!(existingFileRef instanceof import_obsidian17.TFile)) { - new import_obsidian17.Notice("Cannot insert.\nCopied drawing file no longer exists."); - return; - } - new InsertCopiedFileModal({ - plugin, - filetype: "drawing", - instanceAction: () => { - let embedStr = buildDrawingEmbed(existingFileRef.path); - editor.replaceRange(embedStr, editor.getCursor()); - }, - duplicateAction: async () => { - const activeFile = plugin.app.workspace.getActiveFile(); - const duplicatedFileRef = await duplicateDrawingFile(plugin, existingFileRef, activeFile); - if (!duplicatedFileRef) - return; - new import_obsidian17.Notice("Drawing file duplicated"); - let embedStr = buildDrawingEmbed(duplicatedFileRef.path); - editor.replaceRange(embedStr, editor.getCursor()); - }, - cancelAction: () => { - new import_obsidian17.Notice("Insert cancelled."); - } - }).open(); -}; -var insert_remembered_drawing_file_default = insertRememberedDrawingFile; - -// src/commands/insert-remembered-writing-file.ts -var import_obsidian18 = require("obsidian"); -var insertRememberedWritingFile = async (plugin, editor) => { - const v = plugin.app.vault; - const existingFilePath = fetchLocally("rememberedWritingFile"); - if (!existingFilePath || typeof existingFilePath !== "string") { - new import_obsidian18.Notice("Copy a writing embed first."); - return; - } - const existingFileRef = v.getAbstractFileByPath(existingFilePath); - if (!(existingFileRef instanceof import_obsidian18.TFile)) { - new import_obsidian18.Notice("Cannot insert.\nCopied writing file no longer exists."); - return; - } - new InsertCopiedFileModal({ - plugin, - filetype: "writing", - instanceAction: () => { - let embedStr = buildWritingEmbed(existingFileRef.path); - editor.replaceRange(embedStr, editor.getCursor()); - }, - duplicateAction: async () => { - const activeFile = plugin.app.workspace.getActiveFile(); - const duplicatedFileRef = await duplicateWritingFile(plugin, existingFileRef, activeFile); - if (!duplicatedFileRef) - return; - new import_obsidian18.Notice("Writing file duplicated"); - let embedStr = buildWritingEmbed(duplicatedFileRef.path); - editor.replaceRange(embedStr, editor.getCursor()); - }, - cancelAction: () => { - new import_obsidian18.Notice("Insert cancelled."); - } - }).open(); -}; -var insert_remembered_writing_file_default = insertRememberedWritingFile; - -// src/graphics/social-icons/social-icons.ts -var blueskySvgStr = require_bluesky(); -var mastodonSvgStr = require_mastodon(); -var threadsSvgStr = require_threads(); -var twitterSvgStr = require_twitter(); - -// src/notices/version-notices.ts -var semVer = __toESM(require_semver2()); -function showVersionNotice(plugin) { - let curVersion = plugin.manifest.version; - if (curVersion.endsWith("-beta")) { - curVersion = curVersion.replace("-beta", ""); - } - const lastVersionTipRead = plugin.settings.onboardingTips.lastVersionTipRead; - const noLastVersionTipRead = !semVer.valid(lastVersionTipRead); - const updatedToNewerVersion = noLastVersionTipRead || semVer.gt(curVersion, lastVersionTipRead); - if (updatedToNewerVersion) { - showChanges(plugin); - } -} -function showChanges(plugin) { - const noticeBody = createInkNoticeTemplate(1, 3); - noticeBody.createEl("h1").setText(`Changes in Ink v0.3.4`); - const listEl = noticeBody.createEl("ul"); - listEl.createEl("li").setText(`Fixed update notice text colour in light mode (That's why you can read this!).`); - listEl.createEl("li").setText(`Moved Undo/Redo buttons to prevent accidental back button taps.`); - listEl.createEl("li").setText(`Added new command icons.`); - listEl.createEl("li").setText(`Added extra blank lines while writing.`); - listEl.createEl("li").setText(`Fixed some visual theming bugs.`); - const link = noticeBody.createEl("a"); - link.setAttribute("href", "https://youtube.com/live/50EpBdPwrxY"); - link.setText(`View release video`); - link.onClickEvent((e) => e.stopPropagation()); - const { - tertiaryBtnEl - } = createNoticeCtaBar(noticeBody, { - tertiaryLabel: "Dismiss" - }); - const notice = launchPersistentInkNotice(noticeBody); - if (tertiaryBtnEl) { - tertiaryBtnEl.addEventListener("click", () => { - notice.hide(); - plugin.settings.onboardingTips.lastVersionTipRead = plugin.manifest.version; - plugin.saveSettings(); - }); - } -} - -// src/graphics/icons/command-icons.ts -var writeDefaultSvgStr = require_write_default(); -var writeExistingSvgStr = require_write_existing(); -var writePasteSvgStr = require_write_paste(); -var drawDefaultSvgStr = require_draw_default(); -var drawExistingSvgStr = require_draw_existing(); -var drawPasteSvgStr = require_draw_paste(); - -// src/main.ts -var InkPlugin = class extends import_obsidian19.Plugin { - async onload() { - await this.loadSettings(); - (0, import_obsidian19.addIcon)("write_default", writeDefaultSvgStr); - (0, import_obsidian19.addIcon)("write_existing", writeExistingSvgStr); - (0, import_obsidian19.addIcon)("write_paste", writePasteSvgStr); - (0, import_obsidian19.addIcon)("draw_default", drawDefaultSvgStr); - (0, import_obsidian19.addIcon)("draw_existing", drawExistingSvgStr); - (0, import_obsidian19.addIcon)("draw_paste", drawPasteSvgStr); - (0, import_obsidian19.addIcon)("bluesky", blueskySvgStr); - (0, import_obsidian19.addIcon)("mastodon", mastodonSvgStr); - (0, import_obsidian19.addIcon)("threads", threadsSvgStr); - (0, import_obsidian19.addIcon)("twitter", twitterSvgStr); - if (this.settings.writingEnabled) { - registerWritingView(this); - registerWritingEmbed(this); - implementWritingEmbedActions(this); - } - if (this.settings.drawingEnabled) { - registerDrawingView(this); - registerDrawingEmbed(this); - implementDrawingEmbedActions(this); - } - registerSettingsTab(this); - showOnboardingTips_maybe(this); - } - onunload() { - } - async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); - } - async saveSettings() { - await this.saveData(this.settings); - } - async resetSettings() { - this.settings = JSON.parse(JSON.stringify(DEFAULT_SETTINGS)); - this.saveSettings(); - new import_obsidian19.Notice("Ink plugin settings reset"); - } -}; -var inkPluginAtom = atom2(); -function implementWritingEmbedActions(plugin) { - plugin.addCommand({ - id: "create-handwritten-section", - name: "New handwriting section", - icon: "write_default", - editorCallback: (editor) => insert_new_writing_file_default(plugin, editor) - }); - plugin.addCommand({ - id: "embed-writing-file", - name: "Existing handwriting section", - icon: "write_existing", - editorCallback: (editor) => insert_existing_writing_file_default(plugin, editor) - }); - plugin.addCommand({ - id: "insert-copied-writing", - name: "Copied handwriting section", - icon: "write_paste", - editorCallback: (editor) => insert_remembered_writing_file_default(plugin, editor) - }); -} -function implementDrawingEmbedActions(plugin) { - plugin.addCommand({ - id: "create-drawing-section", - name: "New drawing", - icon: "draw_default", - editorCallback: (editor) => insert_new_drawing_file_default(plugin, editor) - }); - plugin.addCommand({ - id: "embed-drawing-file", - name: "Existing drawing", - icon: "draw_existing", - editorCallback: (editor) => insert_existing_drawing_file_default(plugin, editor) - }); - plugin.addCommand({ - id: "insert-copied-drawing", - name: "Copied drawing", - icon: "draw_paste", - editorCallback: (editor) => insert_remembered_drawing_file_default(plugin, editor) - }); -} -function showOnboardingTips_maybe(plugin) { - const newInstall = showWelcomeTips_maybe(plugin); - if (!newInstall) { - showVersionNotice(plugin); - } -} -/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ -/*! - * Author: excalidraw - * MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE - * https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600 - */ -/*! - * MIT License - * Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit - * Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it) - */ -/*! - * MIT License - * Modified code originally from <https://github.com/qzb/is-animated> - * Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com> - */ -/*! - * MIT License: https://github.com/alexgorbatchev/crc/blob/master/LICENSE - * Copyright: 2014 Alex Gorbatchev - * Code: crc32, https://github.com/alexgorbatchev/crc/blob/master/src/calculators/crc32.ts - */ -/*! - * MIT License: https://github.com/sindresorhus/is-webp/blob/main/license - * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) - */ -/*! - * MIT License: https://github.com/vHeemstra/is-apng/blob/main/license - * Copyright (c) Philip van Heemstra - */ -/*! - * canvas-size - * v1.2.6 - * https://github.com/jhildenbiddle/canvas-size - * (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com> - * MIT license - */ -/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/** - * @license React - * react-jsx-runtime.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/** - * @license React - * scheduler.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* nosourcemap */
\ No newline at end of file diff --git a/.obsidian/plugins/ink/manifest.json b/.obsidian/plugins/ink/manifest.json deleted file mode 100755 index fe63491..0000000 --- a/.obsidian/plugins/ink/manifest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "ink", - "name": "Ink", - "author": "Dale de Silva", - "description": "Hand write or draw directly between paragraphs in your notes using a digital pen, stylus, or Apple pencil. Useful for handwriting, sketches, scribbles, or even math equations and scientific notation. Runs on the tldraw framework and drawing provides an infinite canvas.", - "version": "0.3.4", - "minAppVersion": "1.00.0", - "authorUrl": "https://designdebt.club", - "fundingUrl": "https://ko-fi.com/daledesilva", - "isDesktopOnly": false -} diff --git a/.obsidian/plugins/ink/styles.css b/.obsidian/plugins/ink/styles.css deleted file mode 100755 index 97a5fa7..0000000 --- a/.obsidian/plugins/ink/styles.css +++ /dev/null @@ -1,6585 +0,0 @@ -@charset "UTF-8"; - -/* src/ddc-library/settings-styles.scss */ -.ddc_ink_primary-2-button-set .setting-item-info { - display: none; -} -.ddc_ink_primary-2-button-set .setting-item-control > * { - flex-grow: 1; - font-size: var(--font-ui-medium); - height: unset; - line-height: 2em; - width: 50%; -} -.ddc_ink_modal-actions .setting-item-info { - display: none; -} - -/* src/components/dom-components/support-button-set.scss */ -.ddc_ink_support-btn-set .setting-item { - border-top: none !important; -} -.ddc_ink_support-btn-set .setting-item .setting-item-info { - flex-grow: 2; - text-align: right; -} -.ddc_ink_support-btn-set .setting-item .setting-item-control { - flex-grow: 0; -} -.ddc_ink_support-btn-set .ddc_ink_tertiary-button { - color: var(--text-subtle); - background: none; - box-shadow: none; - padding-inline: var(--size-4-1); -} -.ddc_ink_support-btn-set .ddc_ink_tertiary-button:hover { - color: var(--text-normal); -} -.ddc_ink_support-btn-set .ddc_ink_secondary-button { - color: var(--text-normal); -} -.ddc_ink_support-btn-set .ddc_ink_secondary-button svg path { - fill: var(--text-normal); -} -.ddc_ink_support-btn-set .ddc_ink_primary-button { - color: var(--text-on-accent); - background-color: var(--interactive-accent); -} -.ddc_ink_support-btn-set .ddc_ink_primary-button svg path { - fill: var(--text-on-accent); -} -.ddc_ink_support-btn-set .ddc_ink_primary-button:hover { - background-color: var(--interactive-accent-hover); -} - -/* src/tabs/settings-tab/settings-tab.scss */ -.ddc_ink_section { - margin-bottom: 2em; -} -.ddc_ink_section details { - overflow: hidden; - border-style: solid; - border-color: rgba(var(--callout-color), var(--callout-border-opacity)); - border-width: var(--callout-border-width); - border-radius: var(--callout-radius); - background-color: rgba(var(--callout-color), 0.05); - padding: 1em; - margin-block: 1em; - margin-inline: -1em; - --callout-color: - 255,255,255; -} -.ddc_ink_section details.warning { - --callout-color: var(--callout-warning); -} -.ddc_ink_section details summary { - font-weight: 600; -} -.ddc_ink_controls-section { - padding-block-start: 0.2em; - padding-block-end: 0.2em; - padding-inline: 1em; - margin-inline: -1em; - border: none; - border-radius: 10px; - background-color: var(--color-base-20); -} -.ddc_ink_input-medium .setting-item-control input { - width: 100%; -} -.ddc_ink_button-set { - flex-wrap: wrap; - row-gap: 0.5em; -} -.ddc_ink_button-set .setting-item-info { - width: 100%; -} -.ddc_ink_button-set .setting-item-control { - gap: 2px; - flex-wrap: wrap; - padding-bottom: 0.9em; -} -.ddc_ink_button-set .setting-item-control button { - flex-grow: 1; - flex-shrink: 1; -} -.ddc_ink_button-set .setting-item-control .ddc_ink_middle { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} -.ddc_ink_button-set .setting-item-control .ddc_ink_left-most { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} -.ddc_ink_button-set .setting-item-control .ddc_ink_right-most { - border-top-left-radius: 0; - border-bottom-left-radius: 0; -} -.ddc_ink_button-set .setting-item-control .mod-cta:disabled { - box-shadow: inset 1px 1px 3px 0.5px rgba(0, 0, 0, 0.6); - pointer-events: none; -} - -/* src/components/dom-components/notice-components.scss */ -.notice:has(.ddc_ink_notice) { - border-radius: var(--radius-m) !important; - background-color: var(--background-primary-alt) !important; - border: solid 1px var(--background-modifier-border) !important; - box-shadow: 0 2px 8px var(--background-modifier-box-shadow) !important; - pointer-events: none; -} -.ddc_ink_notice { - text-align: left !important; -} -.ddc_ink_notice p.ddc_ink_notice-label { - color: var(--text-faint); - font-size: var(--font-small); - margin: 0; - padding: 0; -} -.ddc_ink_notice h1 { - margin-block-start: 0.1em; - color: var(--text-accent); -} -.ddc_ink_notice p { - font-size: var(--font-text-size); - color: var(--text-normal); -} -.ddc_ink_notice blockquote { - font-size: var(--font-text-size); - padding: 0.5em 0.8em; - margin-inline: 0; - color: var(--text-accent); - background-color: var(--background-primary); - border-radius: var(--button-radius); - display: block; - outline: solid 1px var(--background-modifier-border); - box-shadow: inset 0px 0px 8px var(--background-modifier-box-shadow), 0px 0px 8px var(--background-modifier-box-shadow) !important; -} -.ddc_ink_notice ul, -.ddc_ink_notice ol { - padding-inline-start: 1em; - list-style-position: outside; -} -.ddc_ink_notice ul li, -.ddc_ink_notice ol li { - margin-block-end: 1ch; - color: var(--text-normal); -} -.ddc_ink_notice ul li::marker, -.ddc_ink_notice ol li::marker { - color: var(--text-accent); -} -.ddc_ink_notice a { - pointer-events: all; -} -.ddc_ink_notice .ddc_ink_notice-cta-bar { - display: flex; - flex-direction: row-reverse; - justify-content: space-between; -} -.ddc_ink_notice .ddc_ink_notice-cta-bar Button { - pointer-events: all; -} -.ddc_ink_notice .ddc_ink_notice-cta-bar Button.ddc_ink_tertiary-btn { - color: var(--text-faint); - background: none; - box-shadow: none; - margin-inline: 0; - padding-inline: 0; - padding-top: calc(var(--size-4-1) * 2); - padding-bottom: 0 !important; - display: inline-flex; - align-items: flex-end; - line-height: var(--font-ui-small) !important; -} -.ddc_ink_notice .ddc_ink_notice-cta-bar Button.ddc_ink_tertiary-btn:hover { - color: var(--text-normal); - text-decoration: underline; -} -.ddc_ink_notice .ddc_ink_notice-cta-bar Button.ddc_ink_primary-btn { - color: var(--text-on-accent); - background-color: var(--interactive-accent); -} -.ddc_ink_notice .ddc_ink_notice-cta-bar Button.ddc_ink_primary-btn:hover { - background-color: var(--interactive-accent-hover); -} - -/* src/components/dom-components/toggle-accordion-setting.scss */ -.ddc_ink_toggle-accordion { - padding: 0; -} -.ddc_ink_toggle-accordion .ddc_ink_toggle-accordion-header .ddc_ink_setting { - padding: 0.75em 0; - border-top: 1px solid var(--background-modifier-border); -} -.ddc_ink_toggle-accordion .ddc_ink_toggle-accordion-content { - display: none; -} -.ddc_ink_toggle-accordion.ddc_ink_expanded { - margin-inline: -1em; - margin-bottom: 2em; - border: none; - border-radius: 10px; - overflow: hidden; - background-color: var(--color-base-20); -} -.ddc_ink_toggle-accordion.ddc_ink_expanded .ddc_ink_toggle-accordion-header { - padding-block: 0em; - padding-inline: 1em; - margin-inline: 0; - background-color: var(--background-secondary-alt); -} -.ddc_ink_toggle-accordion.ddc_ink_expanded .ddc_ink_toggle-accordion-header .ddc_ink_setting { - border-top: none; -} -.ddc_ink_toggle-accordion.ddc_ink_expanded .ddc_ink_toggle-accordion-content { - display: block; - background-color: var(--background-primary-alt); - padding-block-start: 0.8em; - padding-block-end: 0; - padding-inline: 1em; -} - -/* src/tldraw/writing/writing-embed.scss */ -.ddc_ink_resize-container.ddc_ink_smooth-transition { - transition-property: height; - transition-duration: 0.5s; - transition-timing-function: ease-out; -} -.markdown-source-view.mod-cm6 .cm-content > .cm-preview-code-block.cm-embed-block.markdown-rendered.ddc_ink_embed-block, -.markdown-source-view.mod-cm6 .cm-content > .cm-preview-code-block.cm-embed-block.markdown-rendered.ddc_ink_embed-block:hover { - contain: unset !important; - overflow: visible !important; - box-shadow: none; -} -.markdown-source-view.mod-cm6 .cm-content > .cm-preview-code-block.cm-embed-block.markdown-rendered.ddc_ink_embed-block .edit-block-button, -.markdown-source-view.mod-cm6 .cm-content > .cm-preview-code-block.cm-embed-block.markdown-rendered.ddc_ink_embed-block:hover .edit-block-button { - display: none; -} - -/* src/tldraw/writing/tldraw-writing-editor.scss */ -.ddc_ink_drawing-editor, -.ddc_ink_writing-editor { -} -.ddc_ink_drawing-editor .tl-container, -.ddc_ink_writing-editor .tl-container { - width: 100%; - height: 100%; - font-size: 12px; - --space-1: 2px; - --space-2: 4px; - --space-3: 8px; - --space-4: 12px; - --space-5: 16px; - --space-6: 20px; - --space-7: 28px; - --space-8: 32px; - --space-9: 64px; - --space-10: 72px; - --radius-0: 2px; - --radius-1: 4px; - --radius-2: 6px; - --radius-3: 9px; - --radius-4: 11px; - --layer-background: 100; - --layer-grid: 150; - --layer-canvas: 200; - --layer-shapes: 300; - --layer-overlays: 400; - --layer-following-indicator: 1000; - --tl-zoom: 1; - --tl-cursor-none: none; - --tl-cursor-default: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z' fill='white'/><path d='m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z' fill='white'/><path d='m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z' fill='black'/><path d='m13 10.814v11.188l2.969-2.866.428-.139h4.768z' fill='black'/></g></svg>") 12 8, default; - --tl-cursor-pointer: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m13.3315 21.3799c-.284-.359-.629-1.093-1.243-1.984-.348-.504-1.211-1.453-1.468-1.935-.223-.426-.199-.617-.146-.97.094-.628.738-1.117 1.425-1.051.519.049.959.392 1.355.716.239.195.533.574.71.788.163.196.203.277.377.509.23.307.302.459.214.121-.071-.496-.187-1.343-.355-2.092-.128-.568-.159-.657-.281-1.093-.129-.464-.195-.789-.316-1.281-.084-.348-.235-1.059-.276-1.459-.057-.547-.087-1.439.264-1.849.275-.321.906-.418 1.297-.22.512.259.803 1.003.936 1.3.239.534.387 1.151.516 1.961.164 1.031.466 2.462.476 2.763.024-.369-.068-1.146-.004-1.5.058-.321.328-.694.666-.795.286-.085.621-.116.916-.055.313.064.643.288.766.499.362.624.369 1.899.384 1.831.086-.376.071-1.229.284-1.584.14-.234.497-.445.687-.479.294-.052.655-.068.964-.008.249.049.586.345.677.487.218.344.342 1.317.379 1.658.015.141.074-.392.293-.736.406-.639 1.843-.763 1.898.639.025.654.02.624.02 1.064 0 .517-.012.828-.04 1.202-.031.4-.117 1.304-.242 1.742-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.191 1.813-.118.562-.079.566-.102.965-.023.398.121.922.121.922s-.802.104-1.234.035c-.391-.063-.875-.841-1-1.079-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.031-3.139.02 0 0 .185-1.011-.227-1.358-.305-.259-.83-.784-1.144-1.06z' fill='white'/><g stroke='black' stroke-linecap='round' stroke-width='.75'><path d='m13.3315 21.3799c-.284-.359-.629-1.093-1.243-1.984-.348-.504-1.211-1.453-1.468-1.935-.223-.426-.199-.617-.146-.97.094-.628.738-1.117 1.425-1.051.519.049.959.392 1.355.716.239.195.533.574.71.788.163.196.203.277.377.509.23.307.302.459.214.121-.071-.496-.187-1.343-.355-2.092-.128-.568-.159-.657-.281-1.093-.129-.464-.195-.789-.316-1.281-.084-.348-.235-1.059-.276-1.459-.057-.547-.087-1.439.264-1.849.275-.321.906-.418 1.297-.22.512.259.803 1.003.936 1.3.239.534.387 1.151.516 1.961.164 1.031.466 2.462.476 2.763.024-.369-.068-1.146-.004-1.5.058-.321.328-.694.666-.795.286-.085.621-.116.916-.055.313.064.643.288.766.499.362.624.369 1.899.384 1.831.086-.376.071-1.229.284-1.584.14-.234.497-.445.687-.479.294-.052.655-.068.964-.008.249.049.586.345.677.487.218.344.342 1.317.379 1.658.015.141.074-.392.293-.736.406-.639 1.843-.763 1.898.639.025.654.02.624.02 1.064 0 .517-.012.828-.04 1.202-.031.4-.117 1.304-.242 1.742-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.191 1.813-.118.562-.079.566-.102.965-.023.398.121.922.121.922s-.802.104-1.234.035c-.391-.063-.875-.841-1-1.079-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.031-3.139.02 0 0 .185-1.011-.227-1.358-.305-.259-.83-.784-1.144-1.06z' stroke-linejoin='round'/><path d='m21.5664 21.7344v-3.459'/><path d='m19.5508 21.7461-.016-3.473'/><path d='m17.5547 18.3047.021 3.426'/></g></g></svg>") 14 10, pointer; - --tl-cursor-cross: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m25 16h-6.01v-6h-2.98v6h-6.01v3h6.01v6h2.98v-6h6.01z' fill='white'/><path d='m23.9902 17.0103h-6v-6.01h-.98v6.01h-6v.98h6v6.01h.98v-6.01h6z' fill='%23231f1f'/></g></svg>") 16 16, crosshair; - --tl-cursor-move: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m19 14h1v1h-1zm1 6h-1v-1h1zm-5-5h-1v-1h1zm0 5h-1v-1h1zm2-10.987-7.985 7.988 5.222 5.221 2.763 2.763 7.984-7.985z' fill='white'/><g fill='black'><path d='m23.5664 16.9971-2.557-2.809v1.829h-4.009-4.001v-1.829l-2.571 2.809 2.572 2.808-.001-1.808h4.001 4.009l-.001 1.808z'/><path d='m17.9873 17h.013v-4.001l1.807.001-2.807-2.571-2.809 2.57h1.809v4.001h.008v4.002l-1.828-.001 2.807 2.577 2.805-2.576h-1.805z'/></g></g></svg>") 16 16, move; - --tl-cursor-grab: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m13.5557 17.5742c-.098-.375-.196-.847-.406-1.552-.167-.557-.342-.859-.47-1.233-.155-.455-.303-.721-.496-1.181-.139-.329-.364-1.048-.457-1.44-.119-.509.033-.924.244-1.206.253-.339.962-.49 1.357-.351.371.13.744.512.916.788.288.46.357.632.717 1.542.393.992.564 1.918.611 2.231l.085.452c-.001-.04-.043-1.122-.044-1.162-.035-1.029-.06-1.823-.038-2.939.002-.126.064-.587.084-.715.078-.5.305-.8.673-.979.412-.201.926-.215 1.401-.017.423.173.626.55.687 1.022.014.109.094.987.093 1.107-.013 1.025.006 1.641.015 2.174.004.231.003 1.625.017 1.469.061-.656.094-3.189.344-3.942.144-.433.405-.746.794-.929.431-.203 1.113-.07 1.404.243.285.305.446.692.482 1.153.032.405-.019.897-.02 1.245 0 .867-.021 1.324-.037 2.121-.001.038-.015.298.023.182.094-.28.188-.542.266-.745.049-.125.241-.614.359-.859.114-.234.211-.369.415-.688.2-.313.415-.448.668-.561.54-.235 1.109.112 1.301.591.086.215.009.713-.028 1.105-.061.647-.254 1.306-.352 1.648-.128.447-.274 1.235-.34 1.601-.072.394-.234 1.382-.359 1.82-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.192 1.812-.117.563-.078.567-.101.965-.024.399.121.923.121.923s-.802.104-1.234.034c-.391-.062-.875-.841-1-1.078-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.03-3.139.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.284-.36-.629-1.093-1.243-1.985-.348-.504-1.027-1.085-1.284-1.579-.223-.425-.331-.954-.19-1.325.225-.594.675-.897 1.362-.832.519.05.848.206 1.238.537.225.19.573.534.75.748.163.195.203.276.377.509.23.307.302.459.214.121' fill='white'/><g stroke='black' stroke-linecap='round' stroke-width='.75'><path d='m13.5557 17.5742c-.098-.375-.196-.847-.406-1.552-.167-.557-.342-.859-.47-1.233-.155-.455-.303-.721-.496-1.181-.139-.329-.364-1.048-.457-1.44-.119-.509.033-.924.244-1.206.253-.339.962-.49 1.357-.351.371.13.744.512.916.788.288.46.357.632.717 1.542.393.992.564 1.918.611 2.231l.085.452c-.001-.04-.043-1.122-.044-1.162-.035-1.029-.06-1.823-.038-2.939.002-.126.064-.587.084-.715.078-.5.305-.8.673-.979.412-.201.926-.215 1.401-.017.423.173.626.55.687 1.022.014.109.094.987.093 1.107-.013 1.025.006 1.641.015 2.174.004.231.003 1.625.017 1.469.061-.656.094-3.189.344-3.942.144-.433.405-.746.794-.929.431-.203 1.113-.07 1.404.243.285.305.446.692.482 1.153.032.405-.019.897-.02 1.245 0 .867-.021 1.324-.037 2.121-.001.038-.015.298.023.182.094-.28.188-.542.266-.745.049-.125.241-.614.359-.859.114-.234.211-.369.415-.688.2-.313.415-.448.668-.561.54-.235 1.109.112 1.301.591.086.215.009.713-.028 1.105-.061.647-.254 1.306-.352 1.648-.128.447-.274 1.235-.34 1.601-.072.394-.234 1.382-.359 1.82-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.192 1.812-.117.563-.078.567-.101.965-.024.399.121.923.121.923s-.802.104-1.234.034c-.391-.062-.875-.841-1-1.078-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.03-3.139.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.284-.36-.629-1.093-1.243-1.985-.348-.504-1.027-1.085-1.284-1.579-.223-.425-.331-.954-.19-1.325.225-.594.675-.897 1.362-.832.519.05.848.206 1.238.537.225.19.573.534.75.748.163.195.203.276.377.509.23.307.302.459.214.121' stroke-linejoin='round'/><path d='m20.5664 21.7344v-3.459'/><path d='m18.5508 21.7461-.016-3.473'/><path d='m16.5547 18.3047.021 3.426'/></g></g></svg>") 16 16, grab; - --tl-cursor-grabbing: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m13.5732 12.0361c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.691.285-.086.62-.116.916-.055.313.064.642.287.765.499.362.623.368 1.899.385 1.831.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.249.049.586.344.677.487.219.344.342 1.316.379 1.658.016.141.074-.393.293-.736.406-.639 1.844-.763 1.898.639.026.654.02.624.02 1.064 0 .516-.012.828-.04 1.202-.03.399-.116 1.304-.241 1.742-.086.301-.371.978-.653 1.384 0 0-1.074 1.25-1.191 1.812-.117.563-.078.567-.102.965-.023.399.121.923.121.923s-.801.104-1.234.034c-.391-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.283-.36-1.002-.929-1.243-1.985-.213-.936-.192-1.395.037-1.77.232-.381.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.159.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.361-.401-.943-.38-1.526.008-.221.103-.771.832-1.042' fill='white'/><g stroke='black' stroke-width='.75'><path d='m13.5732 12.0361c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.691.285-.086.62-.116.916-.055.313.064.642.287.765.499.362.623.368 1.899.385 1.831.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.249.049.586.344.677.487.219.344.342 1.316.379 1.658.016.141.074-.393.293-.736.406-.639 1.844-.763 1.898.639.026.654.02.624.02 1.064 0 .516-.012.828-.04 1.202-.03.399-.116 1.304-.241 1.742-.086.301-.371.978-.653 1.384 0 0-1.074 1.25-1.191 1.812-.117.563-.078.567-.102.965-.023.399.121.923.121.923s-.801.104-1.234.034c-.391-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.283-.36-1.002-.929-1.243-1.985-.213-.936-.192-1.395.037-1.77.232-.381.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.159.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.361-.401-.943-.38-1.526.008-.221.103-.771.832-1.042z' stroke-linejoin='round'/><path d='m20.5664 19.7344v-3.459' stroke-linecap='round'/><path d='m18.5508 19.7461-.016-3.473' stroke-linecap='round'/><path d='m16.5547 16.3047.021 3.426' stroke-linecap='round'/></g></g></svg>") 16 16, grabbing; - --tl-cursor-text: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path fill='white' d='M7.94 0a5.25 5.25 0 0 0-3.47 1.17A5.27 5.27 0 0 0 1 0H0v3h1c1.41 0 1.85.7 2 1v3.94H2v3h1v3c-.13.3-.57 1-2 1H0v3h1a5.27 5.27 0 0 0 3.47-1.17c.98.8 2.21 1.21 3.47 1.17h1v-3h-1c-1.41 0-1.85-.7-2-1v-3H7v-3H6V4c.13-.3.57-1 2-1h1V0H7.94z'/><path fill='black' d='M7.94 2V1a4 4 0 0 0-3.47 1.64A4 4 0 0 0 1 1v1c1.3-.17 2.56.6 3 1.84v5.1H3v1h1v4.16c-.45 1.24-1.7 2-3 1.84v1a4.05 4.05 0 0 0 3.47-1.63 4.05 4.05 0 0 0 3.47 1.63v-1A2.82 2.82 0 0 1 5 14.1V9.93h1v-1H5V3.85A2.81 2.81 0 0 1 7.94 2z'/></g></svg>") 4 10, text; - --tl-cursor-zoom-in: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5' fill='white'/><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5z' stroke='black'/><g fill='black'><path d='m18 14h-2v-2h-2v2h-2v1.98h2v2.02h2v-2.02h2z'/><path d='m23.5859 25 1.414-1.414-5.449-5.449-1.414 1.414z'/></g></g></svg>") 16 16, zoom-in; - --tl-cursor-zoom-out: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5' fill='white'/><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5z' stroke='black'/><g fill='black'><path d='m18 16h-5.98v-1.98h5.98z'/><path d='m23.5859 25 1.414-1.414-5.449-5.449-1.414 1.414z'/></g></g></svg>") 16 16, zoom-out; - --tl-cursor: var(--tl-cursor-default); - --tl-cursor-resize-edge: ew-resize; - --tl-cursor-resize-corner: nesw-resize; - --tl-cursor-ew-resize: ew-resize; - --tl-cursor-ns-resize: ns-resize; - --tl-cursor-nesw-resize: nesw-resize; - --tl-cursor-nwse-resize: nwse-resize; - --tl-cursor-rotate: pointer; - --tl-cursor-nwse-rotate: pointer; - --tl-cursor-nesw-rotate: pointer; - --tl-cursor-senw-rotate: pointer; - --tl-cursor-swne-rotate: pointer; - --tl-scale: calc(1 / var(--tl-zoom)); - --tl-font-draw: "tldraw_draw", sans-serif; - --tl-font-sans: "tldraw_sans", sans-serif; - --tl-font-serif: "tldraw_serif", serif; - --tl-font-mono: "tldraw_mono", monospace; - --a: calc(min(0.5, 1 / var(--tl-zoom)) * 2px); - --b: calc(min(0.5, 1 / var(--tl-zoom)) * -2px); - --tl-text-outline: - 0 var(--b) 0 var(--color-background), - 0 var(--a) 0 var(--color-background), - var(--b) var(--b) 0 var(--color-background), - var(--a) var(--b) 0 var(--color-background), - var(--a) var(--a) 0 var(--color-background), - var(--b) var(--a) 0 var(--color-background); - position: relative; - inset: 0px; - height: 100%; - width: 100%; - overflow: clip; -} -.ddc_ink_drawing-editor .tl-theme__light, -.ddc_ink_writing-editor .tl-theme__light { - --color-accent: hsl(0, 76%, 60%); - --color-background: hsl(210, 20%, 98%); - --color-brush-fill: hsl(0, 0%, 56%, 10.2%); - --color-brush-stroke: hsl(0, 0%, 56%, 25.1%); - --color-grid: hsl(0, 0%, 43%); - --color-low: hsl(204, 16%, 94%); - --color-low-border: hsl(204, 16%, 92%); - --color-culled: hsl(204, 14%, 93%); - --color-muted-none: hsl(0, 0%, 0%, 0%); - --color-muted-0: hsl(0, 0%, 0%, 2%); - --color-muted-1: hsl(0, 0%, 0%, 10%); - --color-muted-2: hsl(0, 0%, 0%, 4.3%); - --color-hint: hsl(0, 0%, 0%, 5.5%); - --color-overlay: hsl(0, 0%, 0%, 20%); - --color-divider: hsl(0, 0%, 91%); - --color-panel-contrast: hsl(0, 0%, 100%); - --color-panel-overlay: hsl(0, 0%, 100%, 82%); - --color-panel: hsl(0, 0%, 99%); - --color-focus: hsl(214, 100%, 29%); - --color-selected: hsl(214, 84%, 56%); - --color-selected-contrast: hsl(0, 0%, 100%); - --color-selection-fill: hsl(210, 100%, 56%, 24%); - --color-selection-stroke: hsl(214, 84%, 56%); - --color-text-0: hsl(0, 0%, 11%); - --color-text-1: hsl(0, 0%, 18%); - --color-text-3: hsl(220, 2%, 65%); - --color-text-shadow: hsl(0, 0%, 100%); - --color-primary: hsl(214, 84%, 56%); - --color-warn: hsl(0, 90%, 43%); - --color-text: hsl(0, 0%, 0%); - --color-laser: hsl(0, 100%, 50%); - --shadow-1: 0px 1px 2px hsl(0, 0%, 0%, 25%), 0px 1px 3px hsl(0, 0%, 0%, 9%); - --shadow-2: - 0px 0px 2px hsl(0, 0%, 0%, 16%), - 0px 2px 3px hsl(0, 0%, 0%, 24%), - 0px 2px 6px hsl(0, 0%, 0%, 0.1), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-3: - 0px 1px 2px hsl(0, 0%, 0%, 28%), - 0px 2px 6px hsl(0, 0%, 0%, 14%), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-4: - 0px 0px 3px hsl(0, 0%, 0%, 19%), - 0px 5px 4px hsl(0, 0%, 0%, 16%), - 0px 2px 16px hsl(0, 0%, 0%, 6%), - inset 0px 0px 0px 1px var(--color-panel-contrast); -} -.ddc_ink_drawing-editor .tl-theme__dark, -.ddc_ink_writing-editor .tl-theme__dark { - --color-accent: hsl(0, 76%, 60%); - --color-background: hsl(240, 5%, 8%); - --color-brush-fill: hsl(0, 0%, 71%, 5.1%); - --color-brush-stroke: hsl(0, 0%, 71%, 25.1%); - --color-grid: hsl(0, 0%, 56%); - --color-low: hsl(260, 5%, 12.5%); - --color-low-border: hsl(207, 10%, 10%); - --color-culled: hsl(210, 11%, 19%); - --color-muted-none: hsl(0, 0%, 100%, 0%); - --color-muted-0: hsl(0, 0%, 100%, 2%); - --color-muted-1: hsl(0, 0%, 100%, 10%); - --color-muted-2: hsl(0, 0%, 100%, 5%); - --color-hint: hsl(0, 0%, 100%, 7%); - --color-overlay: hsl(0, 0%, 0%, 50%); - --color-divider: hsl(240, 9%, 25%); - --color-panel-contrast: hsl(240, 13%, 22%); - --color-panel: hsl(220, 8%, 15%); - --color-panel-overlay: hsl(210, 11%, 24%, 82%); - --color-focus: hsl(217, 76%, 80%); - --color-selected: hsl(217, 89%, 61%); - --color-selected-contrast: hsl(0, 0%, 100%); - --color-selection-fill: hsl(209, 100%, 57%, 20%); - --color-selection-stroke: hsl(214, 84%, 56%); - --color-text-0: hsl(0, 9%, 94%); - --color-text-1: hsl(0, 0%, 85%); - --color-text-3: hsl(210, 6%, 45%); - --color-text-shadow: hsl(210, 13%, 18%); - --color-primary: hsl(214, 84%, 56%); - --color-warn: hsl(0, 81%, 66%); - --color-text: hsl(210, 17%, 98%); - --color-laser: hsl(0, 100%, 50%); - --shadow-1: - 0px 1px 2px hsl(0, 0%, 0%, 16.1%), - 0px 1px 3px hsl(0, 0%, 0%, 22%), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-2: - 0px 1px 3px hsl(0, 0%, 0%, 66.6%), - 0px 2px 6px hsl(0, 0%, 0%, 33%), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-3: - 0px 1px 3px hsl(0, 0%, 0%, 50%), - 0px 2px 12px hsl(0, 0%, 0%, 50%), - inset 0px 0px 0px 1px var(--color-panel-contrast); -} -.ddc_ink_drawing-editor .tl-counter-scaled, -.ddc_ink_writing-editor .tl-counter-scaled { - transform: scale(var(--tl-scale)); - transform-origin: top left; - width: calc(100% * var(--tl-zoom)); - height: calc(100% * var(--tl-zoom)); -} -.ddc_ink_drawing-editor .tl-container, -.ddc_ink_drawing-editor .tl-container *, -.ddc_ink_writing-editor .tl-container, -.ddc_ink_writing-editor .tl-container * { - -webkit-touch-callout: none; - -webkit-tap-highlight-color: transparent; - scrollbar-highlight-color: transparent; - -webkit-user-select: none; - user-select: none; - box-sizing: border-box; - outline: none; -} -.ddc_ink_drawing-editor .tl-container a, -.ddc_ink_writing-editor .tl-container a { - -webkit-touch-callout: initial; -} -.ddc_ink_drawing-editor .tl-container:focus-within, -.ddc_ink_writing-editor .tl-container:focus-within { - outline: 1px solid var(--color-low); -} -.ddc_ink_drawing-editor input, -.ddc_ink_drawing-editor *[contenteditable], -.ddc_ink_drawing-editor *[contenteditable] *, -.ddc_ink_writing-editor input, -.ddc_ink_writing-editor *[contenteditable], -.ddc_ink_writing-editor *[contenteditable] * { - -webkit-user-select: text; -} -.ddc_ink_drawing-editor .tl-canvas, -.ddc_ink_writing-editor .tl-canvas { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - color: var(--color-text); - z-index: var(--layer-canvas); - cursor: var(--tl-cursor); - overflow: clip; - content-visibility: auto; - touch-action: none; - contain: strict; -} -.ddc_ink_drawing-editor .tl-shapes, -.ddc_ink_writing-editor .tl-shapes { - position: relative; - z-index: var(--layer-shapes); -} -.ddc_ink_drawing-editor .tl-overlays, -.ddc_ink_writing-editor .tl-overlays { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - contain: strict; - pointer-events: none; - z-index: var(--layer-overlays); -} -.ddc_ink_drawing-editor .tl-overlays__item, -.ddc_ink_writing-editor .tl-overlays__item { - position: absolute; - top: 0px; - left: 0px; - overflow: visible; - pointer-events: none; - transform-origin: top left; -} -.ddc_ink_drawing-editor .tl-svg-context, -.ddc_ink_writing-editor .tl-svg-context { - position: absolute; - top: 0px; - left: 0px; - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-background, -.ddc_ink_writing-editor .tl-background { - position: absolute; - background-color: var(--color-background); - inset: 0px; - height: 100%; - width: 100%; - z-index: var(--layer-background); -} -.ddc_ink_drawing-editor .tl-grid, -.ddc_ink_writing-editor .tl-grid { - position: absolute; - inset: 0px; - width: 100%; - height: 100%; - touch-action: none; - pointer-events: none; - z-index: var(--layer-grid); - contain: strict; -} -.ddc_ink_drawing-editor .tl-grid-dot, -.ddc_ink_writing-editor .tl-grid-dot { - fill: var(--color-grid); -} -.ddc_ink_drawing-editor .tl-html-layer, -.ddc_ink_writing-editor .tl-html-layer { - position: absolute; - top: 0px; - left: 0px; - width: 1px; - height: 1px; - contain: layout style size; -} -.ddc_ink_drawing-editor .tl-brush, -.ddc_ink_writing-editor .tl-brush { - stroke-width: calc(var(--tl-scale) * 1px); - contain: size layout; -} -.ddc_ink_drawing-editor .tl-brush__default, -.ddc_ink_writing-editor .tl-brush__default { - stroke: var(--color-brush-stroke); - fill: var(--color-brush-fill); -} -.ddc_ink_drawing-editor .tl-scribble, -.ddc_ink_writing-editor .tl-scribble { - stroke-linejoin: round; - stroke-linecap: round; - pointer-events: none; - contain: size layout; -} -.ddc_ink_drawing-editor .tl-shape, -.ddc_ink_writing-editor .tl-shape { - position: absolute; - pointer-events: none; - overflow: visible; - transform-origin: top left; - contain: size layout; -} -.ddc_ink_drawing-editor .tl-shape__culled, -.ddc_ink_writing-editor .tl-shape__culled { - position: relative; - background-color: var(--color-culled); -} -.ddc_ink_drawing-editor .tl-svg-container, -.ddc_ink_writing-editor .tl-svg-container { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - pointer-events: none; - stroke-linecap: round; - stroke-linejoin: round; - transform-origin: top left; - overflow: visible; -} -.ddc_ink_drawing-editor .tl-html-container, -.ddc_ink_writing-editor .tl-html-container { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - pointer-events: none; - stroke-linecap: round; - stroke-linejoin: round; - transform-origin: top left; - color: inherit; -} -.ddc_ink_drawing-editor .tl-collaborator__scribble, -.ddc_ink_writing-editor .tl-collaborator__scribble { - z-index: 10; -} -.ddc_ink_drawing-editor .tl-collaborator__brush, -.ddc_ink_writing-editor .tl-collaborator__brush { - z-index: 20; -} -.ddc_ink_drawing-editor .tl-collaborator__shape-indicator, -.ddc_ink_writing-editor .tl-collaborator__shape-indicator { - z-index: 30; -} -.ddc_ink_drawing-editor .tl-user-scribble, -.ddc_ink_writing-editor .tl-user-scribble { - z-index: 40; -} -.ddc_ink_drawing-editor .tl-user-brush, -.ddc_ink_writing-editor .tl-user-brush { - z-index: 50; -} -.ddc_ink_drawing-editor .tl-user-indicator__selected, -.ddc_ink_writing-editor .tl-user-indicator__selected { - z-index: 60; -} -.ddc_ink_drawing-editor .tl-user-indicator__hovered, -.ddc_ink_writing-editor .tl-user-indicator__hovered { - z-index: 70; -} -.ddc_ink_drawing-editor .tl-user-handles, -.ddc_ink_writing-editor .tl-user-handles { - z-index: 80; -} -.ddc_ink_drawing-editor .tl-user-snapline, -.ddc_ink_writing-editor .tl-user-snapline { - z-index: 90; -} -.ddc_ink_drawing-editor .tl-selection__fg, -.ddc_ink_writing-editor .tl-selection__fg { - pointer-events: none; - z-index: 100; -} -.ddc_ink_drawing-editor .tl-user-indicator__hint, -.ddc_ink_writing-editor .tl-user-indicator__hint { - z-index: 110; - stroke-width: calc(2.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-collaborator__cursor-hint, -.ddc_ink_writing-editor .tl-collaborator__cursor-hint { - z-index: 120; -} -.ddc_ink_drawing-editor .tl-collaborator__cursor, -.ddc_ink_writing-editor .tl-collaborator__cursor { - z-index: 130; -} -.ddc_ink_drawing-editor .tl-cursor, -.ddc_ink_writing-editor .tl-cursor { - overflow: visible; -} -.ddc_ink_drawing-editor .tl-shape-indicator, -.ddc_ink_writing-editor .tl-shape-indicator { - transform-origin: top left; - fill: none; - stroke-width: calc(1.5px * var(--tl-scale)); - contain: size; -} -.ddc_ink_drawing-editor .tl-selection__bg, -.ddc_ink_writing-editor .tl-selection__bg { - position: absolute; - top: 0px; - left: 0px; - transform-origin: top left; - background-color: transparent; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-selection__fg__outline, -.ddc_ink_writing-editor .tl-selection__fg__outline { - fill: none; - pointer-events: none; - stroke: var(--color-selection-stroke); - stroke-width: calc(1.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-corner-handle, -.ddc_ink_writing-editor .tl-corner-handle { - pointer-events: none; - stroke: var(--color-selection-stroke); - fill: var(--color-background); - stroke-width: calc(1.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-text-handle, -.ddc_ink_writing-editor .tl-text-handle { - pointer-events: none; - fill: var(--color-selection-stroke); -} -.ddc_ink_drawing-editor .tl-corner-crop-handle, -.ddc_ink_writing-editor .tl-corner-crop-handle { - pointer-events: none; - fill: none; - stroke: var(--color-selection-stroke); -} -.ddc_ink_drawing-editor .tl-corner-crop-edge-handle, -.ddc_ink_writing-editor .tl-corner-crop-edge-handle { - pointer-events: none; - fill: none; - stroke: var(--color-selection-stroke); -} -.ddc_ink_drawing-editor .tl-mobile-rotate__bg, -.ddc_ink_writing-editor .tl-mobile-rotate__bg { - pointer-events: all; - cursor: var(--tl-cursor-grab); -} -.ddc_ink_drawing-editor .tl-mobile-rotate__fg, -.ddc_ink_writing-editor .tl-mobile-rotate__fg { - pointer-events: none; - stroke: var(--color-selection-stroke); - fill: var(--color-background); - stroke-width: calc(1.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-transparent, -.ddc_ink_writing-editor .tl-transparent { - fill: transparent; - stroke: transparent; -} -.ddc_ink_drawing-editor .tl-handle, -.ddc_ink_writing-editor .tl-handle { - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-handle__bg, -.ddc_ink_writing-editor .tl-handle__bg { - fill: transparent; - stroke: transparent; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-handle__fg, -.ddc_ink_writing-editor .tl-handle__fg { - fill: var(--color-selected-contrast); - stroke: var(--color-selection-stroke); - stroke-width: calc(1.5px * var(--tl-scale)); - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-handle__create, -.ddc_ink_writing-editor .tl-handle__create { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-handle__create:hover, -.ddc_ink_writing-editor .tl-handle__create:hover { - opacity: 1; -} -.ddc_ink_drawing-editor .tl-handle__bg:active, -.ddc_ink_writing-editor .tl-handle__bg:active { - fill: none; -} -.ddc_ink_drawing-editor .tl-handle__bg:hover, -.ddc_ink_writing-editor .tl-handle__bg:hover { - cursor: var(--tl-cursor-grab); - fill: var(--color-selection-fill); -} -@media (pointer: coarse) { - .ddc_ink_drawing-editor .tl-handle__bg:active, - .ddc_ink_writing-editor .tl-handle__bg:active { - fill: var(--color-selection-fill); - } - .ddc_ink_drawing-editor .tl-handle__create, - .ddc_ink_writing-editor .tl-handle__create { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tl-image, -.ddc_ink_drawing-editor .tl-video, -.ddc_ink_writing-editor .tl-image, -.ddc_ink_writing-editor .tl-video { - object-fit: cover; - background-size: cover; - width: 100%; - height: 100%; -} -.ddc_ink_drawing-editor .tl-image-container, -.ddc_ink_drawing-editor .tl-embed-container, -.ddc_ink_writing-editor .tl-image-container, -.ddc_ink_writing-editor .tl-embed-container { - width: 100%; - height: 100%; - pointer-events: all; - display: flex; - justify-content: center; - align-items: center; -} -.ddc_ink_drawing-editor .tl-image__tg, -.ddc_ink_writing-editor .tl-image__tg { - --scale: calc(min(2, var(--tl-scale))); - position: absolute; - top: calc(var(--scale) * 8px); - right: calc(var(--scale) * 8px); - font-size: 10px; - transform-origin: top right; - background-color: var(--color-background); - padding: 2px 4px; - border-radius: var(--radius-1); -} -.ddc_ink_drawing-editor .tl-collaborator-cursor, -.ddc_ink_writing-editor .tl-collaborator-cursor { - position: absolute; -} -.ddc_ink_drawing-editor .tl-nametag, -.ddc_ink_writing-editor .tl-nametag { - position: absolute; - top: 16px; - left: 13px; - width: fit-content; - height: fit-content; - max-width: 120px; - padding: 3px 6px; - white-space: nowrap; - position: absolute; - overflow: hidden; - text-overflow: ellipsis; - font-size: 12px; - font-family: var(--font-body); - border-radius: var(--radius-2); - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tl-nametag-title, -.ddc_ink_writing-editor .tl-nametag-title { - position: absolute; - top: -2px; - left: 13px; - width: fit-content; - height: fit-content; - padding: 0px 6px; - max-width: 120px; - white-space: nowrap; - position: absolute; - overflow: hidden; - text-overflow: ellipsis; - font-size: 12px; - font-family: var(--font-body); - text-shadow: var(--tl-text-outline); - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tl-nametag-chat, -.ddc_ink_writing-editor .tl-nametag-chat { - position: absolute; - top: 16px; - left: 13px; - width: fit-content; - height: fit-content; - color: var(--color-selected-contrast); - white-space: nowrap; - position: absolute; - padding: 3px 6px; - font-size: 12px; - font-family: var(--font-body); - opacity: 1; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tl-cursor-chat, -.ddc_ink_writing-editor .tl-cursor-chat { - position: absolute; - color: var(--color-selected-contrast); - white-space: nowrap; - padding: 3px 6px; - font-size: 12px; - font-family: var(--font-body); - pointer-events: none; - z-index: var(--layer-cursor); - margin-top: 16px; - margin-left: 13px; - opacity: 1; - border: none; - user-select: text; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tl-cursor-chat .tl-cursor-chat__bubble, -.ddc_ink_writing-editor .tl-cursor-chat .tl-cursor-chat__bubble { - padding-right: 12px; -} -.ddc_ink_drawing-editor .tl-cursor-chat::selection, -.ddc_ink_writing-editor .tl-cursor-chat::selection { - background: var(--color-selected); - color: var(--color-selected-contrast); - text-shadow: none; -} -.ddc_ink_drawing-editor .tl-cursor-chat-fade, -.ddc_ink_writing-editor .tl-cursor-chat-fade { - opacity: 0.0001; - transition: opacity 5s ease-in-out; -} -.ddc_ink_drawing-editor .tl-cursor-chat::placeholder, -.ddc_ink_writing-editor .tl-cursor-chat::placeholder { - color: var(--color-selected-contrast); - opacity: 0.7; -} -@keyframes spinner { - to { - transform: rotate(360deg); - } -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper, -.ddc_ink_writing-editor .tl-text-shape__wrapper { - position: relative; - font-weight: normal; - min-width: 1px; - padding: 0px; - margin: 0px; - border: none; - height: 100%; - font-variant: normal; - font-style: normal; - pointer-events: all; - white-space: pre-wrap; - overflow-wrap: break-word; - text-shadow: var(--tl-text-outline); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-align=start], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-align=start] { - text-align: left; -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-align=middle], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-align=middle] { - text-align: center; -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-align=end], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-align=end] { - text-align: right; -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=draw], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=draw] { - font-family: var(--tl-font-draw); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=sans], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=sans] { - font-family: var(--tl-font-sans); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=serif], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=serif] { - font-family: var(--tl-font-serif); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=mono], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=mono] { - font-family: var(--tl-font-mono); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-isediting=true] .tl-text-content, -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-isediting=true] .tl-text-content { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-text, -.ddc_ink_writing-editor .tl-text { - margin: 0px; - padding: 0px; - border: 0px; - color: inherit; - caret-color: var(--color-text); - background: none; - border-image: none; - font-size: inherit; - font-family: inherit; - font-weight: inherit; - line-height: inherit; - font-variant: inherit; - font-style: inherit; - text-align: inherit; - letter-spacing: inherit; - text-shadow: inherit; - outline: none; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - pointer-events: all; - text-rendering: auto; - text-transform: none; - text-indent: 0px; - display: inline-block; - appearance: auto; - column-count: initial !important; - writing-mode: horizontal-tb !important; - word-spacing: 0px; -} -.ddc_ink_drawing-editor .tl-text-measure, -.ddc_ink_writing-editor .tl-text-measure { - position: absolute; - z-index: -999999; - top: 0px; - left: 0px; - opacity: 0; - width: max-content; - box-sizing: border-box; - pointer-events: none; - line-break: normal; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - resize: none; - border: none; - user-select: none; - contain: style paint; - -webkit-user-select: none; -} -.ddc_ink_drawing-editor .tl-text-input, -.ddc_ink_drawing-editor .tl-text-content, -.ddc_ink_writing-editor .tl-text-input, -.ddc_ink_writing-editor .tl-text-content { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - min-width: 1px; - min-height: 1px; - overflow: visible; - outline: none; -} -.ddc_ink_drawing-editor .tl-text-content, -.ddc_ink_writing-editor .tl-text-content { - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-text-input, -.ddc_ink_writing-editor .tl-text-input { - resize: none; - user-select: all; - -webkit-user-select: text; - overflow: hidden; - cursor: var(--tl-cursor-text); -} -.ddc_ink_drawing-editor .tl-text-input::selection, -.ddc_ink_writing-editor .tl-text-input::selection { - background: var(--color-selected); - color: var(--color-selected-contrast); - text-shadow: none; -} -.ddc_ink_drawing-editor .tl-snap-indicator, -.ddc_ink_writing-editor .tl-snap-indicator { - stroke: var(--color-accent); - stroke-width: calc(1px * var(--tl-scale)); - fill: none; -} -.ddc_ink_drawing-editor .tl-snap-point, -.ddc_ink_writing-editor .tl-snap-point { - stroke: var(--color-accent); - stroke-width: calc(1px * var(--tl-scale)); - fill: none; -} -.ddc_ink_drawing-editor .tl-group, -.ddc_ink_writing-editor .tl-group { - stroke: var(--color-text); - stroke-width: calc(1px * var(--tl-scale)); - opacity: 0.5; -} -.ddc_ink_drawing-editor .tl-bookmark__container, -.ddc_ink_writing-editor .tl-bookmark__container { - width: 100%; - height: 100%; - position: relative; - border: 1px solid var(--color-panel-contrast); - background-color: var(--color-panel); - border-radius: var(--radius-2); - display: flex; - flex-direction: column; - overflow: hidden; -} -.ddc_ink_drawing-editor .tl-bookmark__image_container, -.ddc_ink_writing-editor .tl-bookmark__image_container { - flex: 1; - overflow: hidden; - border-top-left-radius: var(--radius-1); - border-top-right-radius: var(--radius-1); - width: 100%; - height: 100%; - display: flex; - justify-content: flex-end; - align-items: flex-start; -} -.ddc_ink_drawing-editor .tl-bookmark__image_container > .tl-hyperlink-button::after, -.ddc_ink_writing-editor .tl-bookmark__image_container > .tl-hyperlink-button::after { - background-color: var(--color-panel); -} -.ddc_ink_drawing-editor .tl-bookmark__placeholder, -.ddc_ink_writing-editor .tl-bookmark__placeholder { - width: 100%; - height: 100%; - background-color: var(--color-muted-2); - border-bottom: 1px solid var(--color-muted-2); -} -.ddc_ink_drawing-editor .tl-bookmark__image, -.ddc_ink_writing-editor .tl-bookmark__image { - width: 100%; - height: 100%; - object-fit: cover; - object-position: center; -} -.ddc_ink_drawing-editor .tl-bookmark__copy_container, -.ddc_ink_writing-editor .tl-bookmark__copy_container { - background-color: var(--color-muted); - padding: var(--space-4); - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-bookmark__heading, -.ddc_ink_drawing-editor .tl-bookmark__description, -.ddc_ink_drawing-editor .tl-bookmark__link, -.ddc_ink_writing-editor .tl-bookmark__heading, -.ddc_ink_writing-editor .tl-bookmark__description, -.ddc_ink_writing-editor .tl-bookmark__link { - margin: 0px; - width: 100%; - font-family: inherit; -} -.ddc_ink_drawing-editor .tl-bookmark__heading, -.ddc_ink_writing-editor .tl-bookmark__heading { - font-size: 16px; - font-weight: bold; - padding-bottom: var(--space-2); - margin: 8px 0px; -} -.ddc_ink_drawing-editor .tl-bookmark__description, -.ddc_ink_writing-editor .tl-bookmark__description { - font-size: 12px; - padding-bottom: var(--space-4); -} -.ddc_ink_drawing-editor .tl-bookmark__link, -.ddc_ink_writing-editor .tl-bookmark__link { - font-size: 14px; - pointer-events: all; - z-index: 999; - overflow: hidden; - display: block; - color: var(--color-text); - text-overflow: ellipsis; - text-decoration: none; - color: var(--color-text-1); - cursor: var(--tl-cursor-pointer); -} -.ddc_ink_drawing-editor .tl-bookmark__link:hover, -.ddc_ink_writing-editor .tl-bookmark__link:hover { - color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-hyperlink-button, -.ddc_ink_writing-editor .tl-hyperlink-button { - background: none; - margin: 0px; - position: absolute; - top: 0px; - right: 0px; - height: 44px; - width: 44px; - display: flex; - align-items: center; - justify-content: center; - z-index: 200; - font-size: 12px; - font-weight: 400; - color: var(--color-text-1); - padding: 13px; - cursor: var(--tl-cursor-pointer); - border: none; - outline: none; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-hyperlink-button::after, -.ddc_ink_writing-editor .tl-hyperlink-button::after { - content: ""; - z-index: -1; - position: absolute; - right: 6px; - bottom: 6px; - display: block; - width: calc(100% - 12px); - height: calc(100% - 12px); - border-radius: var(--radius-1); - background-color: var(--color-background); - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-hyperlink-button:hover, -.ddc_ink_writing-editor .tl-hyperlink-button:hover { - color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-hyperlink-button:focus-visible, -.ddc_ink_writing-editor .tl-hyperlink-button:focus-visible { - color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-hyperlink-button__icon, -.ddc_ink_writing-editor .tl-hyperlink-button__icon { - width: 18px; - height: 18px; - background-color: currentColor; - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-hyperlink-button__hidden, -.ddc_ink_writing-editor .tl-hyperlink-button__hidden { - display: none; -} -.ddc_ink_drawing-editor .tl-text-label, -.ddc_ink_writing-editor .tl-text-label { - display: flex; - justify-content: center; - align-items: center; - color: var(--color-text); - text-shadow: var(--tl-text-outline); - line-height: inherit; - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: 10; -} -.ddc_ink_drawing-editor .tl-text-label[data-isediting=true] .tl-text-content, -.ddc_ink_writing-editor .tl-text-label[data-isediting=true] .tl-text-content { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-text-label[data-hastext=false][data-isediting=false] > .tl-text-label__inner, -.ddc_ink_writing-editor .tl-text-label[data-hastext=false][data-isediting=false] > .tl-text-label__inner { - width: 40px; - height: 40px; -} -.ddc_ink_drawing-editor .tl-text-label[data-hastext=true][data-isediting=false] .tl-text-content, -.ddc_ink_writing-editor .tl-text-label[data-hastext=true][data-isediting=false] .tl-text-content { - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-text-label__inner, -.ddc_ink_writing-editor .tl-text-label__inner { - position: relative; - width: fit-content; - height: fit-content; - display: flex; - align-items: center; - justify-content: center; - pointer-events: none; - min-height: auto; -} -.ddc_ink_drawing-editor .tl-text-label__inner > .tl-text-content, -.ddc_ink_writing-editor .tl-text-label__inner > .tl-text-content { - position: relative; - top: 0px; - left: 0px; - padding: 16px; - height: fit-content; - width: fit-content; - border-radius: var(--radius-1); - max-width: 100%; - z-index: 3; -} -.ddc_ink_drawing-editor .tl-text-label__inner > .tl-text-input, -.ddc_ink_writing-editor .tl-text-label__inner > .tl-text-input { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - padding: 16px; - z-index: 4; -} -.ddc_ink_drawing-editor .tl-text-label[data-textwrap=true] > .tl-text-label__inner, -.ddc_ink_writing-editor .tl-text-label[data-textwrap=true] > .tl-text-label__inner { - max-width: 100%; -} -.ddc_ink_drawing-editor .tl-text-label[data-isediting=true], -.ddc_ink_writing-editor .tl-text-label[data-isediting=true] { - background-color: transparent; - min-height: auto; -} -.ddc_ink_drawing-editor .tl-text-label[data-isediting=true] p, -.ddc_ink_writing-editor .tl-text-label[data-isediting=true] p { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-text-label[data-align=start], -.ddc_ink_drawing-editor .tl-text-label[data-align=start-legacy], -.ddc_ink_writing-editor .tl-text-label[data-align=start], -.ddc_ink_writing-editor .tl-text-label[data-align=start-legacy] { - text-align: left; -} -.ddc_ink_drawing-editor .tl-text-label[data-align=middle], -.ddc_ink_drawing-editor .tl-text-label[data-align=middle-legacy], -.ddc_ink_writing-editor .tl-text-label[data-align=middle], -.ddc_ink_writing-editor .tl-text-label[data-align=middle-legacy] { - text-align: center; -} -.ddc_ink_drawing-editor .tl-text-label[data-align=end], -.ddc_ink_drawing-editor .tl-text-label[data-align=end-legacy], -.ddc_ink_writing-editor .tl-text-label[data-align=end], -.ddc_ink_writing-editor .tl-text-label[data-align=end-legacy] { - text-align: right; -} -.ddc_ink_drawing-editor .tl-arrow-hint, -.ddc_ink_writing-editor .tl-arrow-hint { - stroke: var(--color-text-1); - fill: none; - stroke-linecap: round; - overflow: visible; -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=draw], -.ddc_ink_drawing-editor .tl-text-label[data-font=draw], -.ddc_ink_writing-editor .tl-arrow-label[data-font=draw], -.ddc_ink_writing-editor .tl-text-label[data-font=draw] { - font-family: var(--tl-font-draw); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=sans], -.ddc_ink_drawing-editor .tl-text-label[data-font=sans], -.ddc_ink_writing-editor .tl-arrow-label[data-font=sans], -.ddc_ink_writing-editor .tl-text-label[data-font=sans] { - font-family: var(--tl-font-sans); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=serif], -.ddc_ink_drawing-editor .tl-text-label[data-font=serif], -.ddc_ink_writing-editor .tl-arrow-label[data-font=serif], -.ddc_ink_writing-editor .tl-text-label[data-font=serif] { - font-family: var(--tl-font-serif); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=mono], -.ddc_ink_drawing-editor .tl-text-label[data-font=mono], -.ddc_ink_writing-editor .tl-arrow-label[data-font=mono], -.ddc_ink_writing-editor .tl-text-label[data-font=mono] { - font-family: var(--tl-font-mono); -} -.ddc_ink_drawing-editor .tl-arrow-label, -.ddc_ink_writing-editor .tl-arrow-label { - position: absolute; - top: -1px; - left: -1px; - width: 2px; - height: 2px; - padding: 0px; - display: flex; - justify-content: center; - align-items: center; - color: var(--color-text); - text-shadow: var(--tl-text-outline); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-isediting=true] p, -.ddc_ink_writing-editor .tl-arrow-label[data-isediting=true] p { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-arrow-label[data-isediting=true] > .tl-arrow-label__inner, -.ddc_ink_writing-editor .tl-arrow-label[data-isediting=true] > .tl-arrow-label__inner { - background-color: var(--color-background); -} -.ddc_ink_drawing-editor .tl-arrow-label__inner, -.ddc_ink_writing-editor .tl-arrow-label__inner { - border-radius: var(--radius-1); - box-sizing: content-box; - position: relative; - height: max-content; - width: max-content; - pointer-events: all; - display: flex; - justify-content: center; - align-items: center; -} -.ddc_ink_drawing-editor .tl-arrow-label p, -.ddc_ink_drawing-editor .tl-arrow-label textarea, -.ddc_ink_writing-editor .tl-arrow-label p, -.ddc_ink_writing-editor .tl-arrow-label textarea { - margin: 0px; - padding: 0px; - border: 0px; - color: inherit; - caret-color: var(--color-text); - background: none; - border-image: none; - font-size: inherit; - font-family: inherit; - font-weight: inherit; - line-height: inherit; - font-variant: inherit; - font-style: inherit; - text-align: inherit; - letter-spacing: inherit; - text-shadow: inherit; - outline: none; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - pointer-events: all; - text-rendering: auto; - text-transform: none; - text-indent: 0px; - display: inline-block; - appearance: auto; - column-count: initial !important; - writing-mode: horizontal-tb !important; - word-spacing: 0px; -} -.ddc_ink_drawing-editor .tl-arrow-label p, -.ddc_ink_writing-editor .tl-arrow-label p { - position: relative; - height: max-content; - z-index: 2; - padding: 4px; - overflow: visible; -} -.ddc_ink_drawing-editor .tl-arrow-label textarea, -.ddc_ink_writing-editor .tl-arrow-label textarea { - z-index: 3; - margin: 0px; - padding: 4px; - height: 100%; - width: 100%; - position: absolute; - resize: none; - border: 0px; - user-select: all; - -webkit-user-select: text; - caret-color: var(--color-text); - border-image: none; - min-width: 4px; -} -.ddc_ink_drawing-editor .tl-note__container, -.ddc_ink_writing-editor .tl-note__container { - position: relative; - width: 100%; - height: 100%; - border-radius: var(--radius-2); - box-shadow: var(--shadow-1); - overflow: hidden; - border-color: currentColor; - border-style: solid; - border-width: 1px; -} -.ddc_ink_drawing-editor .tl-note__container .tl-text-label, -.ddc_ink_writing-editor .tl-note__container .tl-text-label { - text-shadow: none; -} -.ddc_ink_drawing-editor .tl-note__scrim, -.ddc_ink_writing-editor .tl-note__scrim { - position: absolute; - z-index: 1; - inset: 0px; - height: 100%; - width: 100%; - background-color: var(--color-background); - opacity: 0.28; -} -.ddc_ink_drawing-editor .tl-loading, -.ddc_ink_writing-editor .tl-loading { - background-color: var(--color-background); - color: var(--color-text-1); - height: 100%; - width: 100%; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - gap: var(--space-2); - font-size: 14px; - font-weight: 500; - opacity: 0; - animation: fade-in 0.2s ease-in-out forwards; - animation-delay: 0.2s; -} -@keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tl-frame__body, -.ddc_ink_writing-editor .tl-frame__body { - stroke-width: calc(1px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-frame__creating, -.ddc_ink_writing-editor .tl-frame__creating { - stroke: var(--color-selected); - fill: none; -} -.ddc_ink_drawing-editor .tl-frame-heading, -.ddc_ink_writing-editor .tl-frame-heading { - display: flex; - align-items: center; - position: absolute; - transform-origin: 0% 100%; - overflow: hidden; - max-width: 100%; - min-width: 32px; - height: auto; - font-size: 12px; - padding-bottom: 4px; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-frame-heading-hit-area, -.ddc_ink_writing-editor .tl-frame-heading-hit-area { - pointer-events: all; - transform-origin: 0% 100%; - display: flex; - height: 100%; - width: 100%; - align-items: center; - border-radius: var(--radius-1); - background-color: var(--color-background); -} -.ddc_ink_drawing-editor .tl-frame-label, -.ddc_ink_writing-editor .tl-frame-label { - pointer-events: all; - overflow: hidden; - text-overflow: ellipsis; - padding: var(--space-3) var(--space-3); - position: relative; - font-size: inherit; - white-space: pre; - border: 1px solid transparent; -} -.ddc_ink_drawing-editor .tl-frame-label__editing, -.ddc_ink_writing-editor .tl-frame-label__editing { - color: transparent; - white-space: pre; - width: auto; - overflow: visible; - background-color: var(--color-panel); - border-radius: var(--radius-1); - border-color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-frame-name-input, -.ddc_ink_writing-editor .tl-frame-name-input { - position: absolute; - border: none; - background: none; - outline: none; - padding: var(--space-3) var(--space-3); - inset: 0px; - height: 100%; - width: 100%; - font-size: inherit; - font-family: inherit; - font-weight: inherit; - width: 100%; - color: var(--color-text-1); - border-radius: var(--radius-1); - user-select: all; - -webkit-user-select: text; - white-space: pre; - cursor: var(--tl-cursor-text); -} -@media (max-width: 600px) { - .ddc_ink_drawing-editor .tl-frame-heading, - .ddc_ink_writing-editor .tl-frame-heading { - font-size: 16px; - } -} -.ddc_ink_drawing-editor .tl-embed, -.ddc_ink_writing-editor .tl-embed { - border: none; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tl-shape-error-boundary, -.ddc_ink_writing-editor .tl-shape-error-boundary { - width: 100%; - height: 100%; - background-color: var(--color-muted-1); - border-width: calc(1px * var(--tl-scale)); - border-color: var(--color-muted-1); - border-style: solid; - border-radius: calc(var(--radius-1) * var(--tl-scale)); - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - text-align: left; - position: relative; - pointer-events: all; - overflow: hidden; - padding: var(--space-2); -} -.ddc_ink_drawing-editor .tl-shape-error-boundary::before, -.ddc_ink_writing-editor .tl-shape-error-boundary::before { - transform: scale(var(--tl-scale)); - content: "Error"; - font-size: 12px; - font-family: inherit; - color: var(--color-text-0); -} -.ddc_ink_drawing-editor .tl-error-boundary, -.ddc_ink_writing-editor .tl-error-boundary { - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - padding: var(--space-4); - background-color: var(--color-background); - color: var(--color-text-1); - position: absolute; - z-index: 600; -} -.ddc_ink_drawing-editor .tl-error-boundary__overlay, -.ddc_ink_writing-editor .tl-error-boundary__overlay { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: 500; - background-color: var(--color-overlay); -} -.ddc_ink_drawing-editor .tl-error-boundary__content *, -.ddc_ink_writing-editor .tl-error-boundary__content * { - user-select: all; - -webkit-user-select: text; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-error-boundary__canvas, -.ddc_ink_writing-editor .tl-error-boundary__canvas { - pointer-events: none; - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: -1; -} -.ddc_ink_drawing-editor .tl-error-boundary__canvas::after, -.ddc_ink_writing-editor .tl-error-boundary__canvas::after { - content: " "; - display: block; - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: 600; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-error-boundary__content, -.ddc_ink_writing-editor .tl-error-boundary__content { - width: fit-content; - height: fit-content; - max-width: 100%; - width: 400px; - max-height: 100%; - background-color: var(--color-panel); - padding: 16px; - border-radius: 16px; - box-shadow: var(--shadow-2); - font-size: 14px; - font-weight: 400; - display: flex; - flex-direction: column; - overflow: auto; - z-index: 600; - gap: 12px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content__expanded, -.ddc_ink_writing-editor .tl-error-boundary__content__expanded { - width: 600px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content h2, -.ddc_ink_writing-editor .tl-error-boundary__content h2 { - font-size: 16px; - margin: 0px; - font-weight: 500; -} -.ddc_ink_drawing-editor .tl-error-boundary__content h4, -.ddc_ink_writing-editor .tl-error-boundary__content h4 { - border: 1px solid var(--color-low-border); - margin: -6px 0 0 0; - padding: var(--space-5); - border-radius: var(--radius-2); - font-weight: normal; -} -.ddc_ink_drawing-editor .tl-error-boundary__content p, -.ddc_ink_writing-editor .tl-error-boundary__content p { - line-height: 1.5; - margin: 0px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content pre, -.ddc_ink_writing-editor .tl-error-boundary__content pre { - background-color: var(--color-muted-2); - margin-top: 0; - padding: var(--space-5); - border-radius: var(--radius-2); - overflow: auto; - font-size: 12px; - max-height: 320px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content button, -.ddc_ink_writing-editor .tl-error-boundary__content button { - background: none; - border: none; - font-family: inherit; - font-size: 14px; - font-weight: 500; - padding: var(--space-4); - border-radius: var(--radius-3); - cursor: var(--tl-cursor-pointer); - color: inherit; - background-color: transparent; -} -.ddc_ink_drawing-editor .tl-error-boundary__content button:hover, -.ddc_ink_writing-editor .tl-error-boundary__content button:hover { - background-color: var(--color-low); -} -.ddc_ink_drawing-editor .tl-error-boundary__content a, -.ddc_ink_writing-editor .tl-error-boundary__content a { - color: var(--color-text-1); - font-weight: 500; - text-decoration: none; -} -.ddc_ink_drawing-editor .tl-error-boundary__content a:hover, -.ddc_ink_writing-editor .tl-error-boundary__content a:hover { - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tl-error-boundary__content__error, -.ddc_ink_writing-editor .tl-error-boundary__content__error { - position: relative; - margin: -6px 0 0 0; -} -.ddc_ink_drawing-editor .tl-error-boundary__content__error button, -.ddc_ink_writing-editor .tl-error-boundary__content__error button { - position: absolute; - top: var(--space-2); - right: var(--space-2); - font-size: 12px; - padding: var(--space-2) var(--space-3); - background-color: var(--color-panel); - border-radius: var(--radius-1); -} -.ddc_ink_drawing-editor .tl-error-boundary__content__actions, -.ddc_ink_writing-editor .tl-error-boundary__content__actions { - display: flex; - justify-content: space-between; - gap: var(--space-4); - margin: 0px; - margin-left: -4px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content__actions__group, -.ddc_ink_writing-editor .tl-error-boundary__content__actions__group { - display: flex; - gap: var(--space-4); -} -.ddc_ink_drawing-editor .tl-error-boundary__content .tl-error-boundary__reset, -.ddc_ink_writing-editor .tl-error-boundary__content .tl-error-boundary__reset { - color: var(--color-warn); -} -.ddc_ink_drawing-editor .tl-error-boundary__content .tl-error-boundary__refresh, -.ddc_ink_writing-editor .tl-error-boundary__content .tl-error-boundary__refresh { - background-color: var(--color-primary); - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tl-error-boundary__content .tl-error-boundary__refresh:hover, -.ddc_ink_writing-editor .tl-error-boundary__content .tl-error-boundary__refresh:hover { - background-color: var(--color-primary); - opacity: 0.9; -} -.ddc_ink_drawing-editor .tl-hidden, -.ddc_ink_writing-editor .tl-hidden { - opacity: 0; - pointer-events: none; -} -.ddc_ink_drawing-editor .debug__ui-logger, -.ddc_ink_writing-editor .debug__ui-logger { - position: absolute; - top: 62px; - left: 16px; - color: #555; - font-size: 12px; - font-family: monospace; -} -.ddc_ink_drawing-editor .tl-container, -.ddc_ink_writing-editor .tl-container { - --layer-panels: 300; - --layer-menus: 400; - --layer-overlays: 500; - --layer-toasts: 650; - --layer-cursor: 700; -} -.ddc_ink_drawing-editor .tlui-button, -.ddc_ink_writing-editor .tlui-button { - position: relative; - height: 40px; - min-width: 40px; - padding: 0px 12px; - display: flex; - align-items: center; - justify-content: center; - background-color: transparent; - border: transparent; - color: currentColor; - cursor: pointer; - pointer-events: all; - font-weight: inherit; - font-family: inherit; - text-rendering: optimizeLegibility; - font-size: 12px; - gap: 0px; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-button:disabled, -.ddc_ink_writing-editor .tlui-button:disabled { - color: var(--color-text-3); - text-shadow: none; - cursor: default; -} -.ddc_ink_drawing-editor .tlui-button:disabled .tlui-kbd, -.ddc_ink_writing-editor .tlui-button:disabled .tlui-kbd { - color: var(--color-text-3); -} -.ddc_ink_drawing-editor .tlui-button > *, -.ddc_ink_writing-editor .tlui-button > * { - position: relative; - z-index: 1; -} -.ddc_ink_drawing-editor .tlui-button__label, -.ddc_ink_writing-editor .tlui-button__label { - flex-grow: 2; - text-align: left; -} -.ddc_ink_drawing-editor .tlui-button:focus-visible:not(:hover), -.ddc_ink_writing-editor .tlui-button:focus-visible:not(:hover) { - outline: 1px solid var(--color-selected); - outline-offset: -4px; - border-radius: var(--radius-3); -} -.ddc_ink_drawing-editor .tlui-button::after, -.ddc_ink_writing-editor .tlui-button::after { - display: block; - content: ""; - position: absolute; - inset: 4px; - background-color: transparent; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tlui-button[aria-expanded=true]::after, -.ddc_ink_writing-editor .tlui-button[aria-expanded=true]::after { - background-color: var(--color-muted-0); - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-button__icon + .tlui-button__label, -.ddc_ink_writing-editor .tlui-button__icon + .tlui-button__label { - margin-left: var(--space-2); -} -.ddc_ink_drawing-editor .tlui-button[data-state=hinted]::after, -.ddc_ink_writing-editor .tlui-button[data-state=hinted]::after { - background-color: var(--color-hint); - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-button[data-state=hinted]:not(:disabled, :focus-visible):active:after, -.ddc_ink_writing-editor .tlui-button[data-state=hinted]:not(:disabled, :focus-visible):active:after { - background: var(--color-hint); - opacity: 1; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button::after, - .ddc_ink_writing-editor .tlui-button::after { - background-color: var(--color-muted-2); - opacity: 0; - } - .ddc_ink_drawing-editor .tlui-button:not(:disabled):hover::after, - .ddc_ink_writing-editor .tlui-button:not(:disabled):hover::after { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-button__low, -.ddc_ink_writing-editor .tlui-button__low { - border-radius: var(--radius-3); - background-color: var(--color-low); -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__low::after, - .ddc_ink_writing-editor .tlui-button__low::after { - background-color: var(--color-muted-2); - } -} -.ddc_ink_drawing-editor .tlui-button__primary, -.ddc_ink_writing-editor .tlui-button__primary { - color: var(--color-primary); -} -.ddc_ink_drawing-editor .tlui-button__danger, -.ddc_ink_writing-editor .tlui-button__danger { - color: var(--color-warn); - text-shadow: none; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__primary:not(:disabled, :focus-visible):hover, - .ddc_ink_writing-editor .tlui-button__primary:not(:disabled, :focus-visible):hover { - color: var(--color-primary); - } - .ddc_ink_drawing-editor .tlui-button__danger:not(:disabled, :focus-visible):hover, - .ddc_ink_writing-editor .tlui-button__danger:not(:disabled, :focus-visible):hover { - color: var(--color-warn); - text-shadow: none; - } -} -.ddc_ink_drawing-editor .tlui-button__panel, -.ddc_ink_writing-editor .tlui-button__panel { - position: relative; -} -.ddc_ink_drawing-editor .tlui-button__menu, -.ddc_ink_writing-editor .tlui-button__menu { - height: 40px; - min-height: 40px; - width: 100%; - gap: 8px; - margin: -4px 0px; -} -.ddc_ink_drawing-editor .tlui-button__menu:nth-child(1), -.ddc_ink_writing-editor .tlui-button__menu:nth-child(1) { - margin-top: 0px; -} -.ddc_ink_drawing-editor .tlui-button__menu:nth-last-child(1), -.ddc_ink_writing-editor .tlui-button__menu:nth-last-child(1) { - margin-bottom: 0px; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__menu::after, - .ddc_ink_writing-editor .tlui-button__menu::after { - inset: 4px; - border-radius: var(--radius-2); - } -} -.ddc_ink_drawing-editor .tlui-button__checkbox, -.ddc_ink_writing-editor .tlui-button__checkbox { - padding-left: 8px; -} -.ddc_ink_drawing-editor .tlui-button__checkbox__indicator, -.ddc_ink_writing-editor .tlui-button__checkbox__indicator { - width: 15px; - height: 15px; -} -.ddc_ink_drawing-editor .tlui-toolbar__lock-button, -.ddc_ink_writing-editor .tlui-toolbar__lock-button { - position: absolute; - top: 4px; - right: 0px; - pointer-events: all; - height: 40px; - width: 40px; - min-width: 0px; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tlui-toolbar__lock-button::after, -.ddc_ink_writing-editor .tlui-toolbar__lock-button::after { - top: 4px; - left: 8px; - inset: 4px; -} -.ddc_ink_drawing-editor .tlui-button__tool, -.ddc_ink_writing-editor .tlui-button__tool { - position: relative; - height: 48px; - width: 48px; - margin-left: -2px; - margin-right: -2px; -} -.ddc_ink_drawing-editor .tlui-button__tool:nth-of-type(1), -.ddc_ink_writing-editor .tlui-button__tool:nth-of-type(1) { - margin-left: 0px; -} -.ddc_ink_drawing-editor .tlui-button__tool:nth-last-of-type(1), -.ddc_ink_writing-editor .tlui-button__tool:nth-last-of-type(1) { - margin-right: 0px; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__tool::after, - .ddc_ink_writing-editor .tlui-button__tool::after { - inset: 4px; - border-radius: 8px; - } - .ddc_ink_drawing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):hover, - .ddc_ink_writing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):hover { - color: var(--color-selected-contrast); - } -} -.ddc_ink_drawing-editor .tlui-button__tool[data-state=selected], -.ddc_ink_writing-editor .tlui-button__tool[data-state=selected] { - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):active, -.ddc_ink_writing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):active { - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tlui-button__tool[data-state=selected]:not(:disabled)::after, -.ddc_ink_writing-editor .tlui-button__tool[data-state=selected]:not(:disabled)::after { - background: var(--color-selected); - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-button__tool, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-button__tool { - height: 48px; - width: 44px; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-button__tool > .tlui-icon, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-button__tool > .tlui-icon { - height: 16px; - width: 16px; -} -.ddc_ink_drawing-editor .tlui-button__help, -.ddc_ink_writing-editor .tlui-button__help { - height: 32px; - width: 32px; - padding: 0px; - min-width: 32px; - border-radius: 100%; - background-color: var(--color-low); - border: 1px solid var(--color-low-border); -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__help::after, - .ddc_ink_writing-editor .tlui-button__help::after { - background-color: var(--color-muted-2); - border-radius: 100%; - inset: 4px; - } -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal, -.ddc_ink_writing-editor .tlui-buttons__horizontal { - display: flex; - flex-direction: row; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *, -.ddc_ink_writing-editor .tlui-buttons__horizontal > * { - margin-left: -2px; - margin-right: -2px; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *:nth-child(1), -.ddc_ink_writing-editor .tlui-buttons__horizontal > *:nth-child(1) { - margin-left: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *:nth-last-child(1), -.ddc_ink_writing-editor .tlui-buttons__horizontal > *:nth-last-child(1) { - margin-right: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *:only-child, -.ddc_ink_writing-editor .tlui-buttons__horizontal > *:only-child { - width: 56px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid, -.ddc_ink_writing-editor .tlui-buttons__grid { - display: grid; - grid-template-columns: repeat(4, auto); - grid-auto-flow: row; - overflow: hidden; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button, -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button { - margin: -2px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n) { - margin-right: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n - 3), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n - 3) { - margin-left: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(-n + 4), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(-n + 4) { - margin-top: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-last-of-type(-n + 4), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-last-of-type(-n + 4) { - margin-bottom: 0px; -} -.ddc_ink_drawing-editor .tlui-zoom-menu__button__pct, -.ddc_ink_writing-editor .tlui-zoom-menu__button__pct { - width: 60px; - min-width: 60px; - text-align: center; -} -.ddc_ink_drawing-editor .tlui-layout, -.ddc_ink_writing-editor .tlui-layout { - position: relative; - display: grid; - grid-template-columns: 1fr; - grid-template-rows: minmax(0px, 1fr) auto; - grid-auto-rows: auto; - height: 100%; - max-height: 100%; - overflow: clip; - pointer-events: none; - user-select: none; - contain: strict; - z-index: var(--layer-panels); - -webkit-transform: translate3d(0, 0, 0); - --sab: env(safe-area-inset-bottom); -} -.ddc_ink_drawing-editor .tlui-layout__top, -.ddc_ink_writing-editor .tlui-layout__top { - grid-column: 1; - grid-row: 1; - display: flex; - min-width: 0px; - justify-content: space-between; -} -.ddc_ink_drawing-editor .tlui-layout__top__left, -.ddc_ink_writing-editor .tlui-layout__top__left { - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: flex-start; - width: 100%; - height: 100%; - flex: 0 1 0; -} -.ddc_ink_drawing-editor .tlui-layout__top__right, -.ddc_ink_writing-editor .tlui-layout__top__right { - display: flex; - flex-direction: column; - align-items: flex-end; - justify-content: flex-start; - height: 100%; - flex: 0 0 auto; - min-width: 0px; -} -.ddc_ink_drawing-editor .scrollable, -.ddc_ink_drawing-editor .scrollable *, -.ddc_ink_writing-editor .scrollable, -.ddc_ink_writing-editor .scrollable * { - pointer-events: all; - touch-action: auto; - overscroll-behavior: none; -} -.ddc_ink_drawing-editor .tlui-helper-buttons, -.ddc_ink_writing-editor .tlui-helper-buttons { - position: relative; - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - width: min-content; - gap: var(--space-3); - margin: var(--space-2) var(--space-3); - white-space: nowrap; - pointer-events: none; - z-index: var(--layer-panels); -} -.ddc_ink_drawing-editor .tlui-icon, -.ddc_ink_writing-editor .tlui-icon { - flex-shrink: 0; - width: 18px; - height: 18px; - background-color: currentColor; -} -.ddc_ink_drawing-editor .tlui-icon__small, -.ddc_ink_writing-editor .tlui-icon__small { - width: 15px; - height: 15px; -} -.ddc_ink_drawing-editor .tlui-slider, -.ddc_ink_writing-editor .tlui-slider { - position: relative; - display: flex; - align-items: center; - user-select: none; - touch-action: none; -} -.ddc_ink_drawing-editor .tlui-slider__container, -.ddc_ink_writing-editor .tlui-slider__container { - width: 100%; - padding: 0px var(--space-4); -} -.ddc_ink_drawing-editor .tlui-slider__track, -.ddc_ink_writing-editor .tlui-slider__track { - position: relative; - flex-grow: 1; - height: 44px; - cursor: pointer; -} -.ddc_ink_drawing-editor .tlui-slider__track::after, -.ddc_ink_writing-editor .tlui-slider__track::after { - display: block; - position: absolute; - top: calc(50% - 2px); - content: ""; - height: 3px; - width: 100%; - background-color: var(--color-muted-1); - border-radius: 14px; -} -.ddc_ink_drawing-editor .tlui-slider__range, -.ddc_ink_writing-editor .tlui-slider__range { - position: absolute; - top: calc(50% - 2px); - left: 0px; - height: 3px; - background-color: var(--color-selected); - border-radius: 14px; -} -.ddc_ink_drawing-editor .tlui-slider__thumb, -.ddc_ink_writing-editor .tlui-slider__thumb { - all: unset; - cursor: grab; - display: block; - width: 18px; - height: 18px; - position: relative; - top: -1px; - background-color: var(--color-panel); - border-radius: 999px; - box-shadow: inset 0px 0px 0px 2px var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-slider__thumb:active, -.ddc_ink_writing-editor .tlui-slider__thumb:active { - cursor: grabbing; - box-shadow: inset 0px 0px 0px 2px var(--color-text-1), var(--shadow-1); -} -.ddc_ink_drawing-editor .tlui-slider__thumb:focus-visible, -.ddc_ink_writing-editor .tlui-slider__thumb:focus-visible { - box-shadow: inset 0 0 0 2px var(--color-focus); -} -.ddc_ink_drawing-editor .tlui-kbd, -.ddc_ink_writing-editor .tlui-kbd { - font-family: inherit; - font-size: 11px; - line-height: 11px; - display: grid; - justify-items: center; - grid-auto-flow: column; - grid-template-columns: auto; - grid-auto-columns: minmax(1em, auto); - align-self: bottom; - color: var(--color-text-1); - margin-left: var(--space-4); -} -.ddc_ink_drawing-editor .tlui-kbd > span, -.ddc_ink_writing-editor .tlui-kbd > span { - width: 100%; - text-align: center; - display: inline; - margin: 0px; - padding: 2px; - border-radius: 2px; -} -.ddc_ink_drawing-editor .tlui-kbd > span:last-child, -.ddc_ink_writing-editor .tlui-kbd > span:last-child { - padding-right: 0; -} -.ddc_ink_drawing-editor .tlui-kbd:not(:last-child), -.ddc_ink_writing-editor .tlui-kbd:not(:last-child) { - margin-right: var(--space-2); -} -.ddc_ink_drawing-editor .tlui-focus-button, -.ddc_ink_writing-editor .tlui-focus-button { - z-index: var(--layer-panels); - pointer-events: all; -} -.ddc_ink_drawing-editor .tlui-popover, -.ddc_ink_writing-editor .tlui-popover { - position: relative; - display: flex; - align-content: stretch; -} -.ddc_ink_drawing-editor .tlui-popover__content, -.ddc_ink_writing-editor .tlui-popover__content { - position: relative; - max-height: 75vh; - margin: 0px; - border: none; - border-radius: var(--radius-3); - background-color: var(--color-panel); - box-shadow: var(--shadow-3); - z-index: var(--layer-menus); - overflow: hidden; - overflow-y: auto; - touch-action: auto; - overscroll-behavior: none; - scrollbar-width: none; - -ms-overflow-style: none; -} -.ddc_ink_drawing-editor .tlui-debug-panel, -.ddc_ink_writing-editor .tlui-debug-panel { - background-color: var(--color-low); - width: 100%; - display: grid; - align-items: center; - grid-template-columns: 1fr auto auto auto; - justify-content: space-between; - padding-left: var(--space-4); - border-top: 1px solid var(--color-background); - font-size: 12px; - color: var(--color-text-1); - z-index: var(--layer-panels); - pointer-events: all; -} -.ddc_ink_drawing-editor .tlui-debug-panel__current-state, -.ddc_ink_writing-editor .tlui-debug-panel__current-state { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} -.ddc_ink_drawing-editor .tlui-debug-panel__fps, -.ddc_ink_writing-editor .tlui-debug-panel__fps { - margin-right: 8px; -} -.ddc_ink_drawing-editor .tlui-debug-panel__fps__slow, -.ddc_ink_writing-editor .tlui-debug-panel__fps__slow { - font-weight: bold; - color: var(--color-warn); -} -.ddc_ink_drawing-editor .tlui-menu-zone, -.ddc_ink_writing-editor .tlui-menu-zone { - position: relative; - z-index: var(--layer-panels); - width: fit-content; - border-right: 2px solid var(--color-background); - border-bottom: 2px solid var(--color-background); - border-bottom-right-radius: var(--radius-4); - background-color: var(--color-low); -} -.ddc_ink_drawing-editor .tlui-menu-zone *[data-state=open]::after, -.ddc_ink_writing-editor .tlui-menu-zone *[data-state=open]::after { - background: linear-gradient(180deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-style-panel__wrapper, -.ddc_ink_writing-editor .tlui-style-panel__wrapper { - box-shadow: var(--shadow-2); - border-radius: var(--radius-3); - pointer-events: all; - background-color: var(--color-panel); - height: fit-content; - max-height: 100%; - margin: 8px; - touch-action: auto; - overscroll-behavior: none; - overflow-y: auto; - overflow-x: hidden; - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-style-panel, -.ddc_ink_writing-editor .tlui-style-panel { - position: relative; - z-index: var(--layer-panels); - pointer-events: all; - width: 148px; - max-width: 148px; -} -.ddc_ink_drawing-editor .tlui-style-panel::-webkit-scrollbar, -.ddc_ink_writing-editor .tlui-style-panel::-webkit-scrollbar { - display: none; -} -.ddc_ink_drawing-editor .tlui-style-panel .tlui-button.select, -.ddc_ink_writing-editor .tlui-style-panel .tlui-button.select { - width: 100%; -} -.ddc_ink_drawing-editor .tlui-style-panel__section, -.ddc_ink_writing-editor .tlui-style-panel__section { - display: flex; - position: relative; - flex-direction: column; -} -.ddc_ink_drawing-editor .tlui-style-panel__section:nth-of-type(n + 2):not(:last-child), -.ddc_ink_writing-editor .tlui-style-panel__section:nth-of-type(n + 2):not(:last-child) { - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-style-panel__section:empty, -.ddc_ink_writing-editor .tlui-style-panel__section:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-style-panel__section__common:not(:only-child), -.ddc_ink_writing-editor .tlui-style-panel__section__common:not(:only-child) { - margin-bottom: 7px; - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-style-panel__row, -.ddc_ink_writing-editor .tlui-style-panel__row { - display: flex; -} -.ddc_ink_drawing-editor .tlui-style-panel__row__extra-button, -.ddc_ink_writing-editor .tlui-style-panel__row__extra-button { - margin-left: -2px; -} -.ddc_ink_drawing-editor .tlui-style-panel__double-select-picker, -.ddc_ink_writing-editor .tlui-style-panel__double-select-picker { - display: flex; - grid-template-columns: 1fr auto; - align-items: center; - padding-left: var(--space-4); - color: var(--color-text-1); - font-size: 12px; -} -.ddc_ink_drawing-editor .tlui-style-panel__double-select-picker-label, -.ddc_ink_writing-editor .tlui-style-panel__double-select-picker-label { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - flex-grow: 2; - max-width: 100%; -} -.ddc_ink_drawing-editor .tlui-style-panel__section *[data-state=open]::after, -.ddc_ink_writing-editor .tlui-style-panel__section *[data-state=open]::after { - background: var(--color-muted-0); -} -.ddc_ink_drawing-editor .tlui-input, -.ddc_ink_writing-editor .tlui-input { - background: none; - margin: 0px; - position: relative; - z-index: 1; - height: 40px; - max-height: 40px; - display: flex; - align-items: center; - justify-content: center; - font-family: inherit; - font-size: 12px; - font-weight: inherit; - color: var(--color-text-1); - padding: var(--space-4); - padding-left: 0px; - border: none; - outline: none; - text-overflow: ellipsis; - width: 100%; - user-select: all; - text-rendering: optimizeLegibility; - -webkit-user-select: auto !important; -} -.ddc_ink_drawing-editor .tlui-input__wrapper, -.ddc_ink_writing-editor .tlui-input__wrapper { - width: 100%; - height: 44px; - display: flex; - align-items: center; - gap: var(--space-4); - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-input__wrapper > .tlui-icon, -.ddc_ink_writing-editor .tlui-input__wrapper > .tlui-icon { - flex-shrink: 0; -} -@media (max-width: 600px) { - @supports (-webkit-touch-callout: none) { - .ddc_ink_drawing-editor, - .ddc_ink_writing-editor { - } - .ddc_ink_drawing-editor .tlui-input, - .ddc_ink_writing-editor .tlui-input { - font-size: 16px; - } - } -} -.ddc_ink_drawing-editor .tlui-dialog__overlay, -.ddc_ink_writing-editor .tlui-dialog__overlay { - position: absolute; - top: 0px; - left: 0px; - width: 100%; - height: 100%; - z-index: var(--layer-overlays); - background-color: var(--color-overlay); - pointer-events: all; - animation: fadeIn 0.12s ease-out; - display: grid; - place-items: center; - overflow-y: auto; -} -.ddc_ink_drawing-editor .tlui-dialog__content, -.ddc_ink_writing-editor .tlui-dialog__content { - display: flex; - flex-direction: column; - position: relative; - cursor: default; - background-color: var(--color-panel); - box-shadow: var(--shadow-3); - border-radius: var(--radius-3); - font-size: 12px; - overflow: hidden; - min-width: 300px; - max-width: 80%; - max-height: 80%; -} -.ddc_ink_drawing-editor .tlui-dialog__header, -.ddc_ink_writing-editor .tlui-dialog__header { - position: relative; - display: flex; - align-items: center; - flex: 0; - z-index: 999; - padding-left: var(--space-4); - color: var(--color-text); - height: 44px; -} -.ddc_ink_drawing-editor .tlui-dialog__header__title, -.ddc_ink_writing-editor .tlui-dialog__header__title { - flex: 1; - font-weight: inherit; - font-size: 12px; - margin: 0px; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-dialog__header__close, -.ddc_ink_writing-editor .tlui-dialog__header__close { - justify-self: flex-end; -} -.ddc_ink_drawing-editor .tlui-dialog__body, -.ddc_ink_writing-editor .tlui-dialog__body { - padding: var(--space-4) var(--space-4); - flex: 0 1; - overflow-y: auto; - overflow-x: hidden; - color: var(--color-text-1); - user-select: all; - -webkit-user-select: text; -} -.ddc_ink_drawing-editor .tlui-dialog__footer, -.ddc_ink_writing-editor .tlui-dialog__footer { - position: relative; - z-index: 999; -} -.ddc_ink_drawing-editor .tlui-dialog__footer__actions, -.ddc_ink_writing-editor .tlui-dialog__footer__actions { - display: flex; - align-items: center; - justify-content: flex-end; -} -.ddc_ink_drawing-editor .tlui-dialog__footer__actions > .tlui-button:nth-last-child(n+2), -.ddc_ink_writing-editor .tlui-dialog__footer__actions > .tlui-button:nth-last-child(n+2) { - margin-right: -4px; -} -.ddc_ink_drawing-editor .tlui-toolbar, -.ddc_ink_writing-editor .tlui-toolbar { - grid-column: 1/span 3; - grid-row: 1; - display: flex; - align-items: center; - justify-content: center; - flex-grow: 2; - padding-bottom: calc(var(--space-3) + var(--sab)); -} -.ddc_ink_drawing-editor .tlui-toolbar__inner, -.ddc_ink_writing-editor .tlui-toolbar__inner { - position: relative; - width: fit-content; - display: flex; - gap: var(--space-3); - align-items: flex-end; -} -.ddc_ink_drawing-editor .tlui-toolbar__left, -.ddc_ink_writing-editor .tlui-toolbar__left { - width: fit-content; -} -.ddc_ink_drawing-editor .tlui-toolbar__extras, -.ddc_ink_writing-editor .tlui-toolbar__extras { - position: relative; - z-index: 1; - width: 100%; - pointer-events: none; - top: 6px; - height: 48px; -} -.ddc_ink_drawing-editor .tlui-toolbar__extras:empty, -.ddc_ink_writing-editor .tlui-toolbar__extras:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-toolbar__extras__controls, -.ddc_ink_writing-editor .tlui-toolbar__extras__controls { - display: flex; - position: relative; - flex-direction: row; - z-index: 1; - background-color: var(--color-low); - border-top-left-radius: var(--radius-4); - border-top-right-radius: var(--radius-4); - border: 2px solid var(--color-background); - margin-left: 8px; - margin-right: 0px; - pointer-events: all; - width: fit-content; -} -.ddc_ink_drawing-editor .tlui-toolbar__tools, -.ddc_ink_writing-editor .tlui-toolbar__tools { - display: flex; - flex-direction: row; - background-color: var(--color-low); - border-radius: var(--radius-4); - z-index: var(--layer-panels); - pointer-events: all; - position: relative; - align-items: center; - background: var(--color-panel); - box-shadow: var(--shadow-2); -} -.ddc_ink_drawing-editor .tlui-toolbar__overflow, -.ddc_ink_writing-editor .tlui-toolbar__overflow { - width: 40px; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-toolbar__overflow, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-toolbar__overflow { - width: 32px; - padding: 0px; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-toolbar *[data-state=open]::after, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-toolbar *[data-state=open]::after { - background: linear-gradient(0deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-help-menu, -.ddc_ink_writing-editor .tlui-help-menu { - pointer-events: all; - position: absolute; - bottom: var(--space-2); - right: var(--space-2); - z-index: var(--layer-panels); - border: 2px solid var(--color-background); - border-radius: 100%; -} -.ddc_ink_drawing-editor .tlui-context-menu__move-to-page__name, -.ddc_ink_writing-editor .tlui-context-menu__move-to-page__name { - max-width: min(300px, 35vw); - overflow: hidden; - text-overflow: ellipsis; -} -.ddc_ink_drawing-editor .tlui-context-menu__move-to-page__name[data-disabled], -.ddc_ink_writing-editor .tlui-context-menu__move-to-page__name[data-disabled] { - color: var(--color-text-3); - pointer-events: none; -} -.ddc_ink_drawing-editor .tlui-menu:empty, -.ddc_ink_writing-editor .tlui-menu:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-menu, -.ddc_ink_writing-editor .tlui-menu { - z-index: var(--layer-menus); - height: fit-content; - width: fit-content; - max-height: 80vh; - border-radius: var(--radius-3); - pointer-events: all; - touch-action: auto; - overflow-y: auto; - overscroll-behavior: none; - background-color: var(--color-panel); - box-shadow: var(--shadow-3); -} -.ddc_ink_drawing-editor .tlui-menu::-webkit-scrollbar, -.ddc_ink_writing-editor .tlui-menu::-webkit-scrollbar { - display: none; -} -.ddc_ink_drawing-editor .tlui-menu__arrow, -.ddc_ink_writing-editor .tlui-menu__arrow { - position: relative; - top: -1px; - fill: var(--color-panel); - stroke: var(--color-panel-contrast); - stroke-width: 1px; -} -.ddc_ink_drawing-editor .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu__group { - width: 100%; -} -.ddc_ink_drawing-editor .tlui-menu__group:empty, -.ddc_ink_writing-editor .tlui-menu__group:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu__group { - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-menu__group:nth-last-of-type(1), -.ddc_ink_writing-editor .tlui-menu__group:nth-last-of-type(1) { - border-bottom: none; -} -.ddc_ink_drawing-editor .tlui-menu__submenu__trigger[data-state=open]:not(:hover)::after, -.ddc_ink_writing-editor .tlui-menu__submenu__trigger[data-state=open]:not(:hover)::after { - border-radius: var(--radius-1); - background: linear-gradient(90deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-menu__submenu__trigger[data-direction=left][data-state=open]:not(:hover)::after, -.ddc_ink_writing-editor .tlui-menu__submenu__trigger[data-direction=left][data-state=open]:not(:hover)::after { - border-radius: var(--radius-1); - background: linear-gradient(270deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-menu[data-size=large] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=large] > .tlui-menu__group { - min-width: initial; -} -.ddc_ink_drawing-editor .tlui-menu[data-size=medium] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=medium] > .tlui-menu__group { - min-width: 144px; -} -.ddc_ink_drawing-editor .tlui-menu[data-size=small] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=small] > .tlui-menu__group { - min-width: 96px; -} -.ddc_ink_drawing-editor .tlui-menu[data-size=tiny] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=tiny] > .tlui-menu__group { - min-width: 0px; -} -.ddc_ink_drawing-editor .tlui-actions-menu, -.ddc_ink_writing-editor .tlui-actions-menu { - max-height: calc(100vh - 150px); -} -.ddc_ink_drawing-editor .tlui-toast__viewport, -.ddc_ink_writing-editor .tlui-toast__viewport { - position: absolute; - inset: 0px; - margin: 0px; - display: flex; - align-items: flex-end; - justify-content: flex-end; - flex-direction: column; - gap: var(--space-3); - pointer-events: none; - padding: 0px var(--space-3) 64px 0px; - z-index: var(--layer-toasts); -} -.ddc_ink_drawing-editor .tlui-toast__viewport > *, -.ddc_ink_writing-editor .tlui-toast__viewport > * { - pointer-events: all; -} -.ddc_ink_drawing-editor .tlui-toast__icon, -.ddc_ink_writing-editor .tlui-toast__icon { - padding-top: var(--space-4); - padding-left: var(--space-4); - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-toast__container, -.ddc_ink_writing-editor .tlui-toast__container { - min-width: 200px; - display: flex; - flex-direction: row; - background-color: var(--color-panel); - box-shadow: var(--shadow-2); - border-radius: var(--radius-3); - font-size: 12px; -} -.ddc_ink_drawing-editor .tlui-toast__main, -.ddc_ink_writing-editor .tlui-toast__main { - flex-grow: 2; - max-width: 280px; -} -.ddc_ink_drawing-editor .tlui-toast__content, -.ddc_ink_writing-editor .tlui-toast__content { - padding: var(--space-4); - display: flex; - flex-direction: column; - gap: var(--space-3); -} -.ddc_ink_drawing-editor .tlui-toast__title, -.ddc_ink_writing-editor .tlui-toast__title { - font-weight: bold; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-toast__description, -.ddc_ink_writing-editor .tlui-toast__description { - color: var(--color-text-1); - padding: var(--space-3); - margin: 0px; - padding: 0px; -} -.ddc_ink_drawing-editor .tlui-toast__icon + .tlui-toast__main > .tlui-toast__actions, -.ddc_ink_writing-editor .tlui-toast__icon + .tlui-toast__main > .tlui-toast__actions { - padding-left: 0px; -} -.ddc_ink_drawing-editor .tlui-toast__actions, -.ddc_ink_writing-editor .tlui-toast__actions { - display: flex; - flex-direction: row; - justify-content: flex-start; - margin-left: 0; -} -.ddc_ink_drawing-editor .tlui-toast__close, -.ddc_ink_writing-editor .tlui-toast__close { - align-self: flex-end; - flex-shrink: 0; -} -@media (prefers-reduced-motion: no-preference) { - .ddc_ink_drawing-editor .tlui-toast__container[data-state=open], - .ddc_ink_writing-editor .tlui-toast__container[data-state=open] { - animation: slide-in 200ms cubic-bezier(0.785, 0.135, 0.15, 0.86); - } - .ddc_ink_drawing-editor .tlui-toast__container[data-state=closed], - .ddc_ink_writing-editor .tlui-toast__container[data-state=closed] { - animation: hide 100ms ease-in; - } - .ddc_ink_drawing-editor .tlui-toast__container[data-swipe=move], - .ddc_ink_writing-editor .tlui-toast__container[data-swipe=move] { - transform: translateX(var(--radix-toast-swipe-move-x)); - } - .ddc_ink_drawing-editor .tlui-toast__container[data-swipe=cancel], - .ddc_ink_writing-editor .tlui-toast__container[data-swipe=cancel] { - transform: translateX(0); - transition: transform 200ms ease-out; - } - .ddc_ink_drawing-editor .tlui-toast__container[data-swipe=end], - .ddc_ink_writing-editor .tlui-toast__container[data-swipe=end] { - animation: swipe-out 100ms ease-out; - } -} -.ddc_ink_drawing-editor .tlui-layout__bottom, -.ddc_ink_writing-editor .tlui-layout__bottom { - grid-row: 2; -} -.ddc_ink_drawing-editor .tlui-layout__bottom__main, -.ddc_ink_writing-editor .tlui-layout__bottom__main { - width: 100%; - position: relative; - display: flex; - align-items: flex-end; - justify-content: center; -} -.ddc_ink_drawing-editor .tlui-navigation-panel, -.ddc_ink_writing-editor .tlui-navigation-panel { - display: flex; - width: min-content; - flex-direction: column; - z-index: var(--layer-panels); - pointer-events: all; - position: absolute; - left: 0px; - bottom: 0px; -} -.ddc_ink_drawing-editor .tlui-navigation-panel::before, -.ddc_ink_writing-editor .tlui-navigation-panel::before { - content: ""; - display: block; - position: absolute; - z-index: -1; - inset: -2px -2px 0px 0px; - border-radius: 0; - border-top: 2px solid var(--color-background); - border-right: 2px solid var(--color-background); - border-top-right-radius: var(--radius-4); - background-color: var(--color-low); -} -.ddc_ink_drawing-editor .tlui-navigation-panel__toggle .tlui-icon, -.ddc_ink_writing-editor .tlui-navigation-panel__toggle .tlui-icon { - opacity: 0.24; -} -.ddc_ink_drawing-editor .tlui-navigation-panel__toggle:active .tlui-icon, -.ddc_ink_writing-editor .tlui-navigation-panel__toggle:active .tlui-icon { - opacity: 1; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-navigation-panel__toggle:hover .tlui-icon, - .ddc_ink_writing-editor .tlui-navigation-panel__toggle:hover .tlui-icon { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-minimap, -.ddc_ink_writing-editor .tlui-minimap { - width: 100%; - height: 96px; - min-height: 96px; - overflow: hidden; - padding: var(--space-3); - padding-top: 0px; -} -.ddc_ink_drawing-editor .tlui-minimap__canvas, -.ddc_ink_writing-editor .tlui-minimap__canvas { - position: relative; - width: 100%; - height: 100%; -} -@keyframes hide { - 0% { - opacity: 1; - } - 100% { - opacity: 0; - } -} -@keyframes slide-in { - from { - transform: translateX(calc(100% + var(--space-3))); - } - to { - transform: translateX(0px); - } -} -@keyframes swipe-out { - from { - transform: translateX(var(--radix-toast-swipe-end-x)); - } - to { - transform: translateX(calc(100% + var(--space-3))); - } -} -.ddc_ink_drawing-editor .tlui-page-menu__wrapper, -.ddc_ink_writing-editor .tlui-page-menu__wrapper { - position: relative; - display: flex; - flex-direction: column; - width: 220px; - height: fit-content; - max-height: 50vh; -} -.ddc_ink_drawing-editor .tlui-page-menu__trigger, -.ddc_ink_writing-editor .tlui-page-menu__trigger { - width: 128px; -} -.ddc_ink_drawing-editor .tlui-page-menu__header, -.ddc_ink_writing-editor .tlui-page-menu__header { - display: flex; - flex-direction: row; - align-items: center; - width: 100%; - height: 40px; - padding-left: var(--space-4); - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-page-menu__header > .tlui-button:nth-of-type(1), -.ddc_ink_writing-editor .tlui-page-menu__header > .tlui-button:nth-of-type(1) { - margin-right: -4px; -} -.ddc_ink_drawing-editor .tlui-page-menu__header__title, -.ddc_ink_writing-editor .tlui-page-menu__header__title { - color: var(--color-text); - font-size: 12px; - flex-grow: 2; -} -.ddc_ink_drawing-editor .tlui-page-menu__name, -.ddc_ink_writing-editor .tlui-page-menu__name { - flex-grow: 2; - text-align: left; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.ddc_ink_drawing-editor .tlui-page-menu__list, -.ddc_ink_writing-editor .tlui-page-menu__list { - position: relative; - touch-action: auto; - flex-direction: column; - max-height: 100%; - overflow-x: hidden; - overflow-y: auto; - touch-action: auto; -} -.ddc_ink_drawing-editor .tlui-page-menu__item, -.ddc_ink_writing-editor .tlui-page-menu__item { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - gap: 0px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item:nth-of-type(n + 2), -.ddc_ink_writing-editor .tlui-page-menu__item:nth-of-type(n + 2) { - margin-top: -4px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button, -.ddc_ink_writing-editor .tlui-page-menu__item__button { - width: 100%; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button:not(:only-child), -.ddc_ink_writing-editor .tlui-page-menu__item__button:not(:only-child) { - flex-grow: 2; - margin-right: -2px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button > span, -.ddc_ink_writing-editor .tlui-page-menu__item__button > span { - display: block; - flex-grow: 2; - text-align: left; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button__checkbox, -.ddc_ink_writing-editor .tlui-page-menu__item__button__checkbox { - padding-left: 35px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button__check, -.ddc_ink_writing-editor .tlui-page-menu__item__button__check { - position: absolute; - left: 0px; - width: 24px; - padding-left: 10px; - display: inline-flex; - align-items: center; - justify-content: center; - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable { - position: absolute; - top: 0px; - left: 0px; - width: 100%; - height: fit-content; - display: flex; - flex-direction: row; - align-items: center; - overflow: hidden; - z-index: 1; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__title, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__title { - flex: 1; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__title > .tlui-input__wrapper, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__title > .tlui-input__wrapper { - height: 100%; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable:focus-within, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable:focus-within { - z-index: 10; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__handle, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__handle { - touch-action: none; - width: 32px; - min-width: 0px; - height: 40px; - cursor: grab; - color: var(--color-text-3); - flex-shrink: 0; - margin-right: -9px; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__handle:active, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__handle:active { - cursor: grabbing; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__input, -.ddc_ink_writing-editor .tlui-page-menu__item__input { - margin-left: 12px; - height: 100%; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__submenu, -.ddc_ink_writing-editor .tlui-page_menu__item__submenu { - pointer-events: all; - flex: 0; - cursor: pointer; - margin: 0px; - display: none; - margin-left: -2px; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__submenu[data-isediting=true], -.ddc_ink_writing-editor .tlui-page_menu__item__submenu[data-isediting=true] { - display: block; - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__submenu > .tlui-button, -.ddc_ink_writing-editor .tlui-page_menu__item__submenu > .tlui-button { - opacity: 0; -} -@media (any-pointer: coarse) { - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu > .tlui-button { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button .tlui-button__icon, -.ddc_ink_writing-editor .tlui-page-menu__item__button .tlui-button__icon { - margin-right: 4px; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu { - display: block; - } - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu[data-isediting=true] > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu[data-isediting=true] > .tlui-button { - opacity: 0; - } - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu > .tlui-button[data-state=open], - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu:hover > .tlui-button, - .ddc_ink_drawing-editor .tlui-page_menu__item__sortable:focus-within > .tlui-page_menu__item__submenu > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu > .tlui-button[data-state=open], - .ddc_ink_writing-editor .tlui-page_menu__item__submenu:hover > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__sortable:focus-within > .tlui-page_menu__item__submenu > .tlui-button { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-edit-link-dialog, -.ddc_ink_writing-editor .tlui-edit-link-dialog { - display: flex; - flex-direction: column; - gap: var(--space-4); - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-edit-link-dialog__input, -.ddc_ink_writing-editor .tlui-edit-link-dialog__input { - background-color: var(--color-muted-2); - flex-grow: 2; - border-radius: var(--radius-2); - padding: 0px var(--space-4); -} -.ddc_ink_drawing-editor .tlui-embed__spacer, -.ddc_ink_writing-editor .tlui-embed__spacer { - flex-grow: 2; - min-height: 0px; - margin-left: calc(-1 * var(--space-4)); - margin-top: calc(-1 * var(--space-4)); - pointer-events: none; -} -.ddc_ink_drawing-editor .tlui-embed-dialog__list, -.ddc_ink_writing-editor .tlui-embed-dialog__list { - display: flex; - flex-direction: column; - padding-bottom: var(--space-5); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__item__image, -.ddc_ink_writing-editor .tlui-embed-dialog__item__image { - width: 24px; - height: 24px; - display: flex; - align-items: center; - justify-content: center; - background-size: contain; - background-repeat: no-repeat; - background-position: center center; -} -.ddc_ink_drawing-editor .tlui-embed-dialog__enter, -.ddc_ink_writing-editor .tlui-embed-dialog__enter { - display: flex; - flex-direction: column; - gap: var(--space-4); - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__input, -.ddc_ink_writing-editor .tlui-embed-dialog__input { - background-color: var(--color-muted-2); - flex-grow: 2; - border-radius: var(--radius-2); - padding: 0px var(--space-4); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__warning, -.ddc_ink_writing-editor .tlui-embed-dialog__warning { - color: var(--color-warn); - text-shadow: none; -} -.ddc_ink_drawing-editor .tlui-embed-dialog__instruction__link, -.ddc_ink_writing-editor .tlui-embed-dialog__instruction__link { - display: flex; - gap: var(--space-1); - margin-top: var(--space-4); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__enter a, -.ddc_ink_writing-editor .tlui-embed-dialog__enter a { - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-following-indicator, -.ddc_ink_writing-editor .tlui-following-indicator { - display: block; - position: absolute; - inset: 0px; - border-width: 2px; - border-style: solid; - z-index: var(--layer-following-indicator); - pointer-events: none; -} -.ddc_ink_drawing-editor .tlui-offline-indicator, -.ddc_ink_writing-editor .tlui-offline-indicator { - display: flex; - flex-direction: row; - gap: var(--space-3); - color: var(--color-text); - background-color: var(--color-low); - border: 3px solid var(--color-background); - padding: 0px var(--space-5); - height: 42px; - align-items: center; - justify-content: center; - border-radius: 99px; - opacity: 0; - animation: fade-in; - animation-duration: 0.12s; - animation-delay: 2s; - animation-fill-mode: forwards; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__header, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__header { - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__body, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__body { - position: relative; - columns: 3; - column-gap: var(--space-9); - pointer-events: all; - touch-action: auto; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__body__tablet, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__body__tablet { - columns: 2; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__body__mobile, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__body__mobile { - columns: 1; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__group, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__group { - break-inside: avoid-column; - padding-bottom: var(--space-6); -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__group__title, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__group__title { - font-size: inherit; - font-weight: inherit; - margin: 0px; - color: var(--color-text-3); - height: 32px; - display: flex; - align-items: center; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__group__content, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__group__content { - display: flex; - flex-direction: column; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__key-pair, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__key-pair { - display: flex; - gap: var(--space-4); - align-items: center; - justify-content: space-between; - height: 32px; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__key-pair__key, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__key-pair__key { - flex: 1; - font-size: 12px; -} -.ddc_ink_writing-editor { - transition: height 0.5s ease; -} -.ddc_ink_writing-editor .tl-container { - outline: none !important; -} -.ddc_ink_writing-editor .tl-container .tl-canvas { - background: none; - overflow: hidden; -} -.ddc_ink_writing-editor .tl-container .tl-canvas .tl-background { - background: none; -} -.ddc_ink_writing-editor { - outline: solid 8px var(--color-base-10); - border-radius: 20px; - background-color: var(--color-base-05); -} -.ddc_ink_writing-editor line { - stroke: var(--color-base-50); - stroke-width: 2px; -} - -/* src/tldraw/writing-menu/writing-menu.scss */ -.ink_menu-bar { - pointer-events: none; -} -.ink_menu-bar button { - animation: menu-button_scale-up 0.3s 0.1s ease-out; - animation-fill-mode: both; - pointer-events: auto; - background-color: var(--interactive-normal); - color: var(--color-base-60); - fill: var(--color-base-60); -} -.ink_menu-bar button:hover { - background-color: var(--interactive-hover); - color: var(--color-base-100); - fill: var(--color-base-100); -} -.ink_menu-bar button:disabled { - animation: menu-button_scale-up 0.3s ease-out; - opacity: 1; - cursor: default; - color: var(--text-on-accent); - fill: var(--text-on-accent); - background-color: var(--interactive-accent); -} -.ink_menu-bar button:disabled:hover { - box-shadow: var(--input-shadow); -} -.ink_menu-bar_full { - flex-grow: 1; - display: flex; - flex-direction: row; - justify-content: space-between; -} -.ink_menu-bar_floating { - flex-grow: 1; - display: flex; - flex-direction: row; - justify-content: space-between; -} -@keyframes menu-button_scale-up { - from { - transform: scale(0); - } - to { - transform: scale(1); - } -} -.ink_quick-menu { - display: flex; - flex-direction: row; - gap: 8px; -} -.ink_quick-menu button { - width: 2.5em; - height: 2.5em; - border-radius: 0.8em; - padding: 0 !important; -} -.ink_quick-menu button svg { - width: 1.5em !important; - height: 1.5em !important; -} -.ink_quick-menu button:disabled { - visibility: hidden; -} -.ink_tool-menu { - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - display: flex; - flex-direction: row; - justify-content: center; - gap: 8px; -} -.ink_tool-menu button { - width: 2.5em; - height: 2.5em; - border-radius: 2.5em; - padding: 0 !important; -} -.ink_tool-menu button svg { - width: 1.5em !important; - height: 1.5em !important; -} -.ink_other-menu { - display: flex; - flex-direction: row; -} - -/* src/tldraw/primary-menu-bar/primary-menu-bar.scss */ -.ink_primary-menu-bar { - position: absolute; - top: 0; - left: 0; - right: 0; - z-index: 1000; - padding: 8px; - display: flex; - flex-direction: row; - justify-content: space-between; - pointer-events: none; -} -.cm-embed-block .ink_primary-menu-bar { - padding: 8px var(--file-margins); - transition-property: transform; - transition-duration: 0.2s; - transition-timing-function: cubic-bezier(0, 0.5, 0, 1); -} -.cm-embed-block .ink_primary-menu-bar.ddc_ink_active { - transform: translate(0, -100%); -} - -/* src/tldraw/extended-writing-menu/extended-writing-menu.scss */ -.ink_extended-writing-menu { - display: flex; - gap: 4px; - pointer-events: none; -} -.ink_extended-writing-menu button { - width: auto; - pointer-events: auto; - background-color: var(--interactive-normal); - color: var(--color-base-60); - fill: var(--color-base-60); -} -.ink_extended-writing-menu button:hover { - background-color: var(--interactive-hover); - color: var(--color-base-100); - fill: var(--color-base-100); -} -.ink_extended-writing-menu button:disabled { - cursor: default; - color: var(--text-on-accent); - fill: var(--text-on-accent); - background-color: var(--interactive-accent); -} -.ink_extended-writing-menu button:disabled:hover { - box-shadow: var(--input-shadow); -} -.ink_extended-writing-menu button { - width: 2.5em; - height: 2.5em; - border-radius: 0.8em; - padding: 0 !important; -} -.ink_extended-writing-menu button.ddc_ink_btn-slim { - width: 1.9em; - height: 2.5em; -} -.ink_extended-writing-menu button svg { - width: 1.5em !important; - height: 1.5em !important; -} - -/* src/tldraw/overflow-menu/overflow-menu.scss */ -.ddc_ink_overflow-button-and-menu { - position: relative; -} -.ddc_ink_overflow-button-and-menu .ddc_ink_dropdown { - position: absolute; - top: 100%; - right: 0; - width: 10em; - background-color: var(--interactive-normal); - color: var(--color-base-60); - fill: var(--color-base-60); - box-shadow: var(--input-shadow); - border-radius: 10px; - display: none; -} -.ddc_ink_overflow-button-and-menu .ddc_ink_dropdown.ddc_ink_visible { - display: block; -} -.ddc_ink_overflow-button-and-menu .ddc_ink_dropdown li { - padding: 0.5em; -} - -/* src/tldraw/secondary-menu-bar/secondary-menu-bar.scss */ -.ink_secondary-menu-bar { - position: absolute; - bottom: 0; - left: 0; - right: 0; - z-index: 1000; - padding: 8px; - display: flex; - flex-direction: row; - justify-content: center; - pointer-events: none; -} -.cm-embed-block .ink_secondary-menu-bar { - padding: 8px var(--file-margins); - transition-property: transform; - transition-duration: 0.2s; - transition-timing-function: cubic-bezier(0, 0.5, 0, 1); -} -.cm-embed-block .ink_secondary-menu-bar.ddc_ink_active { - transform: translate(0, 50%); -} - -/* src/tldraw/modify-menu/modify-menu.scss */ -.ink_modify-menu { - display: flex; - flex-direction: row; - gap: 8px; -} -.ink_modify-menu button { - width: 2.5em; - height: 2.5em; - border-radius: 0.8em; - padding: 0 !important; -} -.ink_modify-menu button svg { - width: 1.5em !important; - height: 1.5em !important; -} -.ink_modify-menu button:disabled { - visibility: hidden; -} - -/* src/tldraw/writing/writing-embed-preview/writing-embed-preview.scss */ -.ddc_ink_writing-embed-preview { - pointer-events: none; - overflow: visible; -} -.ddc_ink_writing-embed-preview.ddc_ink_visible-background { - border: solid 1px var(--color-base-20); - border-radius: 20px; - background-color: var(--color-base-05); -} -.ddc_ink_writing-embed-preview line { - stroke: var(--color-base-50); - stroke-width: 2px; -} -.ddc_ink_writing-embed-preview:not(.ddc_ink_visible-lines) line { - display: none; -} -.theme-dark .ddc_ink_writing-embed-preview path { - fill: rgb(242, 242, 242); -} -.theme-light .ddc_ink_writing-embed-preview path { - fill: rgb(29, 29, 29); -} - -/* src/tldraw/drawing/tldraw-drawing-editor.scss */ -.ddc_ink_drawing-editor, -.ddc_ink_writing-editor { -} -.ddc_ink_drawing-editor .tl-container, -.ddc_ink_writing-editor .tl-container { - width: 100%; - height: 100%; - font-size: 12px; - --space-1: 2px; - --space-2: 4px; - --space-3: 8px; - --space-4: 12px; - --space-5: 16px; - --space-6: 20px; - --space-7: 28px; - --space-8: 32px; - --space-9: 64px; - --space-10: 72px; - --radius-0: 2px; - --radius-1: 4px; - --radius-2: 6px; - --radius-3: 9px; - --radius-4: 11px; - --layer-background: 100; - --layer-grid: 150; - --layer-canvas: 200; - --layer-shapes: 300; - --layer-overlays: 400; - --layer-following-indicator: 1000; - --tl-zoom: 1; - --tl-cursor-none: none; - --tl-cursor-default: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z' fill='white'/><path d='m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z' fill='white'/><path d='m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z' fill='black'/><path d='m13 10.814v11.188l2.969-2.866.428-.139h4.768z' fill='black'/></g></svg>") 12 8, default; - --tl-cursor-pointer: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m13.3315 21.3799c-.284-.359-.629-1.093-1.243-1.984-.348-.504-1.211-1.453-1.468-1.935-.223-.426-.199-.617-.146-.97.094-.628.738-1.117 1.425-1.051.519.049.959.392 1.355.716.239.195.533.574.71.788.163.196.203.277.377.509.23.307.302.459.214.121-.071-.496-.187-1.343-.355-2.092-.128-.568-.159-.657-.281-1.093-.129-.464-.195-.789-.316-1.281-.084-.348-.235-1.059-.276-1.459-.057-.547-.087-1.439.264-1.849.275-.321.906-.418 1.297-.22.512.259.803 1.003.936 1.3.239.534.387 1.151.516 1.961.164 1.031.466 2.462.476 2.763.024-.369-.068-1.146-.004-1.5.058-.321.328-.694.666-.795.286-.085.621-.116.916-.055.313.064.643.288.766.499.362.624.369 1.899.384 1.831.086-.376.071-1.229.284-1.584.14-.234.497-.445.687-.479.294-.052.655-.068.964-.008.249.049.586.345.677.487.218.344.342 1.317.379 1.658.015.141.074-.392.293-.736.406-.639 1.843-.763 1.898.639.025.654.02.624.02 1.064 0 .517-.012.828-.04 1.202-.031.4-.117 1.304-.242 1.742-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.191 1.813-.118.562-.079.566-.102.965-.023.398.121.922.121.922s-.802.104-1.234.035c-.391-.063-.875-.841-1-1.079-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.031-3.139.02 0 0 .185-1.011-.227-1.358-.305-.259-.83-.784-1.144-1.06z' fill='white'/><g stroke='black' stroke-linecap='round' stroke-width='.75'><path d='m13.3315 21.3799c-.284-.359-.629-1.093-1.243-1.984-.348-.504-1.211-1.453-1.468-1.935-.223-.426-.199-.617-.146-.97.094-.628.738-1.117 1.425-1.051.519.049.959.392 1.355.716.239.195.533.574.71.788.163.196.203.277.377.509.23.307.302.459.214.121-.071-.496-.187-1.343-.355-2.092-.128-.568-.159-.657-.281-1.093-.129-.464-.195-.789-.316-1.281-.084-.348-.235-1.059-.276-1.459-.057-.547-.087-1.439.264-1.849.275-.321.906-.418 1.297-.22.512.259.803 1.003.936 1.3.239.534.387 1.151.516 1.961.164 1.031.466 2.462.476 2.763.024-.369-.068-1.146-.004-1.5.058-.321.328-.694.666-.795.286-.085.621-.116.916-.055.313.064.643.288.766.499.362.624.369 1.899.384 1.831.086-.376.071-1.229.284-1.584.14-.234.497-.445.687-.479.294-.052.655-.068.964-.008.249.049.586.345.677.487.218.344.342 1.317.379 1.658.015.141.074-.392.293-.736.406-.639 1.843-.763 1.898.639.025.654.02.624.02 1.064 0 .517-.012.828-.04 1.202-.031.4-.117 1.304-.242 1.742-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.191 1.813-.118.562-.079.566-.102.965-.023.398.121.922.121.922s-.802.104-1.234.035c-.391-.063-.875-.841-1-1.079-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.031-3.139.02 0 0 .185-1.011-.227-1.358-.305-.259-.83-.784-1.144-1.06z' stroke-linejoin='round'/><path d='m21.5664 21.7344v-3.459'/><path d='m19.5508 21.7461-.016-3.473'/><path d='m17.5547 18.3047.021 3.426'/></g></g></svg>") 14 10, pointer; - --tl-cursor-cross: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m25 16h-6.01v-6h-2.98v6h-6.01v3h6.01v6h2.98v-6h6.01z' fill='white'/><path d='m23.9902 17.0103h-6v-6.01h-.98v6.01h-6v.98h6v6.01h.98v-6.01h6z' fill='%23231f1f'/></g></svg>") 16 16, crosshair; - --tl-cursor-move: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m19 14h1v1h-1zm1 6h-1v-1h1zm-5-5h-1v-1h1zm0 5h-1v-1h1zm2-10.987-7.985 7.988 5.222 5.221 2.763 2.763 7.984-7.985z' fill='white'/><g fill='black'><path d='m23.5664 16.9971-2.557-2.809v1.829h-4.009-4.001v-1.829l-2.571 2.809 2.572 2.808-.001-1.808h4.001 4.009l-.001 1.808z'/><path d='m17.9873 17h.013v-4.001l1.807.001-2.807-2.571-2.809 2.57h1.809v4.001h.008v4.002l-1.828-.001 2.807 2.577 2.805-2.576h-1.805z'/></g></g></svg>") 16 16, move; - --tl-cursor-grab: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m13.5557 17.5742c-.098-.375-.196-.847-.406-1.552-.167-.557-.342-.859-.47-1.233-.155-.455-.303-.721-.496-1.181-.139-.329-.364-1.048-.457-1.44-.119-.509.033-.924.244-1.206.253-.339.962-.49 1.357-.351.371.13.744.512.916.788.288.46.357.632.717 1.542.393.992.564 1.918.611 2.231l.085.452c-.001-.04-.043-1.122-.044-1.162-.035-1.029-.06-1.823-.038-2.939.002-.126.064-.587.084-.715.078-.5.305-.8.673-.979.412-.201.926-.215 1.401-.017.423.173.626.55.687 1.022.014.109.094.987.093 1.107-.013 1.025.006 1.641.015 2.174.004.231.003 1.625.017 1.469.061-.656.094-3.189.344-3.942.144-.433.405-.746.794-.929.431-.203 1.113-.07 1.404.243.285.305.446.692.482 1.153.032.405-.019.897-.02 1.245 0 .867-.021 1.324-.037 2.121-.001.038-.015.298.023.182.094-.28.188-.542.266-.745.049-.125.241-.614.359-.859.114-.234.211-.369.415-.688.2-.313.415-.448.668-.561.54-.235 1.109.112 1.301.591.086.215.009.713-.028 1.105-.061.647-.254 1.306-.352 1.648-.128.447-.274 1.235-.34 1.601-.072.394-.234 1.382-.359 1.82-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.192 1.812-.117.563-.078.567-.101.965-.024.399.121.923.121.923s-.802.104-1.234.034c-.391-.062-.875-.841-1-1.078-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.03-3.139.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.284-.36-.629-1.093-1.243-1.985-.348-.504-1.027-1.085-1.284-1.579-.223-.425-.331-.954-.19-1.325.225-.594.675-.897 1.362-.832.519.05.848.206 1.238.537.225.19.573.534.75.748.163.195.203.276.377.509.23.307.302.459.214.121' fill='white'/><g stroke='black' stroke-linecap='round' stroke-width='.75'><path d='m13.5557 17.5742c-.098-.375-.196-.847-.406-1.552-.167-.557-.342-.859-.47-1.233-.155-.455-.303-.721-.496-1.181-.139-.329-.364-1.048-.457-1.44-.119-.509.033-.924.244-1.206.253-.339.962-.49 1.357-.351.371.13.744.512.916.788.288.46.357.632.717 1.542.393.992.564 1.918.611 2.231l.085.452c-.001-.04-.043-1.122-.044-1.162-.035-1.029-.06-1.823-.038-2.939.002-.126.064-.587.084-.715.078-.5.305-.8.673-.979.412-.201.926-.215 1.401-.017.423.173.626.55.687 1.022.014.109.094.987.093 1.107-.013 1.025.006 1.641.015 2.174.004.231.003 1.625.017 1.469.061-.656.094-3.189.344-3.942.144-.433.405-.746.794-.929.431-.203 1.113-.07 1.404.243.285.305.446.692.482 1.153.032.405-.019.897-.02 1.245 0 .867-.021 1.324-.037 2.121-.001.038-.015.298.023.182.094-.28.188-.542.266-.745.049-.125.241-.614.359-.859.114-.234.211-.369.415-.688.2-.313.415-.448.668-.561.54-.235 1.109.112 1.301.591.086.215.009.713-.028 1.105-.061.647-.254 1.306-.352 1.648-.128.447-.274 1.235-.34 1.601-.072.394-.234 1.382-.359 1.82-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.192 1.812-.117.563-.078.567-.101.965-.024.399.121.923.121.923s-.802.104-1.234.034c-.391-.062-.875-.841-1-1.078-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.03-3.139.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.284-.36-.629-1.093-1.243-1.985-.348-.504-1.027-1.085-1.284-1.579-.223-.425-.331-.954-.19-1.325.225-.594.675-.897 1.362-.832.519.05.848.206 1.238.537.225.19.573.534.75.748.163.195.203.276.377.509.23.307.302.459.214.121' stroke-linejoin='round'/><path d='m20.5664 21.7344v-3.459'/><path d='m18.5508 21.7461-.016-3.473'/><path d='m16.5547 18.3047.021 3.426'/></g></g></svg>") 16 16, grab; - --tl-cursor-grabbing: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m13.5732 12.0361c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.691.285-.086.62-.116.916-.055.313.064.642.287.765.499.362.623.368 1.899.385 1.831.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.249.049.586.344.677.487.219.344.342 1.316.379 1.658.016.141.074-.393.293-.736.406-.639 1.844-.763 1.898.639.026.654.02.624.02 1.064 0 .516-.012.828-.04 1.202-.03.399-.116 1.304-.241 1.742-.086.301-.371.978-.653 1.384 0 0-1.074 1.25-1.191 1.812-.117.563-.078.567-.102.965-.023.399.121.923.121.923s-.801.104-1.234.034c-.391-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.283-.36-1.002-.929-1.243-1.985-.213-.936-.192-1.395.037-1.77.232-.381.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.159.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.361-.401-.943-.38-1.526.008-.221.103-.771.832-1.042' fill='white'/><g stroke='black' stroke-width='.75'><path d='m13.5732 12.0361c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.691.285-.086.62-.116.916-.055.313.064.642.287.765.499.362.623.368 1.899.385 1.831.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.249.049.586.344.677.487.219.344.342 1.316.379 1.658.016.141.074-.393.293-.736.406-.639 1.844-.763 1.898.639.026.654.02.624.02 1.064 0 .516-.012.828-.04 1.202-.03.399-.116 1.304-.241 1.742-.086.301-.371.978-.653 1.384 0 0-1.074 1.25-1.191 1.812-.117.563-.078.567-.102.965-.023.399.121.923.121.923s-.801.104-1.234.034c-.391-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.283-.36-1.002-.929-1.243-1.985-.213-.936-.192-1.395.037-1.77.232-.381.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.159.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.361-.401-.943-.38-1.526.008-.221.103-.771.832-1.042z' stroke-linejoin='round'/><path d='m20.5664 19.7344v-3.459' stroke-linecap='round'/><path d='m18.5508 19.7461-.016-3.473' stroke-linecap='round'/><path d='m16.5547 16.3047.021 3.426' stroke-linecap='round'/></g></g></svg>") 16 16, grabbing; - --tl-cursor-text: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path fill='white' d='M7.94 0a5.25 5.25 0 0 0-3.47 1.17A5.27 5.27 0 0 0 1 0H0v3h1c1.41 0 1.85.7 2 1v3.94H2v3h1v3c-.13.3-.57 1-2 1H0v3h1a5.27 5.27 0 0 0 3.47-1.17c.98.8 2.21 1.21 3.47 1.17h1v-3h-1c-1.41 0-1.85-.7-2-1v-3H7v-3H6V4c.13-.3.57-1 2-1h1V0H7.94z'/><path fill='black' d='M7.94 2V1a4 4 0 0 0-3.47 1.64A4 4 0 0 0 1 1v1c1.3-.17 2.56.6 3 1.84v5.1H3v1h1v4.16c-.45 1.24-1.7 2-3 1.84v1a4.05 4.05 0 0 0 3.47-1.63 4.05 4.05 0 0 0 3.47 1.63v-1A2.82 2.82 0 0 1 5 14.1V9.93h1v-1H5V3.85A2.81 2.81 0 0 1 7.94 2z'/></g></svg>") 4 10, text; - --tl-cursor-zoom-in: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5' fill='white'/><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5z' stroke='black'/><g fill='black'><path d='m18 14h-2v-2h-2v2h-2v1.98h2v2.02h2v-2.02h2z'/><path d='m23.5859 25 1.414-1.414-5.449-5.449-1.414 1.414z'/></g></g></svg>") 16 16, zoom-in; - --tl-cursor-zoom-out: url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: black;'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='1' dy='1' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(0 16 16)' filter='url(%23shadow)'><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5' fill='white'/><path d='m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5z' stroke='black'/><g fill='black'><path d='m18 16h-5.98v-1.98h5.98z'/><path d='m23.5859 25 1.414-1.414-5.449-5.449-1.414 1.414z'/></g></g></svg>") 16 16, zoom-out; - --tl-cursor: var(--tl-cursor-default); - --tl-cursor-resize-edge: ew-resize; - --tl-cursor-resize-corner: nesw-resize; - --tl-cursor-ew-resize: ew-resize; - --tl-cursor-ns-resize: ns-resize; - --tl-cursor-nesw-resize: nesw-resize; - --tl-cursor-nwse-resize: nwse-resize; - --tl-cursor-rotate: pointer; - --tl-cursor-nwse-rotate: pointer; - --tl-cursor-nesw-rotate: pointer; - --tl-cursor-senw-rotate: pointer; - --tl-cursor-swne-rotate: pointer; - --tl-scale: calc(1 / var(--tl-zoom)); - --tl-font-draw: "tldraw_draw", sans-serif; - --tl-font-sans: "tldraw_sans", sans-serif; - --tl-font-serif: "tldraw_serif", serif; - --tl-font-mono: "tldraw_mono", monospace; - --a: calc(min(0.5, 1 / var(--tl-zoom)) * 2px); - --b: calc(min(0.5, 1 / var(--tl-zoom)) * -2px); - --tl-text-outline: - 0 var(--b) 0 var(--color-background), - 0 var(--a) 0 var(--color-background), - var(--b) var(--b) 0 var(--color-background), - var(--a) var(--b) 0 var(--color-background), - var(--a) var(--a) 0 var(--color-background), - var(--b) var(--a) 0 var(--color-background); - position: relative; - inset: 0px; - height: 100%; - width: 100%; - overflow: clip; -} -.ddc_ink_drawing-editor .tl-theme__light, -.ddc_ink_writing-editor .tl-theme__light { - --color-accent: hsl(0, 76%, 60%); - --color-background: hsl(210, 20%, 98%); - --color-brush-fill: hsl(0, 0%, 56%, 10.2%); - --color-brush-stroke: hsl(0, 0%, 56%, 25.1%); - --color-grid: hsl(0, 0%, 43%); - --color-low: hsl(204, 16%, 94%); - --color-low-border: hsl(204, 16%, 92%); - --color-culled: hsl(204, 14%, 93%); - --color-muted-none: hsl(0, 0%, 0%, 0%); - --color-muted-0: hsl(0, 0%, 0%, 2%); - --color-muted-1: hsl(0, 0%, 0%, 10%); - --color-muted-2: hsl(0, 0%, 0%, 4.3%); - --color-hint: hsl(0, 0%, 0%, 5.5%); - --color-overlay: hsl(0, 0%, 0%, 20%); - --color-divider: hsl(0, 0%, 91%); - --color-panel-contrast: hsl(0, 0%, 100%); - --color-panel-overlay: hsl(0, 0%, 100%, 82%); - --color-panel: hsl(0, 0%, 99%); - --color-focus: hsl(214, 100%, 29%); - --color-selected: hsl(214, 84%, 56%); - --color-selected-contrast: hsl(0, 0%, 100%); - --color-selection-fill: hsl(210, 100%, 56%, 24%); - --color-selection-stroke: hsl(214, 84%, 56%); - --color-text-0: hsl(0, 0%, 11%); - --color-text-1: hsl(0, 0%, 18%); - --color-text-3: hsl(220, 2%, 65%); - --color-text-shadow: hsl(0, 0%, 100%); - --color-primary: hsl(214, 84%, 56%); - --color-warn: hsl(0, 90%, 43%); - --color-text: hsl(0, 0%, 0%); - --color-laser: hsl(0, 100%, 50%); - --shadow-1: 0px 1px 2px hsl(0, 0%, 0%, 25%), 0px 1px 3px hsl(0, 0%, 0%, 9%); - --shadow-2: - 0px 0px 2px hsl(0, 0%, 0%, 16%), - 0px 2px 3px hsl(0, 0%, 0%, 24%), - 0px 2px 6px hsl(0, 0%, 0%, 0.1), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-3: - 0px 1px 2px hsl(0, 0%, 0%, 28%), - 0px 2px 6px hsl(0, 0%, 0%, 14%), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-4: - 0px 0px 3px hsl(0, 0%, 0%, 19%), - 0px 5px 4px hsl(0, 0%, 0%, 16%), - 0px 2px 16px hsl(0, 0%, 0%, 6%), - inset 0px 0px 0px 1px var(--color-panel-contrast); -} -.ddc_ink_drawing-editor .tl-theme__dark, -.ddc_ink_writing-editor .tl-theme__dark { - --color-accent: hsl(0, 76%, 60%); - --color-background: hsl(240, 5%, 8%); - --color-brush-fill: hsl(0, 0%, 71%, 5.1%); - --color-brush-stroke: hsl(0, 0%, 71%, 25.1%); - --color-grid: hsl(0, 0%, 56%); - --color-low: hsl(260, 5%, 12.5%); - --color-low-border: hsl(207, 10%, 10%); - --color-culled: hsl(210, 11%, 19%); - --color-muted-none: hsl(0, 0%, 100%, 0%); - --color-muted-0: hsl(0, 0%, 100%, 2%); - --color-muted-1: hsl(0, 0%, 100%, 10%); - --color-muted-2: hsl(0, 0%, 100%, 5%); - --color-hint: hsl(0, 0%, 100%, 7%); - --color-overlay: hsl(0, 0%, 0%, 50%); - --color-divider: hsl(240, 9%, 25%); - --color-panel-contrast: hsl(240, 13%, 22%); - --color-panel: hsl(220, 8%, 15%); - --color-panel-overlay: hsl(210, 11%, 24%, 82%); - --color-focus: hsl(217, 76%, 80%); - --color-selected: hsl(217, 89%, 61%); - --color-selected-contrast: hsl(0, 0%, 100%); - --color-selection-fill: hsl(209, 100%, 57%, 20%); - --color-selection-stroke: hsl(214, 84%, 56%); - --color-text-0: hsl(0, 9%, 94%); - --color-text-1: hsl(0, 0%, 85%); - --color-text-3: hsl(210, 6%, 45%); - --color-text-shadow: hsl(210, 13%, 18%); - --color-primary: hsl(214, 84%, 56%); - --color-warn: hsl(0, 81%, 66%); - --color-text: hsl(210, 17%, 98%); - --color-laser: hsl(0, 100%, 50%); - --shadow-1: - 0px 1px 2px hsl(0, 0%, 0%, 16.1%), - 0px 1px 3px hsl(0, 0%, 0%, 22%), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-2: - 0px 1px 3px hsl(0, 0%, 0%, 66.6%), - 0px 2px 6px hsl(0, 0%, 0%, 33%), - inset 0px 0px 0px 1px var(--color-panel-contrast); - --shadow-3: - 0px 1px 3px hsl(0, 0%, 0%, 50%), - 0px 2px 12px hsl(0, 0%, 0%, 50%), - inset 0px 0px 0px 1px var(--color-panel-contrast); -} -.ddc_ink_drawing-editor .tl-counter-scaled, -.ddc_ink_writing-editor .tl-counter-scaled { - transform: scale(var(--tl-scale)); - transform-origin: top left; - width: calc(100% * var(--tl-zoom)); - height: calc(100% * var(--tl-zoom)); -} -.ddc_ink_drawing-editor .tl-container, -.ddc_ink_drawing-editor .tl-container *, -.ddc_ink_writing-editor .tl-container, -.ddc_ink_writing-editor .tl-container * { - -webkit-touch-callout: none; - -webkit-tap-highlight-color: transparent; - scrollbar-highlight-color: transparent; - -webkit-user-select: none; - user-select: none; - box-sizing: border-box; - outline: none; -} -.ddc_ink_drawing-editor .tl-container a, -.ddc_ink_writing-editor .tl-container a { - -webkit-touch-callout: initial; -} -.ddc_ink_drawing-editor .tl-container:focus-within, -.ddc_ink_writing-editor .tl-container:focus-within { - outline: 1px solid var(--color-low); -} -.ddc_ink_drawing-editor input, -.ddc_ink_drawing-editor *[contenteditable], -.ddc_ink_drawing-editor *[contenteditable] *, -.ddc_ink_writing-editor input, -.ddc_ink_writing-editor *[contenteditable], -.ddc_ink_writing-editor *[contenteditable] * { - -webkit-user-select: text; -} -.ddc_ink_drawing-editor .tl-canvas, -.ddc_ink_writing-editor .tl-canvas { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - color: var(--color-text); - z-index: var(--layer-canvas); - cursor: var(--tl-cursor); - overflow: clip; - content-visibility: auto; - touch-action: none; - contain: strict; -} -.ddc_ink_drawing-editor .tl-shapes, -.ddc_ink_writing-editor .tl-shapes { - position: relative; - z-index: var(--layer-shapes); -} -.ddc_ink_drawing-editor .tl-overlays, -.ddc_ink_writing-editor .tl-overlays { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - contain: strict; - pointer-events: none; - z-index: var(--layer-overlays); -} -.ddc_ink_drawing-editor .tl-overlays__item, -.ddc_ink_writing-editor .tl-overlays__item { - position: absolute; - top: 0px; - left: 0px; - overflow: visible; - pointer-events: none; - transform-origin: top left; -} -.ddc_ink_drawing-editor .tl-svg-context, -.ddc_ink_writing-editor .tl-svg-context { - position: absolute; - top: 0px; - left: 0px; - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-background, -.ddc_ink_writing-editor .tl-background { - position: absolute; - background-color: var(--color-background); - inset: 0px; - height: 100%; - width: 100%; - z-index: var(--layer-background); -} -.ddc_ink_drawing-editor .tl-grid, -.ddc_ink_writing-editor .tl-grid { - position: absolute; - inset: 0px; - width: 100%; - height: 100%; - touch-action: none; - pointer-events: none; - z-index: var(--layer-grid); - contain: strict; -} -.ddc_ink_drawing-editor .tl-grid-dot, -.ddc_ink_writing-editor .tl-grid-dot { - fill: var(--color-grid); -} -.ddc_ink_drawing-editor .tl-html-layer, -.ddc_ink_writing-editor .tl-html-layer { - position: absolute; - top: 0px; - left: 0px; - width: 1px; - height: 1px; - contain: layout style size; -} -.ddc_ink_drawing-editor .tl-brush, -.ddc_ink_writing-editor .tl-brush { - stroke-width: calc(var(--tl-scale) * 1px); - contain: size layout; -} -.ddc_ink_drawing-editor .tl-brush__default, -.ddc_ink_writing-editor .tl-brush__default { - stroke: var(--color-brush-stroke); - fill: var(--color-brush-fill); -} -.ddc_ink_drawing-editor .tl-scribble, -.ddc_ink_writing-editor .tl-scribble { - stroke-linejoin: round; - stroke-linecap: round; - pointer-events: none; - contain: size layout; -} -.ddc_ink_drawing-editor .tl-shape, -.ddc_ink_writing-editor .tl-shape { - position: absolute; - pointer-events: none; - overflow: visible; - transform-origin: top left; - contain: size layout; -} -.ddc_ink_drawing-editor .tl-shape__culled, -.ddc_ink_writing-editor .tl-shape__culled { - position: relative; - background-color: var(--color-culled); -} -.ddc_ink_drawing-editor .tl-svg-container, -.ddc_ink_writing-editor .tl-svg-container { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - pointer-events: none; - stroke-linecap: round; - stroke-linejoin: round; - transform-origin: top left; - overflow: visible; -} -.ddc_ink_drawing-editor .tl-html-container, -.ddc_ink_writing-editor .tl-html-container { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - pointer-events: none; - stroke-linecap: round; - stroke-linejoin: round; - transform-origin: top left; - color: inherit; -} -.ddc_ink_drawing-editor .tl-collaborator__scribble, -.ddc_ink_writing-editor .tl-collaborator__scribble { - z-index: 10; -} -.ddc_ink_drawing-editor .tl-collaborator__brush, -.ddc_ink_writing-editor .tl-collaborator__brush { - z-index: 20; -} -.ddc_ink_drawing-editor .tl-collaborator__shape-indicator, -.ddc_ink_writing-editor .tl-collaborator__shape-indicator { - z-index: 30; -} -.ddc_ink_drawing-editor .tl-user-scribble, -.ddc_ink_writing-editor .tl-user-scribble { - z-index: 40; -} -.ddc_ink_drawing-editor .tl-user-brush, -.ddc_ink_writing-editor .tl-user-brush { - z-index: 50; -} -.ddc_ink_drawing-editor .tl-user-indicator__selected, -.ddc_ink_writing-editor .tl-user-indicator__selected { - z-index: 60; -} -.ddc_ink_drawing-editor .tl-user-indicator__hovered, -.ddc_ink_writing-editor .tl-user-indicator__hovered { - z-index: 70; -} -.ddc_ink_drawing-editor .tl-user-handles, -.ddc_ink_writing-editor .tl-user-handles { - z-index: 80; -} -.ddc_ink_drawing-editor .tl-user-snapline, -.ddc_ink_writing-editor .tl-user-snapline { - z-index: 90; -} -.ddc_ink_drawing-editor .tl-selection__fg, -.ddc_ink_writing-editor .tl-selection__fg { - pointer-events: none; - z-index: 100; -} -.ddc_ink_drawing-editor .tl-user-indicator__hint, -.ddc_ink_writing-editor .tl-user-indicator__hint { - z-index: 110; - stroke-width: calc(2.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-collaborator__cursor-hint, -.ddc_ink_writing-editor .tl-collaborator__cursor-hint { - z-index: 120; -} -.ddc_ink_drawing-editor .tl-collaborator__cursor, -.ddc_ink_writing-editor .tl-collaborator__cursor { - z-index: 130; -} -.ddc_ink_drawing-editor .tl-cursor, -.ddc_ink_writing-editor .tl-cursor { - overflow: visible; -} -.ddc_ink_drawing-editor .tl-shape-indicator, -.ddc_ink_writing-editor .tl-shape-indicator { - transform-origin: top left; - fill: none; - stroke-width: calc(1.5px * var(--tl-scale)); - contain: size; -} -.ddc_ink_drawing-editor .tl-selection__bg, -.ddc_ink_writing-editor .tl-selection__bg { - position: absolute; - top: 0px; - left: 0px; - transform-origin: top left; - background-color: transparent; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-selection__fg__outline, -.ddc_ink_writing-editor .tl-selection__fg__outline { - fill: none; - pointer-events: none; - stroke: var(--color-selection-stroke); - stroke-width: calc(1.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-corner-handle, -.ddc_ink_writing-editor .tl-corner-handle { - pointer-events: none; - stroke: var(--color-selection-stroke); - fill: var(--color-background); - stroke-width: calc(1.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-text-handle, -.ddc_ink_writing-editor .tl-text-handle { - pointer-events: none; - fill: var(--color-selection-stroke); -} -.ddc_ink_drawing-editor .tl-corner-crop-handle, -.ddc_ink_writing-editor .tl-corner-crop-handle { - pointer-events: none; - fill: none; - stroke: var(--color-selection-stroke); -} -.ddc_ink_drawing-editor .tl-corner-crop-edge-handle, -.ddc_ink_writing-editor .tl-corner-crop-edge-handle { - pointer-events: none; - fill: none; - stroke: var(--color-selection-stroke); -} -.ddc_ink_drawing-editor .tl-mobile-rotate__bg, -.ddc_ink_writing-editor .tl-mobile-rotate__bg { - pointer-events: all; - cursor: var(--tl-cursor-grab); -} -.ddc_ink_drawing-editor .tl-mobile-rotate__fg, -.ddc_ink_writing-editor .tl-mobile-rotate__fg { - pointer-events: none; - stroke: var(--color-selection-stroke); - fill: var(--color-background); - stroke-width: calc(1.5px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-transparent, -.ddc_ink_writing-editor .tl-transparent { - fill: transparent; - stroke: transparent; -} -.ddc_ink_drawing-editor .tl-handle, -.ddc_ink_writing-editor .tl-handle { - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-handle__bg, -.ddc_ink_writing-editor .tl-handle__bg { - fill: transparent; - stroke: transparent; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-handle__fg, -.ddc_ink_writing-editor .tl-handle__fg { - fill: var(--color-selected-contrast); - stroke: var(--color-selection-stroke); - stroke-width: calc(1.5px * var(--tl-scale)); - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-handle__create, -.ddc_ink_writing-editor .tl-handle__create { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-handle__create:hover, -.ddc_ink_writing-editor .tl-handle__create:hover { - opacity: 1; -} -.ddc_ink_drawing-editor .tl-handle__bg:active, -.ddc_ink_writing-editor .tl-handle__bg:active { - fill: none; -} -.ddc_ink_drawing-editor .tl-handle__bg:hover, -.ddc_ink_writing-editor .tl-handle__bg:hover { - cursor: var(--tl-cursor-grab); - fill: var(--color-selection-fill); -} -@media (pointer: coarse) { - .ddc_ink_drawing-editor .tl-handle__bg:active, - .ddc_ink_writing-editor .tl-handle__bg:active { - fill: var(--color-selection-fill); - } - .ddc_ink_drawing-editor .tl-handle__create, - .ddc_ink_writing-editor .tl-handle__create { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tl-image, -.ddc_ink_drawing-editor .tl-video, -.ddc_ink_writing-editor .tl-image, -.ddc_ink_writing-editor .tl-video { - object-fit: cover; - background-size: cover; - width: 100%; - height: 100%; -} -.ddc_ink_drawing-editor .tl-image-container, -.ddc_ink_drawing-editor .tl-embed-container, -.ddc_ink_writing-editor .tl-image-container, -.ddc_ink_writing-editor .tl-embed-container { - width: 100%; - height: 100%; - pointer-events: all; - display: flex; - justify-content: center; - align-items: center; -} -.ddc_ink_drawing-editor .tl-image__tg, -.ddc_ink_writing-editor .tl-image__tg { - --scale: calc(min(2, var(--tl-scale))); - position: absolute; - top: calc(var(--scale) * 8px); - right: calc(var(--scale) * 8px); - font-size: 10px; - transform-origin: top right; - background-color: var(--color-background); - padding: 2px 4px; - border-radius: var(--radius-1); -} -.ddc_ink_drawing-editor .tl-collaborator-cursor, -.ddc_ink_writing-editor .tl-collaborator-cursor { - position: absolute; -} -.ddc_ink_drawing-editor .tl-nametag, -.ddc_ink_writing-editor .tl-nametag { - position: absolute; - top: 16px; - left: 13px; - width: fit-content; - height: fit-content; - max-width: 120px; - padding: 3px 6px; - white-space: nowrap; - position: absolute; - overflow: hidden; - text-overflow: ellipsis; - font-size: 12px; - font-family: var(--font-body); - border-radius: var(--radius-2); - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tl-nametag-title, -.ddc_ink_writing-editor .tl-nametag-title { - position: absolute; - top: -2px; - left: 13px; - width: fit-content; - height: fit-content; - padding: 0px 6px; - max-width: 120px; - white-space: nowrap; - position: absolute; - overflow: hidden; - text-overflow: ellipsis; - font-size: 12px; - font-family: var(--font-body); - text-shadow: var(--tl-text-outline); - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tl-nametag-chat, -.ddc_ink_writing-editor .tl-nametag-chat { - position: absolute; - top: 16px; - left: 13px; - width: fit-content; - height: fit-content; - color: var(--color-selected-contrast); - white-space: nowrap; - position: absolute; - padding: 3px 6px; - font-size: 12px; - font-family: var(--font-body); - opacity: 1; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tl-cursor-chat, -.ddc_ink_writing-editor .tl-cursor-chat { - position: absolute; - color: var(--color-selected-contrast); - white-space: nowrap; - padding: 3px 6px; - font-size: 12px; - font-family: var(--font-body); - pointer-events: none; - z-index: var(--layer-cursor); - margin-top: 16px; - margin-left: 13px; - opacity: 1; - border: none; - user-select: text; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tl-cursor-chat .tl-cursor-chat__bubble, -.ddc_ink_writing-editor .tl-cursor-chat .tl-cursor-chat__bubble { - padding-right: 12px; -} -.ddc_ink_drawing-editor .tl-cursor-chat::selection, -.ddc_ink_writing-editor .tl-cursor-chat::selection { - background: var(--color-selected); - color: var(--color-selected-contrast); - text-shadow: none; -} -.ddc_ink_drawing-editor .tl-cursor-chat-fade, -.ddc_ink_writing-editor .tl-cursor-chat-fade { - opacity: 0.0001; - transition: opacity 5s ease-in-out; -} -.ddc_ink_drawing-editor .tl-cursor-chat::placeholder, -.ddc_ink_writing-editor .tl-cursor-chat::placeholder { - color: var(--color-selected-contrast); - opacity: 0.7; -} -@keyframes spinner { - to { - transform: rotate(360deg); - } -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper, -.ddc_ink_writing-editor .tl-text-shape__wrapper { - position: relative; - font-weight: normal; - min-width: 1px; - padding: 0px; - margin: 0px; - border: none; - height: 100%; - font-variant: normal; - font-style: normal; - pointer-events: all; - white-space: pre-wrap; - overflow-wrap: break-word; - text-shadow: var(--tl-text-outline); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-align=start], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-align=start] { - text-align: left; -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-align=middle], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-align=middle] { - text-align: center; -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-align=end], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-align=end] { - text-align: right; -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=draw], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=draw] { - font-family: var(--tl-font-draw); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=sans], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=sans] { - font-family: var(--tl-font-sans); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=serif], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=serif] { - font-family: var(--tl-font-serif); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-font=mono], -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-font=mono] { - font-family: var(--tl-font-mono); -} -.ddc_ink_drawing-editor .tl-text-shape__wrapper[data-isediting=true] .tl-text-content, -.ddc_ink_writing-editor .tl-text-shape__wrapper[data-isediting=true] .tl-text-content { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-text, -.ddc_ink_writing-editor .tl-text { - margin: 0px; - padding: 0px; - border: 0px; - color: inherit; - caret-color: var(--color-text); - background: none; - border-image: none; - font-size: inherit; - font-family: inherit; - font-weight: inherit; - line-height: inherit; - font-variant: inherit; - font-style: inherit; - text-align: inherit; - letter-spacing: inherit; - text-shadow: inherit; - outline: none; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - pointer-events: all; - text-rendering: auto; - text-transform: none; - text-indent: 0px; - display: inline-block; - appearance: auto; - column-count: initial !important; - writing-mode: horizontal-tb !important; - word-spacing: 0px; -} -.ddc_ink_drawing-editor .tl-text-measure, -.ddc_ink_writing-editor .tl-text-measure { - position: absolute; - z-index: -999999; - top: 0px; - left: 0px; - opacity: 0; - width: max-content; - box-sizing: border-box; - pointer-events: none; - line-break: normal; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - resize: none; - border: none; - user-select: none; - contain: style paint; - -webkit-user-select: none; -} -.ddc_ink_drawing-editor .tl-text-input, -.ddc_ink_drawing-editor .tl-text-content, -.ddc_ink_writing-editor .tl-text-input, -.ddc_ink_writing-editor .tl-text-content { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - min-width: 1px; - min-height: 1px; - overflow: visible; - outline: none; -} -.ddc_ink_drawing-editor .tl-text-content, -.ddc_ink_writing-editor .tl-text-content { - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-text-input, -.ddc_ink_writing-editor .tl-text-input { - resize: none; - user-select: all; - -webkit-user-select: text; - overflow: hidden; - cursor: var(--tl-cursor-text); -} -.ddc_ink_drawing-editor .tl-text-input::selection, -.ddc_ink_writing-editor .tl-text-input::selection { - background: var(--color-selected); - color: var(--color-selected-contrast); - text-shadow: none; -} -.ddc_ink_drawing-editor .tl-snap-indicator, -.ddc_ink_writing-editor .tl-snap-indicator { - stroke: var(--color-accent); - stroke-width: calc(1px * var(--tl-scale)); - fill: none; -} -.ddc_ink_drawing-editor .tl-snap-point, -.ddc_ink_writing-editor .tl-snap-point { - stroke: var(--color-accent); - stroke-width: calc(1px * var(--tl-scale)); - fill: none; -} -.ddc_ink_drawing-editor .tl-group, -.ddc_ink_writing-editor .tl-group { - stroke: var(--color-text); - stroke-width: calc(1px * var(--tl-scale)); - opacity: 0.5; -} -.ddc_ink_drawing-editor .tl-bookmark__container, -.ddc_ink_writing-editor .tl-bookmark__container { - width: 100%; - height: 100%; - position: relative; - border: 1px solid var(--color-panel-contrast); - background-color: var(--color-panel); - border-radius: var(--radius-2); - display: flex; - flex-direction: column; - overflow: hidden; -} -.ddc_ink_drawing-editor .tl-bookmark__image_container, -.ddc_ink_writing-editor .tl-bookmark__image_container { - flex: 1; - overflow: hidden; - border-top-left-radius: var(--radius-1); - border-top-right-radius: var(--radius-1); - width: 100%; - height: 100%; - display: flex; - justify-content: flex-end; - align-items: flex-start; -} -.ddc_ink_drawing-editor .tl-bookmark__image_container > .tl-hyperlink-button::after, -.ddc_ink_writing-editor .tl-bookmark__image_container > .tl-hyperlink-button::after { - background-color: var(--color-panel); -} -.ddc_ink_drawing-editor .tl-bookmark__placeholder, -.ddc_ink_writing-editor .tl-bookmark__placeholder { - width: 100%; - height: 100%; - background-color: var(--color-muted-2); - border-bottom: 1px solid var(--color-muted-2); -} -.ddc_ink_drawing-editor .tl-bookmark__image, -.ddc_ink_writing-editor .tl-bookmark__image { - width: 100%; - height: 100%; - object-fit: cover; - object-position: center; -} -.ddc_ink_drawing-editor .tl-bookmark__copy_container, -.ddc_ink_writing-editor .tl-bookmark__copy_container { - background-color: var(--color-muted); - padding: var(--space-4); - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-bookmark__heading, -.ddc_ink_drawing-editor .tl-bookmark__description, -.ddc_ink_drawing-editor .tl-bookmark__link, -.ddc_ink_writing-editor .tl-bookmark__heading, -.ddc_ink_writing-editor .tl-bookmark__description, -.ddc_ink_writing-editor .tl-bookmark__link { - margin: 0px; - width: 100%; - font-family: inherit; -} -.ddc_ink_drawing-editor .tl-bookmark__heading, -.ddc_ink_writing-editor .tl-bookmark__heading { - font-size: 16px; - font-weight: bold; - padding-bottom: var(--space-2); - margin: 8px 0px; -} -.ddc_ink_drawing-editor .tl-bookmark__description, -.ddc_ink_writing-editor .tl-bookmark__description { - font-size: 12px; - padding-bottom: var(--space-4); -} -.ddc_ink_drawing-editor .tl-bookmark__link, -.ddc_ink_writing-editor .tl-bookmark__link { - font-size: 14px; - pointer-events: all; - z-index: 999; - overflow: hidden; - display: block; - color: var(--color-text); - text-overflow: ellipsis; - text-decoration: none; - color: var(--color-text-1); - cursor: var(--tl-cursor-pointer); -} -.ddc_ink_drawing-editor .tl-bookmark__link:hover, -.ddc_ink_writing-editor .tl-bookmark__link:hover { - color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-hyperlink-button, -.ddc_ink_writing-editor .tl-hyperlink-button { - background: none; - margin: 0px; - position: absolute; - top: 0px; - right: 0px; - height: 44px; - width: 44px; - display: flex; - align-items: center; - justify-content: center; - z-index: 200; - font-size: 12px; - font-weight: 400; - color: var(--color-text-1); - padding: 13px; - cursor: var(--tl-cursor-pointer); - border: none; - outline: none; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-hyperlink-button::after, -.ddc_ink_writing-editor .tl-hyperlink-button::after { - content: ""; - z-index: -1; - position: absolute; - right: 6px; - bottom: 6px; - display: block; - width: calc(100% - 12px); - height: calc(100% - 12px); - border-radius: var(--radius-1); - background-color: var(--color-background); - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-hyperlink-button:hover, -.ddc_ink_writing-editor .tl-hyperlink-button:hover { - color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-hyperlink-button:focus-visible, -.ddc_ink_writing-editor .tl-hyperlink-button:focus-visible { - color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-hyperlink-button__icon, -.ddc_ink_writing-editor .tl-hyperlink-button__icon { - width: 18px; - height: 18px; - background-color: currentColor; - pointer-events: none; -} -.ddc_ink_drawing-editor .tl-hyperlink-button__hidden, -.ddc_ink_writing-editor .tl-hyperlink-button__hidden { - display: none; -} -.ddc_ink_drawing-editor .tl-text-label, -.ddc_ink_writing-editor .tl-text-label { - display: flex; - justify-content: center; - align-items: center; - color: var(--color-text); - text-shadow: var(--tl-text-outline); - line-height: inherit; - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: 10; -} -.ddc_ink_drawing-editor .tl-text-label[data-isediting=true] .tl-text-content, -.ddc_ink_writing-editor .tl-text-label[data-isediting=true] .tl-text-content { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-text-label[data-hastext=false][data-isediting=false] > .tl-text-label__inner, -.ddc_ink_writing-editor .tl-text-label[data-hastext=false][data-isediting=false] > .tl-text-label__inner { - width: 40px; - height: 40px; -} -.ddc_ink_drawing-editor .tl-text-label[data-hastext=true][data-isediting=false] .tl-text-content, -.ddc_ink_writing-editor .tl-text-label[data-hastext=true][data-isediting=false] .tl-text-content { - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-text-label__inner, -.ddc_ink_writing-editor .tl-text-label__inner { - position: relative; - width: fit-content; - height: fit-content; - display: flex; - align-items: center; - justify-content: center; - pointer-events: none; - min-height: auto; -} -.ddc_ink_drawing-editor .tl-text-label__inner > .tl-text-content, -.ddc_ink_writing-editor .tl-text-label__inner > .tl-text-content { - position: relative; - top: 0px; - left: 0px; - padding: 16px; - height: fit-content; - width: fit-content; - border-radius: var(--radius-1); - max-width: 100%; - z-index: 3; -} -.ddc_ink_drawing-editor .tl-text-label__inner > .tl-text-input, -.ddc_ink_writing-editor .tl-text-label__inner > .tl-text-input { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - padding: 16px; - z-index: 4; -} -.ddc_ink_drawing-editor .tl-text-label[data-textwrap=true] > .tl-text-label__inner, -.ddc_ink_writing-editor .tl-text-label[data-textwrap=true] > .tl-text-label__inner { - max-width: 100%; -} -.ddc_ink_drawing-editor .tl-text-label[data-isediting=true], -.ddc_ink_writing-editor .tl-text-label[data-isediting=true] { - background-color: transparent; - min-height: auto; -} -.ddc_ink_drawing-editor .tl-text-label[data-isediting=true] p, -.ddc_ink_writing-editor .tl-text-label[data-isediting=true] p { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-text-label[data-align=start], -.ddc_ink_drawing-editor .tl-text-label[data-align=start-legacy], -.ddc_ink_writing-editor .tl-text-label[data-align=start], -.ddc_ink_writing-editor .tl-text-label[data-align=start-legacy] { - text-align: left; -} -.ddc_ink_drawing-editor .tl-text-label[data-align=middle], -.ddc_ink_drawing-editor .tl-text-label[data-align=middle-legacy], -.ddc_ink_writing-editor .tl-text-label[data-align=middle], -.ddc_ink_writing-editor .tl-text-label[data-align=middle-legacy] { - text-align: center; -} -.ddc_ink_drawing-editor .tl-text-label[data-align=end], -.ddc_ink_drawing-editor .tl-text-label[data-align=end-legacy], -.ddc_ink_writing-editor .tl-text-label[data-align=end], -.ddc_ink_writing-editor .tl-text-label[data-align=end-legacy] { - text-align: right; -} -.ddc_ink_drawing-editor .tl-arrow-hint, -.ddc_ink_writing-editor .tl-arrow-hint { - stroke: var(--color-text-1); - fill: none; - stroke-linecap: round; - overflow: visible; -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=draw], -.ddc_ink_drawing-editor .tl-text-label[data-font=draw], -.ddc_ink_writing-editor .tl-arrow-label[data-font=draw], -.ddc_ink_writing-editor .tl-text-label[data-font=draw] { - font-family: var(--tl-font-draw); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=sans], -.ddc_ink_drawing-editor .tl-text-label[data-font=sans], -.ddc_ink_writing-editor .tl-arrow-label[data-font=sans], -.ddc_ink_writing-editor .tl-text-label[data-font=sans] { - font-family: var(--tl-font-sans); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=serif], -.ddc_ink_drawing-editor .tl-text-label[data-font=serif], -.ddc_ink_writing-editor .tl-arrow-label[data-font=serif], -.ddc_ink_writing-editor .tl-text-label[data-font=serif] { - font-family: var(--tl-font-serif); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-font=mono], -.ddc_ink_drawing-editor .tl-text-label[data-font=mono], -.ddc_ink_writing-editor .tl-arrow-label[data-font=mono], -.ddc_ink_writing-editor .tl-text-label[data-font=mono] { - font-family: var(--tl-font-mono); -} -.ddc_ink_drawing-editor .tl-arrow-label, -.ddc_ink_writing-editor .tl-arrow-label { - position: absolute; - top: -1px; - left: -1px; - width: 2px; - height: 2px; - padding: 0px; - display: flex; - justify-content: center; - align-items: center; - color: var(--color-text); - text-shadow: var(--tl-text-outline); -} -.ddc_ink_drawing-editor .tl-arrow-label[data-isediting=true] p, -.ddc_ink_writing-editor .tl-arrow-label[data-isediting=true] p { - opacity: 0; -} -.ddc_ink_drawing-editor .tl-arrow-label[data-isediting=true] > .tl-arrow-label__inner, -.ddc_ink_writing-editor .tl-arrow-label[data-isediting=true] > .tl-arrow-label__inner { - background-color: var(--color-background); -} -.ddc_ink_drawing-editor .tl-arrow-label__inner, -.ddc_ink_writing-editor .tl-arrow-label__inner { - border-radius: var(--radius-1); - box-sizing: content-box; - position: relative; - height: max-content; - width: max-content; - pointer-events: all; - display: flex; - justify-content: center; - align-items: center; -} -.ddc_ink_drawing-editor .tl-arrow-label p, -.ddc_ink_drawing-editor .tl-arrow-label textarea, -.ddc_ink_writing-editor .tl-arrow-label p, -.ddc_ink_writing-editor .tl-arrow-label textarea { - margin: 0px; - padding: 0px; - border: 0px; - color: inherit; - caret-color: var(--color-text); - background: none; - border-image: none; - font-size: inherit; - font-family: inherit; - font-weight: inherit; - line-height: inherit; - font-variant: inherit; - font-style: inherit; - text-align: inherit; - letter-spacing: inherit; - text-shadow: inherit; - outline: none; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - pointer-events: all; - text-rendering: auto; - text-transform: none; - text-indent: 0px; - display: inline-block; - appearance: auto; - column-count: initial !important; - writing-mode: horizontal-tb !important; - word-spacing: 0px; -} -.ddc_ink_drawing-editor .tl-arrow-label p, -.ddc_ink_writing-editor .tl-arrow-label p { - position: relative; - height: max-content; - z-index: 2; - padding: 4px; - overflow: visible; -} -.ddc_ink_drawing-editor .tl-arrow-label textarea, -.ddc_ink_writing-editor .tl-arrow-label textarea { - z-index: 3; - margin: 0px; - padding: 4px; - height: 100%; - width: 100%; - position: absolute; - resize: none; - border: 0px; - user-select: all; - -webkit-user-select: text; - caret-color: var(--color-text); - border-image: none; - min-width: 4px; -} -.ddc_ink_drawing-editor .tl-note__container, -.ddc_ink_writing-editor .tl-note__container { - position: relative; - width: 100%; - height: 100%; - border-radius: var(--radius-2); - box-shadow: var(--shadow-1); - overflow: hidden; - border-color: currentColor; - border-style: solid; - border-width: 1px; -} -.ddc_ink_drawing-editor .tl-note__container .tl-text-label, -.ddc_ink_writing-editor .tl-note__container .tl-text-label { - text-shadow: none; -} -.ddc_ink_drawing-editor .tl-note__scrim, -.ddc_ink_writing-editor .tl-note__scrim { - position: absolute; - z-index: 1; - inset: 0px; - height: 100%; - width: 100%; - background-color: var(--color-background); - opacity: 0.28; -} -.ddc_ink_drawing-editor .tl-loading, -.ddc_ink_writing-editor .tl-loading { - background-color: var(--color-background); - color: var(--color-text-1); - height: 100%; - width: 100%; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - gap: var(--space-2); - font-size: 14px; - font-weight: 500; - opacity: 0; - animation: fade-in 0.2s ease-in-out forwards; - animation-delay: 0.2s; -} -@keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tl-frame__body, -.ddc_ink_writing-editor .tl-frame__body { - stroke-width: calc(1px * var(--tl-scale)); -} -.ddc_ink_drawing-editor .tl-frame__creating, -.ddc_ink_writing-editor .tl-frame__creating { - stroke: var(--color-selected); - fill: none; -} -.ddc_ink_drawing-editor .tl-frame-heading, -.ddc_ink_writing-editor .tl-frame-heading { - display: flex; - align-items: center; - position: absolute; - transform-origin: 0% 100%; - overflow: hidden; - max-width: 100%; - min-width: 32px; - height: auto; - font-size: 12px; - padding-bottom: 4px; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-frame-heading-hit-area, -.ddc_ink_writing-editor .tl-frame-heading-hit-area { - pointer-events: all; - transform-origin: 0% 100%; - display: flex; - height: 100%; - width: 100%; - align-items: center; - border-radius: var(--radius-1); - background-color: var(--color-background); -} -.ddc_ink_drawing-editor .tl-frame-label, -.ddc_ink_writing-editor .tl-frame-label { - pointer-events: all; - overflow: hidden; - text-overflow: ellipsis; - padding: var(--space-3) var(--space-3); - position: relative; - font-size: inherit; - white-space: pre; - border: 1px solid transparent; -} -.ddc_ink_drawing-editor .tl-frame-label__editing, -.ddc_ink_writing-editor .tl-frame-label__editing { - color: transparent; - white-space: pre; - width: auto; - overflow: visible; - background-color: var(--color-panel); - border-radius: var(--radius-1); - border-color: var(--color-selected); -} -.ddc_ink_drawing-editor .tl-frame-name-input, -.ddc_ink_writing-editor .tl-frame-name-input { - position: absolute; - border: none; - background: none; - outline: none; - padding: var(--space-3) var(--space-3); - inset: 0px; - height: 100%; - width: 100%; - font-size: inherit; - font-family: inherit; - font-weight: inherit; - width: 100%; - color: var(--color-text-1); - border-radius: var(--radius-1); - user-select: all; - -webkit-user-select: text; - white-space: pre; - cursor: var(--tl-cursor-text); -} -@media (max-width: 600px) { - .ddc_ink_drawing-editor .tl-frame-heading, - .ddc_ink_writing-editor .tl-frame-heading { - font-size: 16px; - } -} -.ddc_ink_drawing-editor .tl-embed, -.ddc_ink_writing-editor .tl-embed { - border: none; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tl-shape-error-boundary, -.ddc_ink_writing-editor .tl-shape-error-boundary { - width: 100%; - height: 100%; - background-color: var(--color-muted-1); - border-width: calc(1px * var(--tl-scale)); - border-color: var(--color-muted-1); - border-style: solid; - border-radius: calc(var(--radius-1) * var(--tl-scale)); - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - text-align: left; - position: relative; - pointer-events: all; - overflow: hidden; - padding: var(--space-2); -} -.ddc_ink_drawing-editor .tl-shape-error-boundary::before, -.ddc_ink_writing-editor .tl-shape-error-boundary::before { - transform: scale(var(--tl-scale)); - content: "Error"; - font-size: 12px; - font-family: inherit; - color: var(--color-text-0); -} -.ddc_ink_drawing-editor .tl-error-boundary, -.ddc_ink_writing-editor .tl-error-boundary { - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - padding: var(--space-4); - background-color: var(--color-background); - color: var(--color-text-1); - position: absolute; - z-index: 600; -} -.ddc_ink_drawing-editor .tl-error-boundary__overlay, -.ddc_ink_writing-editor .tl-error-boundary__overlay { - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: 500; - background-color: var(--color-overlay); -} -.ddc_ink_drawing-editor .tl-error-boundary__content *, -.ddc_ink_writing-editor .tl-error-boundary__content * { - user-select: all; - -webkit-user-select: text; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-error-boundary__canvas, -.ddc_ink_writing-editor .tl-error-boundary__canvas { - pointer-events: none; - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: -1; -} -.ddc_ink_drawing-editor .tl-error-boundary__canvas::after, -.ddc_ink_writing-editor .tl-error-boundary__canvas::after { - content: " "; - display: block; - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - z-index: 600; - pointer-events: all; -} -.ddc_ink_drawing-editor .tl-error-boundary__content, -.ddc_ink_writing-editor .tl-error-boundary__content { - width: fit-content; - height: fit-content; - max-width: 100%; - width: 400px; - max-height: 100%; - background-color: var(--color-panel); - padding: 16px; - border-radius: 16px; - box-shadow: var(--shadow-2); - font-size: 14px; - font-weight: 400; - display: flex; - flex-direction: column; - overflow: auto; - z-index: 600; - gap: 12px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content__expanded, -.ddc_ink_writing-editor .tl-error-boundary__content__expanded { - width: 600px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content h2, -.ddc_ink_writing-editor .tl-error-boundary__content h2 { - font-size: 16px; - margin: 0px; - font-weight: 500; -} -.ddc_ink_drawing-editor .tl-error-boundary__content h4, -.ddc_ink_writing-editor .tl-error-boundary__content h4 { - border: 1px solid var(--color-low-border); - margin: -6px 0 0 0; - padding: var(--space-5); - border-radius: var(--radius-2); - font-weight: normal; -} -.ddc_ink_drawing-editor .tl-error-boundary__content p, -.ddc_ink_writing-editor .tl-error-boundary__content p { - line-height: 1.5; - margin: 0px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content pre, -.ddc_ink_writing-editor .tl-error-boundary__content pre { - background-color: var(--color-muted-2); - margin-top: 0; - padding: var(--space-5); - border-radius: var(--radius-2); - overflow: auto; - font-size: 12px; - max-height: 320px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content button, -.ddc_ink_writing-editor .tl-error-boundary__content button { - background: none; - border: none; - font-family: inherit; - font-size: 14px; - font-weight: 500; - padding: var(--space-4); - border-radius: var(--radius-3); - cursor: var(--tl-cursor-pointer); - color: inherit; - background-color: transparent; -} -.ddc_ink_drawing-editor .tl-error-boundary__content button:hover, -.ddc_ink_writing-editor .tl-error-boundary__content button:hover { - background-color: var(--color-low); -} -.ddc_ink_drawing-editor .tl-error-boundary__content a, -.ddc_ink_writing-editor .tl-error-boundary__content a { - color: var(--color-text-1); - font-weight: 500; - text-decoration: none; -} -.ddc_ink_drawing-editor .tl-error-boundary__content a:hover, -.ddc_ink_writing-editor .tl-error-boundary__content a:hover { - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tl-error-boundary__content__error, -.ddc_ink_writing-editor .tl-error-boundary__content__error { - position: relative; - margin: -6px 0 0 0; -} -.ddc_ink_drawing-editor .tl-error-boundary__content__error button, -.ddc_ink_writing-editor .tl-error-boundary__content__error button { - position: absolute; - top: var(--space-2); - right: var(--space-2); - font-size: 12px; - padding: var(--space-2) var(--space-3); - background-color: var(--color-panel); - border-radius: var(--radius-1); -} -.ddc_ink_drawing-editor .tl-error-boundary__content__actions, -.ddc_ink_writing-editor .tl-error-boundary__content__actions { - display: flex; - justify-content: space-between; - gap: var(--space-4); - margin: 0px; - margin-left: -4px; -} -.ddc_ink_drawing-editor .tl-error-boundary__content__actions__group, -.ddc_ink_writing-editor .tl-error-boundary__content__actions__group { - display: flex; - gap: var(--space-4); -} -.ddc_ink_drawing-editor .tl-error-boundary__content .tl-error-boundary__reset, -.ddc_ink_writing-editor .tl-error-boundary__content .tl-error-boundary__reset { - color: var(--color-warn); -} -.ddc_ink_drawing-editor .tl-error-boundary__content .tl-error-boundary__refresh, -.ddc_ink_writing-editor .tl-error-boundary__content .tl-error-boundary__refresh { - background-color: var(--color-primary); - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tl-error-boundary__content .tl-error-boundary__refresh:hover, -.ddc_ink_writing-editor .tl-error-boundary__content .tl-error-boundary__refresh:hover { - background-color: var(--color-primary); - opacity: 0.9; -} -.ddc_ink_drawing-editor .tl-hidden, -.ddc_ink_writing-editor .tl-hidden { - opacity: 0; - pointer-events: none; -} -.ddc_ink_drawing-editor .debug__ui-logger, -.ddc_ink_writing-editor .debug__ui-logger { - position: absolute; - top: 62px; - left: 16px; - color: #555; - font-size: 12px; - font-family: monospace; -} -.ddc_ink_drawing-editor .tl-container, -.ddc_ink_writing-editor .tl-container { - --layer-panels: 300; - --layer-menus: 400; - --layer-overlays: 500; - --layer-toasts: 650; - --layer-cursor: 700; -} -.ddc_ink_drawing-editor .tlui-button, -.ddc_ink_writing-editor .tlui-button { - position: relative; - height: 40px; - min-width: 40px; - padding: 0px 12px; - display: flex; - align-items: center; - justify-content: center; - background-color: transparent; - border: transparent; - color: currentColor; - cursor: pointer; - pointer-events: all; - font-weight: inherit; - font-family: inherit; - text-rendering: optimizeLegibility; - font-size: 12px; - gap: 0px; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-button:disabled, -.ddc_ink_writing-editor .tlui-button:disabled { - color: var(--color-text-3); - text-shadow: none; - cursor: default; -} -.ddc_ink_drawing-editor .tlui-button:disabled .tlui-kbd, -.ddc_ink_writing-editor .tlui-button:disabled .tlui-kbd { - color: var(--color-text-3); -} -.ddc_ink_drawing-editor .tlui-button > *, -.ddc_ink_writing-editor .tlui-button > * { - position: relative; - z-index: 1; -} -.ddc_ink_drawing-editor .tlui-button__label, -.ddc_ink_writing-editor .tlui-button__label { - flex-grow: 2; - text-align: left; -} -.ddc_ink_drawing-editor .tlui-button:focus-visible:not(:hover), -.ddc_ink_writing-editor .tlui-button:focus-visible:not(:hover) { - outline: 1px solid var(--color-selected); - outline-offset: -4px; - border-radius: var(--radius-3); -} -.ddc_ink_drawing-editor .tlui-button::after, -.ddc_ink_writing-editor .tlui-button::after { - display: block; - content: ""; - position: absolute; - inset: 4px; - background-color: transparent; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tlui-button[aria-expanded=true]::after, -.ddc_ink_writing-editor .tlui-button[aria-expanded=true]::after { - background-color: var(--color-muted-0); - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-button__icon + .tlui-button__label, -.ddc_ink_writing-editor .tlui-button__icon + .tlui-button__label { - margin-left: var(--space-2); -} -.ddc_ink_drawing-editor .tlui-button[data-state=hinted]::after, -.ddc_ink_writing-editor .tlui-button[data-state=hinted]::after { - background-color: var(--color-hint); - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-button[data-state=hinted]:not(:disabled, :focus-visible):active:after, -.ddc_ink_writing-editor .tlui-button[data-state=hinted]:not(:disabled, :focus-visible):active:after { - background: var(--color-hint); - opacity: 1; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button::after, - .ddc_ink_writing-editor .tlui-button::after { - background-color: var(--color-muted-2); - opacity: 0; - } - .ddc_ink_drawing-editor .tlui-button:not(:disabled):hover::after, - .ddc_ink_writing-editor .tlui-button:not(:disabled):hover::after { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-button__low, -.ddc_ink_writing-editor .tlui-button__low { - border-radius: var(--radius-3); - background-color: var(--color-low); -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__low::after, - .ddc_ink_writing-editor .tlui-button__low::after { - background-color: var(--color-muted-2); - } -} -.ddc_ink_drawing-editor .tlui-button__primary, -.ddc_ink_writing-editor .tlui-button__primary { - color: var(--color-primary); -} -.ddc_ink_drawing-editor .tlui-button__danger, -.ddc_ink_writing-editor .tlui-button__danger { - color: var(--color-warn); - text-shadow: none; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__primary:not(:disabled, :focus-visible):hover, - .ddc_ink_writing-editor .tlui-button__primary:not(:disabled, :focus-visible):hover { - color: var(--color-primary); - } - .ddc_ink_drawing-editor .tlui-button__danger:not(:disabled, :focus-visible):hover, - .ddc_ink_writing-editor .tlui-button__danger:not(:disabled, :focus-visible):hover { - color: var(--color-warn); - text-shadow: none; - } -} -.ddc_ink_drawing-editor .tlui-button__panel, -.ddc_ink_writing-editor .tlui-button__panel { - position: relative; -} -.ddc_ink_drawing-editor .tlui-button__menu, -.ddc_ink_writing-editor .tlui-button__menu { - height: 40px; - min-height: 40px; - width: 100%; - gap: 8px; - margin: -4px 0px; -} -.ddc_ink_drawing-editor .tlui-button__menu:nth-child(1), -.ddc_ink_writing-editor .tlui-button__menu:nth-child(1) { - margin-top: 0px; -} -.ddc_ink_drawing-editor .tlui-button__menu:nth-last-child(1), -.ddc_ink_writing-editor .tlui-button__menu:nth-last-child(1) { - margin-bottom: 0px; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__menu::after, - .ddc_ink_writing-editor .tlui-button__menu::after { - inset: 4px; - border-radius: var(--radius-2); - } -} -.ddc_ink_drawing-editor .tlui-button__checkbox, -.ddc_ink_writing-editor .tlui-button__checkbox { - padding-left: 8px; -} -.ddc_ink_drawing-editor .tlui-button__checkbox__indicator, -.ddc_ink_writing-editor .tlui-button__checkbox__indicator { - width: 15px; - height: 15px; -} -.ddc_ink_drawing-editor .tlui-toolbar__lock-button, -.ddc_ink_writing-editor .tlui-toolbar__lock-button { - position: absolute; - top: 4px; - right: 0px; - pointer-events: all; - height: 40px; - width: 40px; - min-width: 0px; - border-radius: var(--radius-2); -} -.ddc_ink_drawing-editor .tlui-toolbar__lock-button::after, -.ddc_ink_writing-editor .tlui-toolbar__lock-button::after { - top: 4px; - left: 8px; - inset: 4px; -} -.ddc_ink_drawing-editor .tlui-button__tool, -.ddc_ink_writing-editor .tlui-button__tool { - position: relative; - height: 48px; - width: 48px; - margin-left: -2px; - margin-right: -2px; -} -.ddc_ink_drawing-editor .tlui-button__tool:nth-of-type(1), -.ddc_ink_writing-editor .tlui-button__tool:nth-of-type(1) { - margin-left: 0px; -} -.ddc_ink_drawing-editor .tlui-button__tool:nth-last-of-type(1), -.ddc_ink_writing-editor .tlui-button__tool:nth-last-of-type(1) { - margin-right: 0px; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__tool::after, - .ddc_ink_writing-editor .tlui-button__tool::after { - inset: 4px; - border-radius: 8px; - } - .ddc_ink_drawing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):hover, - .ddc_ink_writing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):hover { - color: var(--color-selected-contrast); - } -} -.ddc_ink_drawing-editor .tlui-button__tool[data-state=selected], -.ddc_ink_writing-editor .tlui-button__tool[data-state=selected] { - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):active, -.ddc_ink_writing-editor .tlui-button__tool[data-state=selected]:not(:disabled, :focus-visible):active { - color: var(--color-selected-contrast); -} -.ddc_ink_drawing-editor .tlui-button__tool[data-state=selected]:not(:disabled)::after, -.ddc_ink_writing-editor .tlui-button__tool[data-state=selected]:not(:disabled)::after { - background: var(--color-selected); - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-button__tool, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-button__tool { - height: 48px; - width: 44px; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-button__tool > .tlui-icon, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-button__tool > .tlui-icon { - height: 16px; - width: 16px; -} -.ddc_ink_drawing-editor .tlui-button__help, -.ddc_ink_writing-editor .tlui-button__help { - height: 32px; - width: 32px; - padding: 0px; - min-width: 32px; - border-radius: 100%; - background-color: var(--color-low); - border: 1px solid var(--color-low-border); -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-button__help::after, - .ddc_ink_writing-editor .tlui-button__help::after { - background-color: var(--color-muted-2); - border-radius: 100%; - inset: 4px; - } -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal, -.ddc_ink_writing-editor .tlui-buttons__horizontal { - display: flex; - flex-direction: row; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *, -.ddc_ink_writing-editor .tlui-buttons__horizontal > * { - margin-left: -2px; - margin-right: -2px; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *:nth-child(1), -.ddc_ink_writing-editor .tlui-buttons__horizontal > *:nth-child(1) { - margin-left: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *:nth-last-child(1), -.ddc_ink_writing-editor .tlui-buttons__horizontal > *:nth-last-child(1) { - margin-right: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__horizontal > *:only-child, -.ddc_ink_writing-editor .tlui-buttons__horizontal > *:only-child { - width: 56px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid, -.ddc_ink_writing-editor .tlui-buttons__grid { - display: grid; - grid-template-columns: repeat(4, auto); - grid-auto-flow: row; - overflow: hidden; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button, -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button { - margin: -2px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n) { - margin-right: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n - 3), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(4n - 3) { - margin-left: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(-n + 4), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-of-type(-n + 4) { - margin-top: 0px; -} -.ddc_ink_drawing-editor .tlui-buttons__grid > .tlui-button:nth-last-of-type(-n + 4), -.ddc_ink_writing-editor .tlui-buttons__grid > .tlui-button:nth-last-of-type(-n + 4) { - margin-bottom: 0px; -} -.ddc_ink_drawing-editor .tlui-zoom-menu__button__pct, -.ddc_ink_writing-editor .tlui-zoom-menu__button__pct { - width: 60px; - min-width: 60px; - text-align: center; -} -.ddc_ink_drawing-editor .tlui-layout, -.ddc_ink_writing-editor .tlui-layout { - position: relative; - display: grid; - grid-template-columns: 1fr; - grid-template-rows: minmax(0px, 1fr) auto; - grid-auto-rows: auto; - height: 100%; - max-height: 100%; - overflow: clip; - pointer-events: none; - user-select: none; - contain: strict; - z-index: var(--layer-panels); - -webkit-transform: translate3d(0, 0, 0); - --sab: env(safe-area-inset-bottom); -} -.ddc_ink_drawing-editor .tlui-layout__top, -.ddc_ink_writing-editor .tlui-layout__top { - grid-column: 1; - grid-row: 1; - display: flex; - min-width: 0px; - justify-content: space-between; -} -.ddc_ink_drawing-editor .tlui-layout__top__left, -.ddc_ink_writing-editor .tlui-layout__top__left { - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: flex-start; - width: 100%; - height: 100%; - flex: 0 1 0; -} -.ddc_ink_drawing-editor .tlui-layout__top__right, -.ddc_ink_writing-editor .tlui-layout__top__right { - display: flex; - flex-direction: column; - align-items: flex-end; - justify-content: flex-start; - height: 100%; - flex: 0 0 auto; - min-width: 0px; -} -.ddc_ink_drawing-editor .scrollable, -.ddc_ink_drawing-editor .scrollable *, -.ddc_ink_writing-editor .scrollable, -.ddc_ink_writing-editor .scrollable * { - pointer-events: all; - touch-action: auto; - overscroll-behavior: none; -} -.ddc_ink_drawing-editor .tlui-helper-buttons, -.ddc_ink_writing-editor .tlui-helper-buttons { - position: relative; - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - width: min-content; - gap: var(--space-3); - margin: var(--space-2) var(--space-3); - white-space: nowrap; - pointer-events: none; - z-index: var(--layer-panels); -} -.ddc_ink_drawing-editor .tlui-icon, -.ddc_ink_writing-editor .tlui-icon { - flex-shrink: 0; - width: 18px; - height: 18px; - background-color: currentColor; -} -.ddc_ink_drawing-editor .tlui-icon__small, -.ddc_ink_writing-editor .tlui-icon__small { - width: 15px; - height: 15px; -} -.ddc_ink_drawing-editor .tlui-slider, -.ddc_ink_writing-editor .tlui-slider { - position: relative; - display: flex; - align-items: center; - user-select: none; - touch-action: none; -} -.ddc_ink_drawing-editor .tlui-slider__container, -.ddc_ink_writing-editor .tlui-slider__container { - width: 100%; - padding: 0px var(--space-4); -} -.ddc_ink_drawing-editor .tlui-slider__track, -.ddc_ink_writing-editor .tlui-slider__track { - position: relative; - flex-grow: 1; - height: 44px; - cursor: pointer; -} -.ddc_ink_drawing-editor .tlui-slider__track::after, -.ddc_ink_writing-editor .tlui-slider__track::after { - display: block; - position: absolute; - top: calc(50% - 2px); - content: ""; - height: 3px; - width: 100%; - background-color: var(--color-muted-1); - border-radius: 14px; -} -.ddc_ink_drawing-editor .tlui-slider__range, -.ddc_ink_writing-editor .tlui-slider__range { - position: absolute; - top: calc(50% - 2px); - left: 0px; - height: 3px; - background-color: var(--color-selected); - border-radius: 14px; -} -.ddc_ink_drawing-editor .tlui-slider__thumb, -.ddc_ink_writing-editor .tlui-slider__thumb { - all: unset; - cursor: grab; - display: block; - width: 18px; - height: 18px; - position: relative; - top: -1px; - background-color: var(--color-panel); - border-radius: 999px; - box-shadow: inset 0px 0px 0px 2px var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-slider__thumb:active, -.ddc_ink_writing-editor .tlui-slider__thumb:active { - cursor: grabbing; - box-shadow: inset 0px 0px 0px 2px var(--color-text-1), var(--shadow-1); -} -.ddc_ink_drawing-editor .tlui-slider__thumb:focus-visible, -.ddc_ink_writing-editor .tlui-slider__thumb:focus-visible { - box-shadow: inset 0 0 0 2px var(--color-focus); -} -.ddc_ink_drawing-editor .tlui-kbd, -.ddc_ink_writing-editor .tlui-kbd { - font-family: inherit; - font-size: 11px; - line-height: 11px; - display: grid; - justify-items: center; - grid-auto-flow: column; - grid-template-columns: auto; - grid-auto-columns: minmax(1em, auto); - align-self: bottom; - color: var(--color-text-1); - margin-left: var(--space-4); -} -.ddc_ink_drawing-editor .tlui-kbd > span, -.ddc_ink_writing-editor .tlui-kbd > span { - width: 100%; - text-align: center; - display: inline; - margin: 0px; - padding: 2px; - border-radius: 2px; -} -.ddc_ink_drawing-editor .tlui-kbd > span:last-child, -.ddc_ink_writing-editor .tlui-kbd > span:last-child { - padding-right: 0; -} -.ddc_ink_drawing-editor .tlui-kbd:not(:last-child), -.ddc_ink_writing-editor .tlui-kbd:not(:last-child) { - margin-right: var(--space-2); -} -.ddc_ink_drawing-editor .tlui-focus-button, -.ddc_ink_writing-editor .tlui-focus-button { - z-index: var(--layer-panels); - pointer-events: all; -} -.ddc_ink_drawing-editor .tlui-popover, -.ddc_ink_writing-editor .tlui-popover { - position: relative; - display: flex; - align-content: stretch; -} -.ddc_ink_drawing-editor .tlui-popover__content, -.ddc_ink_writing-editor .tlui-popover__content { - position: relative; - max-height: 75vh; - margin: 0px; - border: none; - border-radius: var(--radius-3); - background-color: var(--color-panel); - box-shadow: var(--shadow-3); - z-index: var(--layer-menus); - overflow: hidden; - overflow-y: auto; - touch-action: auto; - overscroll-behavior: none; - scrollbar-width: none; - -ms-overflow-style: none; -} -.ddc_ink_drawing-editor .tlui-debug-panel, -.ddc_ink_writing-editor .tlui-debug-panel { - background-color: var(--color-low); - width: 100%; - display: grid; - align-items: center; - grid-template-columns: 1fr auto auto auto; - justify-content: space-between; - padding-left: var(--space-4); - border-top: 1px solid var(--color-background); - font-size: 12px; - color: var(--color-text-1); - z-index: var(--layer-panels); - pointer-events: all; -} -.ddc_ink_drawing-editor .tlui-debug-panel__current-state, -.ddc_ink_writing-editor .tlui-debug-panel__current-state { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} -.ddc_ink_drawing-editor .tlui-debug-panel__fps, -.ddc_ink_writing-editor .tlui-debug-panel__fps { - margin-right: 8px; -} -.ddc_ink_drawing-editor .tlui-debug-panel__fps__slow, -.ddc_ink_writing-editor .tlui-debug-panel__fps__slow { - font-weight: bold; - color: var(--color-warn); -} -.ddc_ink_drawing-editor .tlui-menu-zone, -.ddc_ink_writing-editor .tlui-menu-zone { - position: relative; - z-index: var(--layer-panels); - width: fit-content; - border-right: 2px solid var(--color-background); - border-bottom: 2px solid var(--color-background); - border-bottom-right-radius: var(--radius-4); - background-color: var(--color-low); -} -.ddc_ink_drawing-editor .tlui-menu-zone *[data-state=open]::after, -.ddc_ink_writing-editor .tlui-menu-zone *[data-state=open]::after { - background: linear-gradient(180deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-style-panel__wrapper, -.ddc_ink_writing-editor .tlui-style-panel__wrapper { - box-shadow: var(--shadow-2); - border-radius: var(--radius-3); - pointer-events: all; - background-color: var(--color-panel); - height: fit-content; - max-height: 100%; - margin: 8px; - touch-action: auto; - overscroll-behavior: none; - overflow-y: auto; - overflow-x: hidden; - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-style-panel, -.ddc_ink_writing-editor .tlui-style-panel { - position: relative; - z-index: var(--layer-panels); - pointer-events: all; - width: 148px; - max-width: 148px; -} -.ddc_ink_drawing-editor .tlui-style-panel::-webkit-scrollbar, -.ddc_ink_writing-editor .tlui-style-panel::-webkit-scrollbar { - display: none; -} -.ddc_ink_drawing-editor .tlui-style-panel .tlui-button.select, -.ddc_ink_writing-editor .tlui-style-panel .tlui-button.select { - width: 100%; -} -.ddc_ink_drawing-editor .tlui-style-panel__section, -.ddc_ink_writing-editor .tlui-style-panel__section { - display: flex; - position: relative; - flex-direction: column; -} -.ddc_ink_drawing-editor .tlui-style-panel__section:nth-of-type(n + 2):not(:last-child), -.ddc_ink_writing-editor .tlui-style-panel__section:nth-of-type(n + 2):not(:last-child) { - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-style-panel__section:empty, -.ddc_ink_writing-editor .tlui-style-panel__section:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-style-panel__section__common:not(:only-child), -.ddc_ink_writing-editor .tlui-style-panel__section__common:not(:only-child) { - margin-bottom: 7px; - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-style-panel__row, -.ddc_ink_writing-editor .tlui-style-panel__row { - display: flex; -} -.ddc_ink_drawing-editor .tlui-style-panel__row__extra-button, -.ddc_ink_writing-editor .tlui-style-panel__row__extra-button { - margin-left: -2px; -} -.ddc_ink_drawing-editor .tlui-style-panel__double-select-picker, -.ddc_ink_writing-editor .tlui-style-panel__double-select-picker { - display: flex; - grid-template-columns: 1fr auto; - align-items: center; - padding-left: var(--space-4); - color: var(--color-text-1); - font-size: 12px; -} -.ddc_ink_drawing-editor .tlui-style-panel__double-select-picker-label, -.ddc_ink_writing-editor .tlui-style-panel__double-select-picker-label { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - flex-grow: 2; - max-width: 100%; -} -.ddc_ink_drawing-editor .tlui-style-panel__section *[data-state=open]::after, -.ddc_ink_writing-editor .tlui-style-panel__section *[data-state=open]::after { - background: var(--color-muted-0); -} -.ddc_ink_drawing-editor .tlui-input, -.ddc_ink_writing-editor .tlui-input { - background: none; - margin: 0px; - position: relative; - z-index: 1; - height: 40px; - max-height: 40px; - display: flex; - align-items: center; - justify-content: center; - font-family: inherit; - font-size: 12px; - font-weight: inherit; - color: var(--color-text-1); - padding: var(--space-4); - padding-left: 0px; - border: none; - outline: none; - text-overflow: ellipsis; - width: 100%; - user-select: all; - text-rendering: optimizeLegibility; - -webkit-user-select: auto !important; -} -.ddc_ink_drawing-editor .tlui-input__wrapper, -.ddc_ink_writing-editor .tlui-input__wrapper { - width: 100%; - height: 44px; - display: flex; - align-items: center; - gap: var(--space-4); - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-input__wrapper > .tlui-icon, -.ddc_ink_writing-editor .tlui-input__wrapper > .tlui-icon { - flex-shrink: 0; -} -@media (max-width: 600px) { - @supports (-webkit-touch-callout: none) { - .ddc_ink_drawing-editor, - .ddc_ink_writing-editor { - } - .ddc_ink_drawing-editor .tlui-input, - .ddc_ink_writing-editor .tlui-input { - font-size: 16px; - } - } -} -.ddc_ink_drawing-editor .tlui-dialog__overlay, -.ddc_ink_writing-editor .tlui-dialog__overlay { - position: absolute; - top: 0px; - left: 0px; - width: 100%; - height: 100%; - z-index: var(--layer-overlays); - background-color: var(--color-overlay); - pointer-events: all; - animation: fadeIn 0.12s ease-out; - display: grid; - place-items: center; - overflow-y: auto; -} -.ddc_ink_drawing-editor .tlui-dialog__content, -.ddc_ink_writing-editor .tlui-dialog__content { - display: flex; - flex-direction: column; - position: relative; - cursor: default; - background-color: var(--color-panel); - box-shadow: var(--shadow-3); - border-radius: var(--radius-3); - font-size: 12px; - overflow: hidden; - min-width: 300px; - max-width: 80%; - max-height: 80%; -} -.ddc_ink_drawing-editor .tlui-dialog__header, -.ddc_ink_writing-editor .tlui-dialog__header { - position: relative; - display: flex; - align-items: center; - flex: 0; - z-index: 999; - padding-left: var(--space-4); - color: var(--color-text); - height: 44px; -} -.ddc_ink_drawing-editor .tlui-dialog__header__title, -.ddc_ink_writing-editor .tlui-dialog__header__title { - flex: 1; - font-weight: inherit; - font-size: 12px; - margin: 0px; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-dialog__header__close, -.ddc_ink_writing-editor .tlui-dialog__header__close { - justify-self: flex-end; -} -.ddc_ink_drawing-editor .tlui-dialog__body, -.ddc_ink_writing-editor .tlui-dialog__body { - padding: var(--space-4) var(--space-4); - flex: 0 1; - overflow-y: auto; - overflow-x: hidden; - color: var(--color-text-1); - user-select: all; - -webkit-user-select: text; -} -.ddc_ink_drawing-editor .tlui-dialog__footer, -.ddc_ink_writing-editor .tlui-dialog__footer { - position: relative; - z-index: 999; -} -.ddc_ink_drawing-editor .tlui-dialog__footer__actions, -.ddc_ink_writing-editor .tlui-dialog__footer__actions { - display: flex; - align-items: center; - justify-content: flex-end; -} -.ddc_ink_drawing-editor .tlui-dialog__footer__actions > .tlui-button:nth-last-child(n+2), -.ddc_ink_writing-editor .tlui-dialog__footer__actions > .tlui-button:nth-last-child(n+2) { - margin-right: -4px; -} -.ddc_ink_drawing-editor .tlui-toolbar, -.ddc_ink_writing-editor .tlui-toolbar { - grid-column: 1/span 3; - grid-row: 1; - display: flex; - align-items: center; - justify-content: center; - flex-grow: 2; - padding-bottom: calc(var(--space-3) + var(--sab)); -} -.ddc_ink_drawing-editor .tlui-toolbar__inner, -.ddc_ink_writing-editor .tlui-toolbar__inner { - position: relative; - width: fit-content; - display: flex; - gap: var(--space-3); - align-items: flex-end; -} -.ddc_ink_drawing-editor .tlui-toolbar__left, -.ddc_ink_writing-editor .tlui-toolbar__left { - width: fit-content; -} -.ddc_ink_drawing-editor .tlui-toolbar__extras, -.ddc_ink_writing-editor .tlui-toolbar__extras { - position: relative; - z-index: 1; - width: 100%; - pointer-events: none; - top: 6px; - height: 48px; -} -.ddc_ink_drawing-editor .tlui-toolbar__extras:empty, -.ddc_ink_writing-editor .tlui-toolbar__extras:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-toolbar__extras__controls, -.ddc_ink_writing-editor .tlui-toolbar__extras__controls { - display: flex; - position: relative; - flex-direction: row; - z-index: 1; - background-color: var(--color-low); - border-top-left-radius: var(--radius-4); - border-top-right-radius: var(--radius-4); - border: 2px solid var(--color-background); - margin-left: 8px; - margin-right: 0px; - pointer-events: all; - width: fit-content; -} -.ddc_ink_drawing-editor .tlui-toolbar__tools, -.ddc_ink_writing-editor .tlui-toolbar__tools { - display: flex; - flex-direction: row; - background-color: var(--color-low); - border-radius: var(--radius-4); - z-index: var(--layer-panels); - pointer-events: all; - position: relative; - align-items: center; - background: var(--color-panel); - box-shadow: var(--shadow-2); -} -.ddc_ink_drawing-editor .tlui-toolbar__overflow, -.ddc_ink_writing-editor .tlui-toolbar__overflow { - width: 40px; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-toolbar__overflow, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-toolbar__overflow { - width: 32px; - padding: 0px; -} -.ddc_ink_drawing-editor .tlui-layout__mobile .tlui-toolbar *[data-state=open]::after, -.ddc_ink_writing-editor .tlui-layout__mobile .tlui-toolbar *[data-state=open]::after { - background: linear-gradient(0deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-help-menu, -.ddc_ink_writing-editor .tlui-help-menu { - pointer-events: all; - position: absolute; - bottom: var(--space-2); - right: var(--space-2); - z-index: var(--layer-panels); - border: 2px solid var(--color-background); - border-radius: 100%; -} -.ddc_ink_drawing-editor .tlui-context-menu__move-to-page__name, -.ddc_ink_writing-editor .tlui-context-menu__move-to-page__name { - max-width: min(300px, 35vw); - overflow: hidden; - text-overflow: ellipsis; -} -.ddc_ink_drawing-editor .tlui-context-menu__move-to-page__name[data-disabled], -.ddc_ink_writing-editor .tlui-context-menu__move-to-page__name[data-disabled] { - color: var(--color-text-3); - pointer-events: none; -} -.ddc_ink_drawing-editor .tlui-menu:empty, -.ddc_ink_writing-editor .tlui-menu:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-menu, -.ddc_ink_writing-editor .tlui-menu { - z-index: var(--layer-menus); - height: fit-content; - width: fit-content; - max-height: 80vh; - border-radius: var(--radius-3); - pointer-events: all; - touch-action: auto; - overflow-y: auto; - overscroll-behavior: none; - background-color: var(--color-panel); - box-shadow: var(--shadow-3); -} -.ddc_ink_drawing-editor .tlui-menu::-webkit-scrollbar, -.ddc_ink_writing-editor .tlui-menu::-webkit-scrollbar { - display: none; -} -.ddc_ink_drawing-editor .tlui-menu__arrow, -.ddc_ink_writing-editor .tlui-menu__arrow { - position: relative; - top: -1px; - fill: var(--color-panel); - stroke: var(--color-panel-contrast); - stroke-width: 1px; -} -.ddc_ink_drawing-editor .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu__group { - width: 100%; -} -.ddc_ink_drawing-editor .tlui-menu__group:empty, -.ddc_ink_writing-editor .tlui-menu__group:empty { - display: none; -} -.ddc_ink_drawing-editor .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu__group { - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-menu__group:nth-last-of-type(1), -.ddc_ink_writing-editor .tlui-menu__group:nth-last-of-type(1) { - border-bottom: none; -} -.ddc_ink_drawing-editor .tlui-menu__submenu__trigger[data-state=open]:not(:hover)::after, -.ddc_ink_writing-editor .tlui-menu__submenu__trigger[data-state=open]:not(:hover)::after { - border-radius: var(--radius-1); - background: linear-gradient(90deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-menu__submenu__trigger[data-direction=left][data-state=open]:not(:hover)::after, -.ddc_ink_writing-editor .tlui-menu__submenu__trigger[data-direction=left][data-state=open]:not(:hover)::after { - border-radius: var(--radius-1); - background: linear-gradient(270deg, rgba(144, 144, 144, 0) 0%, var(--color-muted-2) 100%); -} -.ddc_ink_drawing-editor .tlui-menu[data-size=large] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=large] > .tlui-menu__group { - min-width: initial; -} -.ddc_ink_drawing-editor .tlui-menu[data-size=medium] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=medium] > .tlui-menu__group { - min-width: 144px; -} -.ddc_ink_drawing-editor .tlui-menu[data-size=small] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=small] > .tlui-menu__group { - min-width: 96px; -} -.ddc_ink_drawing-editor .tlui-menu[data-size=tiny] > .tlui-menu__group, -.ddc_ink_writing-editor .tlui-menu[data-size=tiny] > .tlui-menu__group { - min-width: 0px; -} -.ddc_ink_drawing-editor .tlui-actions-menu, -.ddc_ink_writing-editor .tlui-actions-menu { - max-height: calc(100vh - 150px); -} -.ddc_ink_drawing-editor .tlui-toast__viewport, -.ddc_ink_writing-editor .tlui-toast__viewport { - position: absolute; - inset: 0px; - margin: 0px; - display: flex; - align-items: flex-end; - justify-content: flex-end; - flex-direction: column; - gap: var(--space-3); - pointer-events: none; - padding: 0px var(--space-3) 64px 0px; - z-index: var(--layer-toasts); -} -.ddc_ink_drawing-editor .tlui-toast__viewport > *, -.ddc_ink_writing-editor .tlui-toast__viewport > * { - pointer-events: all; -} -.ddc_ink_drawing-editor .tlui-toast__icon, -.ddc_ink_writing-editor .tlui-toast__icon { - padding-top: var(--space-4); - padding-left: var(--space-4); - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-toast__container, -.ddc_ink_writing-editor .tlui-toast__container { - min-width: 200px; - display: flex; - flex-direction: row; - background-color: var(--color-panel); - box-shadow: var(--shadow-2); - border-radius: var(--radius-3); - font-size: 12px; -} -.ddc_ink_drawing-editor .tlui-toast__main, -.ddc_ink_writing-editor .tlui-toast__main { - flex-grow: 2; - max-width: 280px; -} -.ddc_ink_drawing-editor .tlui-toast__content, -.ddc_ink_writing-editor .tlui-toast__content { - padding: var(--space-4); - display: flex; - flex-direction: column; - gap: var(--space-3); -} -.ddc_ink_drawing-editor .tlui-toast__title, -.ddc_ink_writing-editor .tlui-toast__title { - font-weight: bold; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-toast__description, -.ddc_ink_writing-editor .tlui-toast__description { - color: var(--color-text-1); - padding: var(--space-3); - margin: 0px; - padding: 0px; -} -.ddc_ink_drawing-editor .tlui-toast__icon + .tlui-toast__main > .tlui-toast__actions, -.ddc_ink_writing-editor .tlui-toast__icon + .tlui-toast__main > .tlui-toast__actions { - padding-left: 0px; -} -.ddc_ink_drawing-editor .tlui-toast__actions, -.ddc_ink_writing-editor .tlui-toast__actions { - display: flex; - flex-direction: row; - justify-content: flex-start; - margin-left: 0; -} -.ddc_ink_drawing-editor .tlui-toast__close, -.ddc_ink_writing-editor .tlui-toast__close { - align-self: flex-end; - flex-shrink: 0; -} -@media (prefers-reduced-motion: no-preference) { - .ddc_ink_drawing-editor .tlui-toast__container[data-state=open], - .ddc_ink_writing-editor .tlui-toast__container[data-state=open] { - animation: slide-in 200ms cubic-bezier(0.785, 0.135, 0.15, 0.86); - } - .ddc_ink_drawing-editor .tlui-toast__container[data-state=closed], - .ddc_ink_writing-editor .tlui-toast__container[data-state=closed] { - animation: hide 100ms ease-in; - } - .ddc_ink_drawing-editor .tlui-toast__container[data-swipe=move], - .ddc_ink_writing-editor .tlui-toast__container[data-swipe=move] { - transform: translateX(var(--radix-toast-swipe-move-x)); - } - .ddc_ink_drawing-editor .tlui-toast__container[data-swipe=cancel], - .ddc_ink_writing-editor .tlui-toast__container[data-swipe=cancel] { - transform: translateX(0); - transition: transform 200ms ease-out; - } - .ddc_ink_drawing-editor .tlui-toast__container[data-swipe=end], - .ddc_ink_writing-editor .tlui-toast__container[data-swipe=end] { - animation: swipe-out 100ms ease-out; - } -} -.ddc_ink_drawing-editor .tlui-layout__bottom, -.ddc_ink_writing-editor .tlui-layout__bottom { - grid-row: 2; -} -.ddc_ink_drawing-editor .tlui-layout__bottom__main, -.ddc_ink_writing-editor .tlui-layout__bottom__main { - width: 100%; - position: relative; - display: flex; - align-items: flex-end; - justify-content: center; -} -.ddc_ink_drawing-editor .tlui-navigation-panel, -.ddc_ink_writing-editor .tlui-navigation-panel { - display: flex; - width: min-content; - flex-direction: column; - z-index: var(--layer-panels); - pointer-events: all; - position: absolute; - left: 0px; - bottom: 0px; -} -.ddc_ink_drawing-editor .tlui-navigation-panel::before, -.ddc_ink_writing-editor .tlui-navigation-panel::before { - content: ""; - display: block; - position: absolute; - z-index: -1; - inset: -2px -2px 0px 0px; - border-radius: 0; - border-top: 2px solid var(--color-background); - border-right: 2px solid var(--color-background); - border-top-right-radius: var(--radius-4); - background-color: var(--color-low); -} -.ddc_ink_drawing-editor .tlui-navigation-panel__toggle .tlui-icon, -.ddc_ink_writing-editor .tlui-navigation-panel__toggle .tlui-icon { - opacity: 0.24; -} -.ddc_ink_drawing-editor .tlui-navigation-panel__toggle:active .tlui-icon, -.ddc_ink_writing-editor .tlui-navigation-panel__toggle:active .tlui-icon { - opacity: 1; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-navigation-panel__toggle:hover .tlui-icon, - .ddc_ink_writing-editor .tlui-navigation-panel__toggle:hover .tlui-icon { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-minimap, -.ddc_ink_writing-editor .tlui-minimap { - width: 100%; - height: 96px; - min-height: 96px; - overflow: hidden; - padding: var(--space-3); - padding-top: 0px; -} -.ddc_ink_drawing-editor .tlui-minimap__canvas, -.ddc_ink_writing-editor .tlui-minimap__canvas { - position: relative; - width: 100%; - height: 100%; -} -@keyframes hide { - 0% { - opacity: 1; - } - 100% { - opacity: 0; - } -} -@keyframes slide-in { - from { - transform: translateX(calc(100% + var(--space-3))); - } - to { - transform: translateX(0px); - } -} -@keyframes swipe-out { - from { - transform: translateX(var(--radix-toast-swipe-end-x)); - } - to { - transform: translateX(calc(100% + var(--space-3))); - } -} -.ddc_ink_drawing-editor .tlui-page-menu__wrapper, -.ddc_ink_writing-editor .tlui-page-menu__wrapper { - position: relative; - display: flex; - flex-direction: column; - width: 220px; - height: fit-content; - max-height: 50vh; -} -.ddc_ink_drawing-editor .tlui-page-menu__trigger, -.ddc_ink_writing-editor .tlui-page-menu__trigger { - width: 128px; -} -.ddc_ink_drawing-editor .tlui-page-menu__header, -.ddc_ink_writing-editor .tlui-page-menu__header { - display: flex; - flex-direction: row; - align-items: center; - width: 100%; - height: 40px; - padding-left: var(--space-4); - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-page-menu__header > .tlui-button:nth-of-type(1), -.ddc_ink_writing-editor .tlui-page-menu__header > .tlui-button:nth-of-type(1) { - margin-right: -4px; -} -.ddc_ink_drawing-editor .tlui-page-menu__header__title, -.ddc_ink_writing-editor .tlui-page-menu__header__title { - color: var(--color-text); - font-size: 12px; - flex-grow: 2; -} -.ddc_ink_drawing-editor .tlui-page-menu__name, -.ddc_ink_writing-editor .tlui-page-menu__name { - flex-grow: 2; - text-align: left; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.ddc_ink_drawing-editor .tlui-page-menu__list, -.ddc_ink_writing-editor .tlui-page-menu__list { - position: relative; - touch-action: auto; - flex-direction: column; - max-height: 100%; - overflow-x: hidden; - overflow-y: auto; - touch-action: auto; -} -.ddc_ink_drawing-editor .tlui-page-menu__item, -.ddc_ink_writing-editor .tlui-page-menu__item { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - gap: 0px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item:nth-of-type(n + 2), -.ddc_ink_writing-editor .tlui-page-menu__item:nth-of-type(n + 2) { - margin-top: -4px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button, -.ddc_ink_writing-editor .tlui-page-menu__item__button { - width: 100%; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button:not(:only-child), -.ddc_ink_writing-editor .tlui-page-menu__item__button:not(:only-child) { - flex-grow: 2; - margin-right: -2px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button > span, -.ddc_ink_writing-editor .tlui-page-menu__item__button > span { - display: block; - flex-grow: 2; - text-align: left; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button__checkbox, -.ddc_ink_writing-editor .tlui-page-menu__item__button__checkbox { - padding-left: 35px; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button__check, -.ddc_ink_writing-editor .tlui-page-menu__item__button__check { - position: absolute; - left: 0px; - width: 24px; - padding-left: 10px; - display: inline-flex; - align-items: center; - justify-content: center; - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable { - position: absolute; - top: 0px; - left: 0px; - width: 100%; - height: fit-content; - display: flex; - flex-direction: row; - align-items: center; - overflow: hidden; - z-index: 1; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__title, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__title { - flex: 1; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__title > .tlui-input__wrapper, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__title > .tlui-input__wrapper { - height: 100%; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable:focus-within, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable:focus-within { - z-index: 10; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__handle, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__handle { - touch-action: none; - width: 32px; - min-width: 0px; - height: 40px; - cursor: grab; - color: var(--color-text-3); - flex-shrink: 0; - margin-right: -9px; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__sortable__handle:active, -.ddc_ink_writing-editor .tlui-page_menu__item__sortable__handle:active { - cursor: grabbing; -} -.ddc_ink_drawing-editor .tlui-page-menu__item__input, -.ddc_ink_writing-editor .tlui-page-menu__item__input { - margin-left: 12px; - height: 100%; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__submenu, -.ddc_ink_writing-editor .tlui-page_menu__item__submenu { - pointer-events: all; - flex: 0; - cursor: pointer; - margin: 0px; - display: none; - margin-left: -2px; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__submenu[data-isediting=true], -.ddc_ink_writing-editor .tlui-page_menu__item__submenu[data-isediting=true] { - display: block; - opacity: 1; -} -.ddc_ink_drawing-editor .tlui-page_menu__item__submenu > .tlui-button, -.ddc_ink_writing-editor .tlui-page_menu__item__submenu > .tlui-button { - opacity: 0; -} -@media (any-pointer: coarse) { - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu > .tlui-button { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-page-menu__item__button .tlui-button__icon, -.ddc_ink_writing-editor .tlui-page-menu__item__button .tlui-button__icon { - margin-right: 4px; -} -@media (hover: hover) { - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu { - display: block; - } - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu[data-isediting=true] > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu[data-isediting=true] > .tlui-button { - opacity: 0; - } - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu > .tlui-button[data-state=open], - .ddc_ink_drawing-editor .tlui-page_menu__item__submenu:hover > .tlui-button, - .ddc_ink_drawing-editor .tlui-page_menu__item__sortable:focus-within > .tlui-page_menu__item__submenu > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__submenu > .tlui-button[data-state=open], - .ddc_ink_writing-editor .tlui-page_menu__item__submenu:hover > .tlui-button, - .ddc_ink_writing-editor .tlui-page_menu__item__sortable:focus-within > .tlui-page_menu__item__submenu > .tlui-button { - opacity: 1; - } -} -.ddc_ink_drawing-editor .tlui-edit-link-dialog, -.ddc_ink_writing-editor .tlui-edit-link-dialog { - display: flex; - flex-direction: column; - gap: var(--space-4); - color: var(--color-text); -} -.ddc_ink_drawing-editor .tlui-edit-link-dialog__input, -.ddc_ink_writing-editor .tlui-edit-link-dialog__input { - background-color: var(--color-muted-2); - flex-grow: 2; - border-radius: var(--radius-2); - padding: 0px var(--space-4); -} -.ddc_ink_drawing-editor .tlui-embed__spacer, -.ddc_ink_writing-editor .tlui-embed__spacer { - flex-grow: 2; - min-height: 0px; - margin-left: calc(-1 * var(--space-4)); - margin-top: calc(-1 * var(--space-4)); - pointer-events: none; -} -.ddc_ink_drawing-editor .tlui-embed-dialog__list, -.ddc_ink_writing-editor .tlui-embed-dialog__list { - display: flex; - flex-direction: column; - padding-bottom: var(--space-5); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__item__image, -.ddc_ink_writing-editor .tlui-embed-dialog__item__image { - width: 24px; - height: 24px; - display: flex; - align-items: center; - justify-content: center; - background-size: contain; - background-repeat: no-repeat; - background-position: center center; -} -.ddc_ink_drawing-editor .tlui-embed-dialog__enter, -.ddc_ink_writing-editor .tlui-embed-dialog__enter { - display: flex; - flex-direction: column; - gap: var(--space-4); - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__input, -.ddc_ink_writing-editor .tlui-embed-dialog__input { - background-color: var(--color-muted-2); - flex-grow: 2; - border-radius: var(--radius-2); - padding: 0px var(--space-4); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__warning, -.ddc_ink_writing-editor .tlui-embed-dialog__warning { - color: var(--color-warn); - text-shadow: none; -} -.ddc_ink_drawing-editor .tlui-embed-dialog__instruction__link, -.ddc_ink_writing-editor .tlui-embed-dialog__instruction__link { - display: flex; - gap: var(--space-1); - margin-top: var(--space-4); -} -.ddc_ink_drawing-editor .tlui-embed-dialog__enter a, -.ddc_ink_writing-editor .tlui-embed-dialog__enter a { - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-following-indicator, -.ddc_ink_writing-editor .tlui-following-indicator { - display: block; - position: absolute; - inset: 0px; - border-width: 2px; - border-style: solid; - z-index: var(--layer-following-indicator); - pointer-events: none; -} -.ddc_ink_drawing-editor .tlui-offline-indicator, -.ddc_ink_writing-editor .tlui-offline-indicator { - display: flex; - flex-direction: row; - gap: var(--space-3); - color: var(--color-text); - background-color: var(--color-low); - border: 3px solid var(--color-background); - padding: 0px var(--space-5); - height: 42px; - align-items: center; - justify-content: center; - border-radius: 99px; - opacity: 0; - animation: fade-in; - animation-duration: 0.12s; - animation-delay: 2s; - animation-fill-mode: forwards; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__header, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__header { - border-bottom: 1px solid var(--color-divider); -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__body, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__body { - position: relative; - columns: 3; - column-gap: var(--space-9); - pointer-events: all; - touch-action: auto; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__body__tablet, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__body__tablet { - columns: 2; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__body__mobile, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__body__mobile { - columns: 1; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__group, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__group { - break-inside: avoid-column; - padding-bottom: var(--space-6); -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__group__title, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__group__title { - font-size: inherit; - font-weight: inherit; - margin: 0px; - color: var(--color-text-3); - height: 32px; - display: flex; - align-items: center; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__group__content, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__group__content { - display: flex; - flex-direction: column; - color: var(--color-text-1); -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__key-pair, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__key-pair { - display: flex; - gap: var(--space-4); - align-items: center; - justify-content: space-between; - height: 32px; -} -.ddc_ink_drawing-editor .tlui-shortcuts-dialog__key-pair__key, -.ddc_ink_writing-editor .tlui-shortcuts-dialog__key-pair__key { - flex: 1; - font-size: 12px; -} -.ddc_ink_drawing-editor { - transition: height 0.5s ease; -} -.ddc_ink_drawing-editor .tl-container { - outline: none !important; -} -.ddc_ink_drawing-editor .tl-container .tl-canvas { - background: none; - overflow: hidden; -} -.ddc_ink_drawing-editor .tl-container .tl-canvas .tl-background { - background: none; -} -.ddc_ink_drawing-editor { - outline: solid 8px var(--color-base-10); - border-radius: 20px; - background-color: var(--color-base-05); -} - -/* src/tldraw/drawing-menu/drawing-menu.scss */ - -/* src/tldraw/extended-drawing-menu/extended-drawing-menu.scss */ -.ink_extended-writing-menu { - display: flex; - gap: 4px; - pointer-events: none; -} -.ink_extended-writing-menu button { - width: auto; - pointer-events: auto; - background-color: var(--interactive-normal); - color: var(--color-base-60); -} -.ink_extended-writing-menu button:hover { - background-color: var(--interactive-hover); - color: var(--color-base-100); -} -.ink_extended-writing-menu button:disabled { - cursor: default; - color: var(--text-on-accent); - background-color: var(--interactive-accent); -} -.ink_extended-writing-menu button:disabled:hover { - box-shadow: var(--input-shadow); -} -.ink_extended-writing-menu button { - width: 2.5em; - height: 2.5em; - border-radius: 0.8em; - padding: 0 !important; -} -.ink_extended-writing-menu button.ddc_ink_btn-slim { - width: 1.9em; - height: 2.5em; - border-radius: 0.8em; -} -.ink_extended-writing-menu button svg { - width: 1.5em !important; - height: 1.5em !important; -} - -/* src/tldraw/drawing/drawing-embed.scss */ -.markdown-source-view.mod-cm6 .cm-content > .cm-preview-code-block.cm-embed-block.markdown-rendered[contenteditable=false]:has(.ddc_ink_drawing-embed), -.markdown-source-view.mod-cm6 .cm-content > .cm-preview-code-block.cm-embed-block.markdown-rendered[contenteditable=false]:has(.ddc_ink_drawing-embed):hover { - contain: unset !important; - overflow: visible; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) { - margin: 0 calc(-1 * var(--file-margins)) !important; - z-index: 10; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed):hover { - box-shadow: none; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .edit-block-button { - display: none; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container { - overflow: visible; - clip: unset; - contain: none !important; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container .tlui-layout { - overflow: visible; - clip: unset; - contain: none !important; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container .tlui-layout .tlui-button.tlui-menu__trigger { - display: none; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container .tlui-layout .tlui-navigation-zone { - display: none; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container .tlui-layout .tlui-help-menu { - display: none; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container .tlui-layout .tlui-layout__top { - grid-row: 1; - position: absolute; - top: 0; - right: 0; - translate: 0 -100%; -} -.cm-preview-code-block.cm-embed-block.markdown-rendered:has(.ddc_ink_drawing-embed) .ddc_ink_drawing-editor .tl-container .tlui-layout .tlui-layout__bottom { - grid-row: 1; - position: absolute; - top: 0; - left: 0; - translate: 0 -100%; -} -.ddc_ink_drawing-embed { - box-sizing: content-box; - transition-property: padding; - transition-duration: 0.5s; - transition-timing-function: ease-out; -} -.theme-dark .ddc_ink_drawing-embed-preview path { - fill: rgb(242, 242, 242); -} -.theme-dark .ddc_ink_drawing-embed-preview .ddc_ink_drawing-placeholder path { - stroke: rgb(242, 242, 242) !important; -} -.theme-dark .ddc_ink_drawing-embed-preview .ddc_ink_drawing-placeholder rect, -.theme-dark .ddc_ink_drawing-embed-preview .ddc_ink_drawing-placeholder circle { - stroke: rgb(242, 242, 242) !important; -} -.theme-dark .ddc_ink_drawing-embed-preview rect, -.theme-dark .ddc_ink_drawing-embed-preview circle { - stroke: rgb(242, 242, 242); -} -.theme-light .ddc_ink_drawing-embed-preview path { - fill: rgb(29, 29, 29); -} -.theme-light .ddc_ink_drawing-embed-preview .ddc_ink_drawing-placeholder path { - stroke: rgb(29, 29, 29) !important; -} -.theme-light .ddc_ink_drawing-embed-preview .ddc_ink_drawing-placeholder rect, -.theme-light .ddc_ink_drawing-embed-preview .ddc_ink_drawing-placeholder circle { - stroke: rgb(29, 29, 29) !important; -} - -/* src/tldraw/drawing/drawing-embed-preview/drawing-embed-preview.scss */ -.ddc_ink_drawing-embed-preview { - pointer-events: none; - display: flex; - justify-content: center; - align-items: center; -} -.ddc_ink_drawing-embed-preview img { - pointer-events: auto; - cursor: pointer; -} -.ddc_ink_drawing-embed-preview.ddc_ink_visible-background { - background-color: var(--color-base-05); - border-radius: 20px; -} -.ddc_ink_drawing-embed-preview.ddc_ink_visible-frame { - border: 2px solid var(--color-base-30); - border-radius: 20px; -} - -/* src/components/jsx-components/resize-handle/resize-handle.scss */ -.ddc_ink_resize-handle { - position: absolute; - z-index: 1000; - right: 0; - bottom: 0; - translate: 25% 50%; - pointer-events: auto; - background-color: var(--interactive-normal); - color: var(--color-base-60); - fill: var(--color-base-60); - width: 2.5em; - height: 2.5em; - border-radius: 2.5em; - padding: 0 !important; -} -.ddc_ink_resize-handle:hover { - cursor: nwse-resize; - background-color: var(--interactive-hover); - color: var(--color-base-100); - fill: var(--color-base-100); -} -.ddc_ink_resize-handle svg { - width: 1.5em !important; - height: 1.5em !important; -} -.ddc_ink_resize-handle { - animation: menu-button_scale-up 0.3s 0.1s ease-out; - animation-delay: 0.2s; - animation-fill-mode: both; -} |
